📄 javascript.php
字号:
<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$RCSfile: javascript.php,v $
$Revision: 1.54.2.10 $
$Date: 2007/03/23 16:40:14 $
*/
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
error_reporting(0);
define('IN_DISCUZ', TRUE);
define('DISCUZ_ROOT', '../');
if(PHP_VERSION < '4.1.0') {
$_GET = &$HTTP_GET_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
}
require_once DISCUZ_ROOT.'./forumdata/cache/cache_settings.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_jswizard.php';
if($_DCACHE['settings']['gzipcompress']) {
ob_start('ob_gzhandler');
}
$jsstatus = isset($_DCACHE['settings']['jsstatus']) ? $_DCACHE['settings']['jsstatus'] : 1;
if(!$jsstatus) {
exit("document.write(\"<font color=red>The webmaster did not enable this feature.</font>\");");
}
$jsrefdomains = isset($_DCACHE['settings']['jsrefdomains']) ? $_DCACHE['settings']['jsrefdomains'] : preg_replace("/([^\:]+).*/", "\\1", (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : NULL));
$REFERER = preg_replace("/https?:\/\/([^\:\/]+).*/i", "\\1", (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL));
if($jsrefdomains && (empty($REFERER) | !in_array($REFERER,explode("\r\n",trim($jsrefdomains))))) {
exit("document.write(\"<font color=red>Referer restriction is taking effect.</font>\");");
}
if(!empty($_GET['key']) && !empty($_DCACHE['jswizard'][$_GET['key']]['url'])) {
$cachefile = DISCUZ_ROOT.'./forumdata/cache/javascript_'.$_GET['key'].'.php';
parse_str($_DCACHE['jswizard'][$_GET['key']]['url'], $_GET);
} else {
$authkey = isset($_DCACHE['settings']['authkey']) ? $_DCACHE['settings']['authkey'] : '';
$jsurl = preg_replace("/^(.+?)\&verify\=[0-9a-f]{32}$/", "\\1", $_SERVER['QUERY_STRING']);
$cachefile = DISCUZ_ROOT.'./forumdata/cache/javascript_'.md5($jsurl).'.php';
$verify = isset($_GET['verify']) ? $_GET['verify'] : NULL;
if(!$verify || !$jsurl || $verify != md5($authkey.$jsurl)) {
exit("document.write(\"<font color=red>Authentication failed.</font>\");");
}
}
$expiration = 0;
$timestamp = time();
if((@!include($cachefile)) || $expiration < $timestamp) {
require_once DISCUZ_ROOT.'./config.inc.php';
require_once DISCUZ_ROOT.'./include/db_'.$database.'.class.php';
require_once DISCUZ_ROOT.'./include/global.func.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$function = isset($_GET['function']) ? $_GET['function'] : NULL;
$dateformat = !empty($_DCACHE['settings']['jsdateformat']) ? $_DCACHE['settings']['jsdateformat'] : (!empty($_DCACHE['settings']['dateformat']) ? $_DCACHE['settings']['dateformat'] : 'm/d');
$timeformat = isset($_DCACHE['settings']['timeformat']) ? $_DCACHE['settings']['timeformat'] : 'H:i';
$PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$boardurl = 'http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api|archiver|wap)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/';
$jstemplate = !empty($_GET['jstemplate']) ? (get_magic_quotes_gpc() ? stripslashes($_GET['jstemplate']) : $_GET['jstemplate']) : '';
$jstemplate = preg_replace("/\r\n|\n|\r/", '\n', $jstemplate);
$nocache = !empty($_GET['nocache']) ? 1 : 0;
$jscachelife = (isset($_GET['cachelife']) && $_GET['cachelife'] != '') ? $_GET['cachelife'] : (isset($_DCACHE['settings']['jscachelife']) ? $_DCACHE['settings']['jscachelife'] : 1800);
if($function != 'custom') {
$jstemplatebody = '';
if(preg_match("/\[node\](.+?)\[\/node\]/is", $jstemplate, $node)) {
$jstemplatebody = $jstemplate;
$jstemplate = $node[1];
}
$datalist = $writedata = jsrewrite('document.write("'.jsmodule($function).'");');
if(!$nocache) {
$writedata = "\$datalist = '".addcslashes($writedata, '\\\'')."';";
UpdateCache($cachefile, $writedata);
}
} else {
$customcachefile = $cachefile;
$customnocache = $nocache;
$jscachelife = (isset($_GET['cachelife']) && $_GET['cachelife'] != '') ? $_GET['cachelife'] : (isset($_DCACHE['settings']['jscachelife']) ? $_DCACHE['settings']['jscachelife'] : 1800);
$writedata = preg_match_all("/\[module\](.+?)\[\/module\]/is", $jstemplate, $modulelist);
$modulelist = array_unique($modulelist[1]);
$writedata = $jstemplate;
$nocache = TRUE;
foreach($modulelist as $key) {
if(!empty($_DCACHE['jswizard'][$key]['url'])) {
parse_str($_DCACHE['jswizard'][$key]['url'], $_GET);
$function = isset($_GET['function']) ? $_GET['function'] : NULL;
$find = "/\[module\]".preg_quote($key)."\[\/module\]/is";
$jstemplate = !empty($_GET['jstemplate']) ? (get_magic_quotes_gpc() ? stripslashes($_GET['jstemplate']) : $_GET['jstemplate']) : '';
$jstemplate = preg_replace("/\r\n|\n|\r/", '\n', $jstemplate);
$jstemplatebody = '';
if(preg_match("/\[node\](.+?)\[\/node\]/is", $jstemplate, $node)) {
$jstemplatebody = $jstemplate;
$jstemplate = $node[1];
}
$writedata = preg_replace($find, jsmodule($function), $writedata);
}
}
$nocache = $customnocache;
$datalist = $writedata = jsrewrite('document.write("'.$writedata.'");');
if(!$nocache) {
$writedata = "\$datalist = '".addcslashes($writedata, '\\\'')."';";
UpdateCache($customcachefile, $writedata);
}
}
}
echo $datalist;
function jsmodule($function) {
extract($GLOBALS, EXTR_SKIP);
$fids = isset($_GET['fids']) ? $_GET['fids'] : NULL;
$startrow = isset($_GET['startrow']) ? intval($_GET['startrow']) : 0;
$items = isset($_GET['items']) ? intval($_GET['items']) : 10;
$digest = isset($_GET['digest']) ? intval($_GET['digest']) : 0;
$newwindow = isset($_GET['newwindow']) ? $_GET['newwindow'] : 1;
$LinkTarget = $newwindow == 1 ? " target='_blank'" : ($newwindow == 2 ? " target='main'" : NULL);
if($function == 'threads') {
$orderby = isset($_GET['orderby']) ? (in_array($_GET['orderby'],array('lastpost','dateline','replies','views')) ? $_GET['orderby'] : 'lastpost') : 'lastpost';
$highlight = isset($_GET['highlight']) ? $_GET['highlight'] : 0;
$picpre = isset($_GET['picpre']) ? urldecode($_GET['picpre']) : NULL;
$maxlength = !empty($_GET['maxlength']) ? intval($_GET['maxlength']) : 50;
$fnamelength = isset($_GET['fnamelength']) ? intval($_GET['fnamelength']) : 0;
$blog = !empty($_GET['blog']) ? 1 : 0;
$tids = isset($_GET['tids']) ? $_GET['tids'] : NULL;
$keyword = !empty($_GET['keyword']) ? $_GET['keyword'] : NULL;
$typeids = isset($_GET['typeids']) ? $_GET['typeids'] : NULL;
$special = isset($_GET['special']) ? intval($_GET['special']) : 0;
$threadtype = isset($_GET['threadtype']) ? intval($_GET['threadtype']) : 0;
require DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$datalist = array();
$threadtypeids = array();
if($keyword) {
if(preg_match("(AND|\+|&|\s)", $keyword) && !preg_match("(OR|\|)", $keyword)) {
$andor = ' AND ';
$keywordsrch = '1';
$keyword = preg_replace("/( AND |&| )/is", "+", $keyword);
} else {
$andor = ' OR ';
$keywordsrch = '0';
$keyword = preg_replace("/( OR |\|)/is", "+", $keyword);
}
$keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
foreach(explode('+', $keyword) as $text) {
$text = trim($text);
if($text) {
$keywordsrch .= $andor;
$keywordsrch .= "t.subject LIKE '%$text%'";
}
}
$keyword = " AND ($keywordsrch)";
} else {
$keyword = '';
}
$sql = ($fids ? ' AND t.fid IN (\''.str_replace('_', '\',\'', $fids).'\')' : '')
.$keyword
.($blog ? ' AND t.blog = 1' : '')
.($tids ? ' AND t.tid IN (\''.str_replace('_', '\',\'', $tids).'\')' : '')
.($typeids ? ' AND t.typeid IN (\''.str_replace('_', '\',\'', $typeids).'\')' : '')
.(($special > 0 && $special < 31) ? threadrange($special, 'special', 5) : '')
.(($digest > 0 && $digest < 15) ? threadrange($digest, 'digest') : '');
$sqlfrom = strexists('{message}', $jstemplate) ?
"FROM `{$tablepre}threads` t" :
"p.message FROM `{$tablepre}threads` t LEFT JOIN `{$tablepre}posts` p ON p.tid=t.tid AND p.first='1'";
$query = $db->query("SELECT t.tid,t.fid,t.readperm,t.author,t.authorid,t.subject,t.dateline,t.lastpost,t.lastposter,t.views,t.replies,t.highlight,t.digest,t.typeid,
$sqlfrom WHERE t.readperm='0'
$sql
AND t.displayorder>='0'
AND t.fid>'0'
ORDER BY t.$orderby DESC
LIMIT $startrow,$items;"
);
while($data = $db->fetch_array($query)) {
$datalist[$data['tid']]['fid'] = $data['fid'];
$datalist[$data['tid']]['fname'] = isset($_DCACHE['forums'][$data['fid']]['name']) ? str_replace('\'', ' ',addslashes($_DCACHE['forums'][$data['fid']]['name'])) : NULL;
$datalist[$data['tid']]['fnamelength'] = strlen($datalist[$data['tid']]['fname']);
$datalist[$data['tid']]['subject'] = isset($data['subject']) ? str_replace('\'', ' ',addslashes($data['subject'])) : NULL;
$datalist[$data['tid']]['dateline'] = gmdate("$dateformat $timeformat",$data['dateline'] + $_DCACHE['settings']['timeoffset'] * 3600);
$datalist[$data['tid']]['lastpost'] = gmdate("$dateformat $timeformat",$data['lastpost'] + $_DCACHE['settings']['timeoffset'] * 3600);
$datalist[$data['tid']]['lastposter'] = $data['lastposter'];
$datalist[$data['tid']]['views'] = $data['views'];
$datalist[$data['tid']]['replies'] = $data['replies'];
$datalist[$data['tid']]['highlight'] = $data['highlight'];
$datalist[$data['tid']]['message'] = str_replace(array('\'',"\n","\r"), array(' ','',''), addslashes(cutstr(dhtmlspecialchars(preg_replace("/(\[.+\])/s", '', strip_tags(nl2br($data['message'])))), 255)));
if($data['author']) {
$datalist[$data['tid']]['author'] = "<a href='".$boardurl."space.php?uid=$data[authorid]'$LinkTarget>$data[author]</a>";
} else {
$datalist[$data['tid']]['author'] = 'Anonymous';
}
if($data['lastposter']) {
$datalist[$data['tid']]['lastposter'] = "<a href='".$boardurl."space.php?username=".rawurlencode($data['lastposter'])."'$LinkTarget>$data[lastposter]</a>";
} else {
$datalist[$data['tid']]['lastposter'] = 'Anonymous';
}
$datalist[$data['tid']]['typeid'] = $data['typeid'];
$threadtypeids[] = $data['typeid'];
}
if($threadtype && $threadtypeids) {
$typelist = array();
$query = $db->query("SELECT typeid, name FROM {$tablepre}threadtypes WHERE typeid IN ('".implode('\',\'', $threadtypeids)."')");
while($typearray = $db->fetch_array($query)) {
$typelist[$typearray['typeid']] = $typearray['name'];
}
foreach($datalist AS $tid=>$value) {
if($value['typeid'] && isset($typelist[$value['typeid']])) {
$datalist[$tid]['subject'] = '['.$typelist[$value['typeid']].']'.$value['subject'];
}
}
}
$writedata = '';
if(is_array($datalist)) {
$colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
$prefix = $picpre ? "<img src='$picpre' border='0' align='absmiddle'>" : NULL;
$jstemplate = !$jstemplate ? '{prefix} {subject}<br>' : $jstemplate;
foreach($datalist AS $tid=>$value) {
$SubjectStyles = '';
if($highlight && $value['highlight']) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -