getOptions()); Zend_Registry::set('config', $c); require_once 'WsScore/Configure.php'; $oldconfig = new Configure(); /** Zend_Application */ require_once 'Zend/Application.php'; // Create application, bootstrap, and run $application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); try { $opts = new Zend_Console_Getopt( //Options array( 'help|?' => "Aide.", ) ); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage(); exit; } //Usage if(isset($opts->help)) { echo $opts->getUsageMessage(); exit; } function getFilePdf($url, $file) { $result = true; $fp = fopen($file, 'w'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); // Check if any error occured if(curl_errno($ch)) { $result = false; } curl_close($ch); fclose($fp); return $result; } $reportSubject = ''; $reportMsg = ''; //Lire la base de données - Récupérer les éléments sans fichier //Connect to the database try { $db = Zend_Db::factory($this->dbConfig->db->jo); $db->getConnection(); } catch (Zend_Db_Adapter_Exception $e) { } catch (Zend_Exception $e) { } $baseUrl = 'http://extranetrec.scores-decisions.com/fichier/pdfassociation/actes/'; $path = SECURE_STORAGE . 'associations/actes/'; //Lecture des données $acteM = new Application_Model_AssoActes($db); $sql = $acteM->select()->where('pdfLink=?', ''); $acteList = $acteM->fetchAll($sql); if ($acteList->count()>0) { foreach ($acteList->toArray() as $item) { $date = substr($item['date_acte'],0,4).substr($item['date_acte'],5,2).substr($item['date_acte'],8,2); if (intval($item['siren'])==0) { $file = 'ST-'.$item['waldec'].'-'.$date; } else { $file = 'ST-'.$item['siren'].'-'.$date; } //Télécharger le fichier $isDownload = getFilePdf($baseUrl.$file, $path.$file); if ($isDownload && file_exists($path.$file)) { //Récupérer les informations du PDF $pdfInfos = array(); $pdfInfos['pdfLink'] = $file; $pdfInfos['pdfSize'] = filesize($path.$file); //Get PDF version $handle = fopen($path.$file, 'r'); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); if (preg_match("/^\%PDF\-(.*)\s/U", $buffer, $matches)) { $version = $matches[1]; } break; } fclose($handle); } $pdfInfos['pdfVer'] = $version; //Get PDF number of pages $pdf = new Zend_Pdf($path.$file, null, true); $pdfInfos['pdfPage'] = count($pdf->pages); //Modifier la ligne dans la base de données $acteM->update($pdfInfos, 'id='.$item['id']); } } } $reportMsg = "\nGénéré par getActesAsso."; //Envoyer un mail de rapport $mail = new Zend_Mail(); $tr = new Zend_Mail_Transport_Smtp('smtp.celeste.fr'); $mail->setDefaultTransport($tr); $mail->setFrom('production@scores-decisions.com', 'Production'); $mail->addTo('support@scores-decisions.com', 'Support'); $mail->setSubject($reportSubject); $mail->setBodyText(mb_convert_encoding($reportMsg, 'ISO-8859-1', 'UTF-8')); $mail->send();