Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(60);
- // Variables
- // file on the web server
- $local_file = "log.txt";
- // ftp server
- $ftp_server = "81.19.216.171";
- // ftp username
- $ftp_username = 'Shaun1';
- // ftp password
- $ftp_userpass = 'poo';
- /****
- Do not edit anything below here!!
- There is the main area you work in below all this code.
- I have marked where you can edit.
- ****/
- // Functions
- function ftpConnect($ftp_server, $ftp_username, $ftp_userpass, $local_file)
- {
- $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
- $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
- ftp_chdir($ftp_conn, "81.19.216.171_2700");
- $ftp_dir = ftp_rawlist($ftp_conn, '');
- $data = array();
- foreach($ftp_dir as $key => $value)
- {
- $date3 = substr($value,0,17);
- $date2 = str_replace('-','/',$date3);
- $date = str_replace(' ',' ',$date2);
- if(strpos($date,'00:') !== false && strpos($date,'PM') !== false)
- {
- $date_1 = substr($date,0,9);
- $date_2 = substr($date,11);
- $date = $date_1.'12'.$date_2;
- }
- $folder = substr($value,-19);
- $data[$folder] = strtotime($date);
- }
- arsort($data);
- $newArray = array_values($data);
- $key = $newArray[0];
- $flipped = array_flip($data);
- $server_directory = $flipped[$key];
- $server_file = "$server_directory/DayZServer_x64.ADM";
- ftp_get($ftp_conn, $local_file, $server_file, FTP_ASCII);
- ftp_close($ftp_conn);
- }
- if(file_exists($local_file))
- {
- // time difference between now and file
- $time_diff = time() - filemtime($local_file);
- // 86400 is one day in seconds
- if($time_diff >= 86400)
- {
- ftpConnect($ftp_server, $ftp_username, $ftp_userpass, $local_file);
- }
- }
- else
- {
- ftpConnect($ftp_server, $ftp_username, $ftp_userpass, $local_file);
- }
- $data = file($local_file);
- /****
- Edit Below Here
- ****/
- ?>
- <!-- Some html -->
- <?php
- // Loop through the array and output the data to the screen
- foreach($data as $value)
- {
- /* This is where you will output the
- data one at a time from the array */
- echo '<p>'.$value.'</p>';
- }
- ?>
- <!-- Some html -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement