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,75 +727,80 @@ 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');
|
||||
$dom_object = new DOMDocument();
|
||||
$ws = new WsScores();
|
||||
if(!file_exists($file)) {
|
||||
file_put_contents($file, $xml); // Ne pas oublier de metre les bons droits sur le dossier.
|
||||
$ws->setLog('scorecsf', $this->siret);
|
||||
} else {
|
||||
$ws->setLog('scorecsf', $this->siret, 0, 'local');
|
||||
}
|
||||
$dom_object->load($file);
|
||||
$companyname = $dom_object->getElementsByTagName('companyname')->item(0)->nodeValue;
|
||||
$rating = $dom_object->getElementsByTagName('rating')->item(0)->nodeValue;
|
||||
$ratingdesc1 = str_replace('?',"'",$dom_object->getElementsByTagName('ratingdesc1')->item(0)->nodeValue);
|
||||
$ratingdesc2 = str_replace('?',"'",$dom_object->getElementsByTagName('ratingdesc2')->item(0)->nodeValue);
|
||||
$creditlimit = $dom_object->getElementsByTagName('creditlimit')->item(0)->nodeValue;
|
||||
$libelle = '';
|
||||
if (strtoupper($creditlimit)<>strtolower($creditlimit) || $creditlimit=='')
|
||||
$strCreditlimit = $creditlimit;
|
||||
else
|
||||
$strCreditlimit = number_format($creditlimit,null,null,' '). ' €';
|
||||
|
||||
if ($rating >= 40){
|
||||
$fontColor = 'green';
|
||||
$imgFeux = '<img src="/themes/default/images/scoring/feux_vert.png"/>';
|
||||
if ($rating>=71) $libelle='Très bonne cote de crédit/solvabilité';
|
||||
elseif ($rating>=51) $libelle='Bonne cote de crédit/solvabilité';
|
||||
else $libelle = 'Solvable';
|
||||
} elseif ($rating >= 20) {
|
||||
$fontColor = 'yellow';//#f2be2c';
|
||||
$imgFeux = '<img src="/themes/default/images/scoring/feux_orange.png"/>';
|
||||
$libelle = 'Précautions recommandées';
|
||||
} elseif (strtoupper($rating) <> strtolower($rating)) {
|
||||
$fontColor = 'black';
|
||||
$imgFeux=' ';
|
||||
}
|
||||
elseif ($rating == '') {
|
||||
$fontColor = 'black';
|
||||
$imgFeux = ' ';
|
||||
}
|
||||
else {
|
||||
$fontColor = 'red';
|
||||
$imgFeux = '<img src="/themes/default/images/scoring/feux_rouge.png"/>';
|
||||
if ($rating == 0) $libelle='Entreprise en situation de défaillance et ayant un très fort risque de radiation';
|
||||
else $libelle = 'Avertissement - Crédit à votre discrétion';
|
||||
}
|
||||
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');
|
||||
|
||||
/** Assigne les valeur a la vue **/
|
||||
if (!empty($companyname)) {
|
||||
$this->view->raisonSociale = $companyname;
|
||||
} else {
|
||||
$session = new SessionEntreprise($this->siret, $this->id);
|
||||
$this->view->raisonSociale = $session->getRaisonSociale();
|
||||
}
|
||||
$this->view->emailCommande = $user->getEmail();
|
||||
$this->view->id = $this->id;
|
||||
$this->view->siren = substr($this->siret, 0,9);
|
||||
$this->view->imgFeux = $imgFeux;
|
||||
$this->view->fontColor = $fontColor;
|
||||
$this->view->rating = $rating;
|
||||
$this->view->libelle = $libelle;
|
||||
$this->view->strCreditlimit = $strCreditlimit;
|
||||
$dom_object = new DOMDocument();
|
||||
$ws = new WsScores();
|
||||
if(!file_exists($file)) {
|
||||
file_put_contents($file, $xml); // Ne pas oublier de metre les bons droits sur le dossier.
|
||||
$ws->setLog('scorecsf', $this->siret);
|
||||
} else {
|
||||
$ws->setLog('scorecsf', $this->siret, 0, 'local');
|
||||
}
|
||||
$dom_object->load($file);
|
||||
$companyname = $dom_object->getElementsByTagName('companyname')->item(0)->nodeValue;
|
||||
$rating = $dom_object->getElementsByTagName('rating')->item(0)->nodeValue;
|
||||
$ratingdesc1 = str_replace('?',"'",$dom_object->getElementsByTagName('ratingdesc1')->item(0)->nodeValue);
|
||||
$ratingdesc2 = str_replace('?',"'",$dom_object->getElementsByTagName('ratingdesc2')->item(0)->nodeValue);
|
||||
$creditlimit = $dom_object->getElementsByTagName('creditlimit')->item(0)->nodeValue;
|
||||
$libelle = '';
|
||||
if (strtoupper($creditlimit)<>strtolower($creditlimit) || $creditlimit=='')
|
||||
$strCreditlimit = $creditlimit;
|
||||
else
|
||||
$strCreditlimit = number_format($creditlimit,null,null,' '). ' €';
|
||||
|
||||
if ($rating >= 40){
|
||||
$fontColor = 'green';
|
||||
$imgFeux = '<img src="/themes/default/images/scoring/feux_vert.png"/>';
|
||||
if ($rating>=71) $libelle='Très bonne cote de crédit/solvabilité';
|
||||
elseif ($rating>=51) $libelle='Bonne cote de crédit/solvabilité';
|
||||
else $libelle = 'Solvable';
|
||||
} elseif ($rating >= 20) {
|
||||
$fontColor = 'yellow';//#f2be2c';
|
||||
$imgFeux = '<img src="/themes/default/images/scoring/feux_orange.png"/>';
|
||||
$libelle = 'Précautions recommandées';
|
||||
} elseif (strtoupper($rating) <> strtolower($rating)) {
|
||||
$fontColor = 'black';
|
||||
$imgFeux=' ';
|
||||
}
|
||||
elseif ($rating == '') {
|
||||
$fontColor = 'black';
|
||||
$imgFeux = ' ';
|
||||
}
|
||||
else {
|
||||
$fontColor = 'red';
|
||||
$imgFeux = '<img src="/themes/default/images/scoring/feux_rouge.png"/>';
|
||||
if ($rating == 0) $libelle='Entreprise en situation de défaillance et ayant un très fort risque de radiation';
|
||||
else $libelle = 'Avertissement - Crédit à votre discrétion';
|
||||
}
|
||||
|
||||
/** Assigne les valeur a la vue **/
|
||||
if (!empty($companyname)) {
|
||||
$this->view->raisonSociale = $companyname;
|
||||
} else {
|
||||
$session = new SessionEntreprise($this->siret, $this->id);
|
||||
$this->view->raisonSociale = $session->getRaisonSociale();
|
||||
}
|
||||
$this->view->emailCommande = $user->getEmail();
|
||||
$this->view->id = $this->id;
|
||||
$this->view->siren = substr($this->siret, 0,9);
|
||||
$this->view->imgFeux = $imgFeux;
|
||||
$this->view->fontColor = $fontColor;
|
||||
$this->view->rating = $rating;
|
||||
$this->view->libelle = $libelle;
|
||||
$this->view->strCreditlimit = $strCreditlimit;
|
||||
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,13 +2,13 @@
|
||||
class LogoController extends Zend_Controller_Action
|
||||
{
|
||||
protected $pathLogo = '';
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->pathLogo = $c->profil->path->data.'/logos';
|
||||
}
|
||||
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
@ -16,18 +16,18 @@ class LogoController extends Zend_Controller_Action
|
||||
$siren = $request->getParam('siren', '');
|
||||
$isin = $request->getParam('isin', '');
|
||||
$logo = $this->_findlogo($siren, $isin);
|
||||
|
||||
|
||||
$this->view->assign('siren', $siren);
|
||||
$this->view->assign('logo', $logo);
|
||||
}
|
||||
|
||||
|
||||
public function uploadAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
$siren = $request->getParam('siren');
|
||||
|
||||
|
||||
if ($request->isPost()) {
|
||||
|
||||
if ( !empty($siren) && isset($_FILES['file']) && $_FILES['file']['error']!=UPLOAD_ERR_NO_FILE )
|
||||
@ -66,25 +66,25 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
$this->view->assign('siren', $siren);
|
||||
}
|
||||
|
||||
|
||||
public function cropAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
$siren = $request->getParam('siren');
|
||||
$image = $request->getParam('image');
|
||||
|
||||
|
||||
if ($request->isPost())
|
||||
{
|
||||
$jpeg_quality = 90;
|
||||
$png_quality = 9;
|
||||
|
||||
|
||||
list($name, $ext) = explode('.', $image);
|
||||
|
||||
|
||||
$src = $name.'.'.$ext;
|
||||
$dst = str_replace('tmp_', '', $src);
|
||||
|
||||
|
||||
//Création image
|
||||
switch($ext){
|
||||
case 'gif':
|
||||
@ -125,14 +125,14 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
$this->view->assign('siren', $siren);
|
||||
}
|
||||
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
$file = $request->getParam('image');
|
||||
|
||||
|
||||
if ( !empty($file) ) {
|
||||
list($name, $ext) = explode('.', $file);
|
||||
$name_dst = str_replace('tmp_','',$name);
|
||||
@ -196,79 +196,81 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
}
|
||||
$this->view->assign('message', $message);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function urlAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
$siren = $request->getParam('siren');
|
||||
|
||||
|
||||
if ($request->isPost()){
|
||||
|
||||
require_once 'common/curl.php';
|
||||
|
||||
$logoUrl = $request->getParam('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');
|
||||
|
||||
|
||||
//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);
|
||||
$this->view->assign('image', $name_file);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
$file = $request->getParam('image');
|
||||
|
||||
|
||||
if ( !empty($file) ){
|
||||
$message = "Erreur suppression fichier.";
|
||||
if ( unlink($this->pathLogo.'/'.$file)){
|
||||
$message = 'Fichier supprimé.';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->view->assign('message', $message);
|
||||
}
|
||||
|
||||
|
||||
//====> Function interne
|
||||
|
||||
|
||||
function _logo( $siren )
|
||||
{
|
||||
$message = '';
|
||||
if ( isset($_FILES['logoFile']) &&
|
||||
$_FILES['logoFile']['error']!=UPLOAD_ERR_NO_FILE ) {
|
||||
|
||||
|
||||
/** Un fichier a été uploadé **/
|
||||
$logoFile = $_FILES['logoFile'];
|
||||
$tmp_file = $logoFile['tmp_name'];
|
||||
|
||||
|
||||
if ( $logoFile['error']!=UPLOAD_ERR_OK ) {
|
||||
$message = 'Erreur lors de la copie du fichier';
|
||||
}
|
||||
|
||||
|
||||
if ( !is_uploaded_file($tmp_file) ){
|
||||
$message = "Le fichier est introuvable";
|
||||
} else {
|
||||
@ -294,9 +296,9 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
//Suppression ou URL fichier image
|
||||
} elseif ( isset($_REQUEST['logoUrl']['del']) ||
|
||||
( isset($_REQUEST['logoUrl']['url']) &&
|
||||
$_REQUEST['logoUrl']['url']!='' ) ) {
|
||||
|
||||
( isset($_REQUEST['logoUrl']['url']) &&
|
||||
$_REQUEST['logoUrl']['url']!='' ) ) {
|
||||
|
||||
//Suppression du fichier
|
||||
if ( isset($_REQUEST['logoUrl']['del']) && $_REQUEST['logoUrl']['del'] )
|
||||
{
|
||||
@ -307,12 +309,12 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
}
|
||||
} else {
|
||||
saisie_getlogo($siren);
|
||||
$this->_getlogo($siren);
|
||||
}
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
||||
function _saveimg( $siren )
|
||||
{
|
||||
$message = '';
|
||||
@ -349,7 +351,7 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
function _findlogo( $siren, $isin = '' )
|
||||
{
|
||||
$img = '';
|
||||
@ -372,14 +374,14 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
return $img;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function _loadlogo( $siren, $isin = '' )
|
||||
{
|
||||
$urlImg = '';
|
||||
$locImg = $this->pathLogo.'/'.$siren;
|
||||
$extensions = array('jpeg', 'jpg', 'png', 'gif', 'bmp');
|
||||
|
||||
|
||||
//Recherche image sur base siren
|
||||
foreach ( $extensions as $ext ) {
|
||||
if ( file_exists($locImg.'.'.$ext) ) {
|
||||
@ -387,7 +389,7 @@ class LogoController extends Zend_Controller_Action
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Recherche image sur base isin
|
||||
if ( $urlImg == '' && $isin != '' ) {
|
||||
$locImg = PATH_LOGOS . $isin;
|
||||
@ -398,7 +400,7 @@ class LogoController extends Zend_Controller_Action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$output = '';
|
||||
//Redimensionnement
|
||||
if ( $urlImg != '' ) {
|
||||
@ -410,34 +412,36 @@ class LogoController extends Zend_Controller_Action
|
||||
} else {
|
||||
$strSize = '';
|
||||
}
|
||||
|
||||
|
||||
$output = '<img src="'.$urlImg.'" '.$strSize.'/>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
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');
|
||||
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);
|
||||
chmod($this->pathLogo.'/'.$name_file, 0755);
|
||||
|
||||
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;
|
||||
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)) {
|
||||
if (file_exists($this->path.'/'.$file)) {
|
||||
return $file;
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
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) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@ class Logo
|
||||
protected $isin = null;
|
||||
protected $logoNom = '';
|
||||
protected $logoSize = '';
|
||||
|
||||
|
||||
public function __construct($siren, $isin = null)
|
||||
{
|
||||
$c = Zend_Registry::get('config');
|
||||
@ -14,7 +14,7 @@ class Logo
|
||||
$this->siren = $siren;
|
||||
$this->isin = $isin;
|
||||
}
|
||||
|
||||
|
||||
public function affiche()
|
||||
{
|
||||
// Ne pas afficher le logo si il n'existe pas OU
|
||||
@ -34,35 +34,38 @@ class Logo
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
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'];
|
||||
$img = $this->path.'/'.$this->siren.'.'.$ext;
|
||||
$fp = fopen($img, 'a');
|
||||
fwrite($fp, $body);
|
||||
fclose($fp);
|
||||
chmod($img, 0755);
|
||||
}
|
||||
try {
|
||||
$client = new Zend_Http_Client($url);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful() ) {
|
||||
$img = $this->path.'/'.$this->siren.'.'.$ext;
|
||||
copy($response->getStreamName(), $img);
|
||||
chmod($img, 0755);
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {}
|
||||
}
|
||||
return $img;
|
||||
}
|
||||
|
||||
|
||||
public function exist()
|
||||
{
|
||||
$img_ext = array('gif', 'png', 'jpg', 'jpeg');
|
||||
@ -88,8 +91,8 @@ class Logo
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function redimage($img_src,$dst_w,$dst_h) {
|
||||
// Lit les dimensions de l'image
|
||||
$size = getimagesize($img_src);
|
||||
@ -104,9 +107,9 @@ class Logo
|
||||
// Sinon teste quel redimensionnement tient dans la zone
|
||||
elseif($test_h>$dst_h) $dst_w = $test_w;
|
||||
else $dst_h = $test_h;
|
||||
|
||||
|
||||
// Affiche les dimensions optimales
|
||||
return "width=".$dst_w." height=".$dst_h;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user