📄 tools.inc.php
字号:
<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$RCSfile: tools.inc.php,v $
$Revision: 1.76.2.3 $
$Date: 2007/03/21 15:52:04 $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if($action == 'updatecache') {
updatecache();
if($tplrefresh) {
$tpl = dir(DISCUZ_ROOT.'./forumdata/templates');
while($entry = $tpl->read()) {
if(preg_match("/\.tpl\.php$/", $entry)) {
@unlink(DISCUZ_ROOT.'./forumdata/templates/'.$entry);
}
}
$tpl->close();
}
if($jsstatus) {
$js = dir(DISCUZ_ROOT.'./forumdata/cache');
while($entry = $js->read()) {
if(preg_match("/^javascript_/", $entry)) {
@unlink(DISCUZ_ROOT.'./forumdata/cache/'.$entry);
}
}
$js->close();
}
cpmsg('update_cache_succeed');
} elseif($action == 'jswizard') {
if(!$jsstatus) {
cpmsg('jswizard_disabled', 'admincp.php?action=settings&do=javascript');
}
shownav('menu_tools_javascript');
$jswizard = array();
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable LIKE 'jswizard_".($jssetting != '' ? $jssetting : ($jskey != '' ? $jskey : '%'))."'");
while($settings = $db->fetch_array($query)) {
$jswizard[substr($settings['variable'], 9)] = unserialize($settings['value']);
}
$type = !empty($function) ? $function : (isset($type) ? $type : '');
$edit = isset($edit) ? $edit : NULL;
$editext = ($jssetting || $edit) ? '<input type="hidden" name="edit" value="'.dhtmlspecialchars($jssetting ? $jssetting : $edit).'">' : '';
ksort($jswizard);
if(!empty($type)) {
if(empty($jskey)) {
$jskey = $type.'_'.random(3);
}
$jspreview = '';
if(!empty($function) && !empty($jssetting) && isset($jswizard[$jssetting]['url'])) {
$parameter = $jswizard[$jssetting]['parameter'];
$jskey = $jssetting;
$jssetting = $jswizard[$jssetting]['url'];
$preview = $jssubmit = TRUE;
} else {
$jssetting = '';
}
}
$jskey = trim($jskey);
if(empty($type)) {
if(!submitcheck('jsdelsubmit') && !submitcheck('jsexportsubmit') && !submitcheck('importsubmit')) {
$jstypes = array('threads', 'forums', 'memberrank', 'stats', 'images', -1 => 'custom');
showtype('jswizard_addjs', 'top');
echo '<tr><td class="altbg2">';
foreach($jstypes as $jstype) {
echo '<input type="button" class="button" value="'.$lang['jswizard_'.$jstype].'" onclick="location.href=\'admincp.php?action=jswizard&type='.$jstype.'\'"> ';
}
echo '</td></tr>';
showtype('', 'bottom');
echo '<br>';
?>
<form method="post" action="admincp.php?action=jswizard">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
<tr class="header"><td width="3%"><input class="checkbox" type="checkbox" name="chkall" onclick="checkall(this.form,'keyarray')"></td>
<td><?=$lang['jswizard_key']?></td><td><?=$lang['type']?></td></tr>
<?
foreach($jswizard as $key => $jssetting) {
echo '<tr><td class="altbg1"><input class="checkbox" type="checkbox" name="keyarray[]" value="'.dhtmlspecialchars($key).'">';
echo '<td class="altbg2"><a href="admincp.php?action=jswizard&function='.$jstypes[$jssetting['type']].'&jssetting='.rawurlencode($key).'">'.$key.'</a></td><td class="altbg1">'.$lang['jswizard_'.$jstypes[$jssetting['type']]].'</td>';
}
echo '</td></tr>';
showtype('', 'bottom');
?>
<br><center><input class="button" type="submit" name="jsdelsubmit" value="<?=$lang['jswizard_delete']?>"> <input class="button" type="submit" name="jsexportsubmit" value="<?=$lang['jswizard_download']?>"></center>
</form>
<br>
<form method="post" action="admincp.php?action=jswizard">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
<tr class="header"><td><?=$lang['jswizard_import_stick']?></td></tr>
<tr><td class="altbg1"> <div align="center"><textarea name="importdata" cols="80" rows="8"></textarea><br>
<input class="checkbox" type="radio" name="importrewrite" value="0" checked><?=$lang['jswizard_import_default']?>
<input class="checkbox" type="radio" name="importrewrite" value="1"><?=$lang['jswizard_import_norewrite']?>
<input class="checkbox" type="radio" name="importrewrite" value="2"><?=$lang['jswizard_import_rewrite']?>
</td></tr>
</table><br>
<center><input class="button" type="submit" name="importsubmit" value="<?=$lang['submit']?>"></center></form>
<?
} elseif(submitcheck('jsdelsubmit')) {
if(is_array($keyarray)) {
$keys = implode("','jswizard_", $keyarray);
$db->query("DELETE FROM {$tablepre}settings WHERE variable IN ('jswizard_$keys')");
updatecache('jswizard');
cpmsg('jswizard_succeed', 'admincp.php?action=jswizard');
} else {
header("location: {$boardurl}admincp.php?action=jswizard");
dexit();
}
} elseif(submitcheck('jsexportsubmit')) {
if(is_array($keyarray)) {
$keys = implode("','jswizard_", $keyarray);
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable IN ('jswizard_$keys')");
$exportdataarray = array();
while($exportdata = $db->fetch_array($query)) {
$value = unserialize($exportdata['value']);
switch($value['type']) {
case 0:
unset($value['parameter']['threads_forums']);
unset($value['parameter']['tids']);
unset($value['parameter']['typeids']);
break;
case 1:
unset($value['parameter']['forums_forums']);
break;
case 4:
unset($value['parameter']['images_forums']);
break;
}
$exportdataarray[preg_replace("/^jswizard_/", '', $exportdata['variable'])] = serialize($value);
}
$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
$jswizard_export = "# Discuz! JSWizard Dump\n".
"# Version: Discuz! $version\n".
"# Time: $time \n".
"# From: $bbname ($boardurl) \n".
"#\n".
"# Discuz! Community: http://www.Discuz.net\n".
"# Please visit our website for latest news about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
wordwrap(base64_encode(serialize($exportdataarray)), 60, "\n", 1);
ob_end_clean();
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Encoding: none');
header('Content-Length: '.strlen($jswizard_export));
header('Content-Disposition: attachment; filename=discuz_jswizard_'.date('Ymd').'.txt');
header('Content-Type: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));
echo $jswizard_export;
dexit();
} else {
header("location: {$boardurl}admincp.php?action=jswizard");
dexit();
}
} elseif(submitcheck('importsubmit')) {
$importdata = preg_replace("/(#.*\s+)*/", '', $importdata);
$importarray = unserialize(base64_decode($importdata));
$keys = implode("','jswizard_", array_keys($importarray));
if($importrewrite != 2) {
$query = $db->query("SELECT variable FROM {$tablepre}settings WHERE variable IN ('jswizard_$keys')");
$existkeyarray = array();
while($existkey = $db->fetch_array($query)) {
if($importrewrite == 1) {
unset($importarray[preg_replace("/^jswizard_/", '', $existkey['variable'])]);
} else {
$existkeyarray[] = $existkey['variable'];
}
}
if($importrewrite == 0 && $existkeyarray) {
$existkeys = implode(", ", $existkeyarray);
cpmsg('jswizard_import_exist');
}
}
foreach($importarray as $key => $value) {
$value = addslashes($value);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('jswizard_$key', '$value')");
}
updatecache('jswizard');
cpmsg('jswizard_succeed', 'admincp.php?action=jswizard');
}
} elseif($type == 'threads') {
/* Threads == Start == */
$tcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'lastpost') => 'checked');
for($i = 1; $i <= 5; $i++) {
$tcheckspecial[$i] = !empty($parameter['special'][$i]) ? 'checked' : '';
$tcheckdigest[$i] = !empty($parameter['digest'][$i]) ? 'checked' : '';
}
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
$jsthreadtypeselect = '<select multiple="multiple" name="parameter[typeids][]" size="5"><option value="all">'.$lang['jswizard_all_typeids'].'</optoin><option value=""> </option>';
$query = $db->query("SELECT typeid, name FROM {$tablepre}threadtypes ORDER BY typeid DESC");
while($threadtype = $db->fetch_array($query)) {
$jsthreadtypeselect .= '<option value="'.$threadtype['typeid'].'" '.(isset($parameter['typeids']) && in_array($threadtype['typeid'], $parameter['typeids']) ? 'selected' : '').'>'.$threadtype['name'].'</option>';
}
$jsthreadtypeselect .= '</select>';
if($jssubmit && $function == 'threads') {
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['threads_forums'] && !in_array('all', $parameter['threads_forums'])? '&fids='.jsfids($parameter['threads_forums']) : '').
"&maxlength=$parameter[maxlength]".
"&fnamelength=$parameter[fnamelength]".
"&blog=$parameter[blog]".
"&startrow=$parameter[startrow]".
"&picpre=".rawurlencode($parameter['picpre']).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -