Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 99f3c372 authored by NINASSI Benjamin's avatar NINASSI Benjamin
Browse files

improvement of failed logo detection

parent 9451f2c1
Branches
No related tags found
No related merge requests found
......@@ -50,10 +50,9 @@ class VerifyStructuresLogoCommand extends ContainerAwareCommand
foreach ($structures as $structure) {
$logo = $structure->getLogo();
if($logo){
$file_headers = @get_headers($logo);
if(!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') {
$logo_error_tab[]="Le logo ".$logo." n'existe pas (file not found) pour la structure <b>".$structure->getName()."</b>";
$exists = false;
$exists = $this->is_url_exist($logo);
if(!$exists){
$logo_error_tab[]="Le logo ".$logo." n'existe pas (file not found) pour la structure <b>".$structure->getName()."</b>";
}
}else{
$logo_error_tab[]="Pas de logo défini pour la structure <b>".$structure->getName()."</b>";
......@@ -99,6 +98,21 @@ class VerifyStructuresLogoCommand extends ContainerAwareCommand
$mailer = $container->get('mailer');
$mailer->send($message);
}
private function is_url_exist($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code == 200){
$status = true;
}else{
$status = false;
}
curl_close($ch);
return $status;
}
}
\ No newline at end of file
......@@ -179,7 +179,7 @@ class StructureController extends Controller
$structuresLogos = array();
foreach ($structures as $structure) {
$logo = $structure->getLogo();
if($logo && !in_array ($logo,$structuresLogos)){
if($logo && !in_array($logo,$structuresLogos)){
$structuresLogos[] = $logo;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment