89 lines
2.0 KiB
PHP
89 lines
2.0 KiB
PHP
<?php
|
|
|
|
function getLogo($siteWeb, $siren)
|
|
{
|
|
global $firephp;
|
|
$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)) {
|
|
$logo = trim(strtr($matches[1],'"\'',' '));
|
|
$urlLogo = $siteWeb.$logo;
|
|
|
|
$tmp = explode('.', basename($logo));
|
|
$ext = end($tmp);
|
|
|
|
$page = getUrl($urlLogo, '', '', $siteWeb, false, $arrUrl['host']);
|
|
$firephp->log($page,'page');
|
|
if($page['code']!=400)
|
|
{
|
|
$body = $page['body'];
|
|
$fp = fopen(PATH_LOGOS.$siren.'.'.$ext, 'a');
|
|
fwrite($fp, $body);
|
|
fclose($fp);
|
|
$img = $siren.'.'.$ext;
|
|
}
|
|
}
|
|
return $img;
|
|
}
|
|
|
|
|
|
function logo_exist($siren, $isin = '', $web = '')
|
|
{
|
|
global $firephp;
|
|
$img_ext = array('gif', 'png', 'jpg', 'jpeg');
|
|
$urlImg = '';
|
|
$ext = '';
|
|
// Recherche le logo avec le siren
|
|
$locImg = PATH_LOGOS.$siren;
|
|
foreach($img_ext as $extension)
|
|
{
|
|
if( file_exists($locImg.'.'.$extension) )
|
|
{
|
|
$urlImg = './logos/'.$siren.'.'.$extension;
|
|
$ext = '.'.$extension;
|
|
break;
|
|
}
|
|
}
|
|
// Recherche de logos avec le code isin
|
|
if($urlImg=='' && $isin!='')
|
|
{
|
|
$locImg=PATH_LOGOS.$isin;
|
|
foreach($img_ext as $extension)
|
|
{
|
|
if( file_exists($locImg.'.'.$extension) )
|
|
{
|
|
$urlImg = './logos/'.$isin.'.'.$extension;
|
|
$ext = '.'.$extension;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if( trim($web)!='' && $urlImg=='' )
|
|
{
|
|
$login = array('ylenaour', 'mpurcarin', 'mcochet', 'aegasse', 'jmartory', 'mricois');
|
|
$locImg = '';
|
|
if (substr($web,0,7)!='http://') $siteWeb = 'http://'.$web;
|
|
else $siteWeb = $web;
|
|
|
|
if ( in_array($_SESSION['tabInfo']['login'], $login) )
|
|
{
|
|
$img = getLogo($siteWeb, $siren);
|
|
$firephp->log($img, 'image');
|
|
if($img!==false)
|
|
{
|
|
$urlImg = './logos/'.$img;
|
|
list($locImg, $ext) = explode('.', $img);
|
|
$ext = '.'.$ext;
|
|
}
|
|
}
|
|
}
|
|
return array($urlImg, $locImg.$ext);
|
|
}
|
|
|