Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

fonction include non prise en compte enre balise {php}

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
bifannen
Smarty Rookie


Joined: 07 Dec 2010
Posts: 6

PostPosted: Tue Dec 07, 2010 9:13 am    Post subject: fonction include non prise en compte enre balise {php} Reply with quote

bonjour,
je débute en smarty,
e j'ai un soucis, j'ai écrit du code php dans un fichier template dans les balises {php}, j'appelle une page externe par la fonction include, cela marche en local mais n'est pas pris en compte en ligne...

Que faire ? Est-ce normal ?

Merci
Back to top
View user's profile Send private message
bifannen
Smarty Rookie


Joined: 07 Dec 2010
Posts: 6

PostPosted: Tue Dec 07, 2010 9:42 am    Post subject: Reply with quote

Si cela peu aider certains à m'aider :

Code:

        {php}
      if(isset($_POST['cpl'])){
             global $cpl;
             $cpl = $_POST['cpl'];
             include('http://lesitequejechercheainclure?cpl='.$cpl.'&tre=GVEG');
      }
       {/php}


Je ne comprends vraimen pas pourquoi cela marche en local e pas en ligne.
Back to top
View user's profile Send private message
Gowser
Smarty Pro


Joined: 19 Feb 2008
Posts: 104
Location: Nantes (France)

PostPosted: Tue Dec 07, 2010 6:49 pm    Post subject: Reply with quote

Es-tu sur que les variables globales ne sont pas désactivées sur le serveur ?

Pour le voir :
Code:

print_r(ini_get_all());


et vérifié si register_globals est à "On". Lien : http://www.php.net/manual/fr/security.globals.php

par contre je te déconseille vivement l'utilisation des globales en PHP, un vrai gruyère niveau sécurité

++
Back to top
View user's profile Send private message Send e-mail
bifannen
Smarty Rookie


Joined: 07 Dec 2010
Posts: 6

PostPosted: Thu Dec 09, 2010 2:37 pm    Post subject: Reply with quote

Bonjour,
merci pour votre réponse.

Déjà en effet j'ai enlevé global à la variable $cpl.

Sinon en fait c'est vraiment étrange.

voici mon code :


Code:

{php}
   $cpl = $this->get_template_vars('cpl');
   include('http://www.monurl.com?cpl='.$cpl);
{/php}


Je ne comprends pas, ma version locale m'affiche parfaitement l'inclusion de la page appelée, mais en ligne impossible, je peux bien afficher la variable $cpl, mais l'inclusion n'est pas prise en compte.

D'où cela peut-il provenir ? Y a-t-il des restrictions à l'utilisation de l'include php dans des balises {php} sur un template (je développe un site en base prestashop, NDLR).

J'ai presque fini, il ne me manque que ça !!!
à l'aide !!!
Merci d'avance.
Back to top
View user's profile Send private message
Gowser
Smarty Pro


Joined: 19 Feb 2008
Posts: 104
Location: Nantes (France)

PostPosted: Thu Dec 09, 2010 3:51 pm    Post subject: Reply with quote

Ca doit venir de la config de ton serveur qui n'autorise pas els ouverture distante de fichier, tu dois avoir la variable 'allow_url_fopen' de la config PHP à Off

Encore un coup de
Code:

print_r(ini_get_all());

pour le voir Smile (ou un phpinfo Smile )


http://fr2.php.net/manual/fr/filesystem.configuration.php#ini.allow-url-fopen

++
Back to top
View user's profile Send private message Send e-mail
bifannen
Smarty Rookie


Joined: 07 Dec 2010
Posts: 6

PostPosted: Thu Dec 09, 2010 4:39 pm    Post subject: Reply with quote

Ouiiiii
merci c'ets exactement ça,
la fonction allow_url_fopen est à OFF...

Comment puis-je changer cela ?

Merci mille fois !!!
Back to top
View user's profile Send private message
bifannen
Smarty Rookie


Joined: 07 Dec 2010
Posts: 6

PostPosted: Thu Dec 09, 2010 5:35 pm    Post subject: [Resolu] Reply with quote

C'est bon !!!

j'ai contourné la configuration de mon serveur grâce à la bibliothèque cURL => http://wiki.dreamhost.com/index.php/CURL

Code:

    $site_url = 'http://monurl.com';

    $ch = curl_init();
    $timeout = 5; // set to zero for no timeout
    curl_setopt ($ch, CURLOPT_URL, $site_url);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
   
    ob_start();
    curl_exec($ch);
    curl_close($ch);
    $file_contents = ob_get_contents();
    ob_end_clean();
   
    echo $file_contents;


ça marche parfaitement...pour l'instant !

Personne ne me déconseille cette solution ?
Merci !
Back to top
View user's profile Send private message
Gowser
Smarty Pro


Joined: 19 Feb 2008
Posts: 104
Location: Nantes (France)

PostPosted: Thu Dec 09, 2010 7:35 pm    Post subject: Reply with quote

A ben si moi Smile

Tu as 2 solutions :

1 . Soit changer cette valeur à la volée

en faisant dans ton code :
Code:

ini_set('allow_url_fopen', 1);


2 . Soit en modifiant ton fichier php.ini si tu y a accès

Dans le fichier php.ini
Code:

;;;;;;;;;;;;;;;;;;
; Fopen wrappers ;
;;;;;;;;;;;;;;;;;;

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen = On


++
Back to top
View user's profile Send private message Send e-mail
bifannen
Smarty Rookie


Joined: 07 Dec 2010
Posts: 6

PostPosted: Thu Dec 09, 2010 9:43 pm    Post subject: Reply with quote

Ah je me disais bien...

Merci,
ini_set php(allow_url_include, 1) parait parfait, mais ça ne fonctionne pas,
je suis chez OVH pour l'hébergement (plan premium) et je en sais pas mais ça ne veux pas. De plus étant sur serveur mutualisé, je n'ai pas accès au php.ini.

En attendant je vais rester avec ma solution.

Est-elle dangereuse ?

Merci.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP