Remove depencies of library/common/curl : getUrl
This commit is contained in:
parent
b797542b20
commit
202178c372
@ -217,7 +217,6 @@ class Infogreffe
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->pathData = realpath($c->profil->path->data);
|
||||
require_once 'common/curl.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1286,27 +1285,27 @@ class Infogreffe
|
||||
mkdir($path.$wholePath, 0777, true);
|
||||
}
|
||||
|
||||
if(!file_exists($path.$fichier) || !filesize($path.$fichier)>2000)
|
||||
{
|
||||
if(!file_exists($path.$fichier) || !filesize($path.$fichier)>2000) {
|
||||
|
||||
$erreurDL = '';
|
||||
$page = getUrl($url, '', '', '', false, '', '',0,1);
|
||||
$body = $page['body'];
|
||||
$erreurDL = $body;
|
||||
if (substr($body,0,4)!='%PDF')
|
||||
{
|
||||
$page2 = parse_response($body);
|
||||
$body = $page2['body'];
|
||||
}
|
||||
if( ($page['code']!=408 || $page['code']!=400) && substr($body,0,4)=='%PDF') {
|
||||
//Ecriture du fichier sur le serveur en local
|
||||
if ( file_put_contents($path.$fichier, $body) ) {
|
||||
$return = basename($fichier);
|
||||
$erreurDL = '';
|
||||
} else {
|
||||
$return = false;
|
||||
$erreurDL = "Erreur lors de l'ecriture du fichier";
|
||||
}
|
||||
try {
|
||||
$client = new Zend_Http_Client($url);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful() && substr($response->getBody(),0,4)=='%PDF' ) {
|
||||
if ( copy($response->getStreamName(), $path.$fichier) ) {
|
||||
$return = basename($fichier);
|
||||
$erreurDL = '';
|
||||
} else {
|
||||
$return = false;
|
||||
$erreurDL = "Erreur lors de l'ecriture du fichier";
|
||||
}
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {
|
||||
$return = false;
|
||||
$erreurDL = "Erreur lors de l'ecriture du fichier";
|
||||
}
|
||||
|
||||
if ($trace) {
|
||||
$erreur = new Application_Model_CommandesErreur();
|
||||
preg_match('/(acte|bilan)-([0-9]{9})-(.*)\.pdf$/', $fichier, $ref);
|
||||
@ -1320,6 +1319,7 @@ class Infogreffe
|
||||
);
|
||||
$erreur->insert($data);
|
||||
}
|
||||
|
||||
} else {
|
||||
$return = basename($fichier);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user