Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. <?php
  2. set_time_limit(60);
  3. // Variables
  4. // file on the web server
  5.     $local_file = "log.txt";
  6. // ftp server
  7.     $ftp_server = "81.19.216.171";
  8. // ftp username
  9.     $ftp_username = 'Shaun1';
  10. // ftp password
  11.     $ftp_userpass = 'poo';
  12.  
  13. /****
  14.         Do not edit anything below here!!
  15.        
  16.         There is the main area you work in below all this code.
  17.         I have marked where you can edit.
  18. ****/
  19. // Functions
  20. function ftpConnect($ftp_server, $ftp_username, $ftp_userpass, $local_file)
  21. {
  22.     $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
  23.     $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
  24.    
  25.     ftp_chdir($ftp_conn, "81.19.216.171_2700");
  26.     $ftp_dir = ftp_rawlist($ftp_conn, '');
  27.    
  28.     $data = array();
  29.     foreach($ftp_dir as $key => $value)
  30.     {
  31.         $date3 = substr($value,0,17);
  32.         $date2 = str_replace('-','/',$date3);
  33.         $date = str_replace('  ',' ',$date2);
  34.         if(strpos($date,'00:') !== false && strpos($date,'PM') !== false)
  35.         {
  36.             $date_1 = substr($date,0,9);
  37.             $date_2 = substr($date,11);
  38.             $date = $date_1.'12'.$date_2;
  39.         }
  40.        
  41.         $folder = substr($value,-19);
  42.         $data[$folder] = strtotime($date);
  43.     }
  44.    
  45.     arsort($data);
  46.    
  47.     $newArray = array_values($data);
  48.     $key = $newArray[0];
  49.     $flipped = array_flip($data);
  50.    
  51.     $server_directory = $flipped[$key];
  52.     $server_file = "$server_directory/DayZServer_x64.ADM";
  53.     ftp_get($ftp_conn, $local_file, $server_file, FTP_ASCII);
  54.    
  55.     ftp_close($ftp_conn);
  56. }
  57.  
  58. if(file_exists($local_file))
  59. {
  60.     // time difference between now and file
  61.     $time_diff = time() - filemtime($local_file);
  62.     // 86400 is one day in seconds
  63.     if($time_diff >= 86400)
  64.     {
  65.         ftpConnect($ftp_server, $ftp_username, $ftp_userpass, $local_file);
  66.     }
  67. }
  68. else
  69. {
  70.     ftpConnect($ftp_server, $ftp_username, $ftp_userpass, $local_file);
  71. }
  72.  
  73. $data = file($local_file);
  74.  
  75.  
  76. /****
  77.         Edit Below Here
  78. ****/
  79. ?>
  80.  
  81. <!-- Some html -->
  82.  
  83. <?php
  84. // Loop through the array and output the data to the screen
  85. foreach($data as $value)
  86. {
  87.     /*  This is where you will output the
  88.         data one at a time from the array  */
  89.     echo '<p>'.$value.'</p>';
  90. }
  91. ?>
  92.  
  93. <!-- Some html -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement