Bonjour à tous
j'ai constaté que beaucoup d'entre vous une fois leur site mis en ligne rencontrent des problemes de redirection liés à la variable $_SERVER['PATH_INFO'];
Alors je vous propose ci-dessous ma version de la classe "request" (compatible à celle du tuto) qui devrait résoudre définitivement ce problème. du moins je n'ai pas encore eu de problème avec, même sur un mutualisé.

<?php
/**
 * IrivenCMS Pro : Rapid Development Framework (http://www.iriven.com)
 * Copyright 2008-2013, Iriven France Software, Inc. 
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2008-2013, Iriven France Software, Inc.
 * @link          http://www.iriven.com IrivenCMS Project
 * @package       IrivenCMS.Utility
 * @since         IrivenCMS Pro v 1.0.4
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
class Request{
    public $url; // url appellé par l'utilisteur
    public $page = 1;
    public $prefix = false;
    public $Getdata = false;
    public $Postdata = false;
/**
*
*
**/
public function __construct(){
    $this->url = strlen($this->pathInfo())? $this->pathInfo() : $this->BaseUrl();
    if(!empty($_POST)) $this->Postdata = $_POST;        
    if(!empty($_GET)) $this->Getdata = $_GET;
    if(isset($this->Getdata->page)and is_numeric($this->Getdata->page) and($this->Getdata->page > 0)) $this->page = round($this->Getdata->page);
}
/**
*
*
*/      
private function pathInfo(){
    if (strlen(getenv('PATH_INFO')) > 1) return rtrim(getenv('PATH_INFO'),'/\\');
    if( array_key_exists('PATH_INFO', $_SERVER) and strlen($_SERVER['PATH_INFO']) ) return rtrim($_SERVER['PATH_INFO'], '/\\');
    if( array_key_exists('ORIG_PATH_INFO', $_SERVER) and strlen($_SERVER['ORIG_PATH_INFO']) )   return rtrim($_SERVER['ORIG_PATH_INFO'], '/\\');
    return rtrim(str_replace(BASEURL, '', current(explode('?',$this->Uri()))), '/\\'); 
    }           
/**
 * Returns the current domain for the Session to be saved to, if the installation
 * is on localhost, this returns null and just allows PHP to take care of setting
 * the valid domain for the Session, otherwise it will return the non-www version
 * of the domain host.
 *
 * @return string|null
 *  Null if on localhost, or HTTP_HOST is not set, a string of the domain name sans
 *  www otherwise
 */
public function Domain(){
    if(isset($_SERVER['HTTP_HOST'])){
        if(preg_match('/(localhost|127\.0\.0\.1)/', $_SERVER['HTTP_HOST']) || $_SERVER['SERVER_ADDR'] == '127.0.0.1'){
            return null; // prevent problems on local setups
        }
        $host = strtolower( htmlentities(strip_tags((string) $_SERVER['HTTP_HOST'])));
        return preg_replace('/(^www\.|:\d+$)/i', NULL, $host);
    }
    if(isset($_SERVER['SERVER_NAME'])){
         $host = strtolower( htmlentities(strip_tags((string) $_SERVER['SERVER_NAME'])));
         return preg_replace('/(^www\.|:\d+$)/i', NULL, $host);
        }
    return null;
    }
/**
*
*
*/  
private function Uri() {    
    if( !array_key_exists('REQUEST_URI', $_SERVER) or !strlen($_SERVER['REQUEST_URI'])) {
        if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
            $uri = $_SERVER['HTTP_X_REWRITE_URL'];
        }
        else{
            $uri = BASEURL;
            }
        if($_SERVER['QUERY_STRING'])  $uri .= '?' . $_SERVER['QUERY_STRING'];
    $uri = filter_var($uri,  FILTER_SANITIZE_URL);
    }
    else{
    $uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL);
    }

    if (($uri == '/') || ($uri == '\\')) $uri .= basename(filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_URL));

        if ((strtolower(substr($uri, -4)) == '.ico') ||
            (strtolower(substr($uri, -4)) == '.png') ||
            (strtolower(substr($uri, -4)) == '.gif') ||
            (strtolower(substr($uri, -4)) == '.jpg'))
            return '';
            if ($uri == '') return '';
        $uri = str_replace($this->Scheme(), ':#:', $uri);
        $uri = str_replace(DS, '/', $uri);
        $uri = str_replace(':#:', $this->Scheme(), $uri);
    return rtrim($uri, '/\\');
}   
    /**
     * Get the referrer
     *
     * @access  public
     * @return  bool
     */
public function Referrer(){
    return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);
    }
/**
 * This function determines and returns an absolute URL.
 *
 */
public function Url() {
    // Start defining the URL...
    // URL is http:// plus the host name plus the current directory:
    $url = rtrim($this->BaseUrl(), '/').'/'.ltrim($this->pathInfo(),'/');
    return rtrim($url, '/\\');
} // End of Url() function.
/**
 * This function determines and returns the web site home page URL.
 *
 */
public function BaseUrl() {
    // Start defining the URL...
    // URL is http:// plus the host name plus the current directory:
    $url = $this->Scheme().(($this->ServerPort() !== '') ?($this->Domain().':'.$this->ServerPort()) : $this->Domain());
    return rtrim($url, '/\\');
} // End of BaseUrl() function.
/**
*
*
**/
    private function isHttps(){
    return (bool)(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' ||
                $_SERVER['HTTPS'] === true)) ?
                true:false ;
    }
/**
*
*
**/
    private function Scheme()
    { $Scheme = 'http';
    return $Scheme .=($this->isHttps() === true) ? 's://':'://' ;
    }
/**
*
*
**/
    private function ServerPort(){
    return  (($_SERVER['SERVER_PORT'] != 80 &&
            !($this->isHttps())) ||
            ($_SERVER['SERVER_PORT'] != 443 &&
            ( $this->isHttps() == true))) ?
            (int)$_SERVER['SERVER_PORT'] : '';
    }   
/*
    End of the class
    */
    }

2 réponses


Silence
Réponse acceptée

Bonjour,

Pour ma part j'ai le messsage suivant :
"Le controller http n'existe pas"
Merci d'avance à celui qui pourra nous venir en aide, perso je débute dans la programmation.

EDIT : Pour info j'ai uploader le site sur un serveur ovh mutualisé.

Bonjour,

En utilisant cette class , ca renvoi :

" Page introuvable

Le controller webroot n'existe pas "

Des idées ?