Comprenant

MAPC2012MAPC2012 Member
décembre 2017 modifié dans Entraide
Je salue!
Comment mettre en œuvre les importations de code à partir d'une autre page.
Par exemple:

il existe:
[== PHP ==]
<?php include(dirname(__FILE__).'/header.php'); ?>

Faut:
[== PHP ==]
<?php include(dirname(__FILE__).'http://site.fr/themes/standard/header.php'); ?>

Réponses

  • StéphaneStéphane Member, Former PluXml Project Manager
    Hello

    You can't include a remote file in this way.
    More php code is required. Try this by copying the following code
    <?php
    
        $string = file_get_contents("http://www.example.com");
    
        if($string === FALSE) {
             echo "Could not read the file.";
        } else {
             echo $string;
        }
    
    ?>
    
    Please consider that calling file_get_contents is only possible if allow_url_fopen is set on by your host in php.ini.
    It's not the only available solution, but let's start with it

    Cheers

    Consultant PluXml

    Ancien responsable et développeur de PluXml (2010 à 2018)

  • Stéphane a écrit:
    Please consider that calling file_get_contents is only possible if allow_url_fopen is set on by your host in php.ini.
    It's not the only available solution, but let's start with it

    Cheers

    Inclus. La réponse est:

    Warning: file_get_contents(http://pluxml.mapc2012.ru/version/russian/themes/standard/header.php): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in F:\OpenServer\domains\shop\themes\shop\blog.php on line 3
    Could not read the file.
  • StéphaneStéphane Member, Former PluXml Project Manager
    The file you're trying to include is not accessible by entering his url in the browser. Not a php issue here.
    Maybe not a valid url, or insuffisant access rights.

    link tested: http://pluxml.mapc2012.ru/version/russian/themes/standard/header.php

    ps: please also consider files coming from PluXml's theme are protected with this following line (1st line) to prevent file inclusion from another site.
    <?php if (!defined('PLX_ROOT')) exit; ?>
    

    Consultant PluXml

    Ancien responsable et développeur de PluXml (2010 à 2018)

  • Merci, Stéphane, pour de l'aide. Mais si loin je n'ai pas besoin de trop difficile, j'ai déjà vérifié...
Connectez-vous ou Inscrivez-vous pour répondre.