cdn_ftpusername(); $cdn_ftppassword = $config->cdn_ftppassword(); $cdn_ftppath = $config->cdn_ftppath(); $cdn_ftpserver = $config->cdn_ftpserver(); //$ftp = new FTP($cdn_ftpusername, $cdn_ftppassword, $cdn_ftpserver, $cdn_ftppath); $pictureUri = "https://www.buzzerstar.com/image/$shortcode.png"; $filename = "/tmp/$shortcode.png"; unlink($filename); //echo "Downloading image to cdn.buzzerstar.com\n
"; $f = @fopen($filename, 'w'); $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $pictureUri); curl_setopt($ch, CURLOPT_TIMEOUT, 50); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,50); curl_setopt($ch, CURLOPT_USERAGENT, "cdn.buzzerstar.com Image Loader v0.1"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FILE, $f); curl_exec($ch); if(curl_errno($ch)){ echo 'Class Function - pushPictureToKeyCDN() -> error:' . curl_error($ch); echo "Error Downloading : ^$pictureUri^
"; } curl_close($ch); fclose($f); //echo "PNGCrush Image to cdn.buzzerstar.com\n
"; exec("/usr/local/bin/pngquant --quality=65-88 --speed 1 $filename -o $filename --force"); chmod($filename, 0755); //echo "FTP Upload to cdn: $cdn_ftppath/$shortcode.png this file: $filename\n
"; //$ftp->upload("$cdn_ftppath/$shortcode.png",$filename); $conn_id = ftp_connect($cdn_ftpserver); // Login mit Benutzername und Passwort $login_result = ftp_login($conn_id, $cdn_ftpusername, $cdn_ftppassword); // Datei hochladen ftp_chdir($conn_id, $cdn_ftppath); if (ftp_put($conn_id, "$shortcode.png", $filename, FTP_BINARY)) { // echo "$filename erfolgreich hochgeladen\n"; } else { echo "Ein Fehler trat beim Hochladen von $filename auf -> Manuell auf CDN kopieren : $pictureUri
\n"; } //var_dump($conn_id); // Verbindung schließen ftp_close($conn_id); return; } ?>