inrepublica Posté(e) le 2 octobre 2012 Partager Posté(e) le 2 octobre 2012 (modifié) Bonjour à tous, Je me suis crée un petit script php sur le syno que j'héberge dans le dossier partagé web. Se script effectue quelques requêtes à l'aide de l'extension CURL et les notifie dans un fichier log.txt toujours dans le dossier web. En lançant le script dans un navigateur en local, celui-ci fonctionne à merveille. Par contre dans le but d'automatiser le lancement de ce script, je souhaite le lancer à l'aide de la commande: /usr/bin/php -f /volume1/web/monscript.php Je me connecte donc en telnet au syno et lui lance cette commande, mais c'est remplis d'erreur: PHP Warning: file_exists(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_put_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_put_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_get_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_get_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_put_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_put_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 [2/10/12 15:10:47] - Lancement du script <br>PHP Warning: is_readable(): open_basedir restriction in effect. File(torrent/Towns v0.50b.rar.torrent) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 70 PHP Warning: file_exists(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_put_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_put_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_get_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_get_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_put_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes:/var/lib/asterisk/gui_backups) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_put_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 Je comprend bien que c'est une erreur pour la lecture/ecriture des fichiers, mais pourtant je suis bien en root! Modifié le 2 novembre 2012 par clark17 Lien vers le commentaire Partager sur d’autres sites More sharing options...
loli71 Posté(e) le 2 octobre 2012 Partager Posté(e) le 2 octobre 2012 (modifié) Il s'agit d'un problème de restriction d'accès à ton fichier log.txt par la directive open_basedir de php (qui se trouve dans le php.ini) il faut que tu rajoutes "/volume1/web/php_ratio_manager" dans la ligne open_basedir du fichier php.ini Modifié le 2 octobre 2012 par loli71 1 Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 2 octobre 2012 Auteur Partager Posté(e) le 2 octobre 2012 Ok, merci! Mais c'est bizarre comme comportement d'autoriser la création de ce fichier si je passe par le navigateur, et pas si je le passe en script... Il n'y a pas moyen de contourner se "défaut", comme une autre commande pour que le syno simule un navigateur? Lien vers le commentaire Partager sur d’autres sites More sharing options...
loli71 Posté(e) le 2 octobre 2012 Partager Posté(e) le 2 octobre 2012 (modifié) Je ne sais plus si le fait d'utiliser un script PHP en ligne de commande utilise ou pas le fichier php.ini défini pour le serveur web apache. De même, je me demande si ton problème ne viendrait pas aussi du fait que tu utilises le "-f" pour lancer le script dans ta ligne de commande ... à tester Au cas où, le fichier php.ini se trouve (si je me souviens bien) là : /usr/syno/etc/php/user-setting.ini Où alors au contraire, il faut peut-être que tu rajoutes l'option suivante à ta ligne de commande pour dire à php d'utiliser le fichier php.ini : /usr/bin/php -c /usr/syno/etc/php/user-setting.ini -f /volume1/web/monscript.php Modifié le 2 octobre 2012 par loli71 Lien vers le commentaire Partager sur d’autres sites More sharing options...
PatrickH Posté(e) le 2 octobre 2012 Partager Posté(e) le 2 octobre 2012 Ok, merci! Mais c'est bizarre comme comportement d'autoriser la création de ce fichier si je passe par le navigateur, et pas si je le passe en script... Il n'y a pas moyen de contourner se "défaut", comme une autre commande pour que le syno simule un navigateur? C'est un problème de "sécurité" le php en mode "cli" n'utilise pas les mêmes parametres que le php utilisé par apache pour interpréter ses fichiers ... et ce n'est pas un "défaut" !! Patrick Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 2 octobre 2012 Auteur Partager Posté(e) le 2 octobre 2012 C'est pas un peu bizarre d'autoriser la création de fichier en php si je le lance via apache, et le refuser si je le lance par php? Existe t'il une commande pour lancer mon script php via apache? Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 2 octobre 2012 Auteur Partager Posté(e) le 2 octobre 2012 Bon je viens de tester la modif du php ini, ca ne fonctionne toujours pas... Voici le contenu de mon php.ini open_basedir = /volume1/web:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/v register_globals = Off apc.enabled = 1 display_errors = Off safe_mode_exec_dir = /usr/syno/bin Lien vers le commentaire Partager sur d’autres sites More sharing options...
loli71 Posté(e) le 2 octobre 2012 Partager Posté(e) le 2 octobre 2012 bizarre ton fichier dont la ligne open_basedir se termine par "/v" de toute façon, ton open_basedir contient déjà le répertoire "/volume1/web" en premier, ce qui inclut les répertoire suivant (dont ton répertoire "/volume1/web/php_ratio_manager"). De plus, tu nous indiques que ton script marche bien par le serveur Web, ce qui montre que l'open_basedir est correct. Et pour finir, PatrickH t'a indiqué que php en mode CLI n'utilise pas les même paramètres que le php utilisé par apache, as tu testé la ligne que je t'ai mise 3 postes plus haut ? /usr/bin/php -c /usr/syno/etc/php/user-setting.ini -f /volume1/web/monscript.php Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 2 octobre 2012 Auteur Partager Posté(e) le 2 octobre 2012 Le volume1/web c'est moi qui l'ai rajouté. Putty m'a tronqué la fin de la ligne open_basedir, il y a encore d'autres répertoires en +. Je viens de tester ta commande, ca ne fonctionne pas mieux PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/apc.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/apc.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/bcmath.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/bcmath.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/calendar.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/calendar.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/curl.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/dba.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/dba.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/exif.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/exif.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/ftp.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/ftp.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/gd.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/gettext.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/gettext.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/iconv.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/iconv.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/imap.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/imap.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/mbstring.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/mbstring.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/mysql.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/mysqli.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/openssl.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/openssl.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/pdo_mysql.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/pdo_pgsql.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/pdo_pgsql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/pgsql.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/pgsql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/shmop.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/shmop.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/soap.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/soap.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/sockets.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/sockets.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/wddx.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/wddx.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/xmlrpc.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/xmlrpc.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/zip.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/zip.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/zlib.so' - /usr/syno/php/lib/php/extensions/no-debug-non-zts-20090626/zlib.so: cannot open shared object file: No such file or directory in Unknown on line 0 Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 27 octobre 2012 Auteur Partager Posté(e) le 27 octobre 2012 Je continue mes recherches sur ce sujet. Je pense que le plus simple serait de faire "exécuter" ma page par apache plutôt que php, par contre je ne sais pas comment faire ca... Lien vers le commentaire Partager sur d’autres sites More sharing options...
DjMomo Posté(e) le 27 octobre 2012 Partager Posté(e) le 27 octobre 2012 Le open_basedir ne s'edite pas dans le fichier php.ini ! Mais par ajout du dossier dans le panneau de configuration -> services web Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 27 octobre 2012 Auteur Partager Posté(e) le 27 octobre 2012 Bon finalement, j'ai toujours la même erreur... /usr/bin/php -f /volume1/web/php_ratio_manager/transmission_serveur.php PHP Warning: file_exists(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/volume1/web/php_ratio_manager:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_put_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/volume1/web/php_ratio_manager:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_put_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_get_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/volume1/web/php_ratio_manager:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_get_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_put_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/volume1/web/php_ratio_manager:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_put_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 [27/10/12 18:57:54] - Lancement du script <br>PHP Warning: file_exists(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/volume1/web/php_ratio_manager:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_put_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/volume1/web/php_ratio_manager:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_put_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 20 PHP Warning: file_get_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/volume1/web/php_ratio_manager:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_get_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_put_contents(): open_basedir restriction in effect. File(log.txt) is not within the allowed path(s): (/volume1/web/php_ratio_manager:/etc.defaults:/usr/bin/php:/usr/syno/synoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 PHP Warning: file_put_contents(log.txt): failed to open stream: Operation not permitted in /volume1/web/php_ratio_manager/transmission_serveur.php on line 21 pourtant /volume1/web/php_ratio_manager est bien dans l'openbasedir maintenant... Lien vers le commentaire Partager sur d’autres sites More sharing options...
PatrickH Posté(e) le 29 octobre 2012 Partager Posté(e) le 29 octobre 2012 Ton fichier "log.txt" tu veux l'écrire où exactement (dans quel répertoire)? Patrick Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 29 octobre 2012 Auteur Partager Posté(e) le 29 octobre 2012 Dans /volume1/web/php_ratio_manager/log.txt Lien vers le commentaire Partager sur d’autres sites More sharing options...
PiwiLAbruti Posté(e) le 29 octobre 2012 Partager Posté(e) le 29 octobre 2012 log.txt se trouve dans le même dossier que le script transmission_serveur.php. À mon avis, tu as dû mettre un chemin absolu dans ton script alors qu'il n'y en a pas besoin. Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 29 octobre 2012 Auteur Partager Posté(e) le 29 octobre 2012 Je vais jeter un oeil la dessus... Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 29 octobre 2012 Auteur Partager Posté(e) le 29 octobre 2012 Bon je viens de regarder et pourtant non... Voici la fonction utilisé: // Fonction d'écriture d'un log sur l'écran et dans le fichier log.txt function addLog($txt) { if (!file_exists("log.txt")) file_put_contents("log.txt", ""); file_put_contents("log.txt",date("[j/m/y H:i:s]")." - $txt \r\n".file_get_contents("log.txt")); echo date("[j/m/y H:i:s]")." - $txt <br>"; } Rien d'extraordinaire pourtant... Lien vers le commentaire Partager sur d’autres sites More sharing options...
Mike913 Posté(e) le 31 octobre 2012 Partager Posté(e) le 31 octobre 2012 Bonjour, Perso j' utiliserai plutôt : $fxc = fopen( 'log.txt', "a+"); //'a+' Ouvre en lecture et écriture ; place le pointeur de fichier à la fin du fichier. Si le fichier n'existe pas, on tente de le créer. fputs ($fxc,$txt); fclose ($fxc); et pour l' appel du fichier php: wget -q -O /dev/null http://IP_du_Syno/repertoire/fichier.php Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 31 octobre 2012 Auteur Partager Posté(e) le 31 octobre 2012 Ok c'est noté pour la fonction fopen, j'avais envisagé ça de mémoire mais je voulais écrire dans le sens anti-horaire (les derniers log en premier). Sinon je capte pas ton appel wget? wget c'est pour télécharger un fichier non? Moi je veux qu'il soit exécuté par php... Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 1 novembre 2012 Auteur Partager Posté(e) le 1 novembre 2012 Bon j'avance tout doucement sur le sujet. Mon script avez des erreurs au niveau des chemins d'accès aux fichiers. En effet en l’exécutant par un navigateur le chemin relatif (/configuration/toto.ini) fonctionne bien. Par contre en l’exécutant en ligne de commande (CLI pour les intimes) il lui faut un chemin absolu car il l’exécute non plus dans www mais dans /usr/bin/php. Plus d'infos sur le forum du zero: http://www.siteduzer...e.html#r7808319 Donc je modifie mon script avec des chemins absolus, et je relance ma désormais célèbre commande en SSH sur le syno: /usr/bin/php /volume1/web/php_ratio_manager/transmission_serveur.php Et voici la réponse: PHP Warning: file_put_contents(/volume1/web/php_ratio_manager/log.txt): failed to open stream: Permission denied in /volume1/web/php_ratio_manager/transmission_serveur.php on line 28 Je me retrouve donc avec un problème de permission... Comme je ne suis pas familier avec linux je suis un peu perdu la... Avec un petit ls -l: NAS212j> ls -l -rwxrwxrwx 1 admin users 5672 Nov 1 23:24 commandes.php drwxrwxrwx 2 admin users 4096 Nov 1 23:48 configuration -rwxrwxrwx 1 admin users 385 Nov 1 17:47 credit.html drwxrwxrwx 3 admin users 4096 Nov 1 23:46 images -rwxrwxrwx 1 admin users 4914 Nov 1 18:19 index.php drwxrwxrwx 2 admin users 4096 Nov 1 23:46 librairies -rw-r--r-- 1 nobody nobody 1920 Nov 1 23:48 log.txt -rwxrwxrwx 1 admin users 3364 Nov 1 21:36 readme drwxrwxrwx 2 admin users 4096 Nov 1 23:46 scraper drwxrwxrwx 2 admin users 4096 Nov 1 23:46 torrent -rwxrwxrwx 1 admin users 6017 Nov 1 23:21 transmission_serveur.php Si j'ai bien compris le principe des droits, mon script transmission_serveur.php et pourtant bien exécutable non? Lien vers le commentaire Partager sur d’autres sites More sharing options...
DjMomo Posté(e) le 2 novembre 2012 Partager Posté(e) le 2 novembre 2012 As-tu ton dossier /volume1/web/php_ratio_manager dans ton openbase_dir ? Le problème se pose sur le log.txt qui ne peut être ouvert et non sur le script qui ne peut être exécuté. Lien vers le commentaire Partager sur d’autres sites More sharing options...
inrepublica Posté(e) le 2 novembre 2012 Auteur Partager Posté(e) le 2 novembre 2012 Oui mon dossier est bien ajouté dans le open_base_dir. Par contre effectivement j'ai mal interprété le message d'erreur. Il s'agit bien d'un problème de droit sur le fichier log.txt. Problème résolu avec un petit chmod sur ce fichier. Merci de ton aide! Lien vers le commentaire Partager sur d’autres sites More sharing options...
Mike913 Posté(e) le 2 novembre 2012 Partager Posté(e) le 2 novembre 2012 Ok c'est noté pour la fonction fopen, j'avais envisagé ça de mémoire mais je voulais écrire dans le sens anti-horaire (les derniers log en premier). Sinon je capte pas ton appel wget? wget c'est pour télécharger un fichier non? Moi je veux qu'il soit exécuté par php... Bonjour, Cet appel charge et exécute le fichier, je me sert de cette méthode pour alimenter une base de données toutes les 15 minutes. Lien vers le commentaire Partager sur d’autres sites More sharing options...
Messages recommandés