extranet/www/pages/attente.php

50 lines
1.1 KiB
PHP
Raw Normal View History

<?php
set_time_limit(3600); // Timeout <20> 16 minutes
2009-07-21 07:17:54 +00:00
require_once 'common/ftp.php';
sleep(10);
$siret=$_REQUEST['siret'];
$siren=substr($siret, 0,9);
$tabRef=explode('-', $_REQUEST['ref']);
$source=$tabRef[0];
$nom=$tabRef[1];
$racine=substr($nom,2,10);
$pages=$tabRef[2];
$conn_id = ftp_connect(FTPACTES_HOST);
$login_result = ftp_login($conn_id, FTPACTES_USER, FTPACTES_PASS);
$nbEssais=0;
while (true) {
$tabList=ftp_nlist($conn_id, '.');
foreach ($tabList as $i=>$fichier) {
if (strpos($fichier, $racine)>0) {
// Fichier trouv<75>
sleep(10);
break(2);
}
}
$nbEssais++;
if ($nbEssais<100) sleep(5);
elseif ($nbEssais<200) sleep(30);
else {
ftp_close($con_id);
die("-1");
}
}
if (!ftp_get($conn_id,"/tmp/$source-$siren-$nom-$pages.tif", "$fichier", FTP_BINARY)) {
ftp_close($con_id);
die("-2");
}
ftp_close($con_id);
2009-02-24 15:51:47 +00:00
shell_exec('cd /tmp; /usr/bin/tiff2pdf -o '.$source.'-'.$siren.'-'.$nom.'-'.$pages.'.pdf '.$source.'-'.$siren.'-'.$nom.'-'.$pages.'.tif');
2009-03-02 11:27:23 +00:00
copy('/tmp/'.$source.'-'.$siren.'-'.$nom.'-'.$pages.'.pdf', PATH_DATA.'/pdf/'.$source.'-'.$siren.'-'.$nom.'-'.$pages.'.pdf');
//filesize("/var/www/html/pdf/kbis-$siren.pdf");
die("0");
?>