Changeset 257

Show
Ignore:
Timestamp:
09/14/06 14:35:35 (2 years ago)
Author:
laurentj
Message:

corrections dans le plugin magicquotes et amélioration de la prise en charge des erreurs avant le process()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix-plugins/magicquotes/magicquotes.plugin.php

    r150 r257  
    1616*/ 
    1717 
     18/** 
     19 * This is a plugin which cancel magic quotes effect. Magic quotes should be off 
     20 * with jelix. 
     21 * @package    jelix 
     22 * @subpackage plugins 
     23 */ 
    1824class MagicQuotesPlugin implements jIPlugin { 
    1925 
    20    /** 
     26    /** 
    2127    * 
    2228    */ 
    23    function __construct($config){ 
    24       if(get_magic_quotes_gpc()){ 
    25         $req = $GLOBALS['gJCoord']->request; 
    26         foreach ($req->params as $key=>$elem){ 
    27                 $req->params[$key] = $this->_stripSlashes ($elem); 
     29    function __construct($config){ 
     30        if(get_magic_quotes_gpc()){ 
     31            foreach ($_GET as $key=>$elem){ 
     32                $_GET[$key] = $this->_stripSlashes ($elem); 
     33            } 
     34            foreach ($_POST as $key=>$elem){ 
     35                $_POST[$key] = $this->_stripSlashes ($elem); 
     36            } 
     37            foreach ($_COOKIE as $key=>$elem){ 
     38                $_COOKIE[$key] = $this->_stripSlashes ($elem); 
     39            } 
     40            foreach ($_REQUEST as $key=>$elem){ 
     41                $_REQUEST[$key] = $this->_stripSlashes ($elem); 
     42            } 
    2843        } 
    29       } 
    30       set_magic_quotes_runtime(0); 
    31    } 
     44        set_magic_quotes_runtime(0); 
     45    } 
    3246 
    33    /** 
    34    * enleve tout les slashes d'une chaine ou d'un tableau de chaine 
    35    * @param string/array   $string 
    36    * @return string/array   l'objet transform�  */ 
    37    function _stripSlashes ($string){ 
     47    /** 
     48    * enleve tout les slashes d'une chaine ou d'un tableau de chaine 
     49    * @param string/array   $string 
     50    * @return string/array   l'objet transform�   */ 
     51    protected function _stripSlashes ($string){ 
    3852        if (is_array ($string)){ 
    3953            $toReturn = array (); 
     
    4660            return stripslashes ($string); 
    4761        } 
    48    } 
     62    } 
     63 
    4964    /** 
    5065     * @param    array  $params   plugin parameters for the current action 
     
    5267     */ 
    5368    public function beforeAction($params){ return null;} 
     69 
     70    /** 
     71    * 
     72    */ 
    5473    public function beforeOutput() {} 
    5574 
     75    /** 
     76    * 
     77    */ 
    5678    public function afterProcess (){} 
    5779} 
  • trunk/lib/jelix/core/jCoordinator.class.php

    r256 r257  
    130130        $this->errorMessages[] = array($type, $code, $message, $file, $line); 
    131131        if(!$this->response){ 
    132             if($this->initDefaultResponseOfRequest()) 
    133                 return true; 
     132            return $this->initDefaultResponseOfRequest(); 
    134133        } 
    135134        return !$this->response->acceptSeveralErrors(); 
  • trunk/lib/jelix/core/jErrorHandler.lib.php

    r248 r257  
    5656    } 
    5757 
     58    $doecho=true; 
     59    if($gJCoord->request == null){ 
     60        $errmsg = 'JELIX PANIC ! Error during initialization !! '.$errmsg; 
     61        $doecho = false; 
     62        $action.= ' EXIT'; 
     63    }elseif($gJCoord->response == null){ 
     64        $ret = $gJCoord->initDefaultResponseOfRequest(); 
     65        if(is_string($ret)){ 
     66            $errmsg = 'Double error ! 1)'. $ret.'; 2)'.$errmsg; 
     67        } 
     68    } 
     69 
    5870    // formatage du message 
    5971    $messageLog = strtr($conf['messageLogFormat'], array( 
     
    8092    // traitement du message 
    8193    if(strpos($action , 'ECHOQUIET') !== false){ 
    82         if($gJCoord->addErrorMsg($codeString[$errno], $code, $conf['quietMessage'], '', '')) 
     94        if(!$doecho){ 
     95            header('Content-type: text/plain'); 
     96            echo 'JELIX PANIC ! Error during initialization !! '; 
     97        }elseif($gJCoord->addErrorMsg($codeString[$errno], $code, $conf['quietMessage'], '', '')) 
    8398            $action.=' EXIT'; 
    8499    }elseif(strpos($action , 'ECHO') !== false){ 
    85         if($gJCoord->addErrorMsg($codeString[$errno], $code, $errmsg, $filename, $linenum)) 
     100        if(!$doecho){ 
     101            header('Content-type: text/plain'); 
     102            echo $messageLog; 
     103        }elseif($gJCoord->addErrorMsg($codeString[$errno], $code, $errmsg, $filename, $linenum)){ 
    86104            $action.=' EXIT'; 
     105        } 
    87106    } 
    88107    if(strpos($action , 'LOGFILE') !== false){ 
     
    97116 
    98117    if(strpos($action , 'EXIT') !== false){ 
    99         if($gJCoord->response) $gJCoord->response->outputErrors(); 
     118        if($doecho && $gJCoord->response)  
     119            $gJCoord->response->outputErrors(); 
    100120        exit; 
    101121    } 
  • trunk/lib/jelix/core/jException.lib.php

    r248 r257  
    2828    $action = $conf['exception']; 
    2929 
     30    $doecho=true; 
     31    if($gJCoord->request == null){ 
     32        $msg = 'JELIX PANIC ! Error during initialization !! '.$msg; 
     33        $doecho = false; 
     34    }elseif($gJCoord->response == null){ 
     35        $ret = $gJCoord->initDefaultResponseOfRequest(); 
     36        if(is_string($ret)){ 
     37            $errmsg = 'Double error ! 1)'. $ret.'; 2)'.$errmsg; 
     38        } 
     39 
     40    } 
     41 
    3042    // formatage du message de log 
    3143    $messageLog = strtr($conf['messageLogFormat'], array( 
     
    3951        '\n' => "\n" 
    4052    )); 
    41     if($gJCoord->response == null){ 
    42       $gJCoord->initDefaultResponseOfRequest(); 
    43     } 
    4453 
    4554    if(strpos($action , 'TRACE') !== false){ 
     
    5665    // traitement du message 
    5766    if(strpos($action , 'ECHOQUIET') !== false){ 
    58         if($gJCoord->addErrorMsg('error', $exception->getCode(), $conf['quietMessage'], '', '')) 
    59             $action.=' EXIT'; 
     67        if(!$doecho){ 
     68            header('Content-type: text/plain'); 
     69            echo 'JELIX PANIC ! Error during initialization !! '; 
     70        }else 
     71            $gJCoord->addErrorMsg('error', $exception->getCode(), $conf['quietMessage'], '', ''); 
    6072    }elseif(strpos($action , 'ECHO') !== false){ 
    61        $gJCoord->addErrorMsg('error', $exception->getCode(), $msg, $exception->getFile(), $exception->getLine()); 
     73        if($doecho) 
     74            $gJCoord->addErrorMsg('error', $exception->getCode(), $msg, $exception->getFile(), $exception->getLine()); 
     75        else{ 
     76            header('Content-type: text/plain'); 
     77            echo $messageLog; 
     78        } 
    6279    } 
    6380    if(strpos($action , 'LOGFILE') !== false){ 
     
    7188    } 
    7289 
    73     $gJCoord->response->outputErrors(); 
     90    if($doecho) 
     91        $gJCoord->response->outputErrors(); 
     92    exit; 
    7493} 
    7594 
Download in other formats: Unified Diff Zip Archive