Page 1 sur 1

scandir impossible

Posté : 24 janv. 2018, 18:22
par Beethoven
Bonjour en PHP 7.0 avec apache sous ubuntu je n'arrive pas à scanner un répertoire
à partir du .php qui est à la racine du projet
voici le code php

Code : Tout sélectionner

<?php foreach(scandir(__DIR__.'/img/photo/realisation') as $filename){ echo $filename; }?>
Il n'affiche rien

et j'ai ces droits dans le réperoire img directement sous le .php qui est à la racine du projet :
drwxrwx--- 4 root www-data 4096 déc. 29 10:26 img
et dans img
drwxrwx--- 7 root www-data 4096 déc. 29 10:26 photo
et dans photo
drwxrwx--- 2 root www-data 4096 déc. 29 10:26 realisation
et dans realisation
-rwxrwx--- 1 root www-data 66312 sept. 23 2014 toto.jpg

nota :
Je n'ai pas d'erreurs php dans les logs
j'ai lancé apache avec l'utilisateur root

Que faire?

Re: scandir impossible

Posté : 24 janv. 2018, 18:42
par @rthur
Bonjour,
Bah moi je debuguerai en faisant des var_dump() des différents répertoires, jusqu'à trouver ce qui bloque.
...et bien sûr en activant l'affichage des erreurs en E_ALL si ce n'est pas déjà fait.
<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);

var_dump(__DIR__);
echo '<hr />';

var_dump(scandir(__DIR__));
echo '<hr />';

var_dump(scandir(__DIR__.'/img'));
echo '<hr />';

var_dump(scandir(__DIR__.'/img/photo'));
echo '<hr />';

var_dump(scandir(__DIR__.'/img/photo/realisation'));
echo '<hr />';

Re: scandir impossible

Posté : 25 janv. 2018, 11:17
par Beethoven
Merci, en fait j'arrive bien à scanner les répertoires mais c'est l'utilisation de timthumb.php qui pose problème, il n'affiche pas les images.
le html généré est :
<div class="fotorama__stage__frame fotorama__error fotorama__active" style="left: 0px;"></div>
et cela me génère plein d'erreurs, sur la console avec f12 j'ai pleins d'erreur 400 style:
timthumb.php:1 GET http://10.50.0.19/timthumb.php?src=/img ... JPG&w=1000 400 (Bad Request)
Pourtant je n'ai pas changé timthumb.php je viens juste de tout réinstaller sur un nouveau serveur apache (avec le module rewrite activé)

Voici mon code entier de /var/www/html/realisation.php:
<?php include("inc/header.php"); ?>

<div class="page realisation">

-a-
<?php echo __DIR__."/img/photo/realisation"; ?>
-b-<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);

var_dump(__DIR__);
echo '<hr />';

var_dump(scandir(__DIR__));
echo '<hr />';

var_dump(scandir(__DIR__.'/img'));
echo '<hr />';

var_dump(scandir(__DIR__.'/img/photo'));
echo '<hr />';

var_dump(scandir(__DIR__.'/img/photo/realisation'));
echo '<hr />';
?>
-c-
     <?php foreach(scandir(__DIR__.'/img/photo/realisation') as $filename){
         echo $filename;
     }?>
-d-

                    <?php $photos = scandir(__DIR__.'/img/photo/realisation'); ?>
                    <?php foreach ($photos as $p) { ?>
                        <?php if ($p != '..' & $p != '.'): ?>
                            <?= $p ?>
                        <?php endif ?>
                    <?php } ?>
-e-
             <div class="foto-container">
                <div class="fotorama" data-nav="thumbs" data-nav="thumbs" data-thumbheight="64" data-thumbheight="64"
                    data-autoplay="true"
                    data-width="100%"
                    data-ratio="800/500">

                <?php $photos = scandir(__DIR__.'/img/photo/realisation'); ?>
                    <?php foreach ($photos as $p) { ?>
                        <?php if ($p != '..' & $p != '.'): ?>
                            <img src="/timthumb.php?src=/img/photo/realisation/<?= $p ?>&w=1000">
                        <?php endif ?>
                    <?php } ?>
                </div>
            </div>
</div>

<?php include("inc/footer.php"); ?>
et ce qu'il m'affiche:


-a- /var/www/html/img/photo/realisation

-b-string(13) "/var/www/html"
array(20) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(21) "Presentation_Full.mp4" [3]=> string(21) "Presentation_Half.mp4" [4]=> string(5) "cache" [5]=> string(11) "contact.php" [6]=> string(16) "contact_send.php" [7]=> string(3) "css" [8]=> string(5) "fonts" [9]=> string(10) "groupe.php" [10]=> string(3) "img" [11]=> string(3) "inc" [12]=> string(9) "index.php" [13]=> string(2) "js" [14]=> string(15) "realisation.php" [15]=> string(15) "recrut_send.php" [16]=> string(15) "recrutement.php" [17]=> string(11) "service.php" [18]=> string(11) "station.php" [19]=> string(12) "timthumb.php" }
array(17) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(8) "bg01.jpg" [3]=> string(8) "bg01.png" [4]=> string(9) "bgmap.png" [5]=> string(4) "icon" [6]=> string(8) "logo.png" [7]=> string(7) "map.jpg" [8]=> string(5) "photo" [9]=> string(11) "station.png" [10]=> string(15) "wafit_blanc.png" [11]=> string(9) "zone1.png" [12]=> string(9) "zone2.png" [13]=> string(9) "zone3.png" [14]=> string(9) "zone4.png" [15]=> string(9) "zone5.png" [16]=> string(9) "zone6.png" }
array(7) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(7) "accueil" [3]=> string(7) "bandeau" [4]=> string(11) "realisation" [5]=> string(7) "resized" [6]=> string(7) "service" }
array(43) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(16) "AD systeme U.JPG" [3]=> string(8) "AGIP.jpg" [4]=> string(20) "Apareil Dis ESSO.JPG" [5]=> string(10) "BLIGNY.jpg" [6]=> string(15) "Boutique BP.jpg" [7]=> string(11) "Cuves 3.JPG" [8]=> string(9) "Cuves.jpg" [9]=> string(16) "Distribution.jpg" [10]=> string(59) "ESSO DIETSCH Remplacement des tuyauteries de depotages .JPG" [11]=> string(8) "Elan.JPG" [12]=> string(16) "ElectricitВ.jpg" [13]=> string(26) "Genie civil Palplanche.JPG" [14]=> string(17) "Intermarche 1.JPG" [15]=> string(16) "Ludo S50 014.jpg" [16]=> string(12) "Monoprix.jpg" [17]=> string(19) "Port - leperrey.jpg" [18]=> string(14) "Privatif 1.JPG" [19]=> string(11) "St Pois.JPG" [20]=> string(20) "Systeme U - Brie.jpg" [21]=> string(22) "Systeme U Beauvais.JPG" [22]=> string(17) "Toilettes PMR.JPG" [23]=> string(33) "Total Fos-03-04-2008-DSCF1946.JPG" [24]=> string(15) "Tuyaterie 1.JPG" [25]=> string(34) "Tuyauterie - DВpot PВtrolier.JPG" [26]=> string(14) "Tuyauterie.JPG" [27]=> string(16) "acess mureau.JPG" [28]=> string(26) "chateau-20130507-00449.jpg" [29]=> string(11) "chateau.JPG" [30]=> string(26) "chateau20130523_084835.jpg" [31]=> string(26) "chateau20130523_084853.jpg" [32]=> string(26) "chateau20130523_085241.jpg" [33]=> string(26) "chateau20130523_085307.jpg" [34]=> string(11) "cuves 2.JPG" [35]=> string(15) "intermarche.JPG" [36]=> string(14) "privatif 2.JPG" [37]=> string(14) "privatif 3.JPG" [38]=> string(14) "privatif 4.jpg" [39]=> string(14) "privatif 5.jpg" [40]=> string(14) "privatif 6.JPG" [41]=> string(14) "privatif 7.jpg" [42]=> string(24) "systeme U Palplanche.jpg" }

-c- ...AD systeme U.JPGAGIP.jpgApareil Dis ESSO.JPGBLIGNY.jpgBoutique BP.jpgCuves 3.JPGCuves.jpgDistribution.jpgESSO DIETSCH Remplacement des tuyauteries de depotages .JPGElan.JPGElectricitВ.jpgGenie civil Palplanche.JPGIntermarche 1.JPGLudo S50 014.jpgMonoprix.jpgPort - leperrey.jpgPrivatif 1.JPGSt Pois.JPGSysteme U - Brie.jpgSysteme U Beauvais.JPGToilettes PMR.JPGTotal Fos-03-04-2008-DSCF1946.JPGTuyaterie 1.JPGTuyauterie - DВpot PВtrolier.JPGTuyauterie.JPGacess mureau.JPGchateau-20130507-00449.jpgchateau.JPGchateau20130523_084835.jpgchateau20130523_084853.jpgchateau20130523_085241.jpgchateau20130523_085307.jpgcuves 2.JPGintermarche.JPGprivatif 2.JPGprivatif 3.JPGprivatif 4.jpgprivatif 5.jpgprivatif 6.JPGprivatif 7.jpgsysteme U Palplanche.jpg

-d- AD systeme U.JPG AGIP.jpg Apareil Dis ESSO.JPG BLIGNY.jpg Boutique BP.jpg Cuves 3.JPG Cuves.jpg Distribution.jpg ESSO DIETSCH Remplacement des tuyauteries de depotages .JPG Elan.JPG ElectricitВ.jpg Genie civil Palplanche.JPG Intermarche 1.JPG Ludo S50 014.jpg Monoprix.jpg Port - leperrey.jpg Privatif 1.JPG St Pois.JPG Systeme U - Brie.jpg Systeme U Beauvais.JPG Toilettes PMR.JPG Total Fos-03-04-2008-DSCF1946.JPG Tuyaterie 1.JPG Tuyauterie - DВpot PВtrolier.JPG Tuyauterie.JPG acess mureau.JPG chateau-20130507-00449.jpg chateau.JPG chateau20130523_084835.jpg chateau20130523_084853.jpg chateau20130523_085241.jpg chateau20130523_085307.jpg cuves 2.JPG intermarche.JPG privatif 2.JPG privatif 3.JPG privatif 4.jpg privatif 5.jpg privatif 6.JPG privatif 7.jpg systeme U Palplanche.jpg

-e-

Re: scandir impossible

Posté : 25 janv. 2018, 11:55
par Beethoven
j'ai une bonne piste
http://10.50.0.19/timthumb.php?src=/img ... JPG&w=1000
m'affiche :
A TimThumb error has occured

The following error(s) occured:
GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library

Query String : src=/img/photo/realisation/Systeme%20U%20Beauvais.JPG&w=1000
TimThumb version : 2.8.13

savez vous comment installer cette librairie sous debian?

Re: scandir impossible

Posté : 25 janv. 2018, 14:41
par Beethoven
c'est
sudo apt-get install php7.0-gd (ou php7.1-gd ou php7.2-gd)

Re: scandir impossible

Posté : 25 janv. 2018, 14:42
par Beethoven
Résolu