Exemplo n.º 1
0
 private function generatePreview()
 {
     $ftpCon = new Ftp(FTP_USA, FTP_USA_USR, FTP_USA_PWD);
     $connected = $ftpCon->login_r(null, null, FTP_CONN_RETRIES);
     if (!$connected) {
         return false;
     }
     $from = str_replace("%RESOLUTION%", PREVIEW_WIDTH . "x" . PREVIEW_HEIGHT, $this->getPreview());
     $from = str_replace("contenido", "netuy", $from);
     $from = "/www.wazzup.com.uy/" . $from;
     $previewFilename = "preview" . str_replace(" ", "_", sanitizeString($this->title)) . ".gif";
     $tmp = $this->dirToWrite . "/" . $previewFilename;
     echo "preview {$from} => {$tmp}";
     $bajado = $ftpCon->bajar_r($from, $tmp, FTP_DOWN_RETRIES);
     $targetDir = $this->dirToWrite;
     $prev_sin_ext = str_replace(".gif", "", $previewFilename);
     $ret = copy_format_img($prev_sin_ext, $targetDir, 80, 80, "", ".gif", ".gif");
     echo '<li>Retorno de la copia del preview: ' . print_r($ret, true);
     $ret = copy_format_img($prev_sin_ext, $targetDir, 40, 40, "", ".gif", ".gif");
     echo '<li>Retorno de la copia del preview: ' . print_r($ret, true);
     //Borro el preview original, porque no se sube
     $shellCmd = "cd " . $this->dirToWrite . "; rm -f {$previewFilename}";
     exec($shellCmd);
     $this->previewFilenames[] = $prev_sin_ext . "_80x80.gif";
     $this->previewFilenames[] = $prev_sin_ext . "_40x40.gif";
     $carpeta = $this->calcularCarpeta($this->contentId);
     $pathScreenshots = "/previews/java/240x320/" . $carpeta . "/";
     $this->screenshotsFilenames[] = $this->contentId . "_1.jpg";
     $this->screenshotsFilenames[] = $this->contentId . "_2.jpg";
     $this->screenshotsFilenames[] = $this->contentId . "_3.jpg";
     $ftpCon = new Ftp(FTP_241, FTP_241_USR, FTP_241_PWD);
     $connected = $ftpCon->login_r(null, null, FTP_CONN_RETRIES);
     foreach ($this->screenshotsFilenames as $fn) {
         $tmp = $this->dirToWrite . "/" . $fn;
         $from = $pathScreenshots . "" . $fn;
         echo '<li>Bajando screenshot: ' . $from . ' => ' . $tmp . '</li>';
         $bajado = $ftpCon->bajar_r($from, $tmp, FTP_DOWN_RETRIES);
         //echo '<li>Resultado del FTP: ' . print_r($bajado, true).'</li>';
         $cnvrt = new convert($tmp, "jpg", 240, 320);
         echo '<li>Convirtiendo screenshot para que pese menos....</li>';
         $cnvrt->saveIMG($tmp);
     }
     return $bajado;
 }