Jump to content

MTA Server Automatic Updater (File for latest Version Descr)


Recommended Posts

Posted

I would like programming an MTA server updater program for Linux

Is there a file where the latest Linux server version is in there because it should automatically update as the MTA client then

My InGame Name is: [KPT]Syping/Hulkkiller

Rafael9707s_36118_7.png

Posted

Sometimes updated breaks compatibility with older scripts. Personally I would NOT like my server to autoupdate and get broken, while I sleep or I'm on vacation.

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

nightly.multitheftauto.com running on php, can create and upload a script for get the latest and recommend version for the Linux Server?

Is less work for me, because then I could build my project better (I have my own MTA Panel for hosting and need this for a update interface)

My InGame Name is: [KPT]Syping/Hulkkiller

Rafael9707s_36118_7.png

Posted

I meaning the Nightly Version (nightly.multitheftauto.com), Otherwise this is good with the latest normal Release

I can hosting the php source on my webserver if you want, i can register a sub-domain example.. (mtasa.keppe.org)

My InGame Name is: [KPT]Syping/Hulkkiller

Rafael9707s_36118_7.png

Posted

youre free to alter the code and host it

edit: service edited to do nightlies now and update time set to 2 hrs

http://uhm.sparksptpm.co.uk/mta-linux/latest

http://uhm.sparksptpm.co.uk/mta-linux/get

new source code:

  
<?php 
  
    /**************************************************** 
        MTA LINUX SERVER LATEST BUILD FETCH SERVICE  
        Documentation: [url=http://uhm.sparksptpm.co.uk/mta-linux/]http://uhm.sparksptpm.co.uk/mta-linux/[/url] 
        Developed by uhm under Apache License v2.0 
    *****************************************************/ 
  
  
    function get_data($url) { 
        $ch = curl_init(); 
        curl_setopt($ch, CURLOPT_URL, $url); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); 
        $data = curl_exec($ch); 
        curl_close($ch); 
        return $data; 
    } 
     
         
    function getBetween($haystack,$start,$end,$index=0) 
    { 
        $positions = array(); 
        $positionsB = array(); 
        $count = 0; 
        $cnt2=0; 
  
        while($cnt2<($index+1) && $count = strpos($haystack , $start , $count+1)) { $positions[] = $count+strlen($start); $cnt2++; }  
  
        $cnt2=0; 
        while($cnt2<($index+1) && $count = strpos($haystack , $end , $positions[$cnt2]+1)) { $positionsB[] = $count; $cnt2++; }  
  
        return substr($haystack,$positions[$index],$positionsB[$index]-$positions[$index]); 
    } 
  
  
  
    // get last check date 
    $time = filemtime('cache.txt'); 
    if ((time() - $time) >  7200)   // has it been longer than 2 hrs? (7200 seconds) 
    { 
        $data = get_data('https://nightly.multitheftauto.com/'); 
        $version = getBetween($data,'<img src="mta_nightly.php?image=gz" alt="gz" /> <a href="','"'); 
        file_put_contents ( 'cache.txt' , $version ); // make sure to chmod this file to 777 
    } 
    else 
    { 
        $version = file_get_contents('cache.txt'); 
    } 
     
     
  
    if (isset($_GET['latest'])) 
    { 
        echo getBetween($version,'/','.tar'); 
    } 
    elseif (isset($_GET['get'])) 
    { 
        header('Location: ' . 'https://nightly.multitheftauto.com/' . $version); 
    } 
    else 
    { 
        echo 'Invalid request; see [url=http://uhm.sparksptpm.co.uk/mta-linux/']http://uhm.sparksptpm.co.uk/mta-linux/'[/url]; 
    } 
  
  
?> 

Posted

its work for me, http://mtasa.keppe.org (I am running PHP5.4 on my Server)

My Public Code

  
<?php 
  
    /**************************************************** 
        MTA LINUX SERVER LATEST BUILD FETCH SERVICE 
        Documentation: [url=http://uhm.sparksptpm.co.uk/mta-linux/]http://uhm.sparksptpm.co.uk/mta-linux/[/url] 
        Developed by uhm under Apache License v2.0 
        Edited by KPT (Keppe Project-Team) 
    *****************************************************/ 
  
  
    function get_data($url) { 
        $ch = curl_init(); 
        curl_setopt($ch, CURLOPT_URL, $url); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); 
        $data = curl_exec($ch); 
        curl_close($ch); 
        return $data; 
    } 
    
        
    function getBetween($haystack,$start,$end,$index=0) 
    { 
        $positions = array(); 
        $positionsB = array(); 
        $count = 0; 
        $cnt2=0; 
  
        while($cnt2<($index+1) && $count = strpos($haystack , $start , $count+1)) { $positions[] = $count+strlen($start); $cnt2++; } 
  
        $cnt2=0; 
        while($cnt2<($index+1) && $count = strpos($haystack , $end , $positions[$cnt2]+1)) { $positionsB[] = $count; $cnt2++; } 
  
        return substr($haystack,$positions[$index],$positionsB[$index]-$positions[$index]); 
    } 
  
  
  
    // get last check date 
    $time = filemtime('cache.txt'); 
    if ((time() - $time) >  7200)   // has it been longer than 2 hrs? (7200 seconds) 
    { 
        $data = get_data('https://nightly.multitheftauto.com/'); 
        $psdata = explode("- Current release version",$data); 
        $version = getBetween($psdata[1],'<img src="mta_nightly.php?image=gz" alt="gz" /> <a href="','"'); 
        file_put_contents ( 'cache.txt' , $version ); // make sure to chmod this file to 644, 755, 775 or 777 
    } 
    else 
    { 
        $version = file_get_contents('cache.txt'); 
    } 
    
  
    if (isset($_GET['latest'])) 
    { 
        echo getBetween($version,'/','.tar'); 
    } 
    elseif (isset($_GET['ver'])) 
    { 
        $gdata = getBetween($version,'/','.tar'); 
        $psg1data = explode("-",$gdata); 
        $psg2data = explode("-",$psg1data[1]); 
        echo $psg2data[0]; 
    } 
    elseif (isset($_GET['build'])) 
    { 
        $gdata = getBetween($version,'/','.tar'); 
        $psg1data = explode("-",$gdata); 
        $psg2data = explode("-",$psg1data[3]); 
        echo $psg2data[0]; 
    } 
    elseif (isset($_GET['get'])) 
    { 
        header('Location: ' . 'https://nightly.multitheftauto.com/' . $version); 
    } 
    else 
    { 
        echo 'Invalid request; see [url=http://uhm.sparksptpm.co.uk/mta-linux/']http://uhm.sparksptpm.co.uk/mta-linux/'[/url]; 
    } 
  

Thank your for the help :D thx

My InGame Name is: [KPT]Syping/Hulkkiller

Rafael9707s_36118_7.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...