Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $fastdl_server = '#####';
- $fastdl_user = '#####';
- $fastdl_pass = '#####';
- // Set up basic connection
- $fastdl_id = ftp_connect($fastdl_server);
- // Login with username and password
- $fastdl_login_result = ftp_login($fastdl_id, $fastdl_user, $fastdl_pass);
- // Get the file list for /
- $fastdl_buff = ftp_nlist($fastdl_id, '/not real path ive copied it out/inversion/fastdl/cache/garrysmod/cache');
- // Create the date array
- $fastdl_date = array((count($fastdl_buff) - 1));
- // Put the dates in the date array
- for($i =0; $i < count($fastdl_buff); $i++){
- $buff = ftp_mdtm($fastdl_id, '/not real path ive copied it out/inversion/fastdl/cache/cache/'.$fastdl_buff[$i]);
- $fastdl_date[$i] = $buff;
- }
- // Finds newest date and puts the corrosdponding array number into variable
- $fastdl_newest_date = array_search(max($fastdl_date),$fastdl_date);
- $fastdl_newest_file = $fastdl_buff[$fastdl_newest_date];
- // Checks if the file exists locally.
- if(file_exists('/not real path ive copied it out/inversion/fastdl/cache/'.$fastdl_newest_file)){ echo 'Cache is fine!'; }
- // Clears out the local folder. FTPs newest file down. Clears out the FTP dir.
- else{
- for($i =0; $i < count($fastdl_buff); $i++){
- if($i != $fastdl_newest_date){ftp_delete($fastdl_id,'/not real path/garrysmod/cache/'.$fastdl_buff[$i]);}
- }
- echo 'Cleared out the FTP apart from newest file.<br/>';
- ftp_get($fastdl_id, '/not real path ive copied it out/inversion/fastdl/cache/'.$fastdl_newest_file, '/not real path/garrysmod/cache/'.$fastdl_newest_file, FTP_BINARY);
- echo 'Updated the cache!';
- }
- // close the connection
- ftp_close($fastdl_id);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement