<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: function_debug.php 20537 2011-02-25 08:03:54Z monkey $
*/
if(!empty($_GET['debugaction'])) {
if($_GET['debugaction'] == 'connect' && !empty($_GET['redirect_url'])) {
chdir('../../');
require './source/class/class_core.php';
$discuz = & discuz_core::instance();
$discuz->init();
$uin = md5($_GET['qq']);
$get = array(
'con_expires_in' => '3600',
'con_access_token' => '501|1290144222.3600|48d855c11ecb426c9838|LskyfOZ0moKUfEMINrYmuTaZmlP-xavvfeIM7Ylwi3c.',
'con_uin' => $uin,
'con_is_unbind' => '1',
'con_x_nick' => '',
'con_x_sex' => 'unknown',
'con_x_birthday' => '1977-01-01',
'con_x_email' => '1@22.net',
'con_x_usernames' => base64_encode('User1,User2'),
);
ksort($get);
$str = '';
foreach($get as $k => $v) {
if($v) {
$str .= $k.'='.$v.'&';
}
}
$get['con_sig'] = md5($str.$_G['setting']['connectsitekey']);
header('location: '.$_GET['redirect_url'].'&'.http_build_query($get));
}
exit;
}
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function debugmessage($ajax = 0) {
$m = function_exists('memory_get_usage') ? number_format(memory_get_usage()) : '';
$mt = function_exists('memory_get_peak_usage') ? number_format(memory_get_peak_usage()) : '';
if($m) {
$m = 'Memory usage <s>'.$m.'</s> bytes'.($mt ? ', peak <s>'.$mt.'</s> bytes' : '').' / ';
}
global $_G;
$debugfile = $_G['adminid'] == 1 ? '_debugadmin.php' : '_debug.php';
$akey = md5(random(10));
if(!defined('DISCUZ_DEBUG') || !DISCUZ_DEBUG || defined('IN_ARCHIVER') || defined('IN_MOBILE')) {
return;
}
$phpinfok = 'I';
$viewcachek = 'C';
$mysqlplek = 'P';
$includes = get_included_files();
require_once DISCUZ_ROOT.'./source/discuz_version.php';
$sqldebug = '';
$sqlw = array();
$db = & DB::object();
$queries = count($db->sqldebug);
foreach ($db->sqldebug as $string) {
$sqldebug .= '<li><br />'.$string[1].'s • '.nl2br(htmlspecialchars($string[0])).'<br /></li>';
if(preg_match('/^SELECT /', $string[0])) {
$query = DB::query("EXPLAIN ".$string[0]);
$i = 0;
$sqldebug .= '<table style="border-bottom:none">';
while($row = DB::fetch($query)) {
if(!$i) {
$sqldebug .= '<tr style="border-bottom:1px dotted gray"><td> '.implode(' </td><td> ', array_keys($row)).' </td></tr>';
$i++;
}
if(strexists($row['Extra'], 'Using filesort')) {
$sqlw['Using filesort']++;
$row['Extra'] = str_replace('Using filesort', '<font color=red>Using filesort</font>', $row['Extra']);
}
if(strexists($row['Extra'], 'Using temporary')) {
$sqlw['Using temporary']++;
$row['Extra'] = str_replace('Using temporary', '<font color=red>Using temporary</font>', $row['Extra']);
}
$sqldebug .= '<tr><td> '.implode(' </td><td> ', $row).' </td></tr>';
}
$sqldebug .= '</table>';
}
$sqldebug .= '<table><tr style="border-bottom:1px dotted gray"><td width="270">File</td><td width="80">Line</td><td>Function</td></tr>';
foreach($string[2] as $error) {
$error['file'] = str_replace(DISCUZ_ROOT, '', $error['file']);
$error['class'] = isset($error['class']) ? $error['class'] : '';
$error['type'] = isset($error['type']) ? $error['type'] : '';
$error['function'] = isset($error['function']) ? $error['function'] : '';
$sqldebug .= "<tr><td>$error[file]</td><td>$error[line]</td><td>$error[class]$error[type]$error[function]()</td></tr>";
}
$sqldebug .= '</table>';
}
$ajaxhtml = 'data/'.$debugfile.'_ajax.php';
if($ajax) {
$idk = substr(md5($_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']), 0, 4);
$sqldebug = '<b style="cursor:pointer" onclick="document.getElementById(\''.$idk.'\').style.display=document.getElementById(\''.$idk.'\').style.display == \'\' ? \'none\' : \'\'">Queries: </b> '.$queries.' ('.$_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'].')<ol id="'.$idk.'" style="display:none">'.$sqldebug.'</ol><br>';
file_put_contents(DISCUZ_ROOT.'./'.$ajaxhtml, $sqldebug, FILE_APPEND);
return;
}
file_put_contents(DISCUZ_ROOT.'./'.$ajaxhtml, '<?php if(empty($_GET[\'k\']) || $_GET[\'k\'] != \''.$akey.'\') { exit; } ?><style>body,table { font-size:12px; }table { width:90%;border:1px solid gray; }</style><a href="javascript:;" onclick="location.href=location.href">Refresh</a><br />');
foreach($sqlw as $k => $v) {
$sqlw[$k] = $k.': '.$v;
}
$sqlw = $sqlw ? '<s>('.implode(', ', $sqlw).')</s>' : '';
$debug = '<?php if(empty($_GET[\'k\']) || $_GET[\'k\'] != \''.$akey.'\') { exit; } ?>';
if($_G['adminid'] == 1 && !$ajax) {
$debug .= '<?php
if(isset($_GET[\''.$phpinfok.'\'])) { phpinfo(); exit; }
elseif(isset($_GET[\''.$viewcachek.'\'])) {
chdir(\'../\');
require \'./source/class/class_core.php\';
$discuz = & discuz_core::instance();
$discuz->init();
echo \'<style>body { font-size:12px; }</style>\';
if(!isset($_GET[\'c\'])) {
$query = DB::query("SELECT cname FROM ".DB::table("common_syscache"));
while($names = DB::fetch($query)) {
echo \'<a href="'.$debugfile.'?k='.$akey.'&'.$viewcachek.'&c=\'.$names[\'cname\'].\'" target="_blank" style="float:left;width:200px">\'.$names[\'cname\'].\'</a>\';
}
} else {
loadcache($_GET[\'c\']);
echo \'$_G[\\\'cache\\\'][\'.$_GET[\'c\'].\']<br>\';
debug($_G[\'cache\'][$_GET[\'c\']]);
}
exit;
}
elseif(isset($_GET[\''.$mysqlplek.'\'])) {
chdir(\'../\');
require \'./source/class/class_core.php\';
$discuz = & discuz_core::instance();
$discuz->_init_db();
if(!empty($_GET[\'Id\'])) {
$query = DB::query("KILL ".floatval($_GET[\'Id\']), \'SILENT\');
}
$query = DB::query("SHOW FULL PROCESSLIST");
echo \'<style>table { font-size:12px; }</style>\';
echo \'<table style="border-bottom:none">\';
while($row = DB::fetch($query)) {
if(!$i) {
echo \'<tr style="border-bottom:1px dotted gray"><td> </td><td> \'.implode(\' </td><td> \', array_keys($row)).\' </td></tr>\';
$i++;
}
echo \'<tr><td><a href="'.$debugfile.'?k='.$akey.'&P&Id=\'.$row[\'Id\'].\'">[Kill]</a></td><td> \'.implode(\' </td><td> \', $row).\' </td></tr>\';
}
echo \'</table>\';
exit;
}
?>';
}
$debug .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>';
$debug .= "<script src='../static/js/common.js?".VERHASH."'></script><script>
function switchTab(prefix, current, total, activeclass) {
activeclass = !activeclass ? 'a' : activeclass;
for(var i = 1; i <= total;i++) {
var classname = ' '+$(prefix + '_' + i).className+' ';
$(prefix + '_' + i).className = classname.replace(' '+activeclass+' ','').substr(1);
$(prefix + '_c_' + i).style.display = 'none';
}
$(prefix + '_' + current).className = $(prefix + '_' + current).className + ' '+activeclass;
$(prefix + '_c_' + current).style.display = '';
}
</script>";
if(!defined('IN_ADMINCP') && file_exists(DISCUZ_ROOT.'./static/image/common/temp-grid.png')) $debug .= <<<EOF
<script type="text/javascript">
var s = '<button style="position: fixed; width: 40px; right: 0; top: 30px; border: none; border:1px solid orange;background: yellow; color: red; cursor: pointer;" onclick="var pageHight = top.document.body.clientHeight;$(\'tempgrid\').style.height = pageHight + \'px\';$(\'tempgrid\').style.visibility = top.$(\'tempgrid\').style.visibility == \'hidden\'?\'\':\'hidden\';o.innerHTML = o.innerHTML == \'网格\'?\'关闭\':\'网格\';">网格</button>';
s += '<div id="tempgrid" style="position: absolute; top: 0px; left: 50%; margin-left: -500px; width: 1000px; height: 0; background: url(static/image/common/temp-grid.png); visibility :hidden;"></div>';
top.$('_debug_di
没有合适的资源?快使用搜索试试~ 我知道了~
function_debug.zip_function_debug
共1个文件
php:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 125 浏览量
2022-09-23
11:58:05
上传
评论
收藏 5KB ZIP 举报
温馨提示
相信开发和使用discuz的朋友非常多,但您是否真正掌握到精髓呢。您可能还需要掌握如何调试和断点开发哦,这个测试debug文件适合你。
资源推荐
资源详情
资源评论
收起资源包目录
function_debug.zip (1个子文件)
function_debug.php 15KB
共 1 条
- 1
资源评论
朱moyimi
- 粉丝: 61
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功