コード例 #1
0
ファイル: anwiki.inc.php プロジェクト: MenZil-Team/anwiki
function errorApp($e)
{
    $bLogEnvAvailable = class_exists("AnwComponent") && class_exists("AnwUtils");
    $nErrorNumber = false;
    if ($bLogEnvAvailable) {
        $nErrorNumber = AnwDebug::reportError($e);
    }
    print '<h1>Error</h1>';
    print '<div style="margin:0px auto; width:550px">';
    /*if ($e instanceof PhpRuntimeException)
    	{
    		print '<h1>Error</h1>';
    		
    		if (class_exists("AnwUtils") && AnwUtils::isViewDebugAuthorized())
    		{
    			print '<div style="margin:0px auto; width:550px">' .
    			'<p>'.$e->getMessage().' ('.get_class($e).')<br/>' .
    			'<span style="font-size:12px">'.$e->getFile().', line '.$e->getLine().'</span></p>' .
    			'</div>';
    		}
    	}
    	*/
    //display error details if user is allowed to view it
    if ($bLogEnvAvailable && AnwUtils::isViewDebugAuthorized() || class_exists("AnwDebug") && AnwDebug::isEmergencyDebugEnabled()) {
        print '<p>' . $e->getMessage() . ' (' . get_class($e) . ')<br/>';
        print '<span style="font-size:12px">' . $e->getFile() . ', line ' . $e->getLine() . '</span>';
        print '</p>';
    } else {
        print '<p>A problem occurred. Please try again later or contact an administrator.<br/>' . 'We apologize for inconvenience.</p>';
    }
    if ($nErrorNumber) {
        print '<p>Error has been logged. Please contact the administrator with the following error number : <b>' . $nErrorNumber . '</b></p>';
    }
    print '</div>';
    //display error trace and debug log if user is allowed to view it
    if ($bLogEnvAvailable && AnwUtils::isViewDebugAuthorized()) {
        //display trace
        print '<p>Trace :<br/><ul>';
        $asTrace = $e->getTrace();
        $bFirst = true;
        foreach ($asTrace as $sTrace) {
            $sCss = $bFirst ? 'color:red' : '';
            print '<li style="font-size:14px;' . $sCss . '">';
            if (isset($sTrace['class'])) {
                print $sTrace['class'];
            }
            if (isset($sTrace['type'])) {
                print $sTrace['type'];
            }
            print $sTrace['function'];
            if (isset($sTrace['args'])) {
                //hide args for security reasons
                foreach ($sTrace['args'] as $i => $sArg) {
                    $sTrace['args'][$i] = 'p' . ($i + 1);
                }
                print '(' . implode($sTrace['args'], ", ") . ')';
            }
            print '<br/><span style="font-size:12px">File ' . @$sTrace['file'] . ', line ' . @$sTrace['line'] . '</span><br/>';
            print '</li>';
            $bFirst = false;
        }
        print '</ul></p>';
        //display debug
        if (class_exists("AnwDebug")) {
            print '<p>Debug :<br/><div style="font-size:12px">' . AnwDebug::getLog() . '</font></p>';
        }
    }
    exit;
}
コード例 #2
0
ファイル: class_action.php プロジェクト: voodoo81-81/anwiki
 protected function printOutput()
 {
     header("Content-type: text/html; charset=UTF-8");
     /*AnwDebug::startbench("parseTranslations",true);
     		$sOutput = Anwi18n::parseTranslations($this->out);
     		AnwDebug::stopBench("parseTranslations");*/
     $sOutput = $this->out;
     //full execution time benchmark
     $sElapsedTime = AnwDebug::stopBench("GLOBAL");
     //show execution time ?
     if (self::globalCfgShowExecTime()) {
         $fMemoryUsage = AnwDebug::getMemoryUsage();
         $sOutput = str_replace('%ANWEXECTIME%', ' • ' . $sElapsedTime . ' sec • ' . $fMemoryUsage . ' MB', $sOutput);
     } else {
         $sOutput = str_replace('%ANWEXECTIME%', '', $sOutput);
     }
     //show full debug ?
     if (AnwUtils::isViewDebugAuthorized()) {
         $sLog = AnwDebug::getLog();
         if ($sLog) {
             $sOutput = str_replace('</body>', '<div id="debug">' . $sLog . '</div></body>', $sOutput);
         }
     }
     print $sOutput;
     exit;
 }
コード例 #3
0
ファイル: class_utils.php プロジェクト: voodoo81-81/anwiki
 static function redirect($destination = false, $bPermanent = false)
 {
     if (!$destination || !self::isSafeUrl($destination)) {
         $destination = self::link(AnwComponent::globalCfgHomePage());
     }
     // redirection fails if we don't remove html entity &amp;
     $destination = str_replace('&amp;', '&', $destination);
     if (self::isViewDebugAuthorized()) {
         print 'Redirection ';
         if ($bPermanent) {
             print 'PERMANENT ';
         }
         print ': <a href="' . self::xQuote($destination) . '">' . self::xText($destination) . '</a><br/>';
         print '<br/><br/><hr/>' . AnwDebug::getLog();
         exit;
     } else {
         if ($bPermanent) {
             header("HTTP/1.1 301 Moved Permanently");
         }
         header("Location: {$destination}");
         exit;
         //TODO properly close DB connexion?
     }
 }