$message, 'value'=>$value);
}
}
public static function getLog($type) {
if(isset(self::$data[$type])) {
return self::$data[$type];
} else {
return array();
}
}
public static function navigator() {
if(self::init()) {
if(isset($_GET['profileError'])) {
if($_GET['profileError'] == 'true') {
setcookie('error',1 , 0, '/');
}else {
setcookie('error',null , 0, '/');
unset($_COOKIE['error']);
}
}
if(isset($_COOKIE['error'])) {
error_reporting(E_ALL);
ini_set('display_errors', true);
}
if(isset($_GET['profileSql'])) {
if($_GET['profileSql'] == 'true') {
setcookie('sql',1 , 0, '/');
}else {
setcookie('sql',null , 0, '/');
unset($_COOKIE['sql']);
}
}
if(isset($_GET['profilePhp'])) {
if($_GET['profilePhp'] == 'true') {
setcookie('php',1 , 0, '/');
}else {
setcookie('php',null , 0, '/');
unset($_COOKIE['php']);
}
}
}
}
public static function debugInfo() {
if(self::init()) {
self::pageInfo();
$showError = false;
if(isset($_COOKIE['error'])) {
$showError = true;
}
if(isset($_GET['profileError'])) {
if($_GET['profileError'] == 'true') {
$showError = true;
} else {
$showError = false;
}
}
$showSql = false;
if(isset($_COOKIE['sql'])) {
$showSql = true;
}
if(isset($_GET['profileSql'])) {
if($_GET['profileSql'] == 'true') {
$showSql = true;
} else {
$showSql = false;
}
}
$showPhp = false;
if(isset($_COOKIE['php'])) {
$showPhp = true;
}
if(isset($_GET['profilePhp'])) {
if($_GET['profilePhp'] == 'true') {
$showPhp = true;
} else {
$showPhp = false;
}
}
if($showSql) {
self::sqlDisplay();
}
if($showPhp) {
self::phpInfoDisplay();
}
self::commonDisplay();
}
}
private static function commonDisplay() {
?>
|
foreach(self::getLog('page') as $item) {
echo $item['message'].':'.$item['value'].', ';
}
?>
|
lista sql: onclick="if(this.checked){document.location.href='?profileSql=true'}else{document.location.href='?profileSql=false';}" />
phpinfo: onclick="if(this.checked){document.location.href='?profilePhp=true'}else{document.location.href='?profilePhp=false';}" />
errorreporting-all: onclick="if(this.checked){document.location.href='?profileError=true'}else{document.location.href='?profileError=false';}" />
}
private static function sqlDisplay() {
if(self::$profiling == true) {
$queries = self::getLog('mysql');
echo"";
$totalTime = 0;
foreach($queries as $query) {
?>
| = $query['message']; ?> | = $query['value']; ?> |
$totalTime = ($totalTime+$query['value']);
}
$sqlStart = self::getLog('mysqlStart');
$sqlEnd = self::getLog('mysqlEnd');
if(isset($sqlEnd[0]['value']) && isset($sqlStart[0]['value'])) {
$sqlTime = (($sqlEnd[0]['value'])+($sqlStart[0]['value']));
}
if(isset($sqlTime)){
echo"| Czas nawiazania polaczenia: | ".date("Y-d-m h:i:s", mktime(abs($sqlStart[0]['value'])))." |
";
echo"| Czas trwania polaczenia: | ".$sqlTime." |
";}
echo"
|
|
";
echo"
";
}
}
private static function phpInfoDisplay() {
phpinfo();
}
private static function init() {
$return = false;
if(self::$profiling) {
$return = true;
}
if(in_array($_SERVER['REMOTE_ADDR'], self::$clientIp) && self::$profiling) {
$return = true;
} else {
$return = false;
}
return $return;
}
}
?>