SHARE
TWEET

Untitled

a guest Jun 5th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $ftpServer = "";
  4. $ftpUser = "";
  5. $ftpPass = "";
  6.  
  7. $path = "/path/to/gamedir/downloads/";
  8.  
  9. $destpath = "/path/to/store/sprays/at/";
  10.  
  11. $spray = $_GET["spray"];
  12.  
  13. if (!preg_match("/^[0-9a-fA-F]+$/", $spray)) {
  14.         echo "Invalid spray ID.";
  15.         exit;
  16.     }
  17.  
  18. $file = $spray . ".dat";
  19. $dest = $destpath . $spray . ".vtf";
  20.  
  21. if (!file_exists($dest)) {
  22.     echo "Grabbing spray from server, please wait.<br>";
  23.  
  24.     set_time_limit(160);
  25.  
  26.     $conn = ftp_connect($ftpServer);
  27.  
  28.     $login = ftp_login($conn, $ftpUser, $ftpPass);
  29.  
  30.     ftp_chdir($conn, $path);
  31.  
  32.     $gotFile = ftp_get($conn, $dest, $file, FTP_BINARY);
  33.  
  34.     ftp_quit($conn);
  35. }
  36.  
  37. if (file_exists($dest)) {
  38.     if(!file_exists("{$dest}.0.png")) { // for every frame that there is,
  39.         echo "Converting...<br>";
  40.         exec("/usr/local/bin/vtfconv ".$dest, $out); // convert the file
  41.     }
  42.            
  43.     if(!file_exists("{$dest}.gif")) { // for every frame that there is,
  44.         $derp = 0; // set frames to 0
  45.         $src = array(); // initiate an array
  46.  
  47.         while(file_exists("{$dest}.{$derp}.png")){ // for every frame that there is,
  48.             $src[]="{$dest}.{$derp}.png"; // put it in the source array
  49.             $derp ++; // and count the frame
  50.         } // end
  51.  
  52.         if($derp < 1){ // if the frame number never hit 1 something went wrong,
  53.             echo "Failed to convert {$dest}<br>\n"; // so tell reag that he needs to yell at me more
  54.             $error = 1; // and tell the script that it bugged out
  55.         }
  56.  
  57.         exec("convert -delay 25 -loop 0 -set dispose background ".implode(" ", $src)." {$dest}.gif", $out); // convert the frames to a gif
  58.     }
  59. }
  60.    
  61.  
  62. echo '<img src="/sprays/'.$spray.'.vtf.gif" />';
  63. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top