[RESOLU] Insérer une image pour une variable

Mammouth du PHP | 643 Messages

12 mai 2017, 17:54

Effectivement, "ne peut etre que utilisé sur des urls"
Effectivement c'est le but puisque je teste afin de savoir si ca rend un NOT FOUND ou pas

Mais pourquoi ca marche pour une page et pas l'autre comme dans mon exemple fourni:
http://tripday.fr/sortie/sortir-avignon.html ( ça marche )
http://tripday.fr/sortie/sortir-voiron.html ( ça marche pas )

Le code est le même pour les 2 pages ...

J'ai fait un var_dump de $url_inextante et j'obtiens donc par exemple :

array (size=11)
0 => string 'HTTP/1.1 404 Not Found' (length=22)
'Server' => string 'nginx/1.2.3' (length=11)
'Date' => string 'Fri, 12 May 2017 17:04:59 GMT' (length=29)
'Content-Type' => string 'text/html; charset=iso-8859-1' (length=29)
'Content-Length' => string '234' (length=3)
'Connection' => string 'close' (length=5)
'Accept-Ranges' => string 'bytes' (length=5)
'X-Varnish' => string '2728308185 2728306629' (length=21)
'Age' => string '51' (length=2)
'Via' => string '1.1 varnish' (length=11)
'X-Varnish-Cache' => string 'HIT' (length=3)

Pour rapel j'ai ce problème que en ligne pas en local

Edit:
J'ai testé ceci mais pareil :
if (!empty($ligne['photo']) && file_exists('annonce/img-big-format/miniature/'.$ligne['photo'])) {
    $image = '../annonce/img-big-format/miniature/'.$ligne['photo'];
	  // Si l'image renvoyé est une 404
      }elseif (preg_match("#Not Found#i", $url_inexistante[0])) {
        $ligne['photo'] = 'http://monsite.fr/annonce/img-big-format/defaut.jpg';
          }else{
            $image = '../annonce/remplacement/'.simplification($aLoisirs[$ligne['id_type_loisirs']]).'.jpg';
            }
Le lien qui génére la 404 du coup:
https://static.ticketmaster.fr/static/i ... 398186.gif

Mammouth du PHP | 643 Messages

12 mai 2017, 23:18

Bon j'ai pu avancer et enfin compris le problème, ça vient de ma condition en fait
$url_inexistante = get_headers($ligne['photo'], 1);

if (!empty($ligne['photo']) && $ligne['id_simply_user'] <> '1000' && file_exists('annonce/img-big-format/miniature/'.$ligne['photo'])) {
    $image = '../annonce/img-big-format/miniature/'.$ligne['photo'];
	  // Si l'image renvoyé est une 404
      }elseif (!empty($ligne['photo']) && $ligne['id_simply_user'] = '1000' && preg_match("#Not Found#i", $url_inexistante[0])) {
        $ligne['photo'] = 'http://tripday.fr/annonce/img-big-format/defaut.jpg';
          }else{
            $image = '../annonce/remplacement/'.simplification($aLoisirs[$ligne['id_type_loisirs']]).'.jpg';
            }	
Le but est que si l'id_symply_user est différent de 1000 alors on affiche : /annonce/img-big-format/miniature/'.$ligne['photo'];

Si id_symply_user = 1000 et que la page retourne une 404 alors on affiche l'image par defaut

Sinon bah on applique la photo selon le type de loisir

Le problème vient des photos posté par les internautes qui on un id_simply_user différent de 1000