Remove depencies of library/common/curl : getUrl
This commit is contained in:
parent
a60698181f
commit
ad2984ee91
@ -700,9 +700,6 @@ class EvaluationController extends Zend_Controller_Action
|
||||
if(!$user->checkModeEdition() or !$user->checkPerm('SCORECSF'))
|
||||
$this->render('error/perms', null, 'error');
|
||||
|
||||
require_once 'Evaluation/DomDocument2.lib.php';
|
||||
require_once 'common/curl.php';
|
||||
|
||||
define('CREDITSAFE_WS_URL', 'https://www.creditsafe.fr/getdata/service/CSFRServices.asmx');
|
||||
define('CREDITSAFE_WS_URI', 'https://www.creditsafe.fr/getdata/service/');
|
||||
define('CREDITSAFE_WS_USER', 'scores_decisions');
|
||||
@ -730,14 +727,17 @@ class EvaluationController extends Zend_Controller_Action
|
||||
'</body>'.
|
||||
'</xmlrequest>';
|
||||
|
||||
$success = true;
|
||||
$date = date('Ymd');
|
||||
$url = 'https://www.creditsafe.fr/getdata/service/CSFRServices.asmx/GetData?RequestXmlStr='.$req;
|
||||
$referer = $cookie = '';
|
||||
$page = getUrl($url, $cookie, '', $referer, false, '', '');
|
||||
$referer = $url;
|
||||
$file = APPLICATION_PATH.'/../../data/creditsafe/'.$this->siret.'.xml';
|
||||
$xml = html_entity_decode($page['body'], ENT_QUOTES, 'UTF-8');
|
||||
|
||||
try {
|
||||
$client = new Zend_Http_Client($url);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful() ) {
|
||||
$xml = html_entity_decode($response->getBody(), ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$dom_object = new DOMDocument();
|
||||
$ws = new WsScores();
|
||||
if(!file_exists($file)) {
|
||||
@ -800,6 +800,8 @@ class EvaluationController extends Zend_Controller_Action
|
||||
$this->view->strCreditlimit = $strCreditlimit;
|
||||
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commande de scoring partenaire creditsafe
|
||||
|
@ -208,7 +208,6 @@ class LogoController extends Zend_Controller_Action
|
||||
|
||||
if ($request->isPost()){
|
||||
|
||||
require_once 'common/curl.php';
|
||||
$logoUrl = $request->getParam('url');
|
||||
$tabTmp = parse_url($logoUrl);
|
||||
$hostUrl = $tabTmp['host'];
|
||||
@ -216,20 +215,23 @@ class LogoController extends Zend_Controller_Action
|
||||
$tmp = explode('.', basename($pathUrl));
|
||||
$ext = strtolower(end($tmp));
|
||||
|
||||
$page = getUrl($logoUrl, '', '', '', false, $hostUrl, '', 7);
|
||||
$body = $page['body'];
|
||||
|
||||
$extAuthorized = array('jpeg', 'jpg', 'png', 'gif', 'bmp');
|
||||
|
||||
//Vérification fichier est une image
|
||||
if ( in_array($ext, $extAuthorized ) )
|
||||
{
|
||||
$name_file = $siren.'.'.$ext;
|
||||
$fp = fopen($this->pathLogo.'/'.$name_file, 'w');
|
||||
fwrite($fp, $body);
|
||||
fclose($fp);
|
||||
|
||||
try {
|
||||
$client = new Zend_Http_Client($logoUrl);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful()
|
||||
&& copy($response->getStreamName(), $this->pathLogo.'/'.$name_file) ) {
|
||||
$this->view->assign('image', $name_file);
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {}
|
||||
}
|
||||
$this->view->assign('isPost', true);
|
||||
}
|
||||
$this->view->assign('siren', $siren);
|
||||
@ -307,7 +309,7 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
}
|
||||
} else {
|
||||
saisie_getlogo($siren);
|
||||
$this->_getlogo($siren);
|
||||
}
|
||||
}
|
||||
return $message;
|
||||
@ -418,26 +420,28 @@ class LogoController extends Zend_Controller_Action
|
||||
|
||||
function _getlogo( $siren )
|
||||
{
|
||||
require_once 'common/curl.php';
|
||||
$logoUrl = $_REQUEST['logoUrl']['url'];
|
||||
$tabTmp = parse_url($logoUrl);
|
||||
$hostUrl = $tabTmp['host'];
|
||||
$pathUrl = $tabTmp['path'];
|
||||
$tmp = explode('.', basename($pathUrl));
|
||||
$ext = strtolower(end($tmp));
|
||||
$page = getUrl($logoUrl, '', '', '', false, $hostUrl, '', 7);
|
||||
$body = $page['body'];
|
||||
$extAuthorized = array('jpeg', 'jpg', 'png', 'gif', 'bmp');
|
||||
|
||||
try {
|
||||
$client = new Zend_Http_Client($pathUrl);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful() ) {
|
||||
|
||||
$tmp = explode('.', basename($response->getStreamName()));
|
||||
$ext = strtolower(end($tmp));
|
||||
if ( !in_array($ext, $extAuthorized ) )
|
||||
{
|
||||
$tmp = explode('/', $page['header']['Content-Type']);
|
||||
$ext = trim ( str_replace('?', '',strtolower(end($tmp)) ) );
|
||||
}
|
||||
$name_file = $siren.'.'.$ext;
|
||||
$fp = @fopen($this->pathLogo.'/'.$name_file, 'w');
|
||||
@fwrite($fp, $body);
|
||||
@fclose($fp);
|
||||
if( copy($response->getStreamName(), $this->pathLogo.'/'.$name_file) ) {
|
||||
chmod($this->pathLogo.'/'.$name_file, 0755);
|
||||
}
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {}
|
||||
}
|
||||
|
||||
}
|
@ -24,8 +24,6 @@ class TelechargementController extends Zend_Controller_Action
|
||||
{
|
||||
if (!is_dir($this->path)) mkdir($this->path);
|
||||
|
||||
require_once 'common/curl.php';
|
||||
|
||||
// Recuperation du nom du fichier
|
||||
if ($filename===null) {
|
||||
$tableau = explode('/', $url);
|
||||
@ -48,29 +46,23 @@ class TelechargementController extends Zend_Controller_Action
|
||||
}
|
||||
|
||||
// Recuperation du fichier sur le serveur
|
||||
if (!file_exists($this->path.'/'.$file)) {
|
||||
// On check si le fichier est present sur l'url
|
||||
Zend_Registry::get('firebug')->info('URL : '.$url);
|
||||
$url_tab = getUrl($url, '', '', '', false);
|
||||
if ($url_tab['code'] == 408 ||
|
||||
$url_tab['code'] == 400 ||
|
||||
$url_tab['code'] == 404) {
|
||||
// Fichier non disponible
|
||||
Zend_Registry::get('firebug')->info('Fichier non disponible !');
|
||||
return false;
|
||||
} else {
|
||||
// Ecriture du fichier sur le serveur en local
|
||||
$body = $url_tab['body'];
|
||||
Zend_Registry::get('firebug')->info('Taille fichier '.strlen($body));
|
||||
if ( strlen($body) ) {
|
||||
$fp = fopen($this->path.'/'.$file, 'w');
|
||||
fwrite($fp, $body);
|
||||
fclose($fp);
|
||||
Zend_Registry::get('firebug')->info('Ecriture fichier : '.$this->path.'/'.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (file_exists($this->path.'/'.$file)) {
|
||||
return $file;
|
||||
} else {
|
||||
// On check si le fichier est present sur l'url
|
||||
try {
|
||||
$client = new Zend_Http_Client($url);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful() && copy($response->getStreamName(), $this->path.'/'.$file) ) {
|
||||
return $file;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function init()
|
||||
|
@ -156,14 +156,15 @@ class Scores_Google_Streetview
|
||||
*/
|
||||
public function getImg()
|
||||
{
|
||||
require_once 'common/curl.php';
|
||||
$page = getUrl($this->url, '', '', '', false);
|
||||
|
||||
Zend_Registry::get('firebug')->info('URL = '.$this->url);
|
||||
if ( !in_array($page['code'], array(400, 408, 403)) ) {
|
||||
$body = $page['body'];
|
||||
file_put_contents($this->pathImg(), $body);
|
||||
try {
|
||||
$client = new Zend_Http_Client($url);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful() ) {
|
||||
copy($response->getStreamName(), $this->pathImg());
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,27 +38,30 @@ class Logo
|
||||
public function getFromUrl($siteWeb)
|
||||
{
|
||||
$img = false;
|
||||
require_once 'common/curl.php';
|
||||
if (substr($siteWeb,-1)!='/') $siteWeb.='/';
|
||||
|
||||
$arrUrl = parse_url($siteWeb);
|
||||
$page = getUrl($siteWeb, '', '', '', false, $arrUrl['host'], '', 3);
|
||||
$body = $page['body'];
|
||||
if (preg_match('/<img(?:.*)src=(?:"|\')((?:.*)logo(?:.*)(?:gif|png|jpg|jpeg))/Ui', $body, $matches)) {
|
||||
try {
|
||||
$client = new Zend_Http_Client($url);
|
||||
$response = $client->request('GET');
|
||||
$siteBody = $response->getBody();
|
||||
} catch (Zend_Http_Client_Exception $e) {
|
||||
}
|
||||
|
||||
if (preg_match('/<img(?:.*)src=(?:"|\')((?:.*)logo(?:.*)(?:gif|png|jpg|jpeg))/Ui', $siteBody, $matches)) {
|
||||
$logo = trim(strtr($matches[1],'"\'',' '));
|
||||
$urlLogo = $siteWeb.$logo;
|
||||
$tmp = explode('.', basename($logo));
|
||||
$ext = end($tmp);
|
||||
$page = getUrl($urlLogo, '', '', $siteWeb, false, $arrUrl['host']);
|
||||
if($page['code']!=400)
|
||||
{
|
||||
$body = $page['body'];
|
||||
try {
|
||||
$client = new Zend_Http_Client($url);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful() ) {
|
||||
$img = $this->path.'/'.$this->siren.'.'.$ext;
|
||||
$fp = fopen($img, 'a');
|
||||
fwrite($fp, $body);
|
||||
fclose($fp);
|
||||
copy($response->getStreamName(), $img);
|
||||
chmod($img, 0755);
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {}
|
||||
}
|
||||
return $img;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user