code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: userapp.php 20822 2009-10-26 10:20:57Z monkey $
*/
define('CURSCRIPT', 'userapp');
require_once './include/common.inc.php';
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_scriptlang.php';
if($uchomeurl) {
showmessage('manyou:uchome_exists');
}
$mnid = 'plink_userapp';
$funcstatinfo[] = 'manyou2dz,20090727';
$script = !empty($script) && in_array($script, array('feed', 'user', 'notice', 'invite', 'cp', 'admincp')) ? $script : 'feed';
if(!$my_status && $script != 'admincp') {
showmessage('undefined_action', NULL, 'HALTED');
}
if(!empty($id)) {
$script = 'user';
}
if(!$discuz_uid && $script != 'invite' && $script != 'feed' && $view != 'all') {
showmessage('not_loggedin', $regname, 'NOPERM');
}
$isfounder = isfounder();
require_once DISCUZ_ROOT.'./manyou/sources/'.$script.'.php';
function isfounder($user = '') {
$user = empty($user) ? array('uid' => $GLOBALS['discuz_uid'], 'adminid' => $GLOBALS['adminid'], 'username' => $GLOBALS['discuz_userss']) : $user;
$founders = str_replace(' ', '', $GLOBALS['forumfounders']);
if($user['adminid'] <> 1) {
return FALSE;
} elseif(empty($founders)) {
return TRUE;
} elseif(strexists(",$founders,", ",$user[uid],")) {
return TRUE;
} elseif(!is_numeric($user['username']) && strexists(",$founders,", ",$user[username],")) {
return TRUE;
} else {
return FALSE;
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/userapp.php | PHP | asf20 | 1,512 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: menu.inc.php 21081 2009-11-11 06:49:33Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
showmenu('global', array(
array('menu_settings_basic', 'settings&operation=basic'),
array('menu_settings_access', 'settings&operation=access'),
array('menu_settings_optimize', 'settings&operation=seo'),
array('menu_settings_functions', 'settings&operation=functions'),
array('menu_settings_user', 'settings&operation=permissions'),
array('menu_settings_credits', 'settings&operation=credits'),
$isfounder ? array('menu_settings_mail', 'settings&operation=mail') :array(),
array('menu_settings_sec', 'settings&operation=sec'),
array('menu_settings_datetime', 'settings&operation=datetime'),
array('menu_settings_attachments', 'settings&operation=attach'),
array('menu_settings_dzfeed', 'settings&operation=dzfeed'),
array('menu_settings_wap', 'settings&operation=wap'),
$isfounder ? array('menu_settings_uc', 'settings&operation=uc') : array(),
));
showmenu('forum', array(
array('menu_forums', 'forums'),
array('menu_forums_merge', 'forums&operation=merge'),
array('menu_forums_threadtypes', 'threadtypes'),
array('menu_forums_infotypes', 'threadtypes&special=1'),
array('menu_forums_infomodel', 'threadtypes&operation=typemodel'),
array('menu_forums_infooption', 'threadtypes&operation=typeoption')
));
showmenu('user', array(
array('menu_members_add', 'members&operation=add'),
array('menu_members_edit', 'members'),
array('menu_members_edit_ban_user', 'members&operation=ban'),
array('menu_members_ipban', 'members&operation=ipban'),
array('menu_members_credits', 'members&operation=reward'),
array('menu_moderate_modmembers', 'moderate&operation=members'),
array('menu_profilefields', 'profilefields'),
array('menu_admingroups', 'admingroups'),
array('menu_usergroups', 'usergroups'),
array('menu_ranks', 'ranks')
));
showmenu('topic', array(
array('menu_moderate_posts', 'moderate&operation=threads'),
array('menu_maint_threads', 'threads'),
array('menu_maint_prune', 'prune'),
array('menu_maint_attaches', 'attach'),
array('menu_moderate_recyclebin', 'recyclebin'),
array('menu_posting_tags', 'misc&operation=tag'),
array('menu_posting_censors', 'misc&operation=censor'),
array('menu_posting_attachtypes', 'misc&operation=attachtype'),
array('menu_threads_forumstick', 'threads&operation=forumstick'),
array('menu_post_position_index', 'threads&operation=postposition')
));
showmenu('extended', array(
array('menu_tasks', 'tasks'),
array('menu_magics', 'magics&operation=config'),
array('menu_medals', 'medals'),
array('menu_tools_relatedtag', 'tools&operation=tag'),
array('menu_misc_help', 'faq&operation=list'),
array('menu_qihoo', 'qihoo&operation=config'),
array('menu_ec', 'settings&operation=ec'),
array('menu_settings_msn', 'settings&operation=msn')
));
$pluginmenus = array(
array('menu_addons', 'addons'),
array('menu_plugins', 'plugins')
);
@include_once DISCUZ_ROOT.'./forumdata/cache/adminmenu.php';
if(is_array($adminmenu)) {
foreach($adminmenu as $row) {
$pluginmenus[] = array($row['name'], $row['url']);
}
}
showmenu('plugin', $pluginmenus);
showmenu('style', array(
array('menu_settings_styles', 'settings&operation=styles'),
array('menu_styles', 'styles'),
$isfounder ? array('menu_styles_templates', 'templates') : array(),
array('menu_posting_smilies', 'smilies'),
array('menu_thread_icon', 'misc&operation=icon'),
array('menu_thread_stamp', 'misc&operation=stamp'),
array('menu_posting_editor', 'settings&operation=editor'),
array('menu_misc_onlinelist', 'misc&operation=onlinelist'),
));
showmenu('tool', array(
array('menu_members_newsletter', 'members&operation=newsletter'),
array('menu_misc_announce', 'announce'),
array('menu_tools_updatecaches', 'tools&operation=updatecache'),
array('menu_tools_updatecounters', 'counter'),
array('menu_tools_javascript', 'jswizard'),
array('menu_tools_creditwizard', 'creditwizard'),
array('menu_forum_scheme', 'project'),
$isfounder ? array('menu_db', 'db&operation=export') : array(),
array('menu_logs', 'logs&operation=illegal'),
array('menu_custommenu_manage', 'misc&operation=custommenu'),
array('menu_misc_cron', 'misc&operation=cron'),
array('menu_tools_fileperms', 'tools&operation=fileperms'),
array('menu_tools_filecheck', 'checktools&operation=filecheck')
));
showmenu('adv', array(
array('menu_misc_link', 'misc&operation=link'),
array('memu_focus_topic', 'misc&operation=focus'),
array('menu_adv_custom', 'adv')
));
showmenu('uc', array());
$historymenus = array(array('menu_home', 'home'));
$query = $db->query("SELECT sort, title, url FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort IN ('0','1') ORDER BY dateline DESC LIMIT 0, 10");
$historyexist = 0;
while($custom = $db->fetch_array($query)) {
$historymenus[] = array($custom['title'], substr($custom['url'], 19));
if(!$custom['sort']) {
$historyexist = 1;
}
}
if($historyexist) {
$historymenus[] = array('menu_home_clearhistorymenus', 'misc&operation=custommenu&do=clean', 'main', 'class="menulink"');
}
showmenu('index', $historymenus);
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/menu.inc.php | PHP | asf20 | 5,362 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: logs.inc.php 21053 2009-11-09 10:29:02Z wangjinbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$lpp = empty($lpp) ? 20 : $lpp;
$checklpp = array();
$checklpp[$lpp] = 'selected="selected"';
if(!in_array($operation, array('illegal', 'rate', 'credit', 'mods', 'medal', 'ban', 'cp', 'magic', 'error', 'invite', 'payment'))) {
cpmsg('undefined_action', '', 'error');
}
$logdir = DISCUZ_ROOT.'./forumdata/logs/';
$logfiles = get_log_files($logdir, $operation.'log');
$logs = array();
rsort($logfiles);
if($logfiles) {
$logs = file(!empty($day) ? $logdir.$day.'_'.$operation.'log.php' : $logdir.$logfiles[0]);
}
$page = max(1, intval($page));
$start = ($page - 1) * $lpp;
$logs = array_reverse($logs);
if(empty($keyword)) {
$num = count($logs);
$multipage = multi($num, $lpp, $page, "$BASESCRIPT?action=logs&operation=$operation&lpp=$lpp".(!empty($day) ? '&day='.$day : ''), 0, 3);
$logs = array_slice($logs, $start, $lpp);
} else {
foreach($logs as $key => $value) {
if(strpos($value, $keyword) === FALSE) {
unset($logs[$key]);
}
}
$multipage = '';
}
$usergroup = array();
if(in_array($operation, array('rate', 'mods', 'ban', 'cp'))) {
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$usergroup[$group['groupid']] = $group['grouptitle'];
}
}
shownav('tools', 'nav_logs', 'nav_logs_'.$operation);
if($logfiles) {
$sel = '<select class="right" onchange="location.href=\''.$BASESCRIPT.'?action=logs&operation='.$operation.'&day=\'+this.value">';
foreach($logfiles as $logfile) {
list($date) = explode('_', $logfile);
$sel .= '<option value="'.$date.'"'.($date == $day ? ' selected="selected"' : '').'>'.$date.'</option>';
}
$sel .= '</select>';
} else {
$sel = '';
}
showsubmenu('nav_logs', array(
array(array('menu' => 'nav_logs_member', 'submenu' => array(
array('nav_logs_illegal', 'logs&operation=illegal'),
array('nav_logs_ban', 'logs&operation=ban'),
array('nav_logs_mods', 'logs&operation=mods'),
)), '', in_array($operation, array('illegal', 'ban', 'mods'))),
array(array('menu' => 'nav_logs_system', 'submenu' => array(
array('nav_logs_cp', 'logs&operation=cp'),
array('nav_logs_error', 'logs&operation=error'),
)), '', in_array($operation, array('cp', 'error'))),
array(array('menu' => 'nav_logs_extended', 'submenu' => array(
array('nav_logs_rate', 'logs&operation=rate'),
array('nav_logs_credit', 'logs&operation=credit'),
array('nav_logs_magic', 'logs&operation=magic'),
array('nav_logs_medal', 'logs&operation=medal'),
array('nav_logs_invite', 'logs&operation=invite'),
array('nav_logs_payment', 'logs&operation=payment'),
)), '', in_array($operation, array('rate', 'credit', 'magic', 'medal', 'invite', 'payment')))
), $sel);
showformheader("logs&operation=$operation");
showtableheader('', 'fixpadding');
$filters = '';
if($operation == 'illegal') {
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td23"','class="td23"'), array(
lang('logs_passwd_username'),
lang('logs_passwd_password'),
lang('logs_passwd_security'),
lang('ip'),
lang('time'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
if(strtolower($log[2]) == strtolower($discuz_userss)) {
$log[2] = "<b>$log[2]</b>";
}
$log[5] = $allowviewip ? $log[5] : '-';
showtablerow('', array('class="bold"', '', '', 'class="smallefont"', 'class="smallefont"'), array(
$log[2],
$log[3],
$log[4],
$log[5],
$log[1]
));
}
} elseif($operation == 'rate') {
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td23"','class="td23"','class="td24"'), array(
lang('username'),
lang('usergroup'),
lang('time'),
lang('logs_rating_username'),
lang('logs_rating_rating'),
lang('subject'),
lang('reason'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$log[2] = "<a href=\"space.php?username=".rawurlencode($log[2])."\" target=\"_blank\">$log[2]</a>";
$log[3] = $usergroup[$log[3]];
if($log[4] == $discuz_userss) {
$log[4] = "<b>$log[4]</b>";
}
$log[4] = "<a href=\"space.php?username=".rawurlencode($log[4])."\" target=\"_blank\">$log[4]</a>";
$log[6] = $extcredits[$log[5]]['title'].' '.($log[6] < 0 ? "<b>$log[6]</b>" : "+$log[6]").' '.$extcredits[$log[5]]['unit'];
$log[7] = $log[7] ? "<a href=\"./viewthread.php?tid=$log[7]\" target=\"_blank\" title=\"$log[8]\">".cutstr($log[8], 20)."</a>" : "<i>$lang[logs_rating_manual]</i>";
showtablerow('', array('class="bold"'), array(
$log[2],
$log[3],
$log[1],
$log[4],
(trim($log[10]) == 'D' ? $lang['logs_rating_delete'] : '').$log[6],
$log[7],
$log[9]
));
}
} elseif($operation == 'credit') {
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td24"','class="td24"'), array(
lang('username'),
lang('logs_credit_fromto'),
lang('time'),
lang('logs_credit_send'),
lang('logs_credit_receive'),
lang('action'),
));
$lpp = max(5, empty($lpp) ? 50 : intval($lpp));
$page = max(1, intval($page));
$start_limit = ($page - 1) * $lpp;
$keywordadd = !empty($keyword) ? "AND c.fromto LIKE '%$keyword%'" : '';
$mpurl = "$BASESCRIPT?action=logs&operation=$operation&keyword=".rawurlencode($keyword)."&lpp=$lpp";
if(in_array($opt, array('TFR', 'RCV', 'EXC', 'UGP', 'AFD'))) {
$optadd = "AND c.operation='$opt'";
$mpurl .= '&opt='.$opt;
} else {
$optadd = '';
}
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}creditslog c WHERE 1 $keywordadd $optadd");
$multipage = multi($num, $lpp, $page, $mpurl, 0, 3);
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=credit&opt=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['action'].'</option><option value="">'.$lang['all'].'</option>';
foreach(array('TFR', 'RCV', 'EXC', 'UGP', 'AFD') as $o) {
$filters .= '<option value="'.$o.'" '.(!empty($opt) && $o == $opt ? 'selected="selected"' : '').'>'.$lang['logs_credit_operation_'.strtolower($o)].'</option>';
}
$filters .= '</select>';
$total['send'] = $total['receive'] = array();
$query = $db->query("SELECT c.*, m.username FROM {$tablepre}creditslog c
LEFT JOIN {$tablepre}members m USING (uid)
WHERE 1 $keywordadd $optadd ORDER BY dateline DESC LIMIT $start_limit, $lpp");
while($log = $db->fetch_array($query)) {
$total['send'][$log['sendcredits']] += $log['send'];
$total['receive'][$log['receivecredits']] += $log['receive'];
$log['dateline'] = gmdate('y-n-j H:i', $log['dateline'] + $timeoffset * 3600);
$log['operation'] = $lang['logs_credit_operation_'.strtolower($log['operation'])];
showtablerow('', array('class="bold"'), array(
"<a href=\"space.php?username=".rawurlencode($log['username'])."\" target=\"_blank\">$log[username]",
$log[fromto],
$log[dateline],
isset($extcredits[$log['sendcredits']]) ? $extcredits[$log['sendcredits']]['title'].' '.$log['send'].' '.$extcredits[$log['sendcredits']]['unit'] : $log['send'],
isset($extcredits[$log['receivecredits']]) ? $extcredits[$log['receivecredits']]['title'].' '.$log['receive'].' '.$extcredits[$log['receivecredits']]['unit'] : $log['receive'],
$log[operation],
));
}
$result = array('send' => array(), 'receive' => array());
foreach(array('send', 'receive') as $key) {
foreach($total[$key] as $id => $amount) {
if(isset($extcredits[$id])) {
$result[$key][] = $extcredits[$id]['title'].' '.$amount.' '.$extcredits[$id]['unit'];
}
}
}
showtablerow('', '', array(
'',
'',
'',
$lang['logs_credit_total'].implode('; ', $result['send']),
$lang['logs_credit_total'].implode(', ', $result['receive']),
''
));
} elseif($operation == 'mods') {
include language('modactions');
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td23"','class="td24"','class="td24"','class="td23"'), array(
lang('operator'),
lang('usergroup'),
lang('ip'),
lang('time'),
lang('forum'),
lang('thread'),
lang('action'),
lang('reason'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$log[2] = stripslashes($log[2]);
$log[3] = $usergroup[$log[3]];
$log[4] = $allowviewip ? $log[4] : '-';
$log[6] = "<a href=\"./forumdisplay.php?fid=$log[5]\" target=\"_blank\">$log[6]</a>";
$log[8] = "<a href=\"./viewthread.php?tid=$log[7]\" target=\"_blank\" title=\"$log[8]\">".cutstr($log[8], 15)."</a>";
$log[9] = $modactioncode[trim($log[9])];
showtablerow('', array('class="bold"'), array(
"<a href=\"space.php?username=".rawurlencode($log[2])."\" target=\"_blank\">".($log[2] != $discuz_userss ? "<b>$log[2]</b>" : $log[2]),
$log[3],
$log[4],
$log[1],
$log[6],
$log[8],
$log[9],
$log[10],
));
}
} elseif($operation == 'ban') {
showtablerow('class="header"', array('class="td23"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td24"', 'class="td23"'), array(
lang('operator'),
lang('usergroup'),
lang('ip'),
lang('time'),
lang('username'),
lang('operation'),
lang('logs_banned_group'),
lang('validity'),
lang('reason'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$log[2] = "<a href=\"space.php?username=".rawurlencode($log[2])."\" target=\"_blank\">$log[2]";
$log[3] = $usergroup[$log[3]];
$log[4] = $allowviewip ? $log[4] : '-';
$log[5] = "<a href=\"space.php?username=".rawurlencode($log[5])."\" target=\"_blank\">$log[5]</a>";
$log[8] = trim($log[8]) ? gmdate('y-n-j', $log[8] + $timeoffset * 3600) : '';
showtablerow('', array('class="bold"'), array(
$log[2],
$log[3],
$log[4],
$log[1],
$log[5],
(in_array($log[6], array(4, 5)) && !in_array($log[7], array(4, 5)) ? '<i>'.$lang['logs_banned_unban'].'</i>' : '<b>'.$lang['logs_banned_ban'].'</b>'),
"{$usergroup[$log[6]]} / {$usergroup[$log[7]]}",
$log[8],
$log[9]
));
}
} elseif($operation == 'cp') {
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td24"','class="td24"', ''), array(
lang('operator'),
lang('usergroup'),
lang('ip'),
lang('time'),
lang('action'),
lang('other')
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$log[2] = stripslashes($log[2]);
$log[2] = "<a href=\"space.php?username=".rawurlencode($log[2])."\" target=\"_blank\">".($log[2] != $discuz_userss ? "<b>$log[2]</b>" : $log[2])."</a>";
$log[3] = $usergroup[$log[3]];
$log[4] = $allowviewip ? $log[4] : '-';
$log[5] = $lang['cplog_'.rtrim($log[5])];
$log[6] = cutstr($log[6], 200);
showtablerow('', array('class="bold"'), array($log[2], $log[3], $log[4], $log[1], $log[5], $log[6]));
}
} elseif($operation == 'error') {
showtablerow('class="header"', array('class="td23"', 'class="td24"', 'class="td24"'), array(
lang('type'),
lang('username'),
lang('time'),
lang('message'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$tmp = explode('<br />', $log[3]);
$username = $tmp[1] ? "<a href=\"space.php?username=".rawurlencode($tmp[0])."\" target=\"_blank\">$tmp[0]</a>" : '';
$ip = $tmp[1] ? $tmp[1] : $tmp[0];
showtablerow('', array('class="bold"'), array(
$log[2],
($username ? $username."<br />" : '').$ip,
$log[1],
$log[4]
));
}
} elseif($operation == 'invite') {
if(!submitcheck('invitesubmit')) {
showtablerow('class="header"', array('width="35"','class="td23"','class="td24"','class="td24"','class="td23"','class="td24"','class="td24"'), array(
'',
lang('logs_invite_buyer'),
lang('logs_invite_buydate'),
lang('logs_invite_expiration'),
lang('logs_invite_ip'),
lang('logs_invite_code'),
lang('logs_invite_status'),
));
$tpp = $lpp ? intval($lpp) : $tpp;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$addstatus = '';
if(in_array($status, array(1,2,3,4))) {
$statusurl .= '&status='.$status;
$addstatus = "AND status='$status'";
}
$invitecount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}invites WHERE 1 $addstatus");
$multipage = multi($invitecount, $tpp, $page, "$BASESCRIPT?action=logs&operation=invite&lpp=$lpp$statusurl", 0, 3);
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=invite&status=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['action'].'</option><option value="">'.$lang['all'].'</option>';
foreach(array(1,2,3,4) as $s) {
$filters .= '<option value="'.$s.'" '.(!empty($status) && $s == $status ? 'selected="selected"' : '').'>'.lang('logs_invite_status_'.$s).'</option>';
}
$filters .= '</select>';
$query = $db->query("SELECT i.*, m.username FROM {$tablepre}invites i, {$tablepre}members m
WHERE i.uid=m.uid $addstatus
ORDER BY i.dateline LIMIT $start_limit,$tpp");
while($invite = $db->fetch_array($query)) {
$invite['statuslog'] = $lang['logs_invite_status_'.$invite['status']];
$username = "<a href=\"space.php?uid=$invite[uid]\">$invite[username]</a>";
$invite['dateline'] = gmdate('Y-n-j H:i', $invite['dateline'] + $timeoffset * 3600);
$invite['expiration'] = gmdate('Y-n-j H:i', $invite['expiration'] + $timeoffset * 3600);
$stats = $invite['statuslog'].($invite['status'] == 2 ? ' [<a href="space.php?uid='.$invite['reguid'].'">'.$lang['logs_invite_target'].'</a>]' : '');
showtablerow('', array('', 'class="bold"'), array(
'<input type="checkbox" class="checkbox" name="delete[]" value="'.$invite[invitecode].'" />',
$username,
$invite['dateline'],
$invite['expiration'],
$invite['inviteip'],
$invite['invitecode'],
$stats
));
}
} else {
if($deletelist = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}invites WHERE invitecode IN ($deletelist)");
}
header("Location: $boardurl$BASESCRIPT?action=logs&operation=invite");
}
} elseif($operation == 'magic') {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_magics.php';
$lpp = empty($lpp) ? 50 : $lpp;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $lpp;
$mpurl = "$BASESCRIPT?action=logs&operation=magic&lpp=$lpp";
if(in_array($opt, array('1', '2', '3', '4', '5'))) {
$optadd = "AND ma.action='$opt'";
$mpurl .= '&opt='.$opt;
} else {
$optadd = '';
}
if(!empty($magicid)) {
$magicidadd = "AND ma.magicid='".intval($magicid)."'";
} else {
$magicidadd = '';
}
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}magiclog ma WHERE 1 $magicidadd $optadd");
$multipage = multi($num, $lpp, $page, $mpurl, 0, 3);
$check1 = $check2 = array();
$check1[$magicid] = 'selected="selected"';
$check2[$opt] = 'selected="selected"';
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=magic&opt='.$opt.'&lpp='.$lpp.'&magicid=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['magics_type'].'</option><option value="">'.$lang['magics_type_all'].'</option>';
foreach($_DCACHE['magics'] as $id => $magic) {
$filters .= '<option value="'.$id.'" '.$check1[$id].'>'.$magic['name'].'</option>';
}
$filters .= '</select>';
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=magic&magicid='.$magicid.'&lpp='.$lpp.'&opt=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['action'].'</option><option value="">'.$lang['all'].'</option>';
foreach(array('1', '2', '3', '4', '5') as $o) {
$filters .= '<option value="'.$o.'" '.$check2[$o].'>'.$lang['logs_magic_operation_'.$o].'</option>';
}
$filters .= '</select>';
showtablerow('class="header"', array('class="td23"', 'class="td23"', 'class="td24"', 'class="td23"', 'class="td23"', 'class="td24"'), array(
lang('username'),
lang('name'),
lang('time'),
lang('num'),
lang('price'),
lang('action')
));
$query = $db->query("SELECT ma.*, m.username FROM {$tablepre}magiclog ma
LEFT JOIN {$tablepre}members m USING (uid)
WHERE 1 $magicidadd $optadd ORDER BY dateline DESC LIMIT $start_limit, $lpp");
while($log = $db->fetch_array($query)) {
$log['name'] = $_DCACHE['magics'][$log['magicid']]['name'];
$log['dateline'] = gmdate('Y-n-j H:i', $log['dateline'] + $timeoffset * 3600);
$log['action'] = $lang['logs_magic_operation_'.$log['action']];
showtablerow('', array('class="bold"'), array(
"<a href=\"space.php?username=".rawurlencode($log['username'])."\" target=\"_blank\">$log[username]",
$log['name'],
$log['dateline'],
$log['amount'],
$log['price'],
$log['action']
));
}
} elseif($operation == 'medal') {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
$lpp = empty($lpp) ? 50 : $lpp;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $lpp;
$mpurl = "$BASESCRIPT?action=logs&operation=medal&lpp=$lpp";
if(in_array($opt, array('0', '1', '2', '3'))) {
$optadd = "AND me.type='$opt'";
$mpurl .= '&opt='.$opt;
} else {
$optadd = '';
}
if(!empty($medalid)) {
$medalidadd = "AND me.medalid='".intval($medalid)."'";
} else {
$medalidadd = '';
}
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}medallog me WHERE 1 $medalidadd $optadd");
$multipage = multi($num, $lpp, $page, $mpurl, 0, 3);
$check1 = $check2 = array();
$check1[$medalid] = 'selected="selected"';
$check2[$opt] = 'selected="selected"';
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=medal&opt='.$opt.'&lpp='.$lpp.'&medalid=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['medals'].'</option><option value="">'.$lang['all'].'</option>';
foreach($_DCACHE['medals'] as $id => $medal) {
$filters .= '<option value="'.$id.'" '.$check1[$id].'>'.$medal['name'].'</option>';
}
$filters .= '</select>';
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=medal&medalid='.$medalid.'&lpp='.$lpp.'&opt=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['action'].'</option><option value="">'.$lang['all'].'</option>';
foreach(array('0', '1', '2', '3') as $o) {
$filters .= '<option value="'.$o.'" '.$check2[$o].'>'.$lang['logs_medal_operation_'.$o].'</option>';
}
$filters .= '</select>';
showtablerow('class="header"', array('class="td23"', 'class="td24"', 'class="td23"', 'class="td23"'), array(
lang('username'),
lang('logs_medal_name'),
lang('type'),
lang('time'),
lang('logs_medal_expiration')
));
$query = $db->query("SELECT me.*, m.username FROM {$tablepre}medallog me
LEFT JOIN {$tablepre}members m USING (uid)
WHERE 1 $medalidadd $optadd ORDER BY dateline DESC LIMIT $start_limit, $lpp");
while($log = $db->fetch_array($query)) {
$log['name'] = $_DCACHE['medals'][$log['medalid']]['name'];
$log['dateline'] = gmdate('Y-n-j H:i', $log['dateline'] + $timeoffset * 3600);
$log['expiration'] = empty($log['expiration']) ? lang('logs_noexpire') : gmdate('Y-n-j H:i', $log['expiration'] + $timeoffset * 3600);
showtablerow('', array('class="td23"', 'class="td24"', 'class="td23"', 'class="td24"'), array(
"<a href=\"space.php?username=".rawurlencode($log['username'])."\" target=\"_blank\">$log[username]",
$log['name'],
$lang['logs_medal_operation_'.$log['type']],
$log['dateline'],
$log['expiration']
));
}
} elseif($operation == 'payment') {
showtablerow('class="header"', array('width="30%"','class="td23"','class="td23"','class="td24"','class="td23"','class="td24"','class="td24"'), array(
lang('subject'),
lang('logs_payment_amount'),
lang('logs_payment_netamount'),
lang('logs_payment_seller'),
lang('logs_payment_buyer'),
lang('logs_payment_dateline'),
lang('logs_payment_buydateline'),
));
$tpp = $lpp ? intval($lpp) : $tpp;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$threadcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}paymentlog");
$multipage = multi($threadcount, $tpp, $page, "$BASESCRIPT?action=logs&operation=payment&lpp=$lpp", 0, 3);
$paythreadlist = array();
$query = $db->query("SELECT p.*, m.username, t.subject, t.dateline AS postdateline, t.author, t.authorid AS tauthorid
FROM {$tablepre}paymentlog p
LEFT JOIN {$tablepre}members m ON m.uid=p.uid
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
ORDER BY p.dateline LIMIT $start_limit,$tpp");
while($paythread = $db->fetch_array($query)) {
$paythread['seller'] = $paythread['tauthorid'] ? "<a href=\"space.php?uid=$paythread[tauthorid]\">$paythread[author]</a>" : lang('logs_payment_del')."(<a href=\"space.php?uid=$paythread[authorid]\">".lang('logs_payment_view')."</a>)";;
$paythread['buyer'] = "<a href=\"space.php?uid=$paythread[uid]\">$paythread[username]</a>";
$paythread['subject'] = $paythread['subject'] ? "<a href=\"viewthread.php?tid=$paythread[tid]\">$paythread[subject]</a>" : lang('logs_payment_del');
$paythread['dateline'] = gmdate('Y-n-j H:i', $paythread['dateline'] + $timeoffset * 3600);
$paythread['postdateline'] = $paythread['postdateline'] ? gmdate('Y-n-j H:i', $paythread['postdateline'] + $timeoffset * 3600) : lang('logs_payment_del');
$paythreadlist[] = $paythread;
}
foreach($paythreadlist as $paythread) {
showtablerow('', array('', 'class="bold"'), array(
$paythread['subject'],
$paythread['amount'],
$paythread['netamount'],
$paythread['seller'],
$paythread['buyer'],
$paythread['postdateline'],
$paythread['dateline']
));
}
}
function get_log_files($logdir = '', $action = 'action') {
$dir = opendir($logdir);
$files = array();
while($entry = readdir($dir)) {
$files[] = $entry;
}
closedir($dir);
if($files) {
sort($files);
$logfile = $action;
$logfiles = array();
$ym = '';
foreach($files as $file) {
if(strpos($file, $logfile) !== FALSE) {
if(substr($file, 0, 6) != $ym) {
$ym = substr($file, 0, 6);
}
$logfiles[$ym][] = $file;
}
}
if($logfiles) {
$lfs = array();
foreach($logfiles as $ym => $lf) {
$lastlogfile = $lf[0];
unset($lf[0]);
$lf[] = $lastlogfile;
$lfs = array_merge($lfs, $lf);
}
return array_slice($lfs, -2, 2);
}
return array();
}
return array();
}
showsubmit($operation == 'invite' ? 'invitesubmit' : '', 'submit', 'del', $filters, $multipage.lang('logs_lpp').':<select onchange="if(this.options[this.selectedIndex].value != \'\') {window.location=\''.$BASESCRIPT.'?action=logs&operation='.$operation.'&lpp=\'+this.options[this.selectedIndex].value+\'&sid='.$sid.'\' }"><option value="20" '.$checklpp[20].'> 20 </option><option value="40" '.$checklpp[40].'> 40 </option><option value="80" '.$checklpp[80].'> 80 </option></select> <input type="text" class="txt" name="keyword" value="'.$keyword.'" /><input type="submit" class="btn" value="'.$lang['search'].'" />');
showtablefooter();
showformfooter();
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/logs.inc.php | PHP | asf20 | 24,254 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: recyclebin.inc.php 20917 2009-10-29 09:19:37Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./include/post.func.php';
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
cpheader();
if(!$operation) {
shownav('topic', 'nav_recyclebin');
showsubmenu('nav_recyclebin', array(
array('recyclebin_list', 'recyclebin', 1),
array('search', 'recyclebin&operation=search', 0),
array('clean', 'recyclebin&operation=clean', 0)
));
if(!submitcheck('delsubmit') && !submitcheck('undelsubmit')) {
$lpp = empty($lpp) ? 10 : $lpp;
$page = max(1, intval($page));
$start = ($page - 1) * $lpp;
$start_limit = ($page - 1) * $lpp;
showformheader('recyclebin');
showtableheader('recyclebin_list');
showsubtitle(array('', 'thread', 'recyclebin_list_thread', 'recyclebin_list_author', 'recyclebin_list_status', 'recyclebin_list_lastpost', 'recyclebin_list_operation'));
$query = $db->query("SELECT f.name AS forumname,t.tid, t.fid, t.authorid, t.author, t.subject, t.views, t.replies, t.dateline, t.lastpost, t.lastposter,
tm.uid AS moduid, tm.username AS modusername, tm.dateline AS moddateline, tm.action AS modaction
FROM {$tablepre}threads t
LEFT JOIN {$tablepre}threadsmod tm ON tm.tid=t.tid
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
WHERE t.displayorder='-1' $sql
GROUP BY t.tid ORDER BY t.dateline DESC LIMIT $start_limit, $lpp");
while($thread = $db->fetch_array($query)) {
$thread['modthreadkey'] = modthreadkey($thread['tid']);
showtablerow('', array('class="td25"', '', '', 'class="td28"', 'class="td28"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"threadlist[]\" value=\"$thread[tid]\">",
'<a href="viewthread.php?tid='.$thread['tid'].'&modthreadkey='.$thread['modthreadkey'].'" target="_blank">'.$thread['subject'].'</a>',
'<a href="forumdisplay.php?fid='.$thread['fid'].'" target="_blank">'.$thread['forumname'].'</a>',
'<a href="space.php?uid='.$thread['authorid'].'" target="_blank">'.$thread['author'].'</a><br /><em style="font-size:9px;color:#999999;">'.gmdate("$dateformat", $thread['dateline'] + $timeoffset * 3600).'</em>',
$thread['replies'].' / '.$thread['views'],
$thread['lastposter'].'<br /><em style="font-size:9px;color:#999999;">'.gmdate("$dateformat", $thread['lastpost'] + $timeoffset * 3600).'</em>',
$thread['modusername'].'<br /><em style="font-size:9px;color:#999999;">'.gmdate("$dateformat", $thread['moddateline'] + $timeoffset * 3600).'</em>'
));
}
$threadcount = $db->result_first("SELECT count(*) FROM {$tablepre}threads t WHERE t.displayorder='-1'");
$multipage = multi($threadcount, $lpp, $page, "$BASESCRIPT?action=recyclebin&lpp=$lpp", 0, 3);
showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'threadlist\')" /><label for="chkall">'.lang('select_all').'</label> <input type="submit" class="btn" name="delsubmit" value="'.lang('recyclebin_delete').'" /> <input type="submit" class="btn" name="undelsubmit" value="'.lang('recyclebin_undelete').'" />', $multipage);
showtablefooter();
showformfooter();
} else {
if(empty($threadlist)) {
cpmsg('recyclebin_none_selected', $BASESCRIPT.'?action=recyclebin', 'error');
}
$threadsundel = $threadsdel = 0;
if(submitcheck('undelsubmit')) {
$threadsundel = undeletethreads($threadlist);
} elseif(submitcheck('delsubmit')) {
$threadsdel = deletethreads($threadlist);
}
cpmsg('recyclebin_succeed', $BASESCRIPT.'?action=recyclebin', 'succeed');
}
} elseif($operation == 'search') {
if(!submitcheck('rbsubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="inforum"><option value=""> > '.$lang['select'].'</option>'.
'<option value=""> </option>'.forumselect(FALSE, 0, 0, TRUE).'</select>';
if($inforum) {
$forumselect = preg_replace("/(\<option value=\"$inforum\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
}
shownav('topic', 'nav_recyclebin');
showsubmenu('nav_recyclebin', array(
array('recyclebin_list', 'recyclebin', 0),
array('search', 'recyclebin', 1),
array('clean', 'recyclebin&operation=clean', 0)
));
echo <<<EOT
<script type="text/javascript" src="include/js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('rbsearchform').page.value=number;
$('rbsearchform').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'threadsearch', !$searchsubmit);
showformheader('recyclebin&operation=search', '', 'rbsearchform');
showhiddenfields(array('page' => $page));
showtableheader('recyclebin_search');
showsetting('recyclebin_search_forum', '', '', $forumselect);
showsetting('recyclebin_search_author', 'authors', $authors, 'text');
showsetting('recyclebin_search_keyword', 'keywords', $keywords, 'text');
showsetting('recyclebin_search_admin', 'admins', $admins, 'text');
showsetting('recyclebin_search_post_time', array('pstarttime', 'pendtime'), array($pstarttime, $pendtime), 'daterange');
showsetting('recyclebin_search_mod_time', array('mstarttime', 'mendtime'), array($mstarttime, $mendtime), 'daterange');
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
$sql = '';
$sql .= $inforum ? " AND t.fid='$inforum'" : '';
$sql .= $authors != '' ? " AND t.author IN ('".str_replace(',', '\',\'', str_replace(' ', '', $authors))."')" : '';
$sql .= $admins != '' ? " AND tm.username IN ('".str_replace(',', '\',\'', str_replace(' ', '', $admins))."')" : '';
$sql .= $pstarttime != '' ? " AND t.dateline>='".strtotime($pstarttime)."'" : '';
$sql .= $pendtime != '' ? " AND t.dateline<'".strtotime($pendtime)."'" : '';
$sql .= $mstarttime != '' ? " AND tm.dateline>='".strtotime($mstarttime)."'" : '';
$sql .= $mendtime != '' ? " AND tm.dateline<'".strtotime($mendtime)."'" : '';
if(trim($keywords)) {
$sqlkeywords = $or = '';
foreach(explode(',', str_replace(' ', '', $keywords)) as $keyword) {
$sqlkeywords .= " $or t.subject LIKE '%$keyword%'";
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
}
$threadcount = $db->result_first("SELECT count(*)
FROM {$tablepre}threads t
LEFT JOIN {$tablepre}threadsmod tm ON tm.tid=t.tid
WHERE t.displayorder='-1' $sql");
$pagetmp = $page;
do{
$query = $db->query("SELECT f.name AS forumname, f.allowsmilies, f.allowhtml, f.allowbbcode, f.allowimgcode,
t.tid, t.fid, t.authorid, t.author, t.subject, t.views, t.replies, t.dateline,
p.message, p.useip, p.attachment, p.htmlon, p.smileyoff, p.bbcodeoff,
tm.uid AS moduid, tm.username AS modusername, tm.dateline AS moddateline, tm.action AS modaction
FROM {$tablepre}threads t
LEFT JOIN {$tablepre}posts p ON p.tid=t.tid AND p.first='1'
LEFT JOIN {$tablepre}threadsmod tm ON tm.tid=t.tid
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
WHERE t.displayorder='-1' $sql
GROUP BY t.tid ORDER BY t.dateline DESC LIMIT ".(($pagetmp - 1) * $ppp).",$ppp");
$pagetmp--;
} while(!$db->num_rows($query) && $pagetmp);
$multi = multi($threadcount, $ppp, $page, "$BASESCRIPT?action=recyclebin");
$multi = preg_replace("/href=\"$BASESCRIPT\?action=recyclebin&page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location=$BASESCRIPT.'?action=recyclebin&page='+this.value", "page(this.value)", $multi);
echo '<script type="text/JavaScript">var replyreload;function attachimg() {}</script>';
showtagheader('div', 'threadlist', $searchsubmit);
showformheader('recyclebin&operation=search&frame=no', 'target="rbframe"', 'rbform');
showtableheader(lang('recyclebin_result').' '.$threadcount.' <a href="#" onclick="$(\'threadlist\').style.display=\'none\';$(\'threadsearch\').style.display=\'\';" class="act lightlink normal">'.lang('research').'</a>', 'fixpadding');
while($thread = $db->fetch_array($query)) {
$thread['message'] = discuzcode($thread['message'], $thread['smileyoff'], $thread['bbcodeoff'], sprintf('%00b', $thread['htmlon']), $thread['allowsmilies'], $thread['allowbbcode'], $thread['allowimgcode'], $thread['allowhtml']);
$thread['moddateline'] = gmdate("$dateformat $timeformat", $thread['moddateline'] + $timeoffset * 3600);
$thread['dateline'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
if($thread['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$queryattach = $db->query("SELECT aid, filename, filetype, filesize FROM {$tablepre}attachments WHERE tid='$thread[tid]'");
while($attach = $db->fetch_array($queryattach)) {
$thread['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($thread['filename'])."\t".$attach['filetype'])." $attach[filename] (".sizecount($attach['filesize']).")";
}
}
showtablerow("id=\"mod_$thread[tid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
"<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_1\" value=\"delete\" checked=\"checked\" /><label for=\"mod_$thread[tid]_1\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_2\" value=\"undelete\" /><label for=\"mod_$thread[tid]_2\">$lang[undelete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_3\" value=\"ignore\" /><label for=\"mod_$thread[tid]_3\">$lang[ignore]</label></li></ul>",
"<h3><a href=\"forumdisplay.php?fid=$thread[fid]\" target=\"_blank\">$thread[forumname]</a> » $thread[subject]</h3><p><span class=\"bold\">$lang[author]:</span> <a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a> <span class=\"bold\">$lang[time]:</span> $thread[dateline] $lang[threads_replies]: $thread[replies] $lang[threads_views]: $thread[views]</p>"
));
showtablerow("id=\"mod_$thread[tid]_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:120px; word-break: break-all;">'.$thread['message'].'</div>');
showtablerow("id=\"mod_$thread[tid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "$lang[operator]: <a href=\"space.php?uid=$thread[moduid]\" target=\"_blank\">$thread[modusername]</a> $lang[recyclebin_delete_time]: $thread[moddateline]");
}
showsubmit('rbsubmit', 'submit', '', '<a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'delete\')">'.lang('recyclebin_all_delete').'</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'undelete\')">'.lang('recyclebin_all_undelete').'</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'ignore\')">'.lang('recyclebin_all_ignore').'</a> ', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="rbframe" style="display:none"></iframe>';
showtagfooter('div');
}
} else {
$moderation = array('delete' => array(), 'undelete' => array(), 'ignore' => array());
if(is_array($mod)) {
foreach($mod as $tid => $action) {
$moderation[$action][] = intval($tid);
}
}
$threadsdel = deletethreads($moderation['delete']);
$threadsundel = undeletethreads($moderation['undelete']);
//cpmsg('recyclebin_succeed', $BASESCRIPT.'?action=recyclebin&operation=', 'succeed');
eval("\$cpmsg = \"".lang('recyclebin_succeed')."\";");
?>
<script type="text/JavaScript">alert('<?=$cpmsg?>');parent.$('rbsearchform').searchsubmit.click();</script>
<?
}
} elseif($operation == 'clean') {
if(!submitcheck('rbsubmit')) {
shownav('topic', 'nav_recyclebin');
showsubmenu('nav_recyclebin', array(
array('recyclebin_list', 'recyclebin', 0),
array('search', 'recyclebin', 0),
array('clean', 'recyclebin&operation=clean', 1)
));
showformheader('recyclebin&operation=clean');
showtableheader('recyclebin_clean');
showsetting('recyclebin_clean_days', 'days', '30', 'text');
showsubmit('rbsubmit');
showtablefooter();
showformfooter();
} else {
$deletetids = array();
$query = $db->query("SELECT tm.tid FROM {$tablepre}threadsmod tm, {$tablepre}threads t
WHERE tm.dateline<$timestamp-'$days'*86400 AND tm.action='DEL' AND t.tid=tm.tid AND t.displayorder='-1'");
while($thread = $db->fetch_array($query)) {
$deletetids[] = $thread['tid'];
}
$threadsdel = deletethreads($deletetids);
$threadsundel = 0;
cpmsg('recyclebin_succeed', $BASESCRIPT.'?action=recyclebin&operation=clean', 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/recyclebin.inc.php | PHP | asf20 | 13,253 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ec.inc.php 20461 2009-09-28 04:43:28Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if($operation == 'alipay') {
$settings = array();
$query = $db->query("SELECT variable, value FROM {$tablepre}settings WHERE variable IN ('ec_account', 'ec_contract')");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
if(!empty($checktype)) {
require_once DISCUZ_ROOT.'./api/trade/alipay.api.php';
if($checktype == 'credit') {
dheader('location: '.credit_payurl(1, $orderid));
} elseif($checktype == 'virtualgoods') {
$pay = array(
'logistics_type' => 'VIRTUAL'
);
$trade = array(
'subject' => $lang['ec_alipay_check_virtualgoodssubject'],
'itemtype' => 1,
'account' => $settings['ec_account'],
);
$tradelog = array(
'orderid' => 'TEST'.gmdate('YmdHis', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600).random(18),
'baseprice' => 1,
'number' => 1,
'transportfee' => 0,
);
dheader('location: '.trade_payurl($pay, $trade, $tradelog));
} elseif($checktype == 'goods') {
$pay = array(
'logistics_type' => 'EMS',
'transport' => 'SELLER_PAY',
);
$trade = array(
'subject' => $lang['ec_alipay_check_goodssubject'],
'itemtype' => 1,
'account' => $settings['ec_account'],
);
$tradelog = array(
'orderid' => 'TEST'.gmdate('YmdHis', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600).random(18),
'baseprice' => 1,
'number' => 1,
'transportfee' => 0,
);
dheader('location: '.trade_payurl($pay, $trade, $tradelog));
}
exit;
}
list($ec_contract, $ec_securitycode, $ec_partner, $ec_creditdirectpay) = explode("\t", authcode($settings['ec_contract'], 'DECODE', $_DCACHE['settings']['authkey']));
$ec_securitycodemask = $ec_securitycode ? $ec_securitycode{0}.'********'.substr($ec_securitycode, -4) : '';
if(!submitcheck('alipaysubmit')) {
if($from == 'creditwizard') {
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', 0),
array('creditwizard_step_menu_2', 'creditwizard&step=2', 0),
array('creditwizard_step_menu_3', 'creditwizard&step=3', 0),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 1),
array('ec_tenpay', 'ec&operation=tenpay&from=creditwizard', 0),
));
} else {
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 1),
array('nav_ec_tenpay', 'ec&operation=tenpay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0)
));
}
showtips('ec_alipay_tips');
showformheader('ec&operation=alipay');
showtableheader('','nobottom');
showtitle('ec_alipay');
showsetting('ec_alipay_account', 'settingsnew[ec_account]', $settings['ec_account'], 'text');
showsetting('ec_alipay_check', '', '',
'<a href="'.$BASESCRIPT.'?action=ec&operation=alipay&checktype=credit" target="_blank">'.$lang['ec_alipay_checklink_credit'].'</a><br />'.
'<a href="'.$BASESCRIPT.'?action=ec&operation=alipay&checktype=virtualgoods" target="_blank">'.$lang['ec_alipay_checklink_virtualgoods'].'</a><br />'.
'<a href="'.$BASESCRIPT.'?action=ec&operation=alipay&checktype=goods" target="_blank">'.$lang['ec_alipay_checklink_goods'].'</a><br />'
);
showtitle('ec_contract');
showsetting('ec_alipay_contract', 'settingsnew[ec_contract]', $ec_contract, 'radio', 0, 1);
showsetting('ec_alipay_securitycode', 'settingsnew[ec_securitycode]', $ec_securitycodemask, 'text');
showsetting('ec_alipay_partner', 'settingsnew[ec_partner]', $ec_partner, 'text');
showsetting('ec_alipay_creditdirectpay', 'settingsnew[ec_creditdirectpay]', $ec_creditdirectpay, 'radio');
showtablefooter();
showtableheader('', 'notop');
showsubmit('alipaysubmit');
showtablefooter();
showformfooter();
} else {
$settingsnew['ec_account'] = trim($settingsnew['ec_account']);
$settingsnew['ec_securitycode'] = trim($settingsnew['ec_securitycode']);
$db->query("UPDATE {$tablepre}settings SET value='$settingsnew[ec_account]' WHERE variable='ec_account'");
$ec_securitycodemasknew = $settingsnew['ec_securitycode'] ? $settingsnew['ec_securitycode']{0}.'********'.substr($settingsnew['ec_securitycode'], -4) : '';
$settingsnew['ec_securitycode'] = $ec_securitycodemasknew == $ec_securitycodemask ? $ec_securitycode : $settingsnew['ec_securitycode'];
$ec_contract = addslashes(authcode($settingsnew['ec_contract']."\t".$settingsnew['ec_securitycode']."\t".$settingsnew['ec_partner']."\t".$settingsnew['ec_creditdirectpay'], 'ENCODE', $_DCACHE['settings']['authkey']));
$db->query("UPDATE {$tablepre}settings SET value='$ec_contract' WHERE variable='ec_contract'");
updatecache('settings');
cpmsg('alipay_succeed', $BASESCRIPT.'?action=ec&operation=alipay', 'succeed');
}
} elseif($operation == 'tenpay') {
$settings = array();
$query = $db->query("SELECT variable, value FROM {$tablepre}settings WHERE variable IN ('ec_tenpay_account', 'ec_tenpay_bargainor', 'ec_tenpay_key')");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
if(!empty($checktype)) {
require_once DISCUZ_ROOT.'./api/trade/tenpay.api.php';
if($checktype == 'credit') {
dheader('location: '.credit_payurl(1, $orderid));
} elseif($checktype == 'virtualgoods') {
$pay = array(
'logistics_type' => 'VIRTUAL'
);
$trade = array(
'subject' => $lang['ec_tenpay_check_virtualgoodssubject'],
'itemtype' => 1,
'account' => $settings['ec_account'],
);
$tradelog = array(
'orderid' => 'TEST'.gmdate('YmdHis', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600).random(18),
'baseprice' => 1,
'number' => 1,
'transportfee' => 0,
);
dheader('location: '.trade_payurl($pay, $trade, $tradelog));
} elseif($checktype == 'goods') {
$pay = array(
'logistics_type' => 'EMS',
'transport' => 'SELLER_PAY',
);
$trade = array(
'subject' => $lang['ec_tenpay_check_goodssubject'],
'itemtype' => 1,
'account' => $settings['ec_account'],
);
$tradelog = array(
'orderid' => 'TEST'.gmdate('YmdHis', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600).random(18),
'baseprice' => 1,
'number' => 1,
'transportfee' => 0,
);
dheader('location: '.trade_payurl($pay, $trade, $tradelog));
}
exit;
}
if(!submitcheck('tenpaysubmit')) {
if($from == 'creditwizard') {
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', 0),
array('creditwizard_step_menu_2', 'creditwizard&step=2', 0),
array('creditwizard_step_menu_3', 'creditwizard&step=3', 0),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
array('ec_tenpay', 'ec&operation=tenpay&from=creditwizard', 1),
));
} else {
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_tenpay', 'ec&operation=tenpay', 1),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0)
));
}
showtips('ec_tenpay_tips');
showformheader('ec&operation=tenpay');
showtableheader('','nobottom');
showtitle('ec_tenpay');
showsetting('ec_tenpay_bargainor', 'settingsnew[ec_tenpay_bargainor]', $settings['ec_tenpay_bargainor'], 'text');
$tenpay_securitycodemask = $settings['ec_tenpay_key'] ? $settings['ec_tenpay_key']{0}.'********'.substr($settings['ec_tenpay_key'], -4) : '';
showsetting('ec_tenpay_key', 'settingsnew[ec_tenpay_key]', $tenpay_securitycodemask, 'text');
showsetting('ec_tenpay_check', '', '',
'<a href="'.$BASESCRIPT.'?action=ec&operation=tenpay&checktype=credit" target="_blank">'.$lang['ec_alipay_checklink_credit'].'</a><br />');
showtablefooter();
showtableheader('', 'notop');
showsubmit('tenpaysubmit');
showtablefooter();
showformfooter();
} else {
$settingsnew['ec_tenpay_bargainor'] = trim($settingsnew['ec_tenpay_bargainor']);
$settingsnew['ec_tenpay_key'] = trim($settingsnew['ec_tenpay_key']);
$tenpay_securitycodemask = $settings['ec_tenpay_key'] ? $settings['ec_tenpay_key']{0}.'********'.substr($settings['ec_tenpay_key'], -4) : '';
$settingsnew['ec_tenpay_key'] = $tenpay_securitycodemask == $settingsnew['ec_tenpay_key'] ? $settings['ec_tenpay_key'] : $settingsnew['ec_tenpay_key'];
if(!empty($settingsnew['ec_tenpay_bargainor']) && !preg_match('/^\d{10}$/', $settingsnew['ec_tenpay_bargainor'])) {
cpmsg('tenpay_bargainor_invalid', $BASESCRIPT.'?action=ec&operation=tenpay', 'error');
}
if(!empty($settingsnew['ec_tenpay_key']) && !preg_match('/^[a-zA-Z0-9]{32}$/', $settingsnew['ec_tenpay_key'])) {
cpmsg('tenpay_key_invalid', $BASESCRIPT.'?action=ec&operation=tenpay', 'error');
}
$db->query("UPDATE {$tablepre}settings SET value='$settingsnew[ec_tenpay_bargainor]' WHERE variable='ec_tenpay_bargainor'");
$db->query("UPDATE {$tablepre}settings SET value='$settingsnew[ec_tenpay_key]' WHERE variable='ec_tenpay_key'");
updatecache('settings');
cpmsg('tenpay_succeed', $BASESCRIPT.'?action=ec&operation=tenpay', 'succeed');
}
} elseif($operation == 'orders') {
$orderurl = array(
'alipay' => 'https://www.alipay.com/trade/query_trade_detail.htm?trade_no=',
'tenpay' => 'https://www.tenpay.com/med/tradeDetail.shtml?trans_id=',
);
if(!$creditstrans || !$ec_ratio) {
cpmsg('orders_disabled', '', 'error');
}
if(!submitcheck('ordersubmit')) {
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_tenpay', 'ec&operation=tenpay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 1),
array('nav_ec_tradelog', 'tradelog', 0)
));
showtips('ec_orders_tips');
showtagheader('div', 'ordersearch', !submitcheck('searchsubmit', 1));
showformheader('ec&operation=orders');
showtableheader('ec_orders_search');
showsetting('ec_orders_search_status', array('orderstatus', array(
array('', $lang['ec_orders_search_status_all']),
array(1, $lang['ec_orders_search_status_pending']),
array(2, $lang['ec_orders_search_status_auto_finished']),
array(3, $lang['ec_orders_search_status_manual_finished'])
)), intval($orderstatus), 'select');
showsetting('ec_orders_search_id', 'orderid', $orderid, 'text');
showsetting('ec_orders_search_users', 'users', $users, 'text');
showsetting('ec_orders_search_buyer', 'buyer', $buyer, 'text');
showsetting('ec_orders_search_admin', 'admin', $admin, 'text');
showsetting('ec_orders_search_submit_date', array('sstarttime', 'sendtime'), array($sstarttime, $sendtime), 'daterange');
showsetting('ec_orders_search_confirm_date', array('cstarttime', 'cendtime'), array($cstarttime, $cendtime), 'daterange');
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit', 1)) {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$sql = '';
$sql .= $orderstatus != '' ? " AND o.status='$orderstatus'" : '';
$sql .= $orderid != '' ? " AND o.orderid='$orderid'" : '';
$sql .= $users != '' ? " AND m.username IN ('".str_replace(',', '\',\'', str_replace(' ', '', $users))."')" : '';
$sql .= $buyer != '' ? " AND o.buyer='$buyer'" : '';
$sql .= $admin != '' ? " AND o.admin='$admin'" : '';
$sql .= $sstarttime != '' ? " AND o.submitdate>='".strtotime($sstarttime)."'" : '';
$sql .= $sendtime != '' ? " AND o.submitdate<'".strtotime($sendtime)."'" : '';
$sql .= $cstarttime != '' ? " AND o.confirmdate>='".strtotime($cstarttime)."'" : '';
$sql .= $cendtime != '' ? " AND o.confirmdate<'".strtotime($cendtime)."'" : '';
$ordercount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}orders o, {$tablepre}members m WHERE m.uid=o.uid $sql");
$multipage = multi($ordercount, $tpp, $page, "$BASESCRIPT?action=ec&operation=orders&searchsubmit=yes&orderstatus=$orderstatus&orderid=$orderid&users=$users&buyer=$buyer&admin=$admin&sstarttime=$sstarttime&sendtime=$sendtime&cstarttime=$cstarttime&cendtime=$cendtime");
showtagheader('div', 'orderlist', TRUE);
showformheader('ec&operation=orders');
showtableheader('result');
showsubtitle(array('', 'ec_orders_id', 'ec_orders_status', 'ec_orders_buyer', 'ec_orders_amount', 'ec_orders_price', 'ec_orders_submitdate', 'ec_orders_confirmdate'));
$query = $db->query("SELECT o.*, m.username
FROM {$tablepre}orders o, {$tablepre}members m
WHERE m.uid=o.uid $sql ORDER BY o.submitdate DESC
LIMIT $start_limit, $tpp");
while($order = $db->fetch_array($query)) {
switch($order['status']) {
case 1: $order['orderstatus'] = $lang['ec_orders_search_status_pending']; break;
case 2: $order['orderstatus'] = '<b>'.$lang['ec_orders_search_status_auto_finished'].'</b>'; break;
case 3: $order['orderstatus'] = '<b>'.$lang['ec_orders_search_status_manual_finished'].'</b><br />(<a href="space.php?username='.rawurlencode($order['admin']).'" target="_blank">'.$order['admin'].'</a>)'; break;
}
$order['submitdate'] = gmdate("$dateformat $timeformat", $order['submitdate'] + $timeoffset * 3600);
$order['confirmdate'] = $order['confirmdate'] ? gmdate("$dateformat $timeformat", $order['confirmdate'] + $timeoffset * 3600) : 'N/A';
list($orderid, $apitype) = explode("\t", $order['buyer']);
$apitype = $apitype ? $apitype : 'alipay';
$orderid = '<a href="'.$orderurl[$apitype].$orderid.'" target="_blank">'.$orderid.'</a>';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"validate[]\" value=\"$order[orderid]\" ".($order['status'] != 1 ? 'disabled' : '').">",
"$order[orderid]<br />$orderid",
$order[orderstatus],
"<a href=\"space.php?uid=$order[uid]\" target=\"_blank\">$order[username]</a>",
"{$extcredits[$creditstrans]['title']} $order[amount] {$extcredits[$creditstrans]['unit']}",
"$lang[rmb] $order[price] $lang[rmb_yuan]",
$order[submitdate],
$order[confirmdate]
));
}
showsubmit('ordersubmit', 'submit', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'validate\')" /><label for="chkall">'.lang('ec_orders_validate').'</label>', '<a href="#" onclick="$(\'orderlist\').style.display=\'none\';$(\'ordersearch\').style.display=\'\';">'.lang('research').'</a>', $multipage);
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
$numvalidate = 0;
if($validate) {
$orderids = $comma = '';
$confirmdate = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $timestamp + $_DCACHE['settings']['timeoffset'] * 3600);
$query = $db->query("SELECT * FROM {$tablepre}orders WHERE orderid IN ('".implode('\',\'', $validate)."') AND status='1'");
while($order = $db->fetch_array($query)) {
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans+'$order[amount]' WHERE uid='$order[uid]'");
$orderids .= "$comma'$order[orderid]'";
$comma = ',';
$submitdate = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $order['submitdate'] + $_DCACHE['settings']['timeoffset'] * 3600);
sendnotice($order['uid'], 'addfunds', 'systempm');
}
if($numvalidate = $db->num_rows($query)) {
$db->query("UPDATE {$tablepre}orders SET status='3', admin='$discuz_user', confirmdate='$timestamp' WHERE orderid IN ($orderids)");
}
}
cpmsg('orders_validate_succeed', "$BASESCRIPT?action=ec&operation=orders&searchsubmit=yes&orderstatus=$orderstatus&orderid=$orderid&users=$users&buyer=$buyer&admin=$admin&sstarttime=$sstarttime&sendtime=$sendtime&cstarttime=$cstarttime&cendtime=$cendtime", 'succeed');
}
} elseif($operation == 'credit') {
$defaultrank = array(
1 => 4,
2 => 11,
3 => 41,
4 => 91,
5 => 151,
6 => 251,
7 => 501,
8 => 1001,
9 => 2001,
10 => 5001,
11 => 10001,
12 => 20001,
13 => 50001,
14 => 100001,
15 => 200001
);
if(!submitcheck('creditsubmit')) {
$ec_credit = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='ec_credit'");
$ec_credit = $ec_credit ? unserialize($ec_credit) : array(
'maxcreditspermonth' => '6',
'rank' => $defaultrank
);
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_tenpay', 'ec&operation=tenpay', 0),
array('nav_ec_credit', 'ec&operation=ec_credit', 1),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0)
));
showtips('ec_credit_tips');
showformheader('ec&operation=credit');
showtableheader('ec_credit', 'nobottom');
showsetting('ec_credit_maxcreditspermonth', 'ec_creditnew[maxcreditspermonth]', $ec_credit['maxcreditspermonth'], 'text');
showtablefooter('</tbody>');
showtableheader('ec_credit_rank', 'notop fixpadding');
showsubtitle(array('ec_credit_rank', 'ec_credit_between', 'ec_credit_sellericon', 'ec_credit_buyericon'));
foreach($ec_credit['rank'] as $rank => $mincredits) {
showtablerow('', '', array(
$rank,
'<input type="text" class="txt" size="6" name="ec_creditnew[rank]['.$rank.']" value="'.$mincredits.'" /> ~ '.$ec_credit[rank][$rank + 1],
"<img src=\"images/rank/seller/$rank.gif\" border=\"0\">",
"<img src=\"images/rank/buyer/$rank.gif\" border=\"0\">"
));
}
showsubmit('creditsubmit');
showtablefooter();
showformfooter();
} else {
$ec_creditnew['maxcreditspermonth'] = intval($ec_creditnew['maxcreditspermonth']);
if(is_array($ec_creditnew['rank'])) {
foreach($ec_creditnew['rank'] as $rank => $mincredits) {
$mincredits = intval($mincredits);
if($rank == 1 && $mincredits <= 0) {
cpmsg('ecommerce_invalidcredit', '', 'error');
} elseif($rank > 1 && $mincredits <= $ec_creditnew['rank'][$rank - 1]) {
cpmsg('ecommerce_must_larger', '', 'error');
}
$ec_creditnew['rank'][$rank] = $mincredits;
}
} else {
$ec_creditnew['rank'] = $defaultrank;
}
$db->query("UPDATE {$tablepre}settings SET value='".serialize($ec_creditnew)."' WHERE variable='ec_credit'");
updatecache('settings');
cpmsg('ec_credit_succeed', $BASESCRIPT.'?action=ec&operation=credit', 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/ec.inc.php | PHP | asf20 | 19,736 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: smilies.inc.php 18512 2009-06-04 08:09:30Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$imgextarray = array('jpg', 'gif');
if($operation == 'export' && $id) {
$smileyarray = $db->fetch_first("SELECT name, directory FROM {$tablepre}imagetypes WHERE typeid='$id' AND type='smiley'");
if(!$smileyarray) {
cpheader();
cpmsg('smilies_type_nonexistence', '', 'error');
}
$smileyarray['smilies'] = array();
$query = $db->query("SELECT typeid, displayorder, code, url FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id'");
while($smiley = $db->fetch_array($query)) {
$smileyarray['smilies'][] = $smiley;
}
$smileyarray['version'] = strip_tags($version);
exportdata('Discuz! Smilies', $smileyarray['name'], $smileyarray);
}
cpheader();
if(!$operation) {
if(!submitcheck('smiliessubmit')) {
shownav('style', 'smilies_edit');
showsubmenu('nav_smilies', array(
array('smilies_type', 'smilies', 1),
array('smilies_import', 'smilies&operation=import', 0),
));
showtips('smilies_tips_smileytypes');
showformheader('smilies');
showtableheader();
showsubtitle(array('', 'display_order', 'enable', 'smilies_type', 'dir', 'smilies_nums', ''));
$smtypes = 0;
$dirfilter = array();
$query = $db->query("SELECT * FROM {$tablepre}imagetypes WHERE type='smiley' ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
$squery = $db->query("SELECT COUNT(*) FROM {$tablepre}smilies WHERE typeid='$type[typeid]'");
$smiliesnum = $db->result($squery, 0);
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[typeid]\" ".($smiliesnum ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" name=\"displayordernew[$type[typeid]]\" value=\"$type[displayorder]\" size=\"2\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$type[typeid]]\" value=\"1\" ".($type['available'] ? 'checked' : '').">",
"<input type=\"text\" class=\"txt\" name=\"namenew[$type[typeid]]\" value=\"$type[name]\" size=\"15\">",
"./images/smilies/$type[directory]",
"$smiliesnum<input type=\"hidden\" name=\"smiliesnum[$type[typeid]]\" value=\"$smiliesnum\" />",
"<a href=\"$BASESCRIPT?action=smilies&operation=update&id=$type[typeid]\" class=\"act\" onclick=\"return confirm('$lang[smilies_update_confirm1]$type[directory]$lang[smilies_update_confirm2]$type[name]$lang[smilies_update_confirm3]')\">$lang[smilies_update]</a> ".
"<a href=\"$BASESCRIPT?action=smilies&operation=export&id=$type[typeid]\" class=\"act\">$lang[export]</a> ".
"<a href=\"$BASESCRIPT?action=smilies&operation=edit&id=$type[typeid]\" class=\"act\">$lang[detail]</a>"
));
$dirfilter[] = $type['directory'];
$smtypes++;
}
$smdir = DISCUZ_ROOT.'./images/smilies';
$smtypedir = dir($smdir);
$dirnum = 0;
while($entry = $smtypedir->read()) {
if($entry != '.' && $entry != '..' && !in_array($entry, $dirfilter) && preg_match("/^\w+$/", $entry) && strlen($entry) < 30 && is_dir($smdir.'/'.$entry)){
$smiliesdir = dir($smdir.'/'.$entry);
$smnums = 0;
$smilies = '';
while($subentry = $smiliesdir->read()) {
if(in_array(strtolower(fileext($subentry)), $imgextarray) && preg_match("/^[\w\-\.\[\]\(\)\<\> &]+$/", substr($subentry, 0, strrpos($subentry, '.'))) && strlen($subentry) < 30 && is_file($smdir.'/'.$entry.'/'.$subentry)) {
$smilies .= '<input type="hidden" name="smilies['.$dirnum.']['.$smnums.'][available]" value="1"><input type="hidden" name="smilies['.$dirnum.']['.$smnums.'][displayorder]" value="0"><input type="hidden" name="smilies['.$dirnum.']['.$smnums.'][url]" value="'.$subentry.'">';
$smnums++;
}
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
($dirnum ? ' ' : $lang['add_new']),
'<input type="text" class="txt" name="newdisplayorder['.$dirnum.']" value="'.($smtypes + $dirnum + 1).'" size="2" />',
'<input class="checkbox" type="checkbox" name="newavailable['.$dirnum.']" value="1"'.($smnums ? ' checked="checked"' : ' disabled="disabled"').' />',
'<input type="text" class="txt" name="newname['.$dirnum.']" value="" size="15" />',
'./images/smilies/'.$entry.'<input type="hidden" name="newdirectory['.$dirnum.']" value="'.$entry.'">',
"$smnums<input type=\"hidden\" name=\"smnums[$dirnum]\" value=\"$smnums\" />",
$smilies,
'',
''
));
$dirnum++;
}
}
if(!$dirnum) {
showtablerow('', array('', 'colspan="8"'), array(
lang('add_new'),
lang('smiliesupload_tips')
));
}
showsubmit('smiliessubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($namenew)) {
foreach($namenew as $id => $val) {
$availablenew[$id] = $availablenew[$id] && $smiliesnum[$id] > 0 ? 1 : 0;
$db->query("UPDATE {$tablepre}imagetypes SET available='$availablenew[$id]', name='".htmlspecialchars(trim($val))."', displayorder='$displayordernew[$id]' WHERE typeid='$id'");
}
}
if($ids = implodeids($delete)) {
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}smilies WHERE type='smiley' AND typeid IN ($ids)")) {
cpmsg('smilies_delete_invalid', '', 'error');
}
$db->query("DELETE FROM {$tablepre}imagetypes WHERE typeid IN ($ids)");
}
if(is_array($newname)) {
foreach($newname as $key => $val) {
$val = trim($val);
if($val) {
$smurl = './images/smilies/'.$newdiredctory[$key];
if(!is_dir(DISCUZ_ROOT.$smurl)) {
cpmsg('smilies_directory_invalid', '', 'error');
}
$newavailable[$key] = $newavailable[$key] && $smnums[$key] > 0 ? 1 : 0;
$db->query("INSERT INTO {$tablepre}imagetypes (available, name, type, displayorder, directory) VALUES ('$newavailable[$key]', '".htmlspecialchars($val)."', 'smiley', '$newdisplayorder[$key]', '$newdirectory[$key]')");
if($smilies[$key]) {
addsmilies($db->insert_id(), $smilies[$key]);
}
}
}
}
updatecache(array('smileytypes', 'smilies', 'smileycodes', 'smilies_js'));
cpmsg('smilies_edit_succeed', $BASESCRIPT.'?action=smilies', 'succeed');
}
} elseif($operation == 'edit' && $id) {
$type = $db->fetch_first("SELECT typeid, name, directory FROM {$tablepre}imagetypes WHERE typeid='$id'AND type='smiley'");
$smurl = './images/smilies/'.$type['directory'];
$smdir = DISCUZ_ROOT.$smurl;
if(!is_dir($smdir)) {
cpmsg('smilies_directory_invalid', '', 'error');
}
if(!$do) {
if(!submitcheck('editsubmit')) {
$smiliesperpage = 100;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $smiliesperpage;
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id'");
$multipage = multi($num, $smiliesperpage, $page, $BASESCRIPT.'?action=smilies&operation=edit&id='.$id);
$smileynum = 1;
$smilies = '';
$query = $db->query("SELECT * FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id' ORDER BY displayorder LIMIT $start_limit, $smiliesperpage");
while($smiley = $db->fetch_array($query)) {
$smilies .= showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"', 'class="td23"', 'class="td24"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$smiley[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$smiley[id]]\" value=\"$smiley[displayorder]\">",
"<img src=\"$smurl/$smiley[url]\" border=\"0\" onload=\"if(this.height>30) {this.resized=true; this.height=30;}\" onmouseover=\"if(this.resized) this.style.cursor='pointer';\" onclick=\"if(!this.resized) {return false;} else {window.open(this.src);}\">",
$smiley['id'],
"<input type=\"text\" class=\"txt\" size=\"25\" name=\"code[$smiley[id]]\" value=\"".dhtmlspecialchars($smiley['code'])."\" id=\"code_$smileynum\" smileyid=\"$smiley[id]\" />",
"<input type=\"hidden\" value=\"$smiley[url]\" id=\"url_$smileynum\">$smiley[url]"
), TRUE);
$imgfilter[] = $smiley[url];
$smileynum ++;
}
echo <<<EOT
<script type="text/JavaScript">
function addsmileycodes(smiliesnum, pre) {
smiliesnum = parseInt(smiliesnum);
if(smiliesnum > 1) {
for(var i = 1; i < smiliesnum; i++) {
var prefix = trim($(pre + 'prefix').value);
var suffix = trim($(pre + 'suffix').value);
var page = parseInt('$page');
var middle = $(pre + 'middle').value == 1 ? $(pre + 'url_' + i).value.substr(0,$(pre + 'url_' + i).value.lastIndexOf('.')) : ($(pre + 'middle').value == 2 ? i + page * 10 : $(pre + 'code_'+ i).attributes['smileyid'].nodeValue);
if(!prefix || prefix == '$lang[smilies_prefix]' || !suffix || suffix == '$lang[smilies_suffix]') {
alert('$lang[smilies_prefix_tips]');
return;
}
suffix = !suffix || suffix == '$lang[smilies_suffix]' ? '' : suffix;
$(pre + 'code_' + i).value = prefix + middle + suffix;
}
}
}
function autoaddsmileycodes(smiliesnum) {
smiliesnum = parseInt(smiliesnum);
if(smiliesnum > 1) {
for(var i = 1; i < smiliesnum; i++) {
$('code_' + i).value = '{:' + '$id' + '_' + $('code_'+ i).attributes['smileyid'].nodeValue + ':}';
}
}
}
function clearinput(obj, defaultval) {
if(obj.value == defaultval) {
obj.value = '';
}
}
</script>
EOT;
shownav('style', 'nav_smilies');
showsubmenu(lang('smilies_edit').' - '.$type[name], array(
array('admin', "smilies&operation=edit&id=$id", !$do),
array('add', "smilies&operation=edit&do=add&id=$id", $do == 'add')
));
showformheader("smilies&operation=edit&id=$id");
showtableheader('', 'nobottom');
showsubtitle(array('', 'display_order', 'smilies_edit_image', 'smilies_id', 'smilies_edit_code', 'smilies_edit_filename'));
echo $smilies;
showtablerow('', array('', 'colspan="5"'), array(
'',
$lang['smilies_edit_add_code'].' <input type="text" class="txt" style="margin-right:0;width:40px;" size="2" value="{:" title="'.$lang['smilies_prefix'].'" id="prefix" onclick="clearinput(this, \''.$lang['smilies_prefix'].'\')" /> + <select id="middle"><option value="1">'.$lang['smilies_edit_order_file'].'</option><option value="2">'.$lang['smilies_edit_order_radom'].'</option><option value="3">'.$lang['smilies_id'].'</option></select> + <input type="text" class="txt" style="margin-right:0;width:40px;" size="2" value=":}" title="'.$lang['smilies_suffix'].'" id="suffix" onclick="clearinput(this, \''.$lang['smilies_suffix'].'\')" /> <input type="button" class="btn" onclick="addsmileycodes(\''.$smileynum.'\', \'\');" value="'.$lang['apply'].'" /> <input type="button" class="btn" onclick="autoaddsmileycodes(\''.$smileynum.'\');" value="'.$lang['smilies_edit_addcode_auto'].'" />'
));
showsubmit('editsubmit', 'submit', 'del', '<input type="button" class="btn" value="'.$lang['return'].'" onclick="window.location=\''.$BASESCRIPT.'?action=smilies\'">', $multipage);
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}smilies WHERE id IN ($ids)");
}
if(is_array($displayorder)) {
foreach($displayorder as $key => $val) {
$displayorder[$key] = intval($displayorder[$key]);
$code[$key] = trim($code[$key]);
$codeadd = !empty($code[$key]) ? ", code='$code[$key]'" : '';
$db->query("UPDATE {$tablepre}smilies SET displayorder='$displayorder[$key]' $codeadd WHERE id='$key'");
}
}
updatecache(array('smilies', 'smileycodes', 'smilies_js'));
cpmsg('smilies_edit_succeed', "$BASESCRIPT?action=smilies&operation=edit&id=$id", 'succeed');
}
} elseif($do == 'add') {
if(!submitcheck('editsubmit')) {
shownav('style', 'nav_smilies');
showsubmenu(lang('smilies_edit').' - '.$type[name], array(
array('admin', "smilies&operation=edit&id=$id", !$do),
array('add', "smilies&operation=edit&do=add&id=$id", $do == 'add')
));
showtips('smilies_tips');
showtagheader('div', 'addsmilies', TRUE);
showtableheader('smilies_add', 'notop fixpadding');
showtablerow('', '', "<span class=\"bold marginright\">$lang[smilies_type]:</span>$type[name]");
showtablerow('', '', "<span class=\"bold marginright\">$lang[dir]:</span>$smurl $lang[smilies_add_search]");
showtablerow('', '', '<input type="button" class="btn" value="'.$lang['search'].'" onclick="ajaxget(\''.$BASESCRIPT.'?action=smilies&operation=edit&do=add&id='.$id.'&search=yes\', \'addsmilies\', \'addsmilies\', \'auto\');doane(event);">');
showtablefooter();
showtagfooter('div');
if($search) {
$newid = 1;
$newimages = '';
$imgfilter = array();
$query = $db->query("SELECT url FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id'");
while($img = $db->fetch_array($query)) {
$imgfilter[] = $img[url];
}
$smiliesdir = dir($smdir);
while($entry = $smiliesdir->read()) {
if(in_array(strtolower(fileext($entry)), $imgextarray) && !in_array($entry, $imgfilter) && preg_match("/^[\w\-\.\[\]\(\)\<\> &]+$/", substr($entry, 0, strrpos($entry, '.'))) && strlen($entry) < 30 && is_file($smdir.'/'.$entry)) {
$newimages .= showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"smilies[$newid][available]\" value=\"1\" checked=\"checked\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"smilies[$newid][displayorder]\" value=\"0\">",
"<img src=\"$smurl/$entry\" border=\"0\" onload=\"if(this.height>30) {this.resized=true; this.height=30;}\" onmouseover=\"if(this.resized) this.style.cursor='pointer';\" onclick=\"if(!this.resized) {return false;} else {window.open(this.src);}\">",
"<input type=\"hidden\" size=\"25\" name=\"smilies[$newid][url]\" value=\"$entry\" id=\"addurl_$newid\">$entry"
), TRUE);
$newid ++;
}
}
$smiliesdir->close();
ajaxshowheader();
if($newimages) {
showformheader("smilies&operation=edit&do=add&id=$id");
showtableheader('smilies_add', 'notop fixpadding');
showsubtitle(array('', 'display_order', 'smilies_edit_image', 'smilies_edit_filename'));
echo $newimages;
showtablerow('', array('class="td25"', 'colspan="3"'), array(
'<input type="checkbox" name="chkall" onclick="checkAll(\'prefix\', this.form, \'add\')" class="checkbox" checked="checked">'.$lang['enable'],
'<input type="submit" class="btn" name="editsubmit" value="'.$lang['submit'].'"> <input type="button" class="btn" value="'.$lang['research'].'" onclick="ajaxget(\''.$BASESCRIPT.'?action=smilies&operation=edit&do=add&id='.$id.'&search=yes\', \'addsmilies\', \'addsmilies\', \'auto\');doane(event);">'
));
showtablefooter();
showformfooter();
} else {
eval("\$lang[smilies_edit_add_tips] = \"".$lang['smilies_edit_add_tips']."\";");
showtableheader('smilies_add', 'notop');
showtablerow('', 'class="lineheight"', $lang['smilies_edit_add_tips']);
showtablerow('', '', '<input type="button" class="btn" value="'.$lang['research'].'" onclick="ajaxget(\''.$BASESCRIPT.'?action=smilies&operation=edit&do=add&id='.$id.'&search=yes\', \'addsmilies\', \'addsmilies\', \'auto\');doane(event);">');
showtablefooter();
}
ajaxshowfooter();
exit;
}
} else {
if(is_array($smilies)) {
addsmilies($id, $smilies);
}
updatecache(array('smilies', 'smileycodes', 'smilies_js'));
cpmsg('smilies_edit_succeed', "$BASESCRIPT?action=smilies&operation=edit&id=$id", 'succeed');
}
}
} elseif($operation == 'update' && $id) {
if(!$smtype = $db->fetch_first("SELECT name, directory FROM {$tablepre}imagetypes WHERE typeid='$id' AND type='smiley'")) {
cpmsg('smilies_type_nonexistence', '', 'error');
} else {
$smurl = './images/smilies/'.$smtype['directory'];
$smdir = DISCUZ_ROOT.$smurl;
if(!is_dir($smdir)) {
cpmsg('smilies_directory_invalid', '', 'error');
}
}
$num = 0;
$smilies = $imgfilter = array();
$query = $db->query("SELECT url FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id'");
while($img = $db->fetch_array($query)) {
$imgfilter[] = $img[url];
}
$smiliesdir = dir($smdir);
while($entry = $smiliesdir->read()) {
if(in_array(strtolower(fileext($entry)), $imgextarray) && !in_array($entry, $imgfilter) && preg_match("/^[\w\-\.\[\]\(\)\<\> &]+$/", substr($entry, 0, strrpos($entry, '.'))) && strlen($entry) < 30 && is_file($smdir.'/'.$entry)) {
$smilies[] = array('available' => 1, 'displayorder' => 0, 'url' => $entry);
$num++;
}
}
$smiliesdir->close();
if($smilies) {
addsmilies($id, $smilies);
updatecache(array('smilies', 'smileycodes', 'smilies_js'));
cpmsg('smilies_update_succeed', "$BASESCRIPT?action=smilies", 'succeed');
} else {
cpmsg('smilies_update_error', '', 'error');
}
} elseif($operation == 'import') {
if(!submitcheck('importsubmit')) {
shownav('style', 'smilies_edit');
showsubmenu('nav_smilies', array(
array('smilies_type', 'smilies', 0),
array('smilies_import', 'smilies&operation=import', 1),
));
showtips('smilies_tips_import');
showformheader('smilies&operation=import', 'enctype');
showtableheader('smilies_import');
showimportdata();
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
require_once DISCUZ_ROOT.'./admin/importdata.func.php';
$renamed = import_smilies();
cpmsg($renamed ? 'smilies_import_succeed_renamed' : 'smilies_import_succeed', $BASESCRIPT.'?action=smilies', 'succeed');
}
}
function addsmilies($typeid, $smilies = array()) {
global $db, $tablepre;
if(is_array($smilies)) {
$ids = array();
foreach($smilies as $smiley) {
if($smiley['available']) {
$db->query("INSERT INTO {$tablepre}smilies (type, displayorder, typeid, code, url)
VALUES ('smiley', '$smiley[displayorder]', '$typeid', '', '$smiley[url]')");
$ids[] = $db->insert_id();
}
}
if($ids = implodeids($ids)) {
$db->query("UPDATE {$tablepre}smilies SET code=CONCAT('{:', typeid, '_', id, ':}') WHERE id IN ($ids)");
}
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/smilies.inc.php | PHP | asf20 | 18,649 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: announce.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
if(empty($operation)) {
if(!submitcheck('announcesubmit')) {
shownav('tools', 'announce', 'admin');
showsubmenu('announce', array(
array('admin', 'announce', 1),
array('add', 'announce&operation=add', 0)
));
showtips('announce_tips');
showformheader('announce');
showtableheader();
showsubtitle(array('', 'display_order', 'author', 'subject', 'message', 'announce_type', 'start_time', 'end_time', ''));
$announce_type = array(0=>$lang['announce_words'], 1=>$lang['announce_url']);
$query = $db->query("SELECT * FROM {$tablepre}announcements ORDER BY displayorder, starttime DESC, id DESC");
while($announce = $db->fetch_array($query)) {
$disabled = $adminid != 1 && $announce['author'] != $discuz_userss ? 'disabled' : NULL;
$announce['starttime'] = $announce['starttime'] ? gmdate($dateformat, $announce['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : $lang['unlimited'];
$announce['endtime'] = $announce['endtime'] ? gmdate($dateformat, $announce['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : $lang['unlimited'];
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$announce[id]\" $disabled>",
"<input type=\"text\" class=\"txt\" name=\"displayordernew[{$announce[id]}]\" value=\"$announce[displayorder]\" size=\"2\" $disabled>",
"<a href=\"./space.php?username=".rawurlencode($announce['author'])."\" target=\"_blank\">$announce[author]</a>",
dhtmlspecialchars($announce['subject']),
cutstr(strip_tags($announce['message']), 20),
$announce_type[$announce['type']],
$announce['starttime'],
$announce['endtime'],
"<a href=\"$BASESCRIPT?action=announce&operation=edit&announceid=$announce[id]\" $disabled>$lang[edit]</a>"
));
}
showsubmit('announcesubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}announcements WHERE id IN ($ids) AND ('$adminid'='1' OR author='$discuz_user')");
}
if(is_array($displayordernew)) {
foreach($displayordernew as $id => $displayorder) {
$db->query("UPDATE {$tablepre}announcements SET displayorder='$displayorder' WHERE id='$id' AND ('$adminid'='1' OR author='$discuz_user')");
}
}
updatecache(array('pmlist', 'announcements', 'announcements_forum'));
cpmsg('announce_update_succeed', $BASESCRIPT.'?action=announce', 'succeed');
}
} elseif($operation == 'add') {
if(!submitcheck('addsubmit')) {
$newstarttime = gmdate('Y-n-j', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600);
$newendtime = gmdate('Y-n-j', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600 + 86400* 7);
shownav('tools', 'announce', 'add');
showsubmenu('announce', array(
array('admin', 'announce', 0),
array('add', 'announce&operation=add', 1)
));
showformheader('announce&operation=add');
showtableheader('announce_add');
showsetting($lang[subject], 'newsubject', '', 'text');
showsetting($lang['start_time'], 'newstarttime', $newstarttime, 'calendar');
showsetting($lang['end_time'], 'newendtime', $newendtime, 'calendar');
showsetting('announce_type', array('newtype', array(
array(0, $lang['announce_words']),
array(1, $lang['announce_url']))), 0, 'mradio');
showsetting('announce_message', 'newmessage', '', 'textarea');
showsubmit('addsubmit');
showtablefooter();
showformfooter();
} else {
$newstarttime = $newstarttime ? strtotime($newstarttime) : 0;
$newendtime = $newendtime ? strtotime($newendtime) : 0;
if(!$newstarttime) {
cpmsg('announce_time_invalid', '', 'error');
} elseif(!($newsubject = trim($newsubject)) || !($newmessage = trim($newmessage))) {
cpmsg('announce_invalid', '', 'error');
} else {
$newmessage = $newtype == 1 ? explode("\n", $newmessage) : array(0 => $newmessage);
$db->query("INSERT INTO {$tablepre}announcements (author, subject, type, starttime, endtime, message)
VALUES ('$discuz_user', '$newsubject', '$newtype', '$newstarttime', '$newendtime', '{$newmessage[0]}')");
updatecache(array('announcements', 'announcements_forum', 'pmlist'));
cpmsg('announce_succeed', $BASESCRIPT.'?action=announce', 'succeed');
}
}
} elseif($operation == 'edit' && $announceid) {
$announce = $db->fetch_first("SELECT * FROM {$tablepre}announcements WHERE id='$announceid' AND ('$adminid'='1' OR author='$discuz_user')");
if(!$announce) {
cpmsg('announce_nonexistence', '', 'error');
}
if(!submitcheck('editsubmit')) {
$announce['starttime'] = $announce['starttime'] ? gmdate('Y-n-j', $announce['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : "";
$announce['endtime'] = $announce['endtime'] ? gmdate('Y-n-j', $announce['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : "";
shownav('tools', 'announce');
showsubmenu('announce', array(
array('admin', 'announce', 0),
array('add', 'announce&operation=add', 0)
));
showformheader("announce&operation=edit&announceid=$announceid");
showtableheader();
showtitle('announce_edit');
showsetting('subject', 'subjectnew', $announce['subject'], 'text');
showsetting('start_time', 'starttimenew', $announce['starttime'], 'calendar');
showsetting('end_time', 'endtimenew', $announce['endtime'], 'calendar');
showsetting('announce_type', array('typenew', array(
array(0, $lang['announce_words']),
array(1, $lang['announce_url'])
)), $announce['type'], 'mradio');
showsetting('announce_message', 'messagenew', $announce['message'], 'textarea');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
if(strpos($starttimenew, '-')) {
$time = explode('-', $starttimenew);
$starttimenew = gmmktime(0, 0, 0, $time[1], $time[2], $time[0]) - $_DCACHE['settings']['timeoffset'] * 3600;
} else {
$starttimenew = 0;
}
if(strpos($endtimenew, '-')) {
$time = explode('-', $endtimenew);
$endtimenew = gmmktime(0, 0, 0, $time[1], $time[2], $time[0]) - $_DCACHE['settings']['timeoffset'] * 3600;
} else {
$endtimenew = 0;
}
if(!$starttimenew || ($endtimenew && $endtimenew <= $timestamp)) {
cpmsg('announce_time_invalid', '', 'error');
} elseif(!($subjectnew = trim($subjectnew)) || !($messagenew = trim($messagenew))) {
cpmsg('announce_invalid', '', 'error');
} else {
$messagenew = $typenew == 1 ? explode("\n", $messagenew) : array(0 => $messagenew);
$db->query("UPDATE {$tablepre}announcements SET subject='$subjectnew', type='$typenew', starttime='$starttimenew', endtime='$endtimenew', message='{$messagenew[0]}' WHERE id='$announceid' AND ('$adminid'='1' OR author='$discuz_user')");
updatecache('announcements', 'announcements_forum', 'pmlist');
cpmsg('announce_succeed', $BASESCRIPT.'?action=announce', 'succeed');
}
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/announce.inc.php | PHP | asf20 | 7,463 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tools.inc.php 17386 2008-12-17 05:10:00Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if($operation == 'updatecache') {
$step = max(1, intval($step));
shownav('tools', 'nav_updatecache');
showsubmenusteps('nav_updatecache', array(
array('nav_updatecache_confirm', $step == 1),
array('nav_updatecache_verify', $step == 2),
array('nav_updatecache_completed', $step == 3)
));
showtips('tools_updatecache_tips');
if($step == 1) {
cpmsg('<input type=\"checkbox\" name=\"type[]\" value=\"data\" id=\"datacache\" class=\"checkbox\" checked /><label for=\"datacache\">'.$lang[tools_updatecache_data].'</label><input type=\"checkbox\" name=\"type[]\" value=\"tpl\" id=\"tplcache\" class=\"checkbox\" checked /><label for=\"tplcache\">'.$lang[tools_updatecache_tpl].'</label>', $BASESCRIPT.'?action=tools&operation=updatecache&step=2', 'form', '', FALSE);
} elseif($step == 2) {
$type = implode('_', (array)$type);
cpmsg(lang('tools_updatecache_waiting'), "$BASESCRIPT?action=tools&operation=updatecache&step=3&type=$type", 'loading', '', FALSE);
} elseif($step == 3) {
$type = explode('_', $type);
if(in_array('data', $type)) {
updatecache();
}
if(in_array('tpl', $type) && $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();
}
cpmsg('update_cache_succeed', '', 'succeed', '', FALSE);
}
} elseif($operation == 'tag') {
include_once DISCUZ_ROOT.'./uc_client/client.php';
$applist = uc_app_ls();
if(!submitcheck('submit')) {
$query = $db->query("SELECT variable, value FROM {$tablepre}settings WHERE variable IN ('relatedtag', 'relatedtagstatus')");
$settings = array();
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
$relatedtag = unserialize($settings['relatedtag']);
shownav('tools', 'extended_tag');
showsubmenu('extended_tag');
showformheader('tools&operation=tag');
if(!$tagstatus) {
showtips('extended_tag_tips');
}
showtableheader();
showsetting('extended_tag_on', 'relatedtagstatusnew', $settings['relatedtagstatus'], 'radio');
jsinsertunit();
foreach($applist as $data) {
$appid = $data['appid'];
$status = array(intval($relatedtag['status'][$appid]) => 'checked="checked"');
$template = stripslashes(htmlspecialchars($relatedtag['template'][$appid]['template'] != '' ? $relatedtag['template'][$appid]['template'] : '<a href="{url}" target="_blank">{subject}</a>'));
$name = $relatedtag['name'][$appid] != '' ? $relatedtag['name'][$appid] : $data['name'];
showtitle($data['name']);
showsetting('extended_tag_name', 'relatedtagnew[name]['.$appid.']', $name, 'text');
showsetting('extended_tag_status', 'relatedtagnew[status]['.$appid.']', $status[0] ? 0 : 1, 'radio');
showsetting('extended_tag_order', 'relatedtagnew[order]['.$appid.']', $relatedtag['order'][$appid], 'text');
showsetting('extended_tag_items', 'relatedtagnew[limit]['.$appid.']', intval($relatedtag['limit'][$appid]), 'text');
echo '<tr><td class="td27" colspan="2">'.$lang['extended_tag_tpl'].'</td></tr><tr><td class="vtop rowform">'.
'<textarea cols="100" rows="8" id="jstemplate_'.$appid.'" name="relatedtagnew[template]['.$appid.'][template]" class="tarea">'.$template.'</textarea>'.
'<input type="hidden" name="relatedtagnew[template]['.$appid.'][name]" value="'.$data['name'].'" /></td><td class="vtop"><div class="extcredits">';
if(is_array($data['tagtemplates']['fields'])) {
foreach($data['tagtemplates']['fields'] as $field => $memo) {
echo '<a onclick="insertunit(\'{'.$field.'}\', \'jstemplate_'.$appid.'\')" href="###">{'.$field.'}</a> '.$lang['extended_tag_memo'].' '.$memo.'<br />';
}
}
echo '</td></tr>';
showhiddenfields(array('relatedtagnew[template]['.$appid.'][name]' => $data['name']));
}
showsubmit('submit');
showtablefooter();
showformfooter();
} else {
$value = addslashes(serialize($relatedtagnew));
$relatedtagstatusnew = intval($relatedtagstatusnew);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('relatedtag', '$value'),('relatedtagstatus', '$relatedtagstatusnew')");
updatecache('settings');
cpmsg('jswizard_relatedtag_succeed', $BASESCRIPT.'?action=tools&operation=tag', 'succeed');
}
} elseif($operation == 'fileperms') {
$step = max(1, intval($step));
shownav('tools', 'nav_fileperms');
showsubmenusteps('nav_fileperms', array(
array('nav_fileperms_confirm', $step == 1),
array('nav_fileperms_verify', $step == 2),
array('nav_fileperms_completed', $step == 3)
));
if($step == 1) {
cpmsg(lang('fileperms_check_note'), $BASESCRIPT.'?action=tools&operation=fileperms&step=2', 'button', '', FALSE);
} elseif($step == 2) {
cpmsg(lang('fileperms_check_waiting'), $BASESCRIPT.'?action=tools&operation=fileperms&step=3', 'loading', '', FALSE);
} elseif($step == 3) {
showtips('fileperms_tips');
$entryarray = array(
'attachments',
'forumdata',
'forumdata/cache',
'forumdata/logs',
'forumdata/templates',
'forumdata/threadcaches'
);
foreach(array('templates', 'forumdata/cache', 'forumdata/logs', 'forumdata/templates') as $directory) {
getdirentry($directory);
}
$result = '';
foreach($entryarray as $entry) {
$fullentry = DISCUZ_ROOT.'./'.$entry;
if(!is_dir($fullentry) && !file_exists($fullentry)) {
continue;
} else {
if(!is_writeable($fullentry)) {
$result .= '<li class="error">'.(is_dir($fullentry) ? $lang['dir'] : $lang['file'])." ./$entry $lang[fileperms_unwritable]</li>";
}
}
}
$result = $result ? $result : '<li>'.$lang['fileperms_check_ok'].'</li>';
echo '<div class="colorbox"><ul class="fileperms">'.$result.'</ul></div>';
}
}
function getdirentry($directory) {
global $entryarray;
$dir = dir(DISCUZ_ROOT.'./'.$directory);
while($entry = $dir->read()) {
if(!in_array($entry, array('.', '..', 'index.htm'))) {
if(is_dir(DISCUZ_ROOT.'./'.$directory.'/'.$entry)) {
getdirentry($directory."/".$entry);
}
$entryarray[] = $directory.'/'.$entry;
}
}
$dir->close();
}
function jsinsertunit() {
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, obj) {
if(!obj) {
obj = 'jstemplate';
}
$(obj).focus();
if(!isUndefined($(obj).selectionStart)) {
var opn = $(obj).selectionStart + 0;
$(obj).value = $(obj).value.substr(0, $(obj).selectionStart) + text + $(obj).value.substr($(obj).selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$(obj).value += text;
}
}
</script>
<?
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/tools.inc.php | PHP | asf20 | 7,312 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: members.inc.php 21170 2009-11-19 01:59:32Z liulanbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
@set_time_limit(600);
cpheader();
if(!$operation) {
if(!submitcheck('submit', 1)) {
shownav('user', 'nav_members');
showsubmenu('nav_members', array(
array('search', 'members', 1),
array('clean', 'members&operation=clean', 0),
array('nav_repeat', 'members&operation=repeat', 0),
));
showtips('members_admin_tips');
searchmembers();
} else {
countmembers();
$multipage = multi($membernum, $memberperpage, $page, "$BASESCRIPT?action=members&submit=yes".$urladd);
$usergroups = array();
$query = $db->query("SELECT groupid, type, grouptitle FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
switch($group['type']) {
case 'system': $group['grouptitle'] = '<b>'.$group['grouptitle'].'</b>'; break;
case 'special': $group['grouptitle'] = '<i>'.$group['grouptitle'].'</i>'; break;
}
$usergroups[$group['groupid']] = $group;
}
$query = $db->query("SELECT uid, username, adminid, groupid, credits, extcredits1, extcredits2,
extcredits3, extcredits4, extcredits5, extcredits6, extcredits7, extcredits8, posts FROM {$tablepre}members WHERE $conditions LIMIT $start_limit, $memberperpage");
while($member = $db->fetch_array($query)) {
$memberextcredits = array();
foreach($extcredits as $id => $credit) {
$memberextcredits[] = $extcredits[$id]['title'].': '.$member['extcredits'.$id];
}
$members .= showtablerow('', array('class="td25"', '', 'title="'.implode("\n", $memberextcredits).'"'), array(
"<input type=\"checkbox\" name=\"uidarray[]\" value=\"$member[uid]\"".($member['adminid'] == 1 ? 'disabled' : '')." class=\"checkbox\">",
"<a href=\"space.php?uid=$member[uid]\" target=\"_blank\">$member[username]</a>",
$member['credits'],
$member['posts'],
$usergroups[$member['adminid']]['grouptitle'],
$usergroups[$member['groupid']]['grouptitle'],
"<a href=\"$BASESCRIPT?action=members&operation=group&uid=$member[uid]\" class=\"act\">$lang[usergroup]</a><a href=\"$BASESCRIPT?action=members&operation=access&uid=$member[uid]\" class=\"act\">$lang[members_access]</a>".
($extcredits ? "<a href=\"$BASESCRIPT?action=members&operation=credit&uid=$member[uid]\" class=\"act\">$lang[credits]</a>" : "<span disabled>$lang[edit]</span>").
"<a href=\"$BASESCRIPT?action=members&operation=medal&uid=$member[uid]\" class=\"act\">$lang[medals]</a>".
"<a href=\"$BASESCRIPT?action=members&operation=repeat&uid=$member[uid]\" class=\"act\">$lang[members_repeat]</a>".
"<a href=\"$BASESCRIPT?action=members&operation=edit&uid=$member[uid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
shownav('user', 'nav_members');
showsubmenu('nav_members');
showformheader("members&operation=clean");
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
showtableheader(lang('members_search_result').'<a href="javascript:history.go(-1);" class="act lightlink normal">'.lang('research').'</a>');
showsubtitle(array('', 'username', 'credits', 'posts', 'admingroup', 'usergroup', ''));
echo $members;
showtablerow('', array('class="td25"', 'class="lineheight" colspan="7"'), array('', lang('members_admin_comment')));
showsubmit('submit', 'submit', '<input type="checkbox" name="chkall" onclick="checkAll(\'prefix\', this.form, \'uidarray\')" class="checkbox">'.lang('del'), '', $multipage);
showtablefooter();
showformfooter();
}
} elseif($operation == 'repeat') {
if(empty($uid) && empty($username) && empty($ip)) {
shownav('user', 'nav_members');
showsubmenu('nav_members', array(
array('search', 'members', 0),
array('clean', 'members&operation=clean', 0),
array('nav_repeat', 'members&operation=repeat', 1),
));
showformheader("members&operation=repeat");
showtableheader();
showsetting('members_search_repeatuser', 'username', '', 'text');
showsetting('members_search_uid', 'uid', '', 'text');
showsetting('members_search_repeatip', 'ip', $inputip, 'text');
showsubmit('submit', 'submit');
showtablefooter();
showformfooter();
} else {
if(!empty($username)) {
$searchmember = $db->fetch_first("SELECT username, regip, lastip FROM {$tablepre}members WHERE username='$username'");
unset($username);
} elseif(!empty($uid)) {
$searchmember = $db->fetch_first("SELECT username, regip, lastip FROM {$tablepre}members WHERE uid='$uid'");
unset($uid);
} elseif(!empty($ip)) {
$ids = $regip = $lastip = $ip;
$ids = "'".$ids."'";
}
if($searchmember) {
$ips = array();
foreach(array('regip', 'lastip') as $iptype) {
if($searchmember[$iptype] != '' && $searchmember[$iptype] != 'hidden') {
$ips[] = $searchmember[$iptype];
}
}
$ips = array_unique($ips);
$ids = implodeids($ips);
$repeatip = " AND (regip IN ($ids) OR lastip IN ($ids))";
}
$searchmember['username'] .= ' (IP '.htmlspecialchars($ids).')';
countmembers();
$usergroups = array();
$query = $db->query("SELECT groupid, type, grouptitle FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
switch($group['type']) {
case 'system': $group['grouptitle'] = '<b>'.$group['grouptitle'].'</b>'; break;
case 'special': $group['grouptitle'] = '<i>'.$group['grouptitle'].'</i>'; break;
}
$usergroups[$group['groupid']] = $group;
}
$multipage = multi($membernum, $memberperpage, $page, "$BASESCRIPT?action=members&submit=yes".$urladd);
$query = $db->query("SELECT uid, username, adminid, groupid, credits, extcredits1, extcredits2,
extcredits3, extcredits4, extcredits5, extcredits6, extcredits7, extcredits8, posts FROM {$tablepre}members WHERE $conditions LIMIT $start_limit, $memberperpage");
while($member = $db->fetch_array($query)) {
$memberextcredits = array();
foreach($extcredits as $id => $credit) {
$memberextcredits[] = $extcredits[$id]['title'].': '.$member['extcredits'.$id];
}
$members .= showtablerow('', array('class="td25"', '', 'title="'.implode("\n", $memberextcredits).'"'), array(
"<input type=\"checkbox\" name=\"uidarray[]\" value=\"$member[uid]\"".($member['adminid'] == 1 ? 'disabled' : '')." class=\"checkbox\">",
"<a href=\"space.php?uid=$member[uid]\" target=\"_blank\">$member[username]</a>",
$member['credits'],
$member['posts'],
$usergroups[$member['adminid']]['grouptitle'],
$usergroups[$member['groupid']]['grouptitle'],
"<a href=\"$BASESCRIPT?action=members&operation=group&uid=$member[uid]\" class=\"act\">$lang[usergroup]</a><a href=\"$BASESCRIPT?action=members&operation=access&uid=$member[uid]\" class=\"act\">$lang[members_access]</a>".
($extcredits ? "<a href=\"$BASESCRIPT?action=members&operation=credit&uid=$member[uid]\" class=\"act\">$lang[credits]</a>" : "<span disabled>$lang[edit]</span>").
"<a href=\"$BASESCRIPT?action=members&operation=medal&uid=$member[uid]\" class=\"act\">$lang[medals]</a>".
"<a href=\"$BASESCRIPT?action=members&operation=repeat&uid=$member[uid]\" class=\"act\">$lang[members_repeat]</a>".
"<a href=\"$BASESCRIPT?action=members&operation=edit&uid=$member[uid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
shownav('user', 'nav_repeat');
showsubmenu($lang['nav_repeat'].' - '.$searchmember['username']);
showformheader("members&operation=clean");
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
$searchadd = '';
if(is_array($ips)) {
foreach($ips as $ip) {
$searchadd .= '<a href="'.$BASESCRIPT.'?action=members&operation=repeat&inputip='.rawurlencode($ip).'" class="act lightlink normal">'.lang('search').'IP '.htmlspecialchars($ip).'</a>';
}
}
showtableheader(lang('members_search_result').'<a href="'.$BASESCRIPT.'?action=members&operation=repeat" class="act lightlink normal">'.lang('research').'</a>'.$searchadd);
showsubtitle(array('', 'username', 'credits', 'posts', 'admingroup', 'usergroup', ''));
echo $members;
showtablerow('', array('class="td25"', 'class="lineheight" colspan="7"'), array('', lang('members_admin_comment')));
showsubmit('submit', 'submit', '<input type="checkbox" name="chkall" onclick="checkAll(\'prefix\', this.form, \'uidarray\')" class="checkbox">'.lang('del'), '', $multipage);
showtablefooter();
showformfooter();
}
} elseif($operation == 'clean') {
if(!submitcheck('submit', 1)) {
shownav('user', 'nav_members');
showsubmenu('nav_members', array(
array('search', 'members', 0),
array('clean', 'members&operation=clean', 1),
array('nav_repeat', 'members&operation=repeat', 0),
));
searchmembers('clean');
} else {
countmembers();
$uids = 0;
$extra = '';
if(empty($uidarray)) {
$query = $db->query("SELECT uid, groupid, adminid FROM {$tablepre}members WHERE $conditions AND adminid<>1 AND groupid<>1");
} else {
$uids = is_array($uidarray) ? '\''.implode('\', \'', $uidarray).'\'' : '0';
$query = $db->query("SELECT uid, groupid, adminid FROM {$tablepre}members WHERE uid IN($uids) AND adminid<>1 AND groupid<>1");
}
$membernum = $db->num_rows($query);
$uids = $comma = '';
while($member = $db->fetch_array($query)) {
if($membernum < 2000 || !empty($uidarray)) {
$extra .= '<input type="hidden" name="uidarray[]" value="'.$member['uid'].'" />';
}
$uids .= $comma.$member['uid'];
$comma = ',';
}
if((empty($membernum) || empty($uids))) {
cpmsg('members_no_find_deluser', '', 'error');
}
if(!$confirmed) {
cpmsg('members_delete_confirm', "$BASESCRIPT?action=members&operation=clean&submit=yes&confirmed=yes".$urladd, 'form', $extra.'<br /><input type="checkbox" name="includepost" value="1" class="checkbox" />'.$lang['members_delete_post'].($isfounder ? ' <input type="checkbox" name="includeuc" value="1" class="checkbox" />'.$lang['members_delete_ucdata'] : ''));
} else {
if($isfounder && !empty($includeuc)) {
require_once DISCUZ_ROOT.'./uc_client/client.php';
uc_user_delete($uidarray);
}
if(empty($includepost)) {
$query = $db->query("DELETE FROM {$tablepre}members WHERE uid IN ($uids)");
$numdeleted = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}access WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}favorites WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}moderators WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($uids)", 'UNBUFFERED');
manyoulog('user', $uids, 'delete');
cpmsg('members_delete_succeed', '', 'succeed');
} else {
$numdeleted = $numdeleted ? $numdeleted : count($uidarray);
$pertask = 1000;
$current = intval($current);
$next = $current + $pertask;
$threads = $fids = $threadsarray = array();
$query = $db->query("SELECT f.fid, t.tid FROM {$tablepre}threads t LEFT JOIN {$tablepre}forums f ON t.fid=f.fid WHERE t.authorid IN ($uids) ORDER BY f.fid LIMIT $pertask");
while($thread = $db->fetch_array($query)) {
$threads[$thread['fid']] .= ($threads[$thread['fid']] ? ',' : '').$thread['tid'];
}
$nextlink = "$BASESCRIPT?action=members&operation=clean&confirmed=yes&submit=yes&includepost=yes¤t=$next&pertask=$pertask&lastprocess=$processed".$urladd;
if($threads) {
foreach($threads as $fid => $tids) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
foreach(array('threads', 'threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'debateposts', 'attachments', 'favorites', 'typeoptionvars', 'forumrecommend', 'postposition') as $value) {
$db->query("DELETE FROM {$tablepre}$value WHERE tid IN ($tids)", 'UNBUFFERED');
}
require_once DISCUZ_ROOT.'./include/post.func.php';
updateforumcount($fid);
}
if($globalstick && $stickmodify) {
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('globalstick');
}
cpmsg(lang('members_delete_post').': '.lang('members_delete_processing'), $nextlink, 'loadingform', $extra);
} elseif($uids) {
$query = $db->query("DELETE FROM {$tablepre}members WHERE uid IN ($uids)");
$numdeleted = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}access WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}favorites WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}moderators WHERE uid IN ($uids)", 'UNBUFFERED');
$query = $db->query("SELECT uid, attachment, thumb, remote FROM {$tablepre}attachments WHERE uid IN ($uids) LIMIT $pertask");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}posts WHERE authorid IN ($uids)");
$db->query("DELETE FROM {$tablepre}trades WHERE sellerid IN ($uids)");
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($uids)");
manyoulog('user', $uids, 'delete');
cpmsg('members_delete_succeed', '', 'succeed');
} else {
cpmsg('members_no_find_deluser', '', 'error');
}
}
}
}
} elseif($operation == 'newsletter') {
if(!submitcheck('newslettersubmit', 1)) {
shownav('user', 'nav_members_newsletter');
showsubmenusteps('nav_members_newsletter', array(
array('nav_members_select', !$submit),
array('nav_members_notify', $submit),
));
searchmembers('newsletter');
if(submitcheck('submit', 1)) {
countmembers();
showtagheader('div', 'newsletter', TRUE);
showformheader('members&operation=newsletter'.$urladd);
echo '<table class="tb tb1">';
if(!$membernum) {
showtablerow('', 'class="lineheight"', $lang['members_search_nonexistence']);
} else {
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
showtablerow('class="first"', array('class="th11"'), array(
lang('members_newsletter_members'),
"$lang[members_search_result] <a href=\"###\" onclick=\"$('searchmembers').style.display='';$('newsletter').style.display='none';$('step1').className='current';$('step2').className='';\" class=\"act\">$lang[research]</a>"
));
showtagheader('tbody', 'messagebody', TRUE);
shownewsletter();
showtagfooter('tbody');
showsubmit('newslettersubmit', 'submit', 'td');
}
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
countmembers();
notifymembers('newsletter', 'newsletter');
}
} elseif($operation == 'reward') {
if(!submitcheck('rewardsubmit', 1)) {
shownav('user', 'nav_members_reward');
showsubmenusteps('nav_members_reward', array(
array('nav_members_select', !$submit),
array('nav_members_reward', $submit),
));
searchmembers('reward');
if(submitcheck('submit', 1)) {
countmembers();
showtagheader('div', 'reward', TRUE);
showformheader('members&operation=reward'.$urladd);
echo '<table class="tb tb1">';
if(!$membernum) {
showtablerow('', 'class="lineheight"', $lang['members_search_nonexistence']);
showtablefooter();
} else {
$creditscols = array('credits_title');
$creditsvalue = $resetcredits = array();
$js_extcreditids = '';
for($i=1; $i<=8; $i++) {
$js_extcreditids .= (isset($extcredits[$i]) ? ($js_extcreditids ? ',' : '').$i : '');
$creditscols[] = isset($extcredits[$i]) ? $extcredits[$i]['title'] : 'extcredits'.$i;
$creditsvalue[] = isset($extcredits[$i]) ? '<input type="text" class="txt" size="3" id="addextcredits['.$i.']" name="addextcredits['.$i.']" value="0"> '.$extcredits['$i']['unit'] : '<input type="text" class="txt" size="3" value="N/A" disabled>';
$resetcredits[] = isset($extcredits[$i]) ? '<input type="checkbox" id="resetextcredits['.$i.']" name="resetextcredits['.$i.']" value="1" class="radio" disabled> '.$extcredits['$i']['unit'] : '<input type="checkbox" disabled class="radio">';
}
$creditsvalue = array_merge(array('<input type="radio" name="updatecredittype" id="updatecredittype0" value="0" class="radio" onclick="var extcredits = new Array('.$js_extcreditids.'); for(k in extcredits) {$(\'resetextcredits[\'+extcredits[k]+\']\').disabled = true; $(\'addextcredits[\'+extcredits[k]+\']\').disabled = false;}" checked="checked" /><label for="updatecredittype0">'.$lang['members_reward_value'].'</label>'), $creditsvalue);
$resetcredits = array_merge(array('<input type="radio" name="updatecredittype" id="updatecredittype1" value="1" class="radio" onclick="var extcredits = new Array('.$js_extcreditids.'); for(k in extcredits) {$(\'addextcredits[\'+extcredits[k]+\']\').disabled = true; $(\'resetextcredits[\'+extcredits[k]+\']\').disabled = false;}" /><label for="updatecredittype1">'.$lang['members_reward_clean'].'</label>'), $resetcredits);
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
showtablerow('class="first"', array('class="th11"'), array(
lang('members_reward_members'),
"$lang[members_search_result] <a href=\"###\" onclick=\"$('searchmembers').style.display='';$('reward').style.display='none';$('step1').className='current';$('step2').className='';\" class=\"act\">$lang[research]</a>"
));
echo '<tr><td class="th12">'.lang('nav_members_reward').'</td><td>';
showtableheader('', 'noborder');
showsubtitle($creditscols);
showtablerow('', array('class="td23"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), $creditsvalue);
showtablerow('', array('class="td23"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), $resetcredits);
showtablefooter();
echo '</td></tr>';
showtagheader('tbody', 'messagebody');
shownewsletter();
showtagfooter('tbody');
showsubmit('rewardsubmit', 'submit', 'td', '<input class="checkbox" type="checkbox" name="notifymembers" value="1" onclick="$(\'messagebody\').style.display = this.checked ? \'\' : \'none\'" id="credits_notify" /><label for="credits_notify">'.lang('members_reward_notify').'</label>');
}
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
countmembers();
notifymembers('reward', 'creditsnotify');
}
} elseif($operation == 'confermedal') {
$medals = '';
$query = $db->query("SELECT * FROM {$tablepre}medals WHERE available='1' ORDER BY displayorder");
while($medal = $db->fetch_array($query)) {
$medals .= showtablerow('', array('class="td25"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"medals[$medal[medalid]]\" value=\"1\" />",
"<img src=\"images/common/$medal[image]\" />",
$medal['name']
), TRUE);
}
if(!$medals) {
cpmsg('members_edit_medals_nonexistence', $BASESCRIPT.'?action=medals', 'error');
}
if(!submitcheck('confermedalsubmit', 1)) {
shownav('user', 'nav_members_confermedal');
showsubmenusteps('nav_members_confermedal', array(
array('nav_members_select', !$submit),
array('nav_members_confermedal', $submit),
));
searchmembers('confermedal');
if(submitcheck('submit', 1)) {
countmembers();
showtagheader('div', 'confermedal', TRUE);
showformheader('members&operation=confermedal'.$urladd);
echo '<table class="tb tb1">';
if(!$membernum) {
showtablerow('', 'class="lineheight"', $lang['members_search_nonexistence']);
showtablefooter();
} else {
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
showtablerow('class="first"', array('class="th11"'), array(
lang('members_confermedal_members'),
"$lang[members_search_result] <a href=\"###\" onclick=\"$('searchmembers').style.display='';$('confermedal').style.display='none';$('step1').className='current';$('step2').className='';\" class=\"act\">$lang[research]</a>"
));
echo '<tr><td class="th12">'.lang('members_confermedal').'</td><td>';
showtableheader('', 'noborder');
showsubtitle(array('medals_grant', 'medals_image', 'name'));
echo $medals;
showtablefooter();
echo '</td></tr>';
showtagheader('tbody', 'messagebody');
shownewsletter();
showtagfooter('tbody');
showsubmit('confermedalsubmit', 'submit', 'td', '<input class="checkbox" type="checkbox" name="notifymembers" value="1" onclick="$(\'messagebody\').style.display = this.checked ? \'\' : \'none\'" id="grant_notify"/><label for="grant_notify">'.lang('medals_grant_notify').'</label>');
}
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
countmembers();
notifymembers('confermedal', 'medalletter');
}
} elseif($operation == 'add') {
if(!submitcheck('addsubmit')) {
$groupselect = array();
$query = $db->query("SELECT groupid, type, grouptitle, creditshigher, radminid FROM {$tablepre}usergroups WHERE type='member' AND creditshigher='0' OR (groupid NOT IN ('5', '6', '7') AND radminid<>'1' AND type<>'member') ORDER BY (creditshigher<>'0' || creditslower<>'0'), creditslower, groupid");
while($group = $db->fetch_array($query)) {
$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
if($group['type'] == 'member' && $group['creditshigher'] == 0) {
$groupselect[$group['type']] .= "<option value=\"$group[groupid]\" selected>$group[grouptitle]</option>\n";
} else {
$groupselect[$group['type']] .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
}
}
$groupselect = '<optgroup label="'.$lang['usergroups_member'].'">'.$groupselect['member'].'</optgroup>'.
($groupselect['special'] ? '<optgroup label="'.$lang['usergroups_special'].'">'.$groupselect['special'].'</optgroup>' : '').
($groupselect['specialadmin'] ? '<optgroup label="'.$lang['usergroups_specialadmin'].'">'.$groupselect['specialadmin'].'</optgroup>' : '').
'<optgroup label="'.$lang['usergroups_system'].'">'.$groupselect['system'].'</optgroup>';
shownav('user', 'nav_members_add');
showsubmenu('members_add');
showformheader('members&operation=add');
showtableheader();
showsetting('username', 'newusername', '', 'text');
showsetting('password', 'newpassword', '', 'text');
showsetting('email', 'newemail', '', 'text');
showsetting('usergroup', '', '', '<select name="newgroupid">'.$groupselect.'</select>');
showsetting('members_add_email_notify', 'emailnotify', '', 'radio');
showsubmit('addsubmit');
showtablefooter();
showformfooter();
} else {
$newusername = trim($newusername);
$newpassword = trim($newpassword);
$newemail = trim($newemail);
if(!$newusername || !$newpassword || !$newemail) {
cpmsg('members_add_invalid', '', 'error');
}
if($db->result_first("SELECT count(*) FROM {$tablepre}members WHERE username='$newusername'")) {
cpmsg('members_add_username_duplicate', '', 'error');
}
require_once DISCUZ_ROOT.'./uc_client/client.php';
$uid = uc_user_register($newusername, $newpassword, $newemail);
if($uid <= 0) {
if($uid == -1) {
cpmsg('members_add_illegal', '', 'error');
} elseif($uid == -2) {
cpmsg('members_username_protect', '', 'error');
} elseif($uid == -3) {
cpmsg('members_add_username_activation', '', 'error');
} elseif($uid == -4) {
cpmsg('members_email_illegal', '', 'error');
} elseif($uid == -5) {
cpmsg('members_email_domain_illegal', '', 'error');
} elseif($uid == -6) {
cpmsg('members_email_duplicate', '', 'error');
} else {
cpmsg('undefined_action', '', 'error');
}
}
$query = $db->query("SELECT groupid, radminid, type FROM {$tablepre}usergroups WHERE groupid='$newgroupid'");
$group = $db->fetch_array($query);
$newadminid = in_array($group['radminid'], array(1, 2, 3)) ? $group['radminid'] : ($group['type'] == 'special' ? -1 : 0);
if($group['radminid'] == 1) {
cpmsg('members_add_admin_none', '', 'error');
}
if(in_array($group['groupid'], array(5, 6, 7))) {
cpmsg('members_add_ban_all_none', '', 'error');
}
$db->query("INSERT INTO {$tablepre}members (uid, username, password, secques, gender, adminid, groupid, regip, regdate, lastvisit, lastactivity, posts, credits, email, bday, sigstatus, tpp, ppp, styleid, dateformat, timeformat, showemail, newsletter, invisible, timeoffset)
VALUES ('$uid', '$newusername', '".md5(random(10))."', '', '0', '$newadminid', '$newgroupid', 'Manual Acting', '$timestamp', '$timestamp', '$timestamp', '0', '0', '$newemail', '0000-00-00', '0', '0', '0', '0', '0', '{$_DCACHE[settings][timeformat]}', '1', '1', '0', '{$_DCACHE[settings][timeoffset]}')");
$db->query("REPLACE INTO {$tablepre}memberfields (uid) VALUES ('$uid')");
if($emailnotify) {
sendmail("$newusername <$newemail>", 'add_member_subject', 'add_member_message');
}
updatecache('settings');
$newusername = stripslashes($newusername);
cpmsg('members_add_succeed', '', 'succeed');
}
} elseif($operation == 'group') {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=group'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "m.uid='$uid'" : "m.username='$username'";
}
$member = $db->fetch_first("SELECT m.uid, m.username, m.adminid, m.groupid, m.groupexpiry, m.extgroupids, m.credits,
mf.groupterms, u.type AS grouptype, u.grouptitle, u.radminid
FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE $condition");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} elseif(!$isfounder && ($member['adminid'] == 1 || $member['groupid'] == 1)) {
cpmsg('members_super_edit_admin_allow', '', 'error');
}
if(!submitcheck('editsubmit')) {
$checkadminid = array(($member['adminid'] >= 0 ? $member['adminid'] : 0) => 'checked');
$member['groupterms'] = unserialize($member['groupterms']);
if($member['groupterms']['main']) {
$expirydate = gmdate('Y-n-j', $member['groupterms']['main']['time'] + $timeoffset * 3600);
$expirydays = ceil(($member['groupterms']['main']['time'] - $timestamp) / 86400);
$selecteaid = array($member['groupterms']['main']['adminid'] => 'selected');
$selectegid = array($member['groupterms']['main']['groupid'] => 'selected');
} else {
$expirydays = '';
$expirydate = $member['groupexpiry']? gmdate('Y-n-j', $member['groupexpiry'] + $timeoffset * 3600) : '';
$selecteaid = array($member['adminid'] => 'selected');
$selectegid = array(($member['grouptype'] == 'member' ? 0 : $member['groupid']) => 'selected');
}
$extgroups = $expgroups = '';
$radmingids = 0;
$extgrouparray = explode("\t", $member['extgroupids']);
$groups = array('system' => '', 'special' => '', 'member' => '');
$group = array('groupid' => 0, 'radminid' => 0, 'type' => '', 'grouptitle' => $lang['usergroups_system_0'], 'creditshigher' => 0, 'creditslower' => '0');
$query = $db->query("SELECT groupid, radminid, type, grouptitle, creditshigher, creditslower
FROM {$tablepre}usergroups WHERE groupid NOT IN ('6', '7') ORDER BY creditshigher, groupid");
do {
if($group['groupid'] && !in_array($group['groupid'], array(4, 5, 6, 7, 8)) && ($group['type'] == 'system' || $group['type'] == 'special')) {
$extgroups .= showtablerow('', array('class="td27"', 'style="width:70%"'), array(
'<input class="checkbox" type="checkbox" name="extgroupidsnew[]" value="'.$group['groupid'].'" '.(in_array($group['groupid'], $extgrouparray) ? 'checked' : '').' id="extgid_'.$group['groupid'].'" /><label for="extgid_'.$group['groupid'].'"> '.$group['grouptitle'].'</label>',
'<input type="text" class="txt" size="9" name="extgroupexpirynew['.$group['groupid'].']" value="'.(in_array($group['groupid'], $extgrouparray) && !empty($member['groupterms']['ext'][$group['groupid']]) ? gmdate('Y-n-j', $member['groupterms']['ext'][$group['groupid']] + $timeoffset * 3600) : '').'" onclick="showcalendar(event, this)" />'
), TRUE);
}
if($group['groupid'] && $group['type'] == 'member' && !($member['credits'] >= $group['creditshigher'] && $member['credits'] < $group['creditslower']) && $member['groupid'] != $group['groupid']) {
continue;
}
$expgroups .= '<option name="expgroupidnew" value="'.$group['groupid'].'" '.$selectegid[$group['groupid']].'>'.$group['grouptitle'].'</option>';
if($group['groupid'] != 0) {
$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
$groups[$group['type']] .= '<option value="'.$group['groupid'].'"'.($member['groupid'] == $group['groupid'] ? 'selected="selected"' : '').' gtype="'.$group['type'].'">'.$group['grouptitle'].'</option>';
if($group['type'] == 'special' && !$group['radminid']) {
$radmingids .= ','.$group['groupid'];
}
}
} while($group = $db->fetch_array($query));
if(!$groups['member']) {
$group = $db->fetch_first("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type='member' AND creditshigher>='0' ORDER BY creditshigher LIMIT 1");
$groups['member'] = '<option value="'.$group['groupid'].'" gtype="member">'.$group['grouptitle'].'</option>';
}
shownav('user', 'members_group');
eval("\$lang[members_group_member] = \"".$lang['members_group_member']."\";");
showsubmenu('members_group_member');
echo '<script src="include/js/calendar.js" type="text/javascript"></script>';
showformheader("members&operation=group&uid=$member[uid]");
showtableheader('usergroup', 'nobottom');
showsetting('members_group_group', '', '', '<select name="groupidnew" onchange="if(in_array(this.value, ['.$radmingids.'])) {$(\'relatedadminid\').style.display = \'\';$(\'adminidnew\').name=\'adminidnew[\' + this.value + \']\';} else {$(\'relatedadminid\').style.display = \'none\';$(\'adminidnew\').name=\'adminidnew[0]\';}"><optgroup label="'.$lang['usergroups_system'].'">'.$groups['system'].'<optgroup label="'.$lang['usergroups_special'].'">'.$groups['special'].'<optgroup label="'.$lang['usergroups_specialadmin'].'">'.$groups['specialadmin'].'<optgroup label="'.$lang['usergroups_member'].'">'.$groups['member'].'</select>');
showtagheader('tbody', 'relatedadminid', $member['grouptype'] == 'special' && !$member['radminid'], 'sub');
showsetting('members_group_related_adminid', '', '', '<select id="adminidnew" name="adminidnew['.$member['groupid'].']"><option value="0"'.($member['adminid'] == 0 ? ' selected' : '').'>'.$lang['none'].'</option><option value="3"'.($member['adminid'] == 3 ? ' selected' : '').'>'.$lang['usergroups_system_3'].'</option><option value="2"'.($member['adminid'] == 2 ? ' selected' : '').'>'.$lang['usergroups_system_2'].'</option><option value="1"'.($member['adminid'] == 1 ? ' selected' : '').'>'.$lang['usergroups_system_1'].'</option></select>');
showtagfooter('tbody');
showsetting('members_group_validity', 'expirydatenew', $expirydate, 'calendar');
showsetting('members_group_orig_adminid', '', '', '<select name="expgroupidnew">'.$expgroups.'</select>');
showsetting('members_group_orig_groupid', '', '', '<select name="expadminidnew"><option value="0" '.$selecteaid[0].'>'.$lang['usergroups_system_0'].'</option><option value="1" '.$selecteaid[1].'>'.$lang['usergroups_system_1'].'</option><option value="2" '.$selecteaid[2].'>'.$lang['usergroups_system_2'].'</option><option value="3" '.$selecteaid[3].'>'.$lang['usergroups_system_3'].'</option></select>');
showtablefooter();
showtableheader('members_group_extended', 'noborder fixpadding');
showsubtitle(array('usergroup', 'validity'));
echo $extgroups;
showtablerow('', 'colspan="2"', lang('members_group_extended_comment'));
showtablefooter();
showtableheader('members_edit_reason', 'notop');
showsetting('members_group_ban_reason', 'reason', '', 'textarea');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$group = $db->fetch_first("SELECT groupid, radminid, type FROM {$tablepre}usergroups WHERE groupid='$groupidnew'");
if(!$group) {
cpmsg('undefined_action', '', 'error');
}
if(strlen(is_array($extgroupidsnew) ? implode("\t", $extgroupidsnew) : '') > 60) {
cpmsg('members_edit_groups_toomany', '', 'error');
}
$adminidnew = $adminidnew[$groupidnew];
switch($group['type']) {
case 'member':
$groupidnew = in_array($adminidnew, array(1, 2, 3)) ? $adminidnew : $groupidnew;
break;
case 'special':
if($group['radminid']) {
$adminidnew = $group['radminid'];
} elseif(!in_array($adminidnew, array(1, 2, 3))) {
$adminidnew = -1;
}
break;
case 'system':
$adminidnew = in_array($groupidnew, array(1, 2, 3)) ? $groupidnew : -1;
break;
}
$groupterms = array();
if($expirydatenew) {
$maingroupexpirynew = strtotime($expirydatenew);
$group = $db->fetch_first("SELECT groupid, radminid, type FROM {$tablepre}usergroups WHERE groupid='$expgroupidnew'");
if(!$group) {
$expgroupidnew = in_array($expadminidnew, array(1, 2, 3)) ? $expadminidnew : $expgroupidnew;
} else {
switch($group['type']) {
case 'special':
if($group['radminid']) {
$expadminidnew = $group['radminid'];
} elseif(!in_array($expadminidnew, array(1, 2, 3))) {
$expadminidnew = -1;
}
break;
case 'system':
$expadminidnew = in_array($expgroupidnew, array(1, 2, 3)) ? $expgroupidnew : -1;
break;
}
}
if($expgroupidnew == $groupidnew) {
cpmsg('members_edit_groups_illegal', '', 'error');
} elseif($maingroupexpirynew > $timestamp) {
if($expgroupidnew || $expadminidnew) {
$groupterms['main'] = array('time' => $maingroupexpirynew, 'adminid' => $expadminidnew, 'groupid' => $expgroupidnew);
} else {
$groupterms['main'] = array('time' => $maingroupexpirynew);
}
$groupterms['ext'][$groupidnew] = $maingroupexpirynew;
}
}
if(is_array($extgroupexpirynew)) {
foreach($extgroupexpirynew as $extgroupid => $expiry) {
if(is_array($extgroupidsnew) && in_array($extgroupid, $extgroupidsnew) && !isset($groupterms['ext'][$extgroupid]) && $expiry && ($expiry = strtotime($expiry)) > $timestamp) {
$groupterms['ext'][$extgroupid] = $expiry;
}
}
}
$grouptermsnew = addslashes(serialize($groupterms));
$groupexpirynew = groupexpiry($groupterms);
$extgroupidsnew = $extgroupidsnew && is_array($extgroupidsnew) ? implode("\t", $extgroupidsnew) : '';
$db->query("UPDATE {$tablepre}members SET groupid='$groupidnew', adminid='$adminidnew', extgroupids='$extgroupidsnew', groupexpiry='$groupexpirynew' WHERE uid='$member[uid]'");
$db->query("UPDATE {$tablepre}memberfields SET groupterms='$grouptermsnew' WHERE uid='$member[uid]'");
if($groupidnew != $member['groupid'] && (in_array($groupidnew, array(4, 5)) || in_array($member['groupid'], array(4, 5)))) {
banlog($member['username'], $member['groupid'], $groupidnew, $groupexpirynew, $reason);
}
cpmsg('members_edit_groups_succeed', "$BASESCRIPT?action=members&operation=group&uid=$member[uid]", 'succeed');
}
} elseif($operation == 'credit' && $extcredits) {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=credit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "m.uid='$uid'" : "m.username='$username'";
}
$member = $db->fetch_first("SELECT m.*, u.grouptitle, u.type, u.creditslower, u.creditshigher
FROM {$tablepre}members m
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE $condition");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} elseif(!$isfounder && ($member['adminid'] == 1 || $member['groupid'] == 1)) {
cpmsg('members_super_edit_admin_allow', '', 'error');
}
if(!submitcheck('creditsubmit')) {
eval("\$membercredit = @round($creditsformula);");
if($jscreditsformula = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='creditsformula'")) {
$jscreditsformula = str_replace(array('digestposts', 'posts', 'threads', 'pageviews', 'oltime'), array($member['digestposts'], $member['posts'],$member['threads'],$member['pageviews'],$member['oltime']), $jscreditsformula);
}
$creditscols = array('members_credit_ranges', 'credits');
$creditsvalue = array($member['type'] == 'member' ? "$member[creditshigher]~$member[creditslower]" : 'N/A', '<input type="text" class="txt" name="jscredits" id="jscredits" value="'.$membercredit.'" size="3" disabled>');
for($i = 1; $i <= 8; $i++) {
$jscreditsformula = str_replace('extcredits'.$i, "extcredits[$i]", $jscreditsformula);
$creditscols[] = isset($extcredits[$i]) ? $extcredits[$i]['title'] : 'extcredits'.$i;
$creditsvalue[] = isset($extcredits[$i]) ? '<input type="text" class="txt" size="3" name="extcreditsnew['.$i.']" id="extcreditsnew['.$i.']" value="'.$member['extcredits'.$i].'" onkeyup="membercredits()"> '.$extcredits['$i']['unit'] : '<input type="text" class="txt" size="3" value="N/A" disabled>';
}
echo <<<EOT
<script language="JavaScript">
var extcredits = new Array();
function membercredits() {
var credits = 0;
for(var i = 1; i <= 8; i++) {
e = $('extcreditsnew['+i+']');
if(e && parseInt(e.value)) {
extcredits[i] = parseInt(e.value);
} else {
extcredits[i] = 0;
}
}
$('jscredits').value = Math.round($jscreditsformula);
}
</script>
EOT;
shownav('user', 'members_credit');
showsubmenu('members_credit');
showtips('members_credit_tips');
showformheader("members&operation=credit&uid=$uid");
showtableheader(lang('members_credit').' - '.$member['username']."($member[grouptitle])", 'nobottom');
showsubtitle($creditscols);
showtablerow('', array('', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), $creditsvalue);
showtablefooter();
showtableheader('', 'notop');
showtitle('members_edit_reason');
showsetting('members_credit_reason', 'reason', '', 'textarea');
showsubmit('creditsubmit');
showtablefooter();
showformfooter();
} else {
$diffarray = array();
$sql = $comma = '';
if(is_array($extcreditsnew)) {
foreach($extcreditsnew as $id => $value) {
if($member['extcredits'.$id] != ($value = intval($value))) {
$diffarray[$id] = $value - $member['extcredits'.$id];
$sql .= $comma."extcredits$id='$value'";
$comma = ', ';
}
}
}
if($diffarray) {
if(empty($reason)) {
cpmsg('members_edit_reason_invalid', '', 'error');
}
foreach($diffarray as $id => $diff) {
$logs[] = dhtmlspecialchars("$timestamp\t$discuz_userss\t$adminid\t$member[username]\t$id\t$diff\t0\t\t$reason");
}
$db->query("UPDATE {$tablepre}members SET $sql WHERE uid='$uid'");
writelog('ratelog', $logs);
}
cpmsg('members_edit_credits_succeed', "$BASESCRIPT?action=members&operation=credit&uid=$uid", 'succeed');
}
} elseif($operation == 'medal') {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=medal'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "m.uid='$uid'" : "m.username='$username'";
}
$member = $db->fetch_first("SELECT m.uid, m.username, mf.medals
FROM {$tablepre}memberfields mf, {$tablepre}members m
WHERE $condition AND m.uid=mf.uid");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
}
if(!submitcheck('medalsubmit')) {
$medals = '';
$membermedals = array();
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
foreach (explode("\t", $member['medals']) as $key => $membermedal) {
list($medalid, $medalexpiration) = explode("|", $membermedal);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$membermedals[$key] = $medalid;
} else {
unset($membermedals[$key]);
}
}
$query = $db->query("SELECT * FROM {$tablepre}medals WHERE available='1' ORDER BY displayorder");
while($medal = $db->fetch_array($query)) {
$medals .= showtablerow('', array('class="td25"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"medals[$medal[medalid]]\" value=\"1\" ".(in_array($medal['medalid'], $membermedals) ? 'checked' : '')." />",
"<img src=\"images/common/$medal[image]\" />",
$medal['name']
), TRUE);
}
if(!$medals) {
cpmsg('members_edit_medals_nonexistence', '', 'error');
}
shownav('user', 'nav_members_confermedal');
showsubmenu('nav_members_confermedal');
showformheader("members&operation=medal&uid=$uid");
showtableheader("$lang[members_confermedal_to] <a href='space.php?uid=$uid' target='_blank'>$member[username]</a>", 'fixpadding');
showsubtitle(array('medals_grant', 'medals_image', 'name'));
echo $medals;
showsubmit('medalsubmit');
showtablefooter();
showformfooter();
} else {
$medalids = $comma = '';
$medalsdel = $medalsadd = $medalsnew = $origmedalsarray = $medalsarray = array();
if(is_array($medals)) {
foreach($medals as $medalid => $newgranted) {
if($newgranted) {
$medalsarray[] = $medalid;
$medalids .= "$comma'$medalid'";
$comma = ',';
}
}
}
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
foreach($member['medals'] = explode("\t", $member['medals']) as $key => $modmedalid) {
list($medalid, $medalexpiration) = explode("|", $modmedalid);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$origmedalsarray[] = $medalid;
}
}
foreach(array_unique(array_merge($origmedalsarray, $medalsarray)) as $medalid) {
if($medalid) {
$orig = in_array($medalid, $origmedalsarray);
$new = in_array($medalid, $medalsarray);
if($orig != $new) {
if($orig && !$new) {
$medalsdel[] = $medalid;
} elseif(!$orig && $new) {
$medalsadd[] = $medalid;
}
}
}
}
if(!empty($medalids)) {
$query = $db->query("SELECT * FROM {$tablepre}medals WHERE medalid IN ($medalids) ORDER BY displayorder");
while($modmedal = $db->fetch_array($query)) {
if(empty($modmedal['expiration'])) {
$medalsnew[] = $modmedal[medalid];
$medalstatus = 0;
} else {
$modmedal['expiration'] = $timestamp + $modmedal['expiration'] * 86400;
$medalsnew[] = $modmedal[medalid].'|'.$modmedal['expiration'];
$medalstatus = 1;
}
if(in_array($modmedal['medalid'], $medalsadd)) {
$db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('$uid', '".$modmedal[medalid]."', '0', '$timestamp', '".$modmedal['expiration']."', '$medalstatus')");
}
}
}
if(!empty($medalsdel)) {
$db->query("UPDATE {$tablepre}medallog SET type='4' WHERE uid='$uid' AND medalid IN (".implode(',', $medalsdel).")");
}
$medalsnew = implode("\t", $medalsnew);
$db->query("UPDATE {$tablepre}memberfields SET medals='$medalsnew' WHERE uid='$uid'");
cpmsg('members_edit_medals_succeed', "$BASESCRIPT?action=members&operation=medal&uid=$uid", 'succeed');
}
} elseif($operation == 'ban') {
if(!$allowbanuser) {
cpmsg('action_noaccess', '', 'error');
}
$member = array();
if(!empty($username) || !empty($uid)) {
$member = $db->fetch_first("SELECT m.*, mf.*, u.type AS grouptype, u.allowsigbbcode, u.allowsigimgcode FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE ".($uid ? "m.uid='$uid'" : "m.username='$username'"));
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} elseif(($member['grouptype'] == 'system' && in_array($member['groupid'], array(1, 2, 3, 6, 7, 8))) || $member['grouptype'] == 'special') {
cpmsg('members_edit_illegal', '', 'error');
}
$member['groupterms'] = unserialize($member['groupterms']);
$member['banexpiry'] = !empty($member['groupterms']['main']['time']) && ($member['groupid'] == 4 || $member['groupid'] == 5) ? gmdate('Y-n-j', $member['groupterms']['main']['time'] + $timeoffset * 3600) : '';
}
if(!submitcheck('bansubmit')) {
echo '<script src="include/js/calendar.js" type="text/javascript"></script>';
shownav('user', 'members_ban_user');
showsubmenu($lang['members_ban_user'].($member['username'] ? ' -'.$member['username'] : ''));
showformheader('members&operation=ban');
showtableheader();
showsetting('members_ban_username', 'username', $member['username'], 'text');
if($member) {
showtablerow('', 'class="td27"', lang('members_edit_current_status').'<span class="normal">: '.($member['groupid'] == 4 ? $lang['members_ban_post'] : ($member['groupid'] == 5 ? $lang['members_ban_visit'] : $lang['members_ban_none'])).'</span>');
}
showsetting('members_ban_type', array('bannew', array(
array('', $lang['members_ban_none']),
array('post', $lang['members_ban_post']),
array('visit', $lang['members_ban_visit'])
)), '0', 'mradio');
showsetting('members_ban_validity', '', '', selectday('banexpirynew', array(0, 1, 3, 5, 7, 14, 30, 60, 90, 180, 365)));
showsetting('members_ban_delpost', 'delpost', '', 'radio');
showsetting('members_ban_reason', 'reason', '', 'textarea');
showsubmit('bansubmit');
showtablefooter();
showformfooter();
} else {
if(empty($member)) {
cpmsg('members_edit_nonexistence');
}
$sql = 'uid=uid';
$reason = trim($reason);
if(!$reason && ($reasonpm == 1 || $reasonpm == 3)) {
cpmsg('members_edit_reason_invalid', '', 'error');
}
if($bannew == 'post' || $bannew == 'visit') {
$groupidnew = $bannew == 'post' ? 4 : 5;
$banexpirynew = !empty($banexpirynew) ? $timestamp + $banexpirynew * 86400 : 0;
$banexpirynew = $banexpirynew > $timestamp ? $banexpirynew : 0;
if($banexpirynew) {
$member['groupterms']['main'] = array('time' => $banexpirynew, 'adminid' => $member['adminid'], 'groupid' => $member['groupid']);
$member['groupterms']['ext'][$groupidnew] = $banexpirynew;
$sql .= ', groupexpiry=\''.groupexpiry($member['groupterms']).'\'';
} else {
$sql .= ', groupexpiry=0';
}
$adminidnew = -1;
} elseif($member['groupid'] == 4 || $member['groupid'] == 5) {
if(!empty($member['groupterms']['main']['groupid'])) {
$groupidnew = $member['groupterms']['main']['groupid'];
$adminidnew = $member['groupterms']['main']['adminid'];
unset($member['groupterms']['main']);
unset($member['groupterms']['ext'][$member['groupid']]);
$sql .= ', groupexpiry=\''.groupexpiry($member['groupterms']).'\'';
} else {
$groupidnew = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditshigher<='$member[credits]' AND creditslower>'$member[credits]'");
$adminidnew = 0;
}
} else {
$groupidnew = $member['groupid'];
$adminidnew = $member['adminid'];
}
$sql .= ", adminid='$adminidnew', groupid='$groupidnew'";
$db->query("UPDATE {$tablepre}members SET $sql WHERE uid='$member[uid]'");
if($allowbanuser && ($db->affected_rows($query))) {
banlog($member['username'], $member['groupid'], $groupidnew, $banexpirynew, $reason);
}
$db->query("UPDATE {$tablepre}memberfields SET groupterms='".($member['groupterms'] ? addslashes(serialize($member['groupterms'])) : '')."' WHERE uid='$member[uid]'");
if($delpost && $bannew && $adminid == 1) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE uid='$member[uid]'");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
if($member['uid']) {
require_once DISCUZ_ROOT.'./include/post.func.php';
$pidsdelete = $tidsdelete = '0';
$query = $db->query("SELECT pid, fid, tid, first FROM {$tablepre}posts WHERE authorid='$member[uid]'");
while($post = $db->fetch_array($query)) {
$prune['forums'][] = $post['fid'];
$prune['thread'][$post['tid']]++;
if($post['first']) {
$tidsdelete .= ",$post[tid]";
}
$pidsdelete .= ",$post[pid]";
}
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE pid IN ($pidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($tidsdelete)");
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pidsdelete)");
$db->query("DELETE FROM {$tablepre}posts WHERE tid IN ($tidsdelete)");
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polls WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activities WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activityapplies WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
if(!empty($prune)) {
foreach($prune['thread'] as $tid => $decrease) {
updatethreadcount($tid);
}
foreach(array_unique($prune['forums']) as $fid) {
updateforumcount($fid);
}
}
if($globalstick) {
updatecache('globalstick');
}
}
}
cpmsg('members_edit_succeed', $BASESCRIPT.'?action=members&operation=ban', 'succeed');
}
} elseif($operation == 'access') {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=access'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "uid='$uid'" : "username='$username'";
}
$member = $db->fetch_first("SELECT username, adminid, groupid FROM {$tablepre}members WHERE $condition");
if(!$member) {
cpmsg('undefined_action', '', 'error');
} elseif(!$isfounder && ($member['adminid'] == 1 || $member['groupid'] == 1)) {
cpmsg('members_super_edit_admin_allow', '', 'error');
}
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumlist = '<SELECT name="addfid">'.forumselect(FALSE, 0, 0, TRUE).'</select>';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
if(!submitcheck('accesssubmit')) {
shownav('user', 'members_access_edit');
showsubmenu('members_access_edit');
showtips('members_access_tips');
showtableheader(lang('members_access_now').' - '.$member['username'], 'nobottom fixpadding');
showsubtitle(array('forum', 'members_access_view', 'members_access_post', 'members_access_reply', 'members_access_postattach', 'members_access_getattach', 'members_access_adminuser', 'members_access_dateline'));
$accessmasks = array();
$query = $db->query("SELECT a.*, m.username as adminusername FROM {$tablepre}access a LEFT JOIN {$tablepre}members m ON a.adminuser=m.uid WHERE a.uid='$uid'");
while($access = $db->fetch_array($query)) {
$accessmasks[$access['fid']] = $access;
$accessmasks[$access['fid']]['dateline'] = $access['dateline'] ? gmdate("$dateformat $timeformat", $timeoffset * 3600 + $access['dateline']) : '';
}
foreach ($accessmasks as $id => $access) {
$forum = $_DCACHE['forums'][$id];
showtablerow('', '', array(
($forum['type'] == 'forum' ? '' : '|-----')." <a href=\"$BASESCRIPT?action=forums&operation=edit&fid=$forum[fid]&anchor=perm\">$forum[name]</a>",
accessimg($access['allowview']),
accessimg($access['allowpost']),
accessimg($access['allowreply']),
accessimg($access['allowpostattach']),
accessimg($access['allowgetattach']),
$access['adminusername'],
$access['dateline'],
));
}
if(empty($accessmasks)) {
showtablerow('', '', array(
'-',
'-',
'-',
'-',
'-',
'-',
'-',
'-',
));
}
showtablefooter();
showformheader("members&operation=access&uid=$uid");
showtableheader(lang('members_access_add'), 'notop fixpadding');
showsetting('members_access_add_forum', '', '', $forumlist);
foreach(array('view', 'post', 'reply', 'postattach', 'getattach') as $perm) {
showsetting('members_access_add_'.$perm, array('allow'.$perm.'new', array(
array(0, lang('default')),
array(1, lang('members_access_allowed')),
array(-1, lang('members_access_disallowed')),
), TRUE), 0, 'mradio');
}
showsubmit('accesssubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$addfid = intval($addfid);
if($addfid && $_DCACHE['forums'][$addfid]) {
$allowviewnew = !$allowviewnew ? 0 : ($allowviewnew > 0 ? 1 : -1);
$allowpostnew = !$allowpostnew ? 0 : ($allowpostnew > 0 ? 1 : -1);
$allowreplynew = !$allowreplynew ? 0 : ($allowreplynew > 0 ? 1 : -1);
$allowgetattachnew = !$allowgetattachnew ? 0 : ($allowgetattachnew > 0 ? 1 : -1);
$allowpostattachnew = !$allowpostattachnew ? 0 : ($allowpostattachnew > 0 ? 1 : -1);
if($allowviewnew == -1) {
$allowpostnew = $allowreplynew = $allowgetattachnew = $allowpostattachnew = -1;
} elseif($allowpostnew == 1 || $allowreplynew == 1 || $allowgetattachnew == 1 || $allowpostattachnew == 1) {
$allowviewnew = 1;
}
if(!$allowviewnew && !$allowpostnew && !$allowreplynew && !$allowgetattachnew && !$allowpostattachnew) {
$db->query("DELETE FROM {$tablepre}access WHERE uid='$uid' AND fid='$addfid'");
if(!$db->result_first("SELECT count(*) FROM {$tablepre}access WHERE uid='$uid'")) {
$db->query("UPDATE {$tablepre}members SET accessmasks='0' WHERE uid='$uid'");
}
} else {
$db->query("REPLACE INTO {$tablepre}access SET
uid='$uid', fid='$addfid', allowview='$allowviewnew',
allowpost='$allowpostnew', allowreply='$allowreplynew', allowgetattach='$allowgetattachnew',
allowpostattach='$allowpostattachnew', adminuser='$discuz_uid', dateline='$timestamp'");
$db->query("UPDATE {$tablepre}members SET accessmasks='1' WHERE uid='$uid'");
}
updatecache('forums');
}
cpmsg('members_access_succeed', $BASESCRIPT.'?action=members&operation=access&uid='.$uid, 'succeed');
}
} elseif($operation == 'edit') {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "m.uid='$uid'" : "m.username='$username'";
}
$member = $db->fetch_first("SELECT m.*, mf.*, m.uid AS muid, o.*, u.type, u.allowsigbbcode, u.allowsigimgcode, u.allowcusbbcode, u.allowbiobbcode, u.allowbioimgcode, u.allowcusbbcode FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
LEFT JOIN {$tablepre}onlinetime o ON o.uid=m.uid
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE $condition");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} elseif(!$isfounder && ($member['adminid'] == 1 || $member['groupid'] == 1)) {
cpmsg('members_super_edit_admin_allow', '', 'error');
}
$uid = $member['muid'];
require_once DISCUZ_ROOT.'./forumdata/cache/cache_profilefields.php';
$fields = array_merge($_DCACHE['fields_required'], $_DCACHE['fields_optional']);
if(!submitcheck('editsubmit')) {
require_once DISCUZ_ROOT.'./include/editor.func.php';
$styleselect = "<select name=\"styleidnew\">\n<option value=\"\">$lang[use_default]</option>";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$styleselect .= "<option value=\"$style[styleid]\" ".($style['styleid'] == $member['styleid'] ? 'selected="selected"' : '').">$style[name]</option>\n";
}
$styleselect .= '</select>';
$tfcheck = array($member['timeformat'] => 'checked');
$gendercheck = array($member['gender'] => 'checked');
$pscheck = array($member['pmsound'] => 'checked');
$member['regdate'] = gmdate('Y-n-j h:i A', $member['regdate'] + $timeoffset * 3600);
$member['lastvisit'] = gmdate('Y-n-j h:i A', $member['lastvisit'] + $timeoffset * 3600);
$member['bio'] = html2bbcode($member['bio']);
$member['signature'] = html2bbcode($member['sightml']);
shownav('user', 'members_edit');
showsubmenu("$lang[members_edit] - $member[username]");
showformheader("members&operation=edit&uid=$uid");
showtableheader();
showsetting('members_edit_username', '', '', ' '.$member['username']);
showsetting('members_edit_avatar', '', '', ' '.discuz_uc_avatar($uid).'<br /><br /><input name="clearavatar" class="checkbox" type="checkbox" value="1" /> '.$lang['members_edit_avatar_clear']);
showsetting('members_edit_password', 'passwordnew', '', 'text');
showsetting('members_edit_clearquestion', 'clearquestion', !$member['secques'], 'radio');
showsetting('members_edit_nickname', 'nicknamenew', $member['nickname'], 'text');
showsetting('members_edit_gender', '', '', '<input class="radio" type="radio" name="gendernew" value="1" '.$gendercheck[1].'> '.$lang['members_edit_gender_male'].' <input class="radio" type="radio" name="gendernew" value="2" '.$gendercheck[2].'> '.$lang['members_edit_gender_female'].' <input class="radio" type="radio" name="gendernew" value="0" '.$gendercheck[0].'> '.$lang['members_edit_gender_secret']);
showsetting('members_edit_email', 'emailnew', $member['email'], 'text');
showsetting('members_edit_posts', 'postsnew', $member['posts'], 'text');
showsetting('members_edit_digestposts', 'digestpostsnew', $member['digestposts'], 'text');
showsetting('members_edit_pageviews', 'pageviewsnew', $member['pageviews'], 'text');
showsetting('members_edit_online_total', 'totalnew', $member['total'], 'text');
showsetting('members_edit_online_thismonth', 'thismonthnew', $member['thismonth'], 'text');
showsetting('members_edit_regip', 'regipnew', $member['regip'], 'text');
showsetting('members_edit_regdate', 'regdatenew', $member['regdate'], 'text');
showsetting('members_edit_lastvisit', 'lastvisitnew', $member['lastvisit'], 'text');
showsetting('members_edit_lastip', 'lastipnew', $member['lastip'], 'text');
showtitle('members_edit_info');
showsetting('members_edit_site', 'sitenew', $member['site'], 'text');
showsetting('members_edit_qq', 'qqnew', $member['qq'], 'text');
showsetting('members_edit_icq', 'icqnew', $member['icq'], 'text');
showsetting('members_edit_yahoo', 'yahoonew', $member['yahoo'], 'text');
showsetting('members_edit_msn', 'msnnew', $member['msn'], 'text');
showsetting('members_edit_taobao', 'taobaonew', $member['taobao'], 'text');
showsetting('members_edit_alipay', 'alipaynew', $member['alipay'], 'text');
showsetting('members_edit_location', 'locationnew', $member['location'], 'text');
showsetting('members_edit_bday', 'bdaynew', $member['bday'], 'text');
showsetting('members_edit_bio', 'bionew', $member['bio'], 'textarea');
showsetting('members_edit_signature', 'signaturenew', $member['signature'], 'textarea');
showtitle('members_edit_option');
showsetting('members_edit_style', '', '', $styleselect);
showsetting('members_edit_tpp', 'tppnew', $member['tpp'], 'text');
showsetting('members_edit_ppp', 'pppnew', $member['ppp'], 'text');
showsetting('members_edit_cstatus', 'cstatusnew', $member['customstatus'], 'text');
showsetting('members_edit_timeformat', '', '', '<input class="radio" type="radio" name="timeformatnew" value="0" '.$tfcheck[0].'> '.$lang['default'].' <input class="radio" type="radio" name="timeformatnew" value="1" '.$tfcheck[1].'> '.$lang['members_edit_timeformat_12'].' <input class="radio" type="radio" name="timeformatnew" value="2" '.$tfcheck[2].'> '.$lang['members_edit_timeformat_24']);
showsetting('members_edit_timeoffset', 'timeoffsetnew', $member['timeoffset'], 'text');
showsetting('members_edit_pmsound', '', '', '<input class="radio" type="radio" value="0" name="pmsoundnew" '.$pscheck[0].'>'.$lang['none'].' <input class="radio" type="radio" value="1" name="pmsoundnew" '.$pscheck[1].'><a href="images/sound/pm_1.mp3">#1</a> <input class="radio" type="radio" value="2" name="pmsoundnew" '.$pscheck[2].'><a href="images/sound/pm_2.mp3">#2</a> <input class="radio" type="radio" value="3" name="pmsoundnew" '.$pscheck[3].'><a href="images/sound/pm_3.mp3">#3</a>');
showsetting('members_edit_invisible', 'invisiblenew', $member['invisible'], 'radio');
showsetting('members_edit_showemail', 'showemailnew', $member['showemail'], 'radio');
showsetting('members_edit_newsletter', 'newsletternew', $member['newsletter'], 'radio');
showsetting('members_edit_ignorepm', 'ignorepmnew', $member['ignorepm'], 'textarea');
if($fields) {
showtitle('profilefields_fields');
foreach($fields as $field) {
if($field['selective']) {
$fieldselect = "<select name=\"field_$field[fieldid]new\"><option value=\"\"> </option>";
foreach($field['choices'] as $index => $choice) {
$fieldselect .= "<option value=\"$index\" ".($index == $member['field_'.$field['fieldid']] ? 'selected="selected"' : '').">$choice</option>";
}
$fieldselect .= '</select>';
showsetting($field['title'], '', '', $fieldselect);
} else {
showsetting($field['title'], "field_$field[fieldid]new", $member['field_'.$field['fieldid']], 'text');
}
}
}
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
require_once DISCUZ_ROOT.'./uc_client/client.php';
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$questionid = $clearquestion ? 0 : '';
$ucresult = uc_user_edit($member['username'], $passwordnew, $passwordnew, $emailnew, 1, $questionid);
if($clearavatar) {
uc_user_deleteavatar($member['uid']);
}
$creditsnew = intval($creditsnew);
$regdatenew = strtotime($regdatenew);
$lastvisitnew = strtotime($lastvisitnew);
$secquesadd = $clearquestion ? ", secques=''" : '';
$signaturenew = censor($signaturenew);
$sigstatusnew = $signaturenew ? 1 : 0;
$sightmlnew = addslashes(discuzcode(stripslashes($signaturenew), 1, 0, 0, 0, ($member['allowsigbbcode'] ? ($member['allowcusbbcode'] ? 2 : 1) : 0), $member['allowsigimgcode'], 0));
$bionew = censor(dhtmlspecialchars($bionew));
$biohtmlnew = addslashes(discuzcode(stripslashes($bionew), 1, 0, 0, 0, ($member['allowbiobbcode'] ? ($member['allowcusbbcode'] ? 2 : 1) : 0), $member['allowbioimgcode'], 0));
$oltimenew = round($totalnew / 60);
$fieldadd = '';
foreach(array_merge($_DCACHE['fields_required'], $_DCACHE['fields_optional']) as $field) {
$field_key = 'field_'.$field['fieldid'];
$field_val = trim(${'field_'.$field['fieldid'].'new'});
if($field['selective'] && $field_val != '' && !isset($field['choices'][$field_val])) {
cpmsg('undefined_action', '', 'error');
} else {
$fieldadd .= ", $field_key='".dhtmlspecialchars($field_val)."'";
}
}
$emailadd = $ucresult < 0 ? '' : "email='$emailnew', ";
$passwordadd = $ucresult < 0 ? '' : ", password='".md5(random(10))."'";
$db->query("UPDATE {$tablepre}members SET gender='$gendernew', $emailadd posts='$postsnew', digestposts='$digestpostsnew',
pageviews='$pageviewsnew', regip='$regipnew', regdate='$regdatenew', lastvisit='$lastvisitnew', lastip='$lastipnew', bday='$bdaynew',
styleid='$styleidnew', tpp='$tppnew', ppp='$pppnew', timeformat='$timeformatnew', oltime='$oltimenew',
showemail='$showemailnew', newsletter='$newsletternew', invisible='$invisiblenew', timeoffset='$timeoffsetnew',
pmsound='$pmsoundnew', sigstatus='$sigstatusnew' $passwordadd $secquesadd WHERE uid='$uid'");
$db->query("UPDATE {$tablepre}memberfields SET nickname='$nicknamenew', site='$sitenew', qq='$qqnew', icq='$icqnew', yahoo='$yahoonew', msn='$msnnew',
taobao='$taobaonew', alipay='$alipaynew', location='$locationnew', bio='$biohtmlnew', customstatus='$cstatusnew', ignorepm='$ignorepmnew', sightml='$sightmlnew'
$fieldadd WHERE uid='$uid'");
$db->query("REPLACE INTO {$tablepre}onlinetime (uid, thismonth, total)
VALUES ('$uid', '$thismonthnew', '$totalnew')");
manyoulog('user', $uid, 'update');
cpmsg('members_edit_succeed', $BASESCRIPT.'?action=members&operation=edit&uid='.$uid, 'succeed');
}
} elseif($operation == 'ipban') {
if(!submitcheck('ipbansubmit')) {
require_once DISCUZ_ROOT.'./include/misc.func.php';
$iptoban = explode('.', $ip);
$ipbanned = '';
$query = $db->query("SELECT * FROM {$tablepre}banned ORDER BY dateline");
while($banned = $db->fetch_array($query)) {
for($i = 1; $i <= 4; $i++) {
if($banned["ip$i"] == -1) {
$banned["ip$i"] = '*';
}
}
$disabled = $adminid != 1 && $banned['admin'] != $discuz_userss ? 'disabled' : '';
$banned['dateline'] = gmdate($dateformat, $banned['dateline'] + $timeoffset * 3600);
$banned['expiration'] = gmdate($dateformat, $banned['expiration'] + $timeoffset * 3600);
$theip = "$banned[ip1].$banned[ip2].$banned[ip3].$banned[ip4]";
$ipbanned .= showtablerow('', array('class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$banned[id]]\" value=\"$banned[id]\" $disabled />",
$theip,
convertip($theip, "./"),
$banned[admin],
$banned[dateline],
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"expirationnew[$banned[id]]\" value=\"$banned[expiration]\" $disabled />"
), TRUE);
}
shownav('user', 'nav_members_ipban');
showsubmenu('nav_members_ipban');
showtips('members_ipban_tips');
showformheader('members&operation=ipban');
showtableheader();
showsubtitle(array('', 'ip', 'members_ipban_location', 'operator', 'start_time', 'end_time'));
echo $ipbanned;
showtablerow('', array('', 'class="td28" colspan="3"', 'class="td28" colspan="2"'), array(
$lang['add_new'],
'<input type="text" class="txt" name="ip1new" value="'.$iptoban[0].'" size="3" maxlength="3">.<input type="text" class="txt" name="ip2new" value="'.$iptoban[1].'" size="3" maxlength="3">.<input type="text" class="txt" name="ip3new" value="'.$iptoban[2].'" size="3" maxlength="3">.<input type="text" class="txt" name="ip4new" value="'.$iptoban[3].'" size="3" maxlength="3">',
$lang['validity'].': <input type="text" class="txt" name="validitynew" value="30" size="3"> '.$lang['days']
));
showsubmit('ipbansubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}banned WHERE id IN ($ids) AND ('$adminid'='1' OR admin='$discuz_user')");
}
if($ip1new != '' && $ip2new != '' && $ip3new != '' && $ip4new != '') {
$own = 0;
$ip = explode('.', $onlineip);
for($i = 1; $i <= 4; $i++) {
if(!is_numeric(${'ip'.$i.'new'}) || ${'ip'.$i.'new'} < 0) {
if($adminid != 1) {
cpmsg('members_ipban_nopermission', '', 'error');
}
${'ip'.$i.'new'} = -1;
$own++;
} elseif(${'ip'.$i.'new'} == $ip[$i - 1]) {
$own++;
}
${'ip'.$i.'new'} = intval(${'ip'.$i.'new'});
}
if($own == 4) {
cpmsg('members_ipban_illegal', '', 'error');
}
$query = $db->query("SELECT * FROM {$tablepre}banned");
while($banned = $db->fetch_array($query)) {
$exists = 0;
for($i = 1; $i <= 4; $i++) {
if($banned["ip$i"] == -1) {
$exists++;
} elseif($banned["ip$i"] == ${"ip".$i."new"}) {
$exists++;
}
}
if($exists == 4) {
cpmsg('members_ipban_invalid', '', 'error');
}
}
$expiration = $timestamp + $validitynew * 86400;
$db->query("UPDATE {$tablepre}sessions SET groupid='6' WHERE ('$ip1new'='-1' OR ip1='$ip1new') AND ('$ip2new'='-1' OR ip2='$ip2new') AND ('$ip3new'='-1' OR ip3='$ip3new') AND ('$ip4new'='-1' OR ip4='$ip4new')");
$db->query("INSERT INTO {$tablepre}banned (ip1, ip2, ip3, ip4, admin, dateline, expiration)
VALUES ('$ip1new', '$ip2new', '$ip3new', '$ip4new', '$discuz_user', '$timestamp', '$expiration')");
}
if(is_array($expirationnew)) {
foreach($expirationnew as $id => $expiration) {
$db->query("UPDATE {$tablepre}banned SET expiration='".strtotime($expiration)."' WHERE id='$id' AND ('$adminid'='1' OR admin='$discuz_user')");
}
}
updatecache('ipbanned');
cpmsg('members_ipban_succeed', $BASESCRIPT.'?action=members&operation=ipban', 'succeed');
}
}
function searchmembers($operation = '') {
global $db, $tablepre, $usergroupid, $username, $srchemail, $lower, $higher, $extcredits, $submit, $lang;
$groupselect = array();
$usergroupid = isset($usergroupid) && is_array($usergroupid) ? $usergroupid : array();
$query = $db->query("SELECT type, groupid, grouptitle, radminid FROM {$tablepre}usergroups WHERE groupid NOT IN ('6', '7') ORDER BY (creditshigher<>'0' || creditslower<>'0'), creditslower, groupid");
while($group = $db->fetch_array($query)) {
$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
$groupselect[$group['type']] .= "<option value=\"$group[groupid]\" ".(in_array($group['groupid'], $usergroupid) ? 'selected' : '').">$group[grouptitle]</option>\n";
}
$groupselect = '<optgroup label="'.$lang['usergroups_member'].'">'.$groupselect['member'].'</optgroup>'.
($groupselect['special'] ? '<optgroup label="'.$lang['usergroups_special'].'">'.$groupselect['special'].'</optgroup>' : '').
($groupselect['specialadmin'] ? '<optgroup label="'.$lang['usergroups_specialadmin'].'">'.$groupselect['specialadmin'].'</optgroup>' : '').
'<optgroup label="'.$lang['usergroups_system'].'">'.$groupselect['system'].'</optgroup>';
$monthselect = $dayselect = '';
for($m=1; $m<=12; $m++) {
$m = sprintf("%02d", $m);
$monthselect .= "<option value=\"$m\" ".($birthmonth == $m ? 'selected' : '').">$m</option>\n";
}
for($d=1; $d<=31; $d++) {
$d = sprintf("%02d", $d);
$dayselect .= "<option value=\"$d\" ".($birthday == $d ? 'selected' : '').">$d</option>\n";
}
showtagheader('div', 'searchmembers', !$submit);
echo '<script src="include/js/calendar.js" type="text/javascript"></script>';
showformheader("members&operation=$operation", "onSubmit=\"if($('updatecredittype1') && $('updatecredittype1').checked && !window.confirm('$lang[members_reward_clean_alarm]')){return false;} else {return true;}\"");
showtableheader();
showsetting('members_search_user', 'username', $username, 'text');
showsetting('members_search_uid', 'uid', $uid, 'text');
showsetting('members_search_group', '', '', '<select name="usergroupid[]" multiple="multiple" size="10"><option value="all"'.(in_array('all', $usergroupid) ? ' selected' : '').'>'.lang('unlimited').'</option>'.$groupselect.'</select>');
showtagheader('tbody', 'advanceoption');
showsetting('members_search_email', 'srchemail', $srchemail, 'text');
showsetting("$lang[credits] $lang[members_search_between]", array("higher[credits]", "lower[credits]"), array($higher[credits], $lower[credits]), 'range');
if(!empty($extcredits)) {
foreach($extcredits as $id => $credit) {
showsetting("$credit[title] $lang[members_search_between]", array("higher[extcredits$id]", "lower[extcredits$id]"), array($higher['extcredits'.$id], $lower['extcredits'.$id]), 'range');
}
}
showsetting('members_search_postsrange', array('postshigher', 'postslower'), array($postshigher, $postslower), 'range');
showsetting('members_search_regip', 'regip', $regip, 'text');
showsetting('members_search_lastip', 'lastip', $lastip, 'text');
showsetting('members_search_regdaterange', array('regdateafter', 'regdatebefore'), array($regdateafter, $regdatebefore), 'daterange');
showsetting('members_search_lastvisitrange', array('lastvisitafter', 'lastvisitbefore'), array($lastvisitafter, $lastvisitbefore), 'daterange');
showsetting('members_search_lastpostrange', array('lastpostafter', 'lastpostbefore'), array($lastpostafter, $lastpostbefore), 'daterange');
showsetting('members_search_birthday', '', '', '<input type="text" class="txt" name="birthyear" style="width:86px; margin-right:0" value="'.dhtmlspecialchars($year).'"> '.$lang['year'].' <input type="text" class="txt" name="birthmonth" style="width:45px; margin-right:0" value="'.dhtmlspecialchars($month).'"> '.$lang['month'].' <input type="text" class="txt" name="birthday" style="width:45px; margin-right:0" value="'.dhtmlspecialchars($day).'"> '.$lang['day']);
showtagfooter('tbody');
showsubmit('submit', $operation == 'clean' ? 'members_delete' : 'search', '', 'more_options');
showtablefooter();
showformfooter();
showtagfooter('div');
}
function countmembers() {
extract($GLOBALS, EXTR_SKIP);
global $memberperpage, $page, $start_limit, $membernum, $conditions, $urladd;
$memberperpage = 100;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $memberperpage;
$dateoffset = date('Z') - ($timeoffset * 3600);
$username = trim($username);
$conditions = '';
if($username != '') {
$usernames = explode(',', $username);
foreach($usernames as $u) {
$usernameary[] = " username LIKE '".str_replace(array('%', '*', '_'), array('\%', '%', '\_'), $u)."'";
}
$conditions .= " AND (".implode(' OR ', $usernameary).")";
}
$conditions .= intval($uid) ? " AND uid='".intval($uid)."'" : '';
$conditions .= $srchemail != '' ? " AND email LIKE '".str_replace('*', '%', $srchemail)."'" : '';
$conditions .= !empty($usergroupid) && !in_array('all', $usergroupid) != '' ? " AND groupid IN ('".implode('\',\'', $usergroupid)."')" : '';
if(is_array($higher)) {
foreach($higher as $credit => $value) {
$credit = intval(substr($credit, 10));
if($value != '' && $credit > 0 && $credit < 9) {
$value = intval($value);
$conditions .= " AND extcredits$credit>'$value'";
}
}
}
if(is_array($lower)) {
foreach($lower as $credit => $value) {
$credit = intval(substr($credit, 10));
if($value != '' && $credit > 0 && $credit < 9) {
$value = intval($value);
$conditions .= " AND extcredits$credit<'$value'";
}
}
}
$conditions .= $postshigher != '' ? " AND posts>'$postshigher'" : '';
$conditions .= $postslower != '' ? " AND posts<'$postslower'" : '';
$conditions .= $higher['credits'] != '' ? " AND credits>'$higher[credits]'" : '';
$conditions .= $lower['credits'] != '' ? " AND credits<'$lower[credits]'" : '';
$conditions .= $regip != '' ? " AND regip LIKE '$regip%'" : '';
$conditions .= $lastip != '' ? " AND lastip LIKE '$lastip%'" : '';
$conditions .= $regdatebefore != '' ? " AND regdate<'".strtotime($regdatebefore)."'" : '';
$conditions .= $regdateafter != '' ? " AND regdate>'".strtotime($regdateafter)."'" : '';
$conditions .= $lastvisitafter != '' ? " AND lastvisit>'".strtotime($lastvisitafter)."'" : '';
$conditions .= $lastvisitbefore != '' ? " AND lastvisit<'".strtotime($lastvisitbefore)."'" : '';
$conditions .= $lastpostafter != '' ? " AND lastpost>'".strtotime($lastpostafter)."'" : '';
$conditions .= $lastpostbefore != '' ? " AND lastpost<'".strtotime($lastpostbefore)."'" : '';
$conditions .= $repeatip != '' ? $repeatip : '';
$conditions .= $birthyear != '' || $birthmonth != '' || $birthday != '' ? " AND bday LIKE '".(($birthyear ? $birthyear : '%').'-'.($birthmonth? $birthmonth : '%').'-'.($birthday ? $birthday : '%'))."'" : '';
$conditions .= $operation == 'newsletter' && (submitcheck('submit') || submitcheck('sendsubmit', 1) || submitcheck('newslettersubmit', 1)) ? " AND newsletter='1'" : '';
if(!$conditions && !$uidarray && $operation == 'clean') {
cpmsg('members_search_invalid', '', 'error');
} else {
$conditions = '1'.$conditions;
}
$urladd = "&username=".rawurlencode($username)."&uid=".intval($uid)."&srchemail=".rawurlencode($srchemail)."®datebefore=".rawurlencode($regdatebefore)."®dateafter=".rawurlencode($regdateafter)."&postshigher=".rawurlencode($postshigher)."&postslower=".rawurlencode($postslower)."®ip=".rawurlencode($regip)."&lastip=".rawurlencode($lastip)."&lastvisitafter=".rawurlencode($lastvisitafter)."&lastvisitbefore=".rawurlencode($lastvisitbefore)."&lastpostafter=".rawurlencode($lastpostafter)."&lastpostbefore=".rawurlencode($lastpostbefore)."&birthyear=".rawurlencode($birthyear)."&birthmonth=".rawurlencode($birthmonth)."&birthday=".rawurlencode($birthday);
if(is_array($usergroupid)) {
foreach($usergroupid as $gid => $value) {
if($value != '') {
$urladd .= '&usergroupid[]='.rawurlencode($value);
}
}
}
foreach(array('lower', 'higher') as $key) {
if(is_array($$key)) {
foreach($$key as $column => $value) {
$urladd .= '&'.$key.'['.$column.']='.rawurlencode($value);
}
}
}
$membernum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}members WHERE $conditions");
}
function shownewsletter() {
extract($GLOBALS, EXTR_SKIP);
$subject = $message = '';
if($settings = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='$variable'")) {
$settings = unserialize($settings);
$subject = $settings['subject'];
$message = $settings['message'];
}
showtablerow('', array('class="th11"', 'class="longtxt"'), array(
$lang['members_newsletter_subject'],
'<input type="text" class="txt" name="subject" size="80" value='.dhtmlspecialchars($subject).'>'
));
showtablerow('', array('class="th12"', ''), array(
$lang['members_newsletter_message'],
'<textarea name="message" class="tarea" cols="80" rows="10">'.dhtmlspecialchars($message).'</textarea>'
));
showtablerow('', array('', 'class="td12"'), array(
'',
'<ul><li><input class="radio" type="radio" value="email" name="sendvia" id="viaemail" /><label for="viaemail"> '.$lang['email'].'</label></li><li><input class="radio" type="radio" value="pm" checked="checked" name="sendvia" id="viapm" /><label for="viapm"> '.$lang['pm'].'</label></li><li><span class="diffcolor2">'.$lang['members_newsletter_num'].'</span><input type="text" class="txt" name="pertask" value="100" size="10"></li></ul>'
));
}
function notifymembers($operation, $variable) {
extract($GLOBALS, EXTR_SKIP);
if(!empty($current)) {
$subject = $message = '';
if($settings = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='$variable'")) {
$settings = unserialize($settings);
$subject = $settings['subject'];
$message = $settings['message'];
}
} else {
$current = 0;
$subject = trim($subject);
$message = trim(str_replace("\t", ' ', $message));
if($notifymembers && !($subject && $message)) {
cpmsg('members_newsletter_sm_invalid', '', 'error');
}
if($operation == 'reward') {
$updatesql = '';
if($updatecredittype == 0) {
if(is_array($addextcredits) && !empty($addextcredits)) {
foreach($addextcredits as $key => $value) {
$value = intval($value);
if(isset($extcredits[$key]) && !empty($value)) {
$updatesql .= ", extcredits{$key}=extcredits{$key}+($value)";
}
}
}
} else {
if(is_array($resetextcredits) && !empty($resetextcredits)) {
foreach($resetextcredits as $key => $value) {
$value = intval($value);
if(isset($extcredits[$key]) && !empty($value)) {
$updatesql .= ", extcredits{$key}=0";
}
}
}
}
if(!empty($updatesql)) {
$db->query("UPDATE {$tablepre}members set uid=uid $updatesql WHERE $conditions", 'UNBUFFTERED');
} else {
cpmsg('members_reward_invalid', '', 'error');
}
if(!$notifymembers) {
cpmsg('members_reward_succeed', '', 'succeed');
}
} elseif ($operation == 'confermedal') {
$medals = $_POST['medals'];
if(!empty($medals)) {
$medalids = $comma = '';
foreach($medals as $key=> $medalid) {
$medalids .= "$comma'$key'";
$comma = ',';
}
$medalsnew = $comma = '';
$medalsnewarray = $medalidarray = array();
$query = $db->query("SELECT medalid, expiration FROM {$tablepre}medals WHERE medalid IN ($medalids) ORDER BY displayorder");
while($medal = $db->fetch_array($query)) {
$medal['status'] = empty($medal['expiration']) ? 0 : 1;
$medal['expiration'] = empty($medal['expiration'])? 0 : $timestamp + $medal['expiration'] * 86400;
$medal['medal'] = $medal['medalid'].(empty($medal['expiration']) ? '' : '|'.$medal['expiration']);
$medalsnew .= $comma.$medal['medal'];
$medalsnewarray[] = $medal;
$medalidarray[] = $medal['medalid'];
$comma = "\t";
}
$uids = array();
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE $conditions");
while ($medaluid = $db->fetch_array($query)) {
$uids[] = $medaluid['uid'];
}
$query = $db->query("SELECT uid, medals FROM {$tablepre}memberfields WHERE uid IN (".implode(',', $uids).")");
while($medalnew = $db->fetch_array($query)) {
$addmedalnew = '';
if(empty($medalnew['medals'])) {
$addmedalnew = $medalsnew;
} else {
foreach($medalidarray as $medalid) {
if(!in_array($medalid, explode("\t", $medalnew['medals']))){
$addmedalnew .= $medalid."\t";
}
}
$addmedalnew .= $medalnew['medals'];
}
$db->query("UPDATE {$tablepre}memberfields SET medals='".$addmedalnew."' WHERE uid='".$medalnew['uid']."'", 'UNBUFFTERED');
foreach($medalsnewarray as $medalnewarray) {
$db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('".$medalnew['uid']."', '".$medalnewarray['medalid']."', '0', '$timestamp', '".$medalnewarray['expiration']."', '".$medalnewarray['status']."')");
}
}
}
if(!$notifymembers) {
cpmsg('members_confermedal_succeed', '', 'succeed');
}
}
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('$variable', '".
addslashes(serialize(array('subject' => $subject, 'message' => $message)))."')");
}
$pertask = intval($pertask);
$current = intval($current);
$continue = FALSE;
if(in_array($sendvia, array('pm', 'email'))) {
$query = $db->query("SELECT uid, username, groupid, email FROM {$tablepre}members WHERE $conditions LIMIT $current, $pertask");
while($member = $db->fetch_array($query)) {
$sendvia == 'pm' ? sendpm($member['uid'], $subject, $message, 0) : sendmail("$member[username] <$member[email]>", $subject, $message);
$continue = TRUE;
}
}
if($continue) {
$next = $current + $pertask;
eval("\$lang[members_newsletter_processing] = \"".$lang['members_newsletter_processing']."\";");
cpmsg("$lang[members_newsletter_send]: $lang[members_newsletter_processing]", "$BASESCRIPT?action=members&operation=$operation&{$operation}submit=yes¤t=$next&pertask=$pertask&sendvia=".rawurlencode($sendvia).$urladd, 'loading');
} else {
cpmsg('members'.($operation ? '_'.$operation : '').'_notify_succeed', '', 'succeed');
}
}
function banlog($username, $origgroupid, $newgroupid, $expiration, $reason) {
global $discuz_userss, $groupid, $onlineip, $timestamp, $forum, $reason;
writelog('banlog', dhtmlspecialchars("$timestamp\t$discuz_userss\t$groupid\t$onlineip\t$username\t$origgroupid\t$newgroupid\t$expiration\t$reason"));
}
function selectday($varname, $dayarray) {
global $timestamp, $dateformat, $timeformat, $timeoffset, $lang;
$selectday = '<select name="'.$varname.'">';
if($dayarray && is_array($dayarray)) {
foreach($dayarray as $day) {
$langday = $day.'_day';
$daydate = $day ? '('.gmdate("$dateformat $timeformat", ($timestamp + $day * 86400) + $timeoffset * 3600).')' : '';
$selectday .= '<option value='.$day.'>'.$lang[$langday].' '.$daydate.'</option>';
}
}
$selectday .= '</select>';
return $selectday;
}
function accessimg($access) {
return $access == -1 ? '<img src="images/common/access_disallow.gif" />' :
($access == 1 ? '<img src="images/common/access_allow.gif" />' : '<img src="images/common/access_normal.gif" />');
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/members.inc.php | PHP | asf20 | 87,123 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: magics.inc.php 18917 2009-08-03 01:48:48Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$operation = $operation ? $operation : 'admin';
if($operation == 'admin') {
if(!submitcheck('magicsubmit')) {
shownav('extended', 'magics', 'admin');
showsubmenu('nav_magics', array(
array('config', 'magics&operation=config', 0),
array('admin', 'magics&operation=admin', 1),
array('nav_magics_market', 'magics&operation=market', 0)
));
showtips('magics_tips');
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" size="3" name="newdisplayorder[]">', 'td28'],
[1,'', 'td25'],
[1,'', 'td28'],
[1,'<input type="text" class="txt" size="10" name="newname[]">', ''],
[1,'<input type="text" class="txt" size="25" name="newdescription[]">', 'td28'],
[1,'<input type="text" class="txt" size="5" name="newprice[]">', 'td28'],
[1,'<input type="text" class="txt" size="5" name="newnum[]">', 'td23'],
[1,'<select name="newtype[]"><option value="1" selected>$lang[magics_type_1]</option><option value="2">$lang[magics_type_2]</option><option value="4">$lang[magics_type_4]</option><option value="3">$lang[magics_type_3]</option></select>', 'td25'],
[1,'<input type="text" class="txt" size="5" name="newidentifier[]">', 'td25'],
[1,'', 'td25']
]
];
</script>
EOT;
showformheader('magics&operation=admin');
showtableheader('magics_edit');
showsubtitle(array('', 'display_order', 'available', 'magic_recommend', 'name', 'description', 'price', 'num', 'type', 'magics_identifier'));
$magiclist = '';
$addtype = $typeid ? "WHERE type='".intval($typeid)."'" : '';
$query = $db->query("SELECT * FROM {$tablepre}magics $addtype ORDER BY displayorder");
while($magic = $db->fetch_array($query)) {
$magictype = $lang['magics_type_'.$magic['type']];
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td28"', '', 'class="td28"', 'class="td28"', 'class="td23"', 'class="td25"', 'class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$magic[magicid]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$magic[magicid]]\" value=\"$magic[displayorder]\">",
"<input type=\"checkbox\" class=\"checkbox\" name=\"available[$magic[magicid]]\" value=\"1\" ".(!$magic['name'] || !$magic['identifier'] || !$magic['filename'] ? 'disabled' : ($magic['available'] ? 'checked' : '')).">",
"<input type=\"checkbox\" class=\"checkbox\" name=\"recommend[$magic[magicid]]\" value=\"1\" ".(!$magic['name'] || !$magic['identifier'] || !$magic['filename'] ? 'disabled' : ($magic['recommend'] ? 'checked' : '')).">",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"name[$magic[magicid]]\" value=\"$magic[name]\">",
"<input type=\"text\" class=\"txt\" size=\"25\" name=\"description[$magic[magicid]]\" value=\"$magic[description]\">",
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"price[$magic[magicid]]\" value=\"$magic[price]\">",
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"num[$magic[magicid]]\" value=\"$magic[num]\">",
"<a href=\"$BASESCRIPT?action=magics&operation=admin&typeid=$magic[type]\">$magictype</a>",
"<input type=\"hidden\" name=\"identifier[$magic[magicid]]\" value=\"$magic[identifier]\">$magic[identifier]",
"<a href=\"$BASESCRIPT?action=magics&operation=edit&magicid=$magic[magicid]\" class=\"act\">$lang[detail]</a>"
));
}
echo '<tr><td></td><td colspan="9"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['magics_add'].'</a></div></td></tr>';
showsubmit('magicsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}magics WHERE magicid IN ($ids)");
$db->query("DELETE FROM {$tablepre}membermagics WHERE magicid IN ($ids)");
$db->query("DELETE FROM {$tablepre}magicmarket WHERE magicid IN ($ids)");
$db->query("DELETE FROM {$tablepre}magiclog WHERE magicid IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}magics SET available='$available[$id]', name='$name[$id]', identifier='$identifier[$id]', description='$description[$id]', displayorder='$displayorder[$id]', price='$price[$id]', num='$num[$id]', recommend='$recommend[$id]' WHERE magicid='$id'");
}
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
$value = dhtmlspecialchars(trim($value));
$newidentifier = dhtmlspecialchars(trim(strtoupper($newidentifier[$key])));
if($value) {
$query = $db->query("SELECT magicid FROM {$tablepre}magics WHERE identifier='$newidentifier[$key]'");
if($db->num_rows($query)) {
cpmsg('magics_identifier_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}magics (type, name, identifier, description, displayorder, price, num) VALUES ('$newtype[$key]', '$value', '$newidentifier', '$newdescription[$key]', '$newdisplayorder[$key]', '$newprice[$key]', '$newnum[$key]')");
}
}
}
updatecache('magics');
cpmsg('magics_data_succeed', $BASESCRIPT.'?action=magics&operation=admin', 'succeed');
}
} elseif($operation == 'config') {
if(!submitcheck('magicsubmit')) {
$settings = array();
$query = $db->query("SELECT variable, value FROM {$tablepre}settings WHERE variable IN ('magicstatus', 'magicmarket', 'maxmagicprice', 'magicdiscount')");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
shownav('extended', 'magics', 'config');
showsubmenu('nav_magics', array(
array('config', 'magics&operation=config', 1),
array('admin', 'magics&operation=admin', 0),
array('nav_magics_market', 'magics&operation=market', 0)
));
showformheader('magics&operation=config');
showtableheader();
showsetting('magics_config_open', 'settingsnew[magicstatus]', $settings['magicstatus'], 'radio');
showsetting('magics_config_market_open', 'settingsnew[magicmarket]', $settings['magicmarket'], 'radio');
showsetting('magics_config_market_percent', 'settingsnew[maxmagicprice]', $settings['maxmagicprice'], 'text');
showsetting('magics_config_discount', 'settingsnew[magicdiscount]', $settings['magicdiscount'], 'text');
showtablerow('', 'colspan="2"', '<input type="submit" class="btn" name="magicsubmit" value="'.$lang['submit'].'" />');
showtablefooter();
showformfooter();
} else {
if(is_array($settingsnew)) {
foreach($settingsnew as $variable => $value) {
$db->query("UPDATE {$tablepre}settings SET value='$value' WHERE variable='$variable'");
}
}
updatecache('settings');
cpmsg('magics_config_succeed', $BASESCRIPT.'?action=magics&operation=config', 'succeed');
}
} elseif($operation == 'edit') {
if(!submitcheck('magiceditsubmit')) {
$magicid = intval($magicid);
$magic = $db->fetch_first("SELECT * FROM {$tablepre}magics WHERE magicid='$magicid'");
$magicperm = unserialize($magic['magicperm']);
$groups = $fourms = array();
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$groups[$group['groupid']] = $group['grouptitle'];
}
$query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE type NOT IN ('group') AND status='1'");
while($forum = $db->fetch_array($query)) {
$forums[$forum['fid']] = $forum['name'];
}
$typeselect = array($magic['type'] => 'selected');
shownav('extended', 'magics', 'admin');
showsubmenu('nav_magics', array(
array('config', 'magics&operation=config', 0),
array('admin', 'magics&operation=admin', 1),
array('nav_magics_market', 'magics&operation=market', 0)
));
showtips('magics_edit_tips');
showformheader('magics&operation=edit&magicid='.$magicid);
showtableheader();
showtitle($lang['magics_edit'].' - '.$magic['name']);
showsetting('magics_edit_name', 'namenew', $magic['name'], 'text');
showsetting('magics_edit_identifier', 'identifiernew', $magic['identifier'], 'text');
showsetting('magics_edit_type', '', '', '<select name="typenew"><option value="1" '.$typeselect[1].'>'.$lang['magics_type_1'].'</option><option value="2" '.$typeselect[2].'>'.$lang['magics_type_2'].'</option><option value="4" '.$typeselect[4].'>'.$lang['magics_type_4'].'</option><option value="3" '.$typeselect[3].'>'.$lang['magics_type_3'].'</option></select>');
showsetting('magics_edit_price', 'pricenew', $magic['price'], 'text');
showsetting('magics_edit_num', 'numnew', $magic['num'], 'text');
showsetting('magics_edit_weight', 'weightnew', $magic['weight'], 'text');
showsetting('magics_edit_supplytype', array('supplytypenew', array(
array(0, $lang['magics_goods_stack_none']),
array(1, $lang['magics_goods_stack_day']),
array(2, $lang['magics_goods_stack_week']),
array(3, $lang['magics_goods_stack_month']),
)), $magic['supplytype'], 'mradio');
showsetting('magics_edit_supplynum', 'supplynumnew', $magic['supplynum'], 'text');
showsetting('magics_edit_filename', 'filenamenew', $magic['filename'], 'text');
showsetting('magics_edit_description', 'descriptionnew', $magic['description'], 'textarea');
if($magic['type'] == 4) {
showtablefooter();
showtableheader('magics_edit_present');
showsubtitle(array('', 'name', 'num'));
$presentmagiclist = '';
$query = $db->query("SELECT magicid, name, weight FROM {$tablepre}magics WHERE type!='4' ORDER BY displayorder");
while($magic = $db->fetch_array($query)) {
$num = $magicperm['presentcontent'][$magic['magicid']]['num'];
$check = $magicperm['presentcontent'][$magic['magicid']] ? 'checked="checked"' : '';
showtablerow('', array('class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"magiccontent[$magic[magicid]]\" value=\"$magic[magicid]\" $check>",
"$magic[name] <input type=\"hidden\" name=\"weight[$magic[magicid]]\" value=\"$magic[weight]\">",
"<input type=\"text\" class=\"text\" name=\"getnum[$magic[magicid]]\" value=\"$num\">"
));
}
showtablefooter();
showtableheader();
}
showtitle('magics_edit_perm');
showtablerow('', 'class="td27"', $lang['magics_edit_usergroupperm'].':<input class="checkbox" type="checkbox" name="chkall1" onclick="checkAll(\'prefix\', this.form, \'usergroupsperm\', \'chkall1\', true)" id="chkall1" /><label for="chkall1"> '.lang('select_all').'</label>');
showtablerow('', 'colspan="2"', mcheckbox('usergroupsperm', $groups, explode("\t", $magicperm['usergroups'])));
if($magic['type'] == 2 || $magic['type'] == 3) {
showtablerow('', 'class="td27"', $lang['magics_edit_targetgroupperm'].':<input class="checkbox" type="checkbox" name="chkall2" onclick="checkAll(\'prefix\', this.form, \'targetgroupsperm\', \'chkall2\', true)" id="chkall2" /><label for="chkall2"> '.lang('select_all').'</label>');
showtablerow('', 'colspan="2"', mcheckbox('targetgroupsperm', $groups, explode("\t", $magicperm['targetgroups'])));
}
if($magic['type'] == 1) {
showtablerow('', 'class="td27"', $lang['magics_edit_forumperm'].':<input class="checkbox" type="checkbox" name="chkall3" onclick="checkAll(\'prefix\', this.form, \'forumperm\', \'chkall3\', true)" id="chkall3" /><label for="chkall3"> '.lang('select_all').'</label>');
showtablerow('', 'colspan="2"', mcheckbox('forumperm', $forums, explode("\t", $magicperm['forum'])));
}
showsubmit('magiceditsubmit');
showtablefooter();
showformfooter();
} else {
$namenew = dhtmlspecialchars(trim($namenew));
$identifiernew = dhtmlspecialchars(trim(strtoupper($identifiernew)));
$descriptionnew = dhtmlspecialchars($descriptionnew);
$filenamenew = dhtmlspecialchars($filenamenew);
$typenew = ($typenew > 0 && $typenew <= 4) ? $typenew : 1;
$availablenew = !$identifiernew || !$filenamenew ? 0 : 1;
if($typenew == 4) {
$magicperm['presentcontent'] = array();
if(is_array($magiccontent)) {
foreach($magiccontent as $id => $val) {
$num = $getnum[$id] ? intval($getnum[$id]) : 1;
$magicperm['presentcontent'][$id] = array('num' => $num, 'weight' => $weight[$id]);
}
} else {
cpmsg('magics_present_invalid', '', 'error');
}
}
$magicperm['usergroups'] = is_array($usergroupsperm) && !empty($usergroupsperm) ? "\t".implode("\t",$usergroupsperm)."\t" : '';
$magicperm['targetgroups'] = is_array($targetgroupsperm) && !empty($targetgroupsperm) ? "\t".implode("\t",$targetgroupsperm)."\t" : '';
$magicperm['forum'] = is_array($forumperm) && !empty($forumperm) ? "\t".implode("\t",$forumperm)."\t" : '';
$magicpermnew = addslashes(serialize($magicperm));
$supplytypenew = intval($supplytypenew);
$supplynumnew = $supplytypenew ? intval($supplynumnew) : 0;
if(!$namenew) {
cpmsg('magics_parameter_invalid', '', 'error');
}
$query = $db->query("SELECT magicid FROM {$tablepre}magics WHERE identifier='$identifiernew' AND magicid!='$magicid'");
if($db->num_rows($query)) {
cpmsg('magics_identifier_invalid', '', 'error');
}
if(preg_match("/[\\\\\/\:\*\?\"\<\>\|]+/", $filenamenew)) {
cpmsg('magics_filename_illegal', '', 'error');
} elseif(!is_readable(DISCUZ_ROOT.($magicfile = "./include/magic/$filenamenew"))) {
cpmsg('magics_filename_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}magics SET available='$availablenew', type='$typenew', name='$namenew', identifier='$identifiernew', description='$descriptionnew', price='$pricenew', num='$numnew', supplytype='$supplytypenew', supplynum='$supplynumnew', weight='$weightnew', filename='$filenamenew', magicperm='$magicpermnew' WHERE magicid='$magicid'");
updatecache('magics');
cpmsg('magics_data_succeed', $BASESCRIPT.'?action=magics&operation=admin', 'succeed');
}
} elseif($operation == 'market') {
if(!submitcheck('marketsubmit')) {
shownav('extended', 'magics', 'nav_magics_market');
showsubmenu('nav_magics', array(
array('config', 'magics&operation=config', 0),
array('admin', 'magics&operation=admin', 0),
array('nav_magics_market', 'magics&operation=market', 1)
));
showformheader('magics&operation=market');
showtableheader('magics_market');
showsubtitle(array('', 'name', 'description', 'magics_market_seller', 'price', 'num', 'weight'));
$marketlist = '';
$query = $db->query("SELECT ma.*, m.name, m.description, m.weight FROM {$tablepre}magicmarket ma, {$tablepre}magics m WHERE m.magicid=ma.magicid");
while($market = $db->fetch_array($query)) {
$market['weight'] = $market['weight'] * $market['num'];
showtablerow('', array('class="td25"', 'class="bold"', '', 'class="td28"', 'class="td28"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$market[mid]\">",
$market[name],
$market[description],
$market[username],
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"price[$market[mid]]\" value=\"$market[price]\">",
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"num[$market[mid]]\" value=\"$market[num]\">",
$market[weight]
));
}
showsubmit('marketsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}magicmarket WHERE mid IN ($ids)");
}
if(is_array($price)) {
foreach($price as $id => $val) {
$db->query("UPDATE {$tablepre}magicmarket SET price='$price[$id]', num='$num[$id]' WHERE mid='$id'");
}
}
cpmsg('magics_data_succeed', $BASESCRIPT.'?action=magics&operation=market', 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/magics.inc.php | PHP | asf20 | 16,143 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tradelog.inc.php 18655 2009-07-08 10:28:06Z wangjinbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./include/trade.func.php';
include_once language('misc');
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$filter = !isset($filter) ? -1 : $filter;
$sqlfilter = $filter >= 0 ? "WHERE status='$filter'" : '';
$count = $db->fetch_first("SELECT sum(price) AS pricesum, sum(tax) AS taxsum FROM {$tablepre}tradelog status $sqlfilter");
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}tradelog $sqlfilter");
$multipage = multi($num, $tpp, $page, "$BASESCRIPT?action=tradelog&filter=$filter");
$query = $db->query("SELECT * FROM {$tablepre}tradelog $sqlfilter ORDER BY lastupdate DESC LIMIT $start_limit, $tpp");
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_tenpay', 'ec&operation=tenpay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 1)
));
showtableheader();
showsubtitle(array('tradelog_trade_no', 'tradelog_trade_name', 'tradelog_buyer', 'tradelog_seller', 'tradelog_money', 'tradelog_fee', 'tradelog_order_status'));
while($tradelog = $db->fetch_array($query)) {
$tradelog['status'] = trade_getstatus($tradelog['status']);
$tradelog['lastupdate'] = gmdate("$dateformat $timeformat", $tradelog['lastupdate'] + $timeoffset * 3600);
$tradelog['tradeno'] = $tradelog['offline'] ? $lang['tradelog_offline'] : $tradelog['tradeno'];
showtablerow('', '', array(
$tradelog['tradeno'],
'<a target="_blank" href="viewthread.php?do=tradeinfo&tid='.$tradelog['tid'].'&pid='.$tradelog['pid'].'">'.$tradelog['subject'].'</a>',
'<a target="_blank" href="space.php?uid='.$tradelog['buyerid'].'">'.$tradelog['buyer'].'</a>',
'<a target="_blank" href="space.php?uid='.$tradelog['sellerid'].'">'.$tradelog['seller'].'</a>',
$tradelog['price'],
$tradelog['tax'],
'<a target="_blank" href="trade.php?orderid='.$tradelog['orderid'].'">'.$tradelog['status'].'<br />'.$tradelog['lastupdate']
));
}
$statusselect = $lang['tradelog_order_status'].': <select onchange="location.href=\''.$BASESCRIPT.'?action=tradelog&filter=\' + this.value"><option value="-1">'.$lang['tradelog_all_order'].'</option>';
$statuss = trade_getstatus(0, -1);
foreach($statuss as $key => $value) {
$statusselect .= "<option value=\"$key\" ".($filter == $key ? 'selected' : '').">$value</option>";
}
$statusselect .= '</select>';
showsubmit('', '', "$lang[tradelog_order_count] $num".($count['pricesum'] ? ", $lang[tradelog_trade_total] $count[pricesum] $lang[rmb_yuan], $lang[tradelog_fee_total] $count[taxsum] $lang[rmb_yuan]" : ''), '', $multipage.$statusselect);
showtablefooter();
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/tradelog.inc.php | PHP | asf20 | 3,151 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: prune.inc.php 21266 2009-11-24 05:35:06Z liulanbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$page = max(1, intval($page));
require_once DISCUZ_ROOT.'./include/misc.func.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
if(!submitcheck('prunesubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
if($adminid == 1 || $adminid == 2) {
$forumselect = '<select name="forums"><option value=""> > '.$lang['select'].'</option>'.
'<option value=""> </option>'.forumselect(FALSE, 0, 0, TRUE).'</select>';
if($forums) {
$forumselect = preg_replace("/(\<option value=\"$forums\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
}
} else {
$forumselect = $comma = '';
$query = $db->query("SELECT f.name FROM {$tablepre}moderators m, {$tablepre}forums f WHERE m.uid='$discuz_uid' AND m.fid=f.fid");
while($forum = $db->fetch_array($query)) {
$forumselect .= $comma.$forum['name'];
$comma = ', ';
}
$forumselect = $forumselect ? $forumselect : $lang['none'];
}
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? gmdate('Y-n-j', $timestamp + $timeoffset * 3600 - 86400 * 7) : $starttime;
$endtime = $adminid == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? gmdate('Y-n-j', $timestamp + $timeoffset * 3600) : $endtime;
shownav('topic', 'nav_prune');
showsubmenusteps('nav_prune', array(
array('prune_search', !$searchsubmit),
array('nav_prune', $searchsubmit)
));
showtips('prune_tips');
echo <<<EOT
<script type="text/javascript" src="include/js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('pruneforum').page.value=number;
$('pruneforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit);
showformheader("prune", '', 'pruneforum');
showhiddenfields(array('page' => $page));
showtableheader();
showsetting('prune_search_detail', 'detail', $detail, 'radio');
showsetting('prune_search_forum', '', '', $forumselect);
showsetting('prune_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
showsetting('prune_search_user', 'users', $users, 'text');
showsetting('prune_search_ip', 'useip', $useip, 'text');
showsetting('prune_search_keyword', 'keywords', $keywords, 'text');
showsetting('prune_search_lengthlimit', 'lengthlimit', $lengthlimit, 'text');
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
$tidsdelete = $pidsdelete = '0';
$pids = authcode($pids, 'DECODE');
$pidsadd = $pids ? 'pid IN ('.$pids.')' : 'pid IN ('.implodeids($pidarray).')';
$query = $db->query("SELECT fid, tid, pid, first, authorid FROM {$tablepre}posts WHERE $pidsadd");
while($post = $db->fetch_array($query)) {
$prune['forums'][] = $post['fid'];
$prune['thread'][$post['tid']]++;
$pidsdelete .= ",$post[pid]";
$tidsdelete .= $post['first'] ? ",$post[tid]" : '';
}
if($pidsdelete) {
require_once DISCUZ_ROOT.'./include/post.func.php';
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE pid IN ($pidsdelete) OR tid IN ($tidsdelete)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
if(!$donotupdatemember) {
$postsarray = $tuidarray = $ruidarray = array();
$query1 = $db->query("SELECT fid, pid, first, authorid FROM {$tablepre}posts WHERE pid IN ($pidsdelete)");
$query2 = $db->query("SELECT fid, pid, first, authorid FROM {$tablepre}posts WHERE tid IN ($tidsdelete)");
while(($post = $db->fetch_array($query1)) || ($post = $db->fetch_array($query2))) {
$forumpostsarray[$post['fid']][$post['pid']] = $post;
}
foreach($forumpostsarray as $fid => $postsarray) {
$query = $db->query("SELECT postcredits, replycredits FROM {$tablepre}forumfields WHERE fid='$fid'");
if($forum = $db->fetch_array($query)) {
$forum['postcredits'] = !empty($forum['postcredits']) ? unserialize($forum['postcredits']) : array();
$forum['replycredits'] = !empty($forum['replycredits']) ? unserialize($forum['replycredits']) : array();
}
$postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
$replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
$tuidarray = $ruidarray = array();
foreach($postsarray as $post) {
if($post['first']) {
$tuidarray[] = $post['authorid'];
} else {
$ruidarray[] = $post['authorid'];
}
}
if($tuidarray) {
updatepostcredits('-', $tuidarray, $postcredits);
}
if($ruidarray) {
updatepostcredits('-', $ruidarray, $replycredits);
}
}
}
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE pid IN ($pidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($tidsdelete)");
$deletedthreads = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pidsdelete)");
$deletedposts = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}posts WHERE tid IN ($tidsdelete)");
$deletedposts += $db->affected_rows();
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polls WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activities WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activityapplies WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}postposition WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
if(count($prune['thread']) < 50) {
foreach($prune['thread'] as $tid => $decrease) {
updatethreadcount($tid);
}
} else {
$repliesarray = array();
foreach($prune['thread'] as $tid => $decrease) {
$repliesarray[$decrease][] = $tid;
}
foreach($repliesarray as $decrease => $tidarray) {
$db->query("UPDATE {$tablepre}threads SET replies=replies-$decrease WHERE tid IN (".implode(',', $tidarray).")");
}
}
if($globalstick) {
updatecache('globalstick');
}
foreach(array_unique($prune['forums']) as $fid) {
updateforumcount($fid);
}
}
$deletedthreads = intval($deletedthreads);
$deletedposts = intval($deletedposts);
updatemodworks('DLP', $deletedposts);
eval("\$cpmsg = \"".lang('prune_succeed')."\";");
?>
<script type="text/JavaScript">alert('<?=$cpmsg?>');parent.$('pruneforum').searchsubmit.click();</script>
<?
}
if(submitcheck('searchsubmit')) {
$pids = $postcount = '0';
$sql = $error = '';
$keywords = trim($keywords);
$users = trim($users);
if(($starttime == '0' && $endtime == '0') || ($keywords == '' && $useip == '' && $users == '')) {
$error = 'prune_condition_invalid';
}
if($adminid == 1 || $adminid == 2) {
if($forums) {
$sql .= " AND p.fid='$forums'";
}
} else {
$forums = '0';
$query = $db->query("SELECT fid FROM {$tablepre}moderators WHERE uid='$discuz_uid'");
while($forum = $db->fetch_array($query)) {
$forums .= ','.$forum['fid'];
}
$sql .= " AND p.fid IN ($forums)";
}
if($users != '') {
$uids = '-1';
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE username IN ('".str_replace(',', '\',\'', str_replace(' ', '', $users))."')");
while($member = $db->fetch_array($query)) {
$uids .= ",$member[uid]";
}
$sql .= " AND p.authorid IN ($uids)";
}
if($useip != '') {
$sql .= " AND p.useip LIKE '".str_replace('*', '%', $useip)."'";
}
if($keywords != '') {
$sqlkeywords = '';
$or = '';
$keywords = explode(',', str_replace(' ', '', $keywords));
for($i = 0; $i < count($keywords); $i++) {
if(preg_match("/\{(\d+)\}/", $keywords[$i])) {
$keywords[$i] = preg_replace("/\\\{(\d+)\\\}/", ".{0,\\1}", preg_quote($keywords[$i], '/'));
$sqlkeywords .= " $or p.subject REGEXP '".$keywords[$i]."' OR p.message REGEXP '".$keywords[$i]."'";
} else {
$sqlkeywords .= " $or p.subject LIKE '%".$keywords[$i]."%' OR p.message LIKE '%".$keywords[$i]."%'";
}
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
}
if($lengthlimit != '') {
$lengthlimit = intval($lengthlimit);
$sql .= " AND LENGTH(p.message) < $lengthlimit";
}
if($starttime != '0') {
$starttime = strtotime($starttime);
$sql .= " AND p.dateline>'$starttime'";
}
if($adminid == 1 && $endtime != gmdate('Y-n-j', $timestamp + $timeoffset * 3600)) {
if($endtime != '0') {
$endtime = strtotime($endtime);
$sql .= " AND p.dateline<'$endtime'";
}
} else {
$endtime = $timestamp;
}
if(($adminid == 2 && $endtime - $starttime > 86400 * 16) || ($adminid == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'prune_mod_range_illegal';
}
if(!$error) {
if($detail) {
$pagetmp = $page;
do{
$query = $db->query("SELECT p.fid, p.tid, p.pid, p.author, p.authorid, p.dateline, t.subject, p.message FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE t.digest>=0 $sql LIMIT ".(($pagetmp - 1) * $ppp).",$ppp");
$pagetmp--;
} while(!$db->num_rows($query) && $pagetmp);
$posts = '';
while($post = $db->fetch_array($query)) {
$post['dateline'] = gmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
$post['subject'] = cutstr($post['subject'], 30);
$post['message'] = dhtmlspecialchars(cutstr($post['message'], 50));
$posts .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"pidarray[]\" value=\"$post[pid]\" checked />",
"<a href=\"redirect.php?goto=findpost&pid=$post[pid]&ptid=$post[tid]\" target=\"_blank\">$post[subject]</a>",
$post['message'],
"<a href=\"forumdisplay.php?fid=$post[fid]\" target=\"_blank\">{$_DCACHE[forums][$post[fid]][name]}</a>",
"<a href=\"space.php?uid=$post[authorid]\" target=\"_blank\">$post[author]</a>",
$post['dateline']
), TRUE);
}
$postcount = $db->result_first("SELECT count(*) FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE t.digest>=0 $sql");
$multi = multi($postcount, $ppp, $page, "$BASESCRIPT?action=prune");
$multi = preg_replace("/href=\"$BASESCRIPT\?action=prune&page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location=$BASESCRIPT.'?action=prune&page='+this.value", "page(this.value)", $multi);
} else {
$postcount = 0;
$query = $db->query("SELECT pid FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE t.digest>=0 $sql");
while($post = $db->fetch_array($query)) {
$pids .= ','.$post['pid'];
$postcount++;
}
$multi = '';
}
if(!$postcount) {
$error = 'prune_post_nonexistence';
}
}
showtagheader('div', 'postlist', $searchsubmit);
showformheader('prune&frame=no', 'target="pruneframe"');
showhiddenfields(array('pids' => authcode($pids, 'ENCODE')));
showtableheader(lang('prune_result').' '.$postcount.' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';" class="act lightlink normal">'.lang('research').'</a>', 'fixpadding');
if($error) {
echo "<tr><td class=\"lineheight\">$lang[$error]</td></tr>";
} else {
if($detail) {
showsubtitle(array('', 'subject', 'message', 'forum', 'author', 'time'));
echo $posts;
}
}
showsubmit('prunesubmit', 'submit', $detail ? 'del' : '', '<input class="checkbox" type="checkbox" name="donotupdatemember" id="donotupdatemember" value="1" checked="checked" /><label for="donotupdatemember"> '.lang('prune_no_update_member').'</label>', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="pruneframe" style="display:none"></iframe>';
showtagfooter('div');
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/prune.inc.php | PHP | asf20 | 12,950 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ranks.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!submitcheck('ranksubmit')) {
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" size="12" name="newranktitle[]">'],
[1,'<input type="text" class="txt" size="6" name="newpostshigher[]">'],
[1,'<input type="text" class="txt" size="2" name="newstars[]">', 'td28'],
[1,'<input type="text" class="txt" size="6" name="newcolor[]">']
]
];
</script>
EOT;
shownav('user', 'nav_ranks');
showsubmenu('nav_ranks');
showtips('ranks_tips');
showformheader('ranks');
showtableheader();
showsubtitle(array('', 'ranks_title', 'ranks_postshigher', 'ranks_stars', 'ranks_color'));
$query = $db->query("SELECT * FROM {$tablepre}ranks ORDER BY postshigher");
while($rank = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', '', '', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[{$rank[rankid]}]\" value=\"$rank[rankid]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"ranktitlenew[{$rank[rankid]}]\" value=\"$rank[ranktitle]\">",
"<input type=\"text\" class=\"txt\" size=\"6\" name=\"postshighernew[{$rank[rankid]}]\" value=\"$rank[postshigher]\">",
"<input type=\"text\" class=\"txt\" size=\"2\"name=\"starsnew[{$rank[rankid]}]\" value=\"$rank[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\"name=\"colornew[{$rank[rankid]}]\" value=\"$rank[color]\">",
));
}
echo '<tr><td></td><td colspan="4"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['usergroups_level_add'].'</a></div></td></tr>';
showsubmit('ranksubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($delete) {
$ids = implode('\',\'', $delete);
$db->query("DELETE FROM {$tablepre}ranks WHERE rankid IN ('$ids')");
}
foreach($ranktitlenew as $id => $value) {
$db->query("UPDATE {$tablepre}ranks SET ranktitle='$ranktitlenew[$id]', postshigher='$postshighernew[$id]', stars='$starsnew[$id]', color='$colornew[$id]' WHERE rankid='$id'");
}
if(is_array($newranktitle)) {
foreach($newranktitle as $key => $value) {
if($value = trim($value)) {
$db->query("INSERT INTO {$tablepre}ranks (ranktitle, postshigher, stars, color)
VALUES ('$value', '$newpostshigher[$key]', '$newstars[$key]', '$newcolor[$key]')");
}
}
}
updatecache('ranks');
cpmsg('ranks_succeed', $BASESCRIPT.'?action=ranks', 'succeed');
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/ranks.inc.php | PHP | asf20 | 2,756 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: main.inc.php 20857 2009-10-28 00:57:24Z wangjinbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
include language('admincp.menu');
$lang = array_merge($lang, $menulang);
echo <<<EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>$lang[admincp_title]</title>
<meta http-equiv="Content-Type" content="text/html; charset=$charset">
<meta content="Comsenz Inc." name="Copyright" />
<link rel="stylesheet" href="images/admincp/admincp.css" type="text/css" media="all" />
<script src="include/js/common.js" type="text/javascript"></script>
</head>
<body style="margin: 0px" scroll="no">
<div id="append_parent"></div>
<table cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td colspan="2" height="90">
<div class="mainhd">
<div class="logo">Discuz! Administrator's Control Panel</div>
<div class="uinfo">
<p>$lang[header_welcome], <em>$discuz_userss</em> [ <a href="$BASESCRIPT?action=logout&sid=$sid" target="_top">$lang[header_logout]</a> ]</p>
<p class="btnlink"><a href="$indexname" target="_blank">$lang[header_bbs]</a></p>
</div>
<div class="navbg"></div>
<div class="nav">
<ul id="topmenu">
EOT;
showheader('index', 'home');
showheader('global', 'settings&operation=basic');
showheader('style', 'settings&operation=styles');
showheader('forum', 'forums');
showheader('user', 'members');
showheader('topic', 'moderate&operation=threads');
showheader('extended', 'tasks');
showheader('plugin', 'plugins');
showheader('adv', 'adv');
showheader('tool','tools&operation=updatecache');
if($isfounder) {
echo '<li><em><a id="header_uc" hidefocus="true" href="'.UC_API.'/admin.php?m=frame&a=main&iframe=1" onclick="uc_login=1;toggleMenu(\'uc\', \'\');" target="main">'.$lang['header_uc'].'</a></em></li>';
}
echo <<<EOT
</ul>
<div class="currentloca">
<p id="admincpnav"></p>
</div>
<div class="navbd"></div>
<div class="sitemapbtn">
<div style="float: left; margin:-5px 10px 0 0"><form name="search" method="post" action="$BASESCRIPT?action=search" target="main"><input type="text" name="keywords" value="" class="txt" /> <input type="hidden" name="searchsubmit" value="yes" class="btn" /><input type="submit" name="searchsubmit" value="$lang[search]" class="btn" style="margin-top: 5px;vertical-align:middle" /></form></div>
<span id="add2custom"></span>
<a href="###" id="cpmap" onclick="showMap();return false;"><img src="images/admincp/btn_map.gif" title="$lang[admincp_sitemap]" width="72" height="18" /></a>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td valign="top" width="160" class="menutd">
<div id="leftmenu" class="menu">
EOT;
require_once DISCUZ_ROOT.'./admin/menu.inc.php';
$uc_api_url = UC_API;
$ucadd = $isfounder ? ", 'uc'" : '';
echo <<<EOT
</div>
</td>
<td valign="top" width="100%" class="mask" id="mainframes">
<iframe src="$BASESCRIPT?$extra&sid=$sid" id="main" name="main" onload="mainFrame(0)" width="100%" height="100%" frameborder="0" scrolling="yes" style="overflow: visible;display:"></iframe>
</td>
</tr>
</table>
<div class="custombar" id="custombarpanel">
<span id="custombar"></span><span id="custombar_add"></span>
</div>
<div id="scrolllink" style="display: none">
<span onclick="menuScroll(1)"><img src="images/admincp/scrollu.gif" /></span>
<span onclick="menuScroll(2)"><img src="images/admincp/scrolld.gif" /></span>
</div>
<div class="copyright">
<p>Powered by <a href="http://www.discuz.net/" target="_blank">Discuz!</a> $version</p>
<p>© 2001-2009, <a href="http://www.comsenz.com/" target="_blank">Comsenz Inc.</a></p>
</div>
<div id="cpmap_menu" class="custom" style="display: none">
<div class="cside">
<h3><span class="ctitle1">$lang[custommenu]</span><a href="javascript:;" onclick="toggleMenu('tool', 'misc&operation=custommenu');hideMenu();" class="cadmin">$lang[admin]</a></h3>
<ul class="cslist" id="custommenu"></ul>
</div>
<div class="cmain" id="cmain"></div>
<div class="cfixbd"></div>
</div>
<script type="text/JavaScript">
var headers = new Array('index', 'global', 'style', 'forum', 'user', 'topic', 'extended', 'plugin', 'adv', 'tool'$ucadd);
var admincpfilename = '$BASESCRIPT';
var menukey = '', custombarcurrent = 0;
function toggleMenu(key, url) {
if(key == 'index' && url == 'home') {
if(BROWSER.ie) {
doane(event);
}
parent.location.href = admincpfilename + '?frames=yes';
return false;
}
menukey = key;
for(var k in headers) {
if($('menu_' + headers[k])) {
$('menu_' + headers[k]).style.display = headers[k] == key ? '' : 'none';
}
}
var lis = $('topmenu').getElementsByTagName('li');
for(var i = 0; i < lis.length; i++) {
if(lis[i].className == 'navon') lis[i].className = '';
}
$('header_' + key).parentNode.parentNode.className = 'navon';
if(url) {
parent.mainFrame(0);
parent.main.location = admincpfilename + '?action=' + url;
var hrefs = $('menu_' + key).getElementsByTagName('a');
for(var j = 0; j < hrefs.length; j++) {
hrefs[j].className = hrefs[j].href.substr(hrefs[j].href.indexOf(admincpfilename + '?action=') + 19) == url ? 'tabon' : (hrefs[j].className == 'tabon' ? '' : hrefs[j].className);
}
}
setMenuScroll();
return false;
}
function setMenuScroll() {
var obj = $('menu_' + menukey);
var scrollh = document.body.offsetHeight - 160;
obj.style.overflow = 'visible';
obj.style.height = '';
$('scrolllink').style.display = 'none';
if(obj.offsetHeight + 150 > document.body.offsetHeight && scrollh > 0) {
obj.style.overflow = 'hidden';
obj.style.height = scrollh + 'px';
$('scrolllink').style.display = '';
}
custombar_resize();
}
function menuScroll(op, e) {
var obj = $('menu_' + menukey);
var scrollh = document.body.offsetHeight - 160;
if(op == 1) {
obj.scrollTop = obj.scrollTop - scrollh;
} else if(op == 2) {
obj.scrollTop = obj.scrollTop + scrollh;
} else if(op == 3) {
if(!e) e = window.event;
if(e.wheelDelta <= 0 || e.detail > 0) {
obj.scrollTop = obj.scrollTop + 20;
} else {
obj.scrollTop = obj.scrollTop - 20;
}
}
}
function initCpMenus(menuContainerid) {
var key = '';
var hrefs = $(menuContainerid).getElementsByTagName('a');
for(var i = 0; i < hrefs.length; i++) {
if(menuContainerid == 'leftmenu' && !key && '$extra'.indexOf(hrefs[i].href.substr(hrefs[i].href.indexOf(admincpfilename + '?action=') + 12)) != -1) {
key = hrefs[i].parentNode.parentNode.id.substr(5);
hrefs[i].className = 'tabon';
}
if(!hrefs[i].getAttribute('ajaxtarget')) hrefs[i].onclick = function() {
if(menuContainerid != 'custommenu') {
var lis = $(menuContainerid).getElementsByTagName('li');
for(var k = 0; k < lis.length; k++) {
if(lis[k].firstChild.className != 'menulink') lis[k].firstChild.className = '';
}
if(this.className == '') this.className = menuContainerid == 'leftmenu' ? 'tabon' : 'bold';
}
if(menuContainerid != 'leftmenu') {
var hk, currentkey;
var leftmenus = $('leftmenu').getElementsByTagName('a');
for(var j = 0; j < leftmenus.length; j++) {
hk = leftmenus[j].parentNode.parentNode.id.substr(5);
if(this.href.indexOf(leftmenus[j].href) != -1) {
leftmenus[j].className = 'tabon';
if(hk != 'index') currentkey = hk;
} else {
leftmenus[j].className = '';
}
}
if(currentkey) toggleMenu(currentkey);
hideMenu();
}
}
}
return key;
}
var header_key = initCpMenus('leftmenu');
toggleMenu(header_key ? header_key : 'index');
function initCpMap() {
var ul, hrefs, s;
s = '<ul class="cnote"><li><img src="images/admincp/btn_map.gif" /></li><li> $lang[custommenu_tips]</li></ul><table class="cmlist" id="mapmenu"><tr>';
for(var k in headers) {
if(headers[k] != 'index' && headers[k] != 'uc') {
s += '<td valign="top"><ul class="cmblock"><li><h4>' + $('header_' + headers[k]).innerHTML + '</h4></li>';
ul = $('menu_' + headers[k]);
hrefs = ul.getElementsByTagName('a');
for(var i = 0; i < hrefs.length; i++) {
s += '<li><a href="' + hrefs[i].href + '" target="' + hrefs[i].target + '" k="' + headers[k] + '">' + hrefs[i].innerHTML + '</a></li>';
}
s += '</ul></td>';
}
}
s += '</tr></table>';
return s;
}
$('cmain').innerHTML = initCpMap();
initCpMenus('mapmenu');
var cmcache = false;
function showMap() {
showMenu({'ctrlid':'cpmap','evt':'click', 'duration':3, 'pos':'00'});
if(!cmcache) ajaxget(admincpfilename + '?action=misc&operation=custommenu&' + Math.random(), 'custommenu', '');
}
function resetEscAndF5(e) {
e = e ? e : window.event;
actualCode = e.keyCode ? e.keyCode : e.charCode;
if(actualCode == 27) {
if($('cpmap_menu').style.display == 'none') {
showMap();
} else {
hideMenu();
}
}
if(actualCode == 116 && parent.main) {
if(custombarcurrent) {
parent.$('main_' + custombarcurrent).contentWindow.location.reload();
} else {
parent.main.location.reload();
}
if(document.all) {
e.keyCode = 0;
e.returnValue = false;
} else {
e.cancelBubble = true;
e.preventDefault();
}
}
}
function uc_left_menu(uc_menu_data) {
var leftmenu = $('menu_uc');
leftmenu.innerHTML = '';
var html_str = '';
for(var i=0;i<uc_menu_data.length;i+=2) {
html_str += '<li><a href="'+uc_menu_data[(i+1)]+'" hidefocus="true" onclick="uc_left_switch(this)" target="main">'+uc_menu_data[i]+'</a></li>';
}
leftmenu.innerHTML = html_str;
toggleMenu('uc', '');
$('admincpnav').innerHTML = 'UCenter';
}
var uc_left_last = null;
function uc_left_switch(obj) {
if(uc_left_last) {
uc_left_last.className = '';
}
obj.className = 'tabon';
uc_left_last = obj;
}
function uc_modify_sid(sid) {
$('header_uc').href = '$uc_api_url/admin.php?m=frame&a=main&iframe=1&sid=' + sid;
}
function mainFrame(id, src) {
var setFrame = !id ? 'main' : 'main_' + id, obj = $('mainframes').getElementsByTagName('IFRAME'), exists = 0, src = !src ? '' : src;
for(i = 0;i < obj.length;i++) {
if(obj[i].name == setFrame) {
exists = 1;
}
obj[i].style.display = 'none';
}
if(!exists) {
if(BROWSER.ie) {
frame = document.createElement('<iframe name="' + setFrame + '" id="' + setFrame + '"></iframe>');
} else {
frame = document.createElement('iframe');
frame.name = setFrame;
frame.id = setFrame;
}
frame.width = '100%';
frame.height = '100%';
frame.frameBorder = 0;
frame.scrolling = 'yes';
frame.style.overflow = 'visible';
frame.style.display = 'none';
if(src) {
frame.src = src;
}
$('mainframes').appendChild(frame);
}
if(id) {
custombar_set(id);
}
$(setFrame).style.display = '';
if(!src && custombarcurrent) {
$('custombar_' + custombarcurrent).className = '';
custombarcurrent = 0;
}
}
function custombar_update(deleteid) {
var extra = !deleteid ? '' : '&deleteid=' + deleteid;
if(deleteid && $('main_' + deleteid)) {
$('mainframes').removeChild($('main_' + deleteid));
if(deleteid == custombarcurrent) {
mainFrame(0);
}
}
ajaxget(admincpfilename + '?action=misc&operation=custombar' + extra, 'custombar', '', '', '', function () {custombar_resize();});
}
function custombar_resize() {
custombarfixw = document.body.offsetWidth - 180;
$('custombarpanel').style.width = custombarfixw + 'px';
}
function custombar_scroll(op, e) {
var obj = $('custombarpanel');
var step = 40;
if(op == 1) {
obj.scrollLeft = obj.scrollLeft - step;
} else if(op == 2) {
obj.scrollLeft = obj.scrollLeft + step;
} else if(op == 3) {
if(!e) e = window.event;
if(e.wheelDelta <= 0 || e.detail > 0) {
obj.scrollLeft = obj.scrollLeft + step;
} else {
obj.scrollLeft = obj.scrollLeft - step;
}
}
}
function custombar_set(id) {
var currentobj = $('custombar_' + custombarcurrent), obj = $('custombar_' + id);
if(currentobj == obj) {
obj.className = 'current';
return;
}
if(currentobj) {
currentobj.className = '';
}
obj.className = 'current';
custombarcurrent = id;
}
custombar_update();
_attachEvent(document.documentElement, 'keydown', resetEscAndF5);
_attachEvent(window, 'resize', setMenuScroll, document);
if(BROWSER.ie){
$('leftmenu').onmousewheel = function(e) { menuScroll(3, e) };
$('custombarpanel').onmousewheel = function(e) { custombar_scroll(3, e) };
} else {
$('leftmenu').addEventListener("DOMMouseScroll", function(e) { menuScroll(3, e) }, false);
$('custombarpanel').addEventListener("DOMMouseScroll", function(e) { custombar_scroll(3, e) }, false);
}
</script>
</body>
</html>
EOT;
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/main.inc.php | PHP | asf20 | 13,149 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: attach.inc.php 20422 2009-09-27 03:19:30Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!submitcheck('deletesubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$anchor = in_array($anchor, array('search', 'admin')) ? $anchor : 'search';
shownav('topic', 'nav_attaches');
showsubmenusteps('nav_attaches', array(
array('search', !$searchsubmit),
array('admin', $searchsubmit),
));
showtips('attach_tips', 'attach_tips', $searchsubmit);
showtagheader('div', 'search', !$searchsubmit);
showformheader('attach');
showtableheader();
showsetting('attach_nomatched', 'nomatched', 0, 'radio');
showsetting('attach_forum', '', '', '<select name="inforum"><option value="all"> >'.lang('all').'</option><option value=""> </option>'.forumselect(FALSE, 0, 0, TRUE).'</select>');
showsetting('attach_sizerange', array('sizeless', 'sizemore'), array('', ''), 'range');
showsetting('attach_dlcountrange', array('dlcountless', 'dlcountmore'), array('', ''), 'range');
showsetting('attach_daysold', 'daysold', '', 'text');
showsetting('filename', 'filename', '', 'text');
showsetting('attach_keyword', 'keywords', '', 'text');
showsetting('attach_author', 'author', '', 'text');
showsubmit('searchsubmit', 'search');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$sql = "a.pid=p.pid";
$ppp = 100;
if($inforum != 'all') {
$inforum = intval($inforum);
}
$sql .= is_numeric($inforum) ? " AND p.fid='$inforum'" : '';
$sql .= $daysold ? " AND p.dateline<='".($timestamp - (86400 * $daysold))."'" : '';
$sql .= $author ? " AND p.author='$author'" : '';
$sql .= $filename ? " AND a.filename LIKE '%$filename%'" : '';
if($keywords) {
$sqlkeywords = $or = '';
foreach(explode(',', str_replace(' ', '', $keywords)) as $keyword) {
$sqlkeywords .= " $or af.description LIKE '%$keyword%'";
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
}
$sql .= $sizeless ? " AND a.filesize<'$sizeless'" : '';
$sql .= $sizemore ? " AND a.filesize>'$sizemore' " : '';
$sql .= $dlcountless ? " AND a.downloads<'$dlcountless'" : '';
$sql .= $dlcountmore ? " AND a.downloads>'$dlcountmore'" : '';
$attachments = '';
$page = max(1, intval($page));
$query = $db->query("SELECT a.*, af.description, p.fid, p.author, t.tid, t.tid, t.subject, f.name AS fname
FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid, {$tablepre}posts p, {$tablepre}threads t, {$tablepre}forums f
WHERE t.tid=a.tid AND f.fid=p.fid AND t.displayorder>='0' AND p.invisible='0' AND $sql LIMIT ".(($page - 1) * $ppp).','.$ppp);
while($attachment = $db->fetch_array($query)) {
if(!$attachment['remote']) {
$matched = file_exists($attachdir.'/'.$attachment['attachment']) ? '' : lang('attach_lost');
$attachment['url'] = $attachurl;
} else {
@set_time_limit(0);
if(@fclose(@fopen($ftp['attachurl'].'/'.$attachment['attachment'], 'r'))) {
$matched = '';
} else {
$matched = lang('attach_lost');
}
$attachment['url'] = $ftp['attachurl'];
}
$attachsize = sizecount($attachment['filesize']);
if(!$nomatched || ($nomatched && $matched)) {
$attachments .= showtablerow('', array('class="td25"', 'title="'.$attachment['description'].'" class="td21"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$attachment[aid]\" />",
$attachment['remote'] ? "<span class=\"diffcolor3\">$attachment[filename]" : $attachment['filename'],
"<a href=\"$attachment[url]/$attachment[attachment]\" class=\"smalltxt\" target=\"_blank\">".cutstr($attachment['attachment'], 30)."</a>",
$attachment['author'],
"<a href=\"viewthread.php?tid=$attachment[tid]\" target=\"_blank\">".cutstr($attachment['subject'], 20)."</a>",
$attachsize,
$attachment['downloads'],
$matched ? "<em class=\"error\">$matched<em>" : "<a href=\"attachment.php?aid=".aidencode($attachment['aid'])."&noupdate=yes\" target=\"_blank\" class=\"act nomargin\">$lang[download]</a>"
), TRUE);
}
}
$attachmentcount = $db->result_first("SELECT count(*) FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid, {$tablepre}posts p, {$tablepre}threads t, {$tablepre}forums f
WHERE t.tid=a.tid AND f.fid=p.fid AND t.displayorder>='0' AND p.invisible='0' AND $sql");
$multipage = multi($attachmentcount, $ppp, $page, "$BASESCRIPT?action=attachments");
$multipage = preg_replace("/href=\"$BASESCRIPT\?action=attachments&page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multipage);
$multipage = str_replace("window.location=$BASESCRIPT.'?action=attachments&page='+this.value", "page(this.value)", $multipage);
echo <<<EOT
<script type="text/JavaScript">
function page(number) {
$('attachmentforum').page.value=number;
$('attachmentforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'admin', $searchsubmit);
showformheader('attach', '', 'attachmentforum');
showhiddenfields(array(
'page' => $page,
'nomatched' => $nomatched,
'inforum' => $inforum,
'sizeless' => $sizeless,
'sizemore' => $sizemore,
'dlcountless' => $dlcountless,
'dlcountmore' => $dlcountmore,
'daysold' => $daysold,
'filename' => $filename,
'keywords' => $keywords,
'author' => $author,
));
echo '<input type="submit" name="searchsubmit" value="'.lang('submit').'" class="btn" style="display: none" />';
showformfooter();
showformheader('attach&frame=no', 'target="attachmentframe"');
showtableheader();
showsubtitle(array('', 'filename', 'attach_path', 'author', 'attach_thread', 'size', 'attach_downloadnums', ''));
echo $attachments;
showsubmit('deletesubmit', 'submit', 'del', '<a href="###" onclick="$(\'admin\').style.display=\'none\';$(\'search\').style.display=\'\';" class="act lightlink normal">'.lang('research').'</a>', $multipage);
showtablefooter();
showformfooter();
echo '<iframe name="attachmentframe" style="display:none"></iframe>';
showtagfooter('div');
}
} else {
if($ids = implodeids($delete)) {
$tids = $pids = 0;
$query = $db->query("SELECT tid, pid, attachment, thumb, remote FROM {$tablepre}attachments WHERE aid IN ($ids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
$tids .= ','.$attach['tid'];
$pids .= ','.$attach['pid'];
}
$db->query("DELETE FROM {$tablepre}attachments WHERE aid IN ($ids)");
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE aid IN ($ids)");
$attachtids = 0;
$query = $db->query("SELECT tid FROM {$tablepre}attachments WHERE tid IN ($tids) GROUP BY tid ORDER BY pid DESC");
while($attach = $db->fetch_array($query)) {
$attachtids .= ','.$attach['tid'];
}
$db->query("UPDATE {$tablepre}threads SET attachment='0' WHERE tid IN ($tids)".($attachtids ? " AND tid NOT IN ($attachtids)" : NULL));
$attachpids = 0;
$query = $db->query("SELECT pid FROM {$tablepre}attachments WHERE pid IN ($pids) GROUP BY pid ORDER BY pid DESC");
while($attach = $db->fetch_array($query)) {
$attachpids .= ','.$attach['pid'];
}
$db->query("UPDATE {$tablepre}posts SET attachment='0' WHERE pid IN ($pids)".($attachpids ? " AND pid NOT IN ($attachpids)" : NULL));
eval("\$cpmsg = \"".lang('attach_edit_succeed')."\";");
} else {
eval("\$cpmsg = \"".lang('attach_edit_invalid')."\";");
}
echo "<script type=\"text/JavaScript\">alert('$cpmsg');parent.\$('attachmentforum').searchsubmit.click();</script>";
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/attach.inc.php | PHP | asf20 | 8,005 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: admingroups.inc.php 21044 2009-11-09 03:14:02Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(submitcheck('groupsubmit') && $ids = implodeids($delete)) {
$gids = array();
$query = $db->query("SELECT groupid FROM {$tablepre}usergroups WHERE groupid IN ($ids) AND type='special' AND radminid>'0'");
while($g = $db->fetch_array($query)) {
$gids[] = $g['groupid'];
}
if($ids = implodeids($gids)) {
$db->query("DELETE FROM {$tablepre}usergroups WHERE groupid IN ($ids)");
$db->query("DELETE FROM {$tablepre}admingroups WHERE admingid IN ($ids)");
$db->query("DELETE FROM {$tablepre}adminactions WHERE admingid IN ($ids)");
$newgroupid = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditslower>'0' ORDER BY creditslower LIMIT 1");
$db->query("UPDATE {$tablepre}members SET groupid='$newgroupid', adminid='0' WHERE groupid IN ($ids)", 'UNBUFFERED');
deletegroupcache($gids);
}
}
$grouplist = array();
$query = $db->query("SELECT a.*, u.groupid, u.radminid, u.grouptitle, u.stars, u.color, u.groupavatar, u.type FROM {$tablepre}admingroups a
LEFT JOIN {$tablepre}usergroups u ON u.groupid=a.admingid
ORDER BY u.type, u.radminid, a.admingid");
while ($group = $db->fetch_array($query)) {
$grouplist[$group['groupid']] = $group;
}
if(!submitcheck('groupsubmit')) {
shownav('user', 'nav_admingroups');
showsubmenu('nav_admingroups');
showtips('admingroups_tips');
showformheader('admingroups');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'name', 'type', 'admingroups_level', 'usergroups_stars', 'usergroups_color', 'usergroups_avatar', '', ''));
foreach($grouplist as $gid => $group) {
showtablerow('', array('', '', 'class="td25"', '', 'class="td25"'), array(
$group['type'] == 'system' ? '' : "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$group[groupid]\">",
$group['grouptitle'],
$group['type'] == 'system' ? lang('inbuilt') : lang('costom'),
$lang['usergroups_system_'.$group['radminid']],
"<input type=\"text\" class=\"txt\" size=\"2\"name=\"group_stars[$group[groupid]]\" value=\"$group[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\"name=\"group_color[$group[groupid]]\" value=\"$group[color]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_avatar[$group[groupid]]\" value=\"$group[groupavatar]\">",
"<a href=\"$BASESCRIPT?action=usergroups&operation=edit&id={$group[admingid]}&return=admin\">$lang[admingroups_settings_user]</a>",
"<a href=\"$BASESCRIPT?action=admingroups&operation=edit&id=$group[admingid]\">$lang[admingroups_settings_admin]</a>"
));
}
showtablerow('', array('class="td25"', '', '', 'colspan="6"'), array(
lang('add_new'),
'<input type="text" class="txt" size="12" name="grouptitlenew">',
lang('costom'),
"<select name=\"radminidnew\"><option value=\"1\">$lang[usergroups_system_1]</option><option value=\"2\">$lang[usergroups_system_2]</option><option value=\"3\" selected=\"selected\">$lang[usergroups_system_3]</option>",
));
showsubmit('groupsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
foreach($grouplist as $gid => $group) {
$stars = intval($group_stars[$gid]);
$color = dhtmlspecialchars($group_color[$gid]);
$avatar = dhtmlspecialchars($group_avatar[$gid]);
if($group['color'] != $color || $group['stars'] != $stars || $group['groupavatar'] != $avatar) {
$db->query("UPDATE {$tablepre}usergroups SET stars='$stars', color='$color', groupavatar='$avatar' WHERE groupid='$gid'");
}
}
$grouptitlenew = dhtmlspecialchars(trim($grouptitlenew));
$radminidnew = intval($radminidnew);
if($grouptitlenew && in_array($radminidnew, array(1, 2, 3))) {
$ufields = '';
$usergroup = $db->fetch_first("SELECT * FROM {$tablepre}usergroups WHERE groupid='$radminidnew'");
foreach ($usergroup as $key => $val) {
if(!in_array($key, array('groupid', 'radminid', 'type', 'system', 'grouptitle'))) {
$val = addslashes($val);
$ufields .= ", `$key`='$val'";
}
}
$afields = '';
$admingroup = $db->fetch_first("SELECT * FROM {$tablepre}admingroups WHERE admingid='$radminidnew'");
foreach ($admingroup as $key => $val) {
if(!in_array($key, array('admingid'))) {
$val = addslashes($val);
$afields .= ", `$key`='$val'";
}
}
$db->query("INSERT INTO {$tablepre}usergroups SET radminid='$radminidnew', type='special', grouptitle='$grouptitlenew' $ufields");
if($newgroupid = $db->insert_id()) {
$db->query("REPLACE INTO {$tablepre}admingroups SET admingid='$newgroupid' $afields");
if($radminidnew == 1) {
$dactionarray = array('members_edit', 'members_group', 'db_runquery', 'db_import', 'usergroups', 'admingroups', 'templates', 'plugins');
$db->query("REPLACE INTO {$tablepre}adminactions (admingid, disabledactions)
VALUES ('$newgroupid', '".addslashes(serialize($dactionarray))."')");
}
}
}
cpmsg('admingroups_edit_succeed', $BASESCRIPT.'?action=admingroups', 'succeed');
}
} elseif($operation == 'edit') {
$actionarray = array(
'_readonly' => array(),
'settings' => array('basic', 'access', 'styles', 'seo', 'cachethread', 'serveropti', 'editor', 'functions', 'permissions', 'credits', 'mail', 'sec', 'datetime', 'attach', 'wap', 'dzfeed', 'uc', 'ec', 'msn'),
'forums' => array('edit', 'moderators', 'delete', 'merge', 'copy'),
'threadtypes' => array(),
'members' => array('add', 'group', 'access', 'credit', 'medal', 'edit', 'ban', 'ipban', 'reward', 'newsletter', 'confermedal', 'clean', 'repeat'),
'profilefields' => array(),
'usergroups' => array(),
'admingroups' => array(),
'ranks' => array(),
'styles' => array(),
'templates' => array('add', 'edit', 'copy'),
'moderate' => array('members', 'threads', 'replies'),
'threads' => array(),
'prune' => array(),
'recyclebin' => array(),
'announce' => array(),
'smilies' => array(),
'misc' => array('link', 'onlinelist', 'censor', 'bbcode', 'tag', 'icon', 'focus', 'customnav', 'stamp', 'attachtype', 'cron'),
'adv' => array('config', 'advadd', 'advedit'),
'db' => array('runquery', 'optimize', 'export', 'import', 'dbcheck'),
'tools' => array('updatecache', 'fileperms', 'tag'),
'attach' => array(),
'counter' => array(),
'jswizard' => array(),
'creditwizard' => array(),
'qihoo' => array('config', 'topics', 'relatedthreads'),
'tasks' => array(),
'ec' => array('alipay', 'tenpay', 'orders', 'credit'),
'medals' => array(),
'plugins' => array('config', 'edit', 'import', 'export', 'upgrade', 'add', 'hooks', 'vars'),
'logs' => array('illegal', 'ban', 'mods', 'cp', 'error', 'rate', 'credit', 'magic', 'medal', 'invite', 'payment'),
'addons' => array(),
'faq' => array(),
'magic' => array(),
'project' => array(),
);
$actioncat = array (
'admingroups_edit_action_cat_basesetting' => array(array('_readonly', 'settings', 'templates'), array('profilefields', 'ranks', 'styles', 'smilies')),
'admingroups_edit_action_cat_resourcesetting' => array(array('forums', 'members'), array('threadtypes', 'usergroups', 'admingroups')),
'admingroups_edit_action_cat_resourceadmin' => array(array('moderate'), array('threads', 'prune', 'recyclebin', 'attach')),
'admingroups_edit_action_cat_extraadmin' => array(array('ec', 'plugins', 'adv', 'qihoo'), array('tasks', 'magic', 'medals', 'addons')),
'admingroups_edit_action_cat_otheradmin' => array(array('misc', 'tools'), array('announce', 'faq', 'jswizard')),
'admingroups_edit_action_cat_maint' => array(array('db', 'logs'), array('counter', 'creditwizard', 'project')),
);
$submitcheck = submitcheck('groupsubmit');
if(!$submitcheck && empty($gset)) {
$id = isset($id) ? intval($id) : 0;
if(empty($id)) {
$grouplist = "<select name=\"id\" style=\"width: 150px\">\n";
$query = $db->query("SELECT u.groupid, u.grouptitle FROM {$tablepre}admingroups a LEFT JOIN {$tablepre}usergroups u ON u.groupid=a.admingid ORDER BY u.type, u.radminid, a.admingid");
while($group = $db->fetch_array($query)) {
$grouplist .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
}
$grouplist .= '</select>';
cpmsg('admingroups_edit_nonexistence', $BASESCRIPT.'?action=admingroups&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $grouplist);
}
$group = $db->fetch_first("SELECT a.*, aa.disabledactions, u.radminid, u.grouptitle FROM {$tablepre}admingroups a
LEFT JOIN {$tablepre}usergroups u ON u.groupid=a.admingid
LEFT JOIN {$tablepre}adminactions aa ON aa.admingid=a.admingid
WHERE a.admingid='$id'");
if(!$group) {
cpmsg('undefined_action', '', 'error');
}
$query = $db->query("SELECT u.radminid, u.groupid, u.grouptitle FROM {$tablepre}admingroups a LEFT JOIN {$tablepre}usergroups u ON u.groupid=a.admingid ORDER BY u.radminid, a.admingid");
$grouplist = $gutype = '';
while($ggroup = $db->fetch_array($query)) {
if($gutype != $ggroup['radminid']) {
$grouplist .= '<em>'.($ggroup['radminid'] == 1 ? $lang['usergroups_system_1'] : ($ggroup['radminid'] == 2 ? $lang['usergroups_system_2'] : $lang['usergroups_system_3'])).'</em>';
$gutype = $ggroup['radminid'];
}
$grouplist .= '<a href="###" onclick="location.href=\''.$BASESCRIPT.'?action=admingroups&operation=edit&switch=yes&id='.$ggroup['groupid'].'&anchor=\'+currentAnchor+\'&scrolltop=\'+document.documentElement.scrollTop"'.($id == $ggroup['groupid'] ? ' class="current"' : '').'>'.$ggroup['grouptitle'].'</a>';
}
$gselect = '<span id="ugselect" class="right popupmenu_dropmenu" onmouseover="showMenu({\'ctrlid\':this.id,\'pos\':\'34\'});$(\'ugselect_menu\').style.top=(parseInt($(\'ugselect_menu\').style.top)-document.documentElement.scrollTop)+\'px\'">'.$lang['usergroups_switch'].'<em> </em></span>'.
'<div id="ugselect_menu" class="popupmenu_popup" style="display:none">'.$grouplist.'</div>';
$anchor = $group['radminid'] == 1 ?
(in_array($anchor, array('admincpperm', 'threadperm', 'postperm', 'modcpperm', 'otherperm')) ? $anchor : 'admincpperm') :
(in_array($anchor, array('threadperm', 'postperm', 'modcpperm', 'otherperm')) ? $anchor : 'threadperm');
$anchorarray = array(
$group['radminid'] == 1 ? array('admingroups_edit_admincpperm', 'admincpperm', $anchor == 'admincpperm') : array(),
array('admingroups_edit_threadperm', 'threadperm', $anchor == 'threadperm'),
array('admingroups_edit_postperm', 'postperm', $anchor == 'postperm'),
array('admingroups_edit_modcpperm', 'modcpperm', $anchor == 'modcpperm'),
array('admingroups_edit_otherperm', 'otherperm', $anchor == 'otherperm'),
);
showsubmenuanchors($lang['admingroups_edit'].' - '.$group['grouptitle'], $anchorarray, $gselect);
if(!empty($switch)) {
echo '<script type="text/javascript">showMenu({\'ctrlid\':\'ugselect\',\'pos\':\'34\'});</script>';
}
if($id == 1) {
showtips('admingroups_admin_tips');
}
showformheader("admingroups&operation=edit&id=$id");
if($group['radminid'] == 1) {
echo '<style>'.
'.item{ float:left;width: 180px;line-height: 25px; }'.
'.vtop .right, .item .right{ padding: 0 10px; line-height: 22px; background: url(\'images/admincp/bg_repno.gif\') no-repeat -286px -145px; font-weight: normal;margin-right:10px; }'.
'.vtop a:hover.right, .item a:hover.right { text-decoration:none; }'.
'</style>';
showtagheader('div', 'admincpperm', $anchor == 'admincpperm');
showtableheader();
$group['disabledactions'] = $group['disabledactions'] ? (array)unserialize($group['disabledactions']) : array();
foreach($actioncat as $catname => $catdatas) {
showtitle($catname);
$rowtype = 0;
foreach($catdatas as $k => $catdata) {
if($k) {
echo '<tr><td class="vtop td27" width="200"><b>'.$lang['admingroups_edit_action_other'].'</b></td><td>';
}
$j = 1;
foreach($catdata as $actionstr) {
if(!$k) {
$operationstr = $actionarray[$actionstr];
echo '<tr><td class="vtop td27" width="200"><a class="right" title="'.lang('config').'" href="'.$BASESCRIPT.'?frames=yes&action=admingroups&operation=edit&gset='.$actionstr.'" target="_blank"> </a><input name="disabledactionnew[]" value="'.$actionstr.'" class="checkbox" type="checkbox" '.(!in_array($actionstr, $group['disabledactions']) ? 'checked="checked" ' : '').'/>'.lang('admingroups_edit_action_'.$actionstr).'</td><td class="vtop">';
$i = 1;
if($operationstr) {
foreach($operationstr as $opstr) {
$str = $actionstr.'_'.$opstr;
echo '<div class="item"><a class="right" title="'.lang('config').'" href="'.$BASESCRIPT.'?frames=yes&action=admingroups&operation=edit&gset='.$str.'" target="_blank"> </a><label><input name="disabledactionnew[]" value="'.$str.'" class="checkbox" type="checkbox" '.(!in_array($str, $group['disabledactions']) ? 'checked="checked" ' : '').'/>'.lang('admingroups_edit_action_'.$str).'</label></div>';
if($i == 3) {
echo '<br style="clear:both" />';
$i = 0;
}
$i++;
}
} else {
if(isset($lang['admingroups_edit_action_'.$actionstr.'_comment'])) {
echo '<span class="tips2">'.lang('admingroups_edit_action_'.$actionstr.'_comment').'</span>';
}
}
echo '</td></tr>';
} else {
echo '<div class="item"><a class="right" title="'.lang('config').'" href="'.$BASESCRIPT.'?frames=yes&action=admingroups&operation=edit&gset='.$actionstr.'" target="_blank"> </a><input name="disabledactionnew[]" value="'.$actionstr.'" class="checkbox" type="checkbox" '.(!in_array($actionstr, $group['disabledactions']) ? 'checked="checked" ' : '').'/>'.lang('admingroups_edit_action_'.$actionstr).'</div>';
if($j == 3) {
echo '<br style="clear:both" />';
$j = 0;
}
$j++;
}
}
if($k) {
echo '</td></tr>';
}
}
}
showtablefooter();
showtagfooter('div');
}
showtableheader();
showtagheader('tbody', 'threadperm', $anchor == 'threadperm');
showtitle('admingroups_edit_threadperm');
showsetting('admingroups_edit_stick_thread', array('allowstickthreadnew', array(
array(0, $lang['admingroups_edit_stick_thread_none']),
array(1, $lang['admingroups_edit_stick_thread_1']),
array(2, $lang['admingroups_edit_stick_thread_2']),
array(3, $lang['admingroups_edit_stick_thread_3'])
)), $group['allowstickthread'], 'mradio');
showsetting('admingroups_edit_digest_thread', array('allowdigestthreadnew', array(
array(0, $lang['admingroups_edit_digest_thread_none']),
array(1, $lang['admingroups_edit_digest_thread_1']),
array(2, $lang['admingroups_edit_digest_thread_2']),
array(3, $lang['admingroups_edit_digest_thread_3'])
)), $group['allowdigestthread'], 'mradio');
showsetting('admingroups_edit_bump_thread', 'allowbumpthreadnew', $group['allowbumpthread'], 'radio');
showsetting('admingroups_edit_highlight_thread', 'allowhighlightthreadnew', $group['allowhighlightthread'], 'radio');
showsetting('admingroups_edit_recommend_thread', 'allowrecommendthreadnew', $group['allowrecommendthread'], 'radio');
showsetting('admingroups_edit_stamp_thread', 'allowstampthreadnew', $group['allowstampthread'], 'radio');
showsetting('admingroups_edit_close_thread', 'allowclosethreadnew', $group['allowclosethread'], 'radio');
showsetting('admingroups_edit_move_thread', 'allowmovethreadnew', $group['allowmovethread'], 'radio');
showsetting('admingroups_edit_edittype_thread', 'allowedittypethreadnew', $group['allowedittypethread'], 'radio');
showsetting('admingroups_edit_copy_thread', 'allowcopythreadnew', $group['allowcopythread'], 'radio');
showsetting('admingroups_edit_merge_thread', 'allowmergethreadnew', $group['allowmergethread'], 'radio');
showsetting('admingroups_edit_split_thread', 'allowsplitthreadnew', $group['allowsplitthread'], 'radio');
showsetting('admingroups_edit_repair_thread', 'allowrepairthreadnew', $group['allowrepairthread'], 'radio');
showsetting('admingroups_edit_refund', 'allowrefundnew', $group['allowrefund'], 'radio');
showsetting('admingroups_edit_edit_poll', 'alloweditpollnew', $group['alloweditpoll'], 'radio');
showsetting('admingroups_edit_remove_reward', 'allowremoverewardnew', $group['allowremovereward'], 'radio');
showsetting('admingroups_edit_edit_activity', 'alloweditactivitynew', $group['alloweditactivity'], 'radio');
showsetting('admingroups_edit_edit_trade', 'allowedittradenew', $group['allowedittrade'], 'radio');
showtagfooter('tbody');
showtagheader('tbody', 'postperm', $anchor == 'postperm');
showtitle('admingroups_edit_postperm');
showsetting('admingroups_edit_edit_post', 'alloweditpostnew', $group['alloweditpost'], 'radio');
showsetting('admingroups_edit_warn_post', 'allowwarnpostnew', $group['allowwarnpost'], 'radio');
showsetting('admingroups_edit_ban_post', 'allowbanpostnew', $group['allowbanpost'], 'radio');
showsetting('admingroups_edit_del_post', 'allowdelpostnew', $group['allowdelpost'], 'radio');
showtagfooter('tbody');
showtagheader('tbody', 'modcpperm', $anchor == 'modcpperm');
showtitle('admingroups_edit_modcpperm');
showsetting('admingroups_edit_view_report', 'allowviewreportnew', $group['allowviewreport'], 'radio');
showsetting('admingroups_edit_mod_post', 'allowmodpostnew', $group['allowmodpost'], 'radio');
showsetting('admingroups_edit_mod_user', 'allowmodusernew', $group['allowmoduser'], 'radio');
showsetting('admingroups_edit_ban_user', 'allowbanusernew', $group['allowbanuser'], 'radio');
showsetting('admingroups_edit_ban_ip', 'allowbanipnew', $group['allowbanip'], 'radio');
showsetting('admingroups_edit_edit_user', 'alloweditusernew', $group['allowedituser'], 'radio');
showsetting('admingroups_edit_mass_prune', 'allowmassprunenew', $group['allowmassprune'], 'radio');
showsetting('admingroups_edit_edit_forum', 'alloweditforumnew', $group['alloweditforum'], 'radio');
showsetting('admingroups_edit_post_announce', 'allowpostannouncenew', $group['allowpostannounce'], 'radio');
showsetting('admingroups_edit_view_log', 'allowviewlognew', $group['allowviewlog'], 'radio');
showtagfooter('tbody');
showtagheader('tbody', 'otherperm', $anchor == 'otherperm');
showtitle('admingroups_edit_otherperm');
showsetting('admingroups_edit_disable_postctrl', 'disablepostctrlnew', $group['disablepostctrl'], 'radio');
showsetting('admingroups_edit_view_ip', 'allowviewipnew', $group['allowviewip'], 'radio');
showtagfooter('tbody');
if($id != 1) {
showsubmit('groupsubmit');
}
showtablefooter();
showformfooter();
} elseif(!$submitcheck && !empty($gset)) {
list($act, $opr) = explode('_', $gset);
if(!array_key_exists($gset, $actionarray) && !in_array($opr, $actionarray[$act])) {
cpmsg('undefined_action', '', 'error');
}
$groups = array();
$query = $db->query("SELECT ug.type, ug.groupid, ug.grouptitle, ug.radminid, aa.disabledactions
FROM {$tablepre}usergroups ug
LEFT JOIN {$tablepre}adminactions aa ON aa.admingid=ug.groupid
WHERE ug.radminid='1' ORDER BY (ug.creditshigher<>'0' || ug.creditslower<>'0'), ug.creditslower, ug.groupid");
while($group = $db->fetch_array($query)) {
$group['disabledactions'] = $group['disabledactions'] ? unserialize($group['disabledactions']) : '';
$groups[] = $group;
}
shownav('user', 'nav_admingroups');
showsubmenu($lang['admingroups_edit'].' - '.lang('admingroups_edit_permdetail').' - '.lang('admingroups_edit_action_'.$gset));
showformheader("admingroups&operation=edit&id=$id&gset=$gset");
showtableheader();
showtitle('admingroups_edit_action_'.$gset);
foreach($groups as $group) {
echo '<tr><td class="vtop td27" width="150" style="height:20px">'.$group['grouptitle'].'</td>';
echo '<td><input name="gsetnew[]" type="checkbox" class="checkbox" '.($group['groupid'] != 1 ? '' : 'disabled="disabled"').' value="'.$group['groupid'].'" '.($group['disabledactions'] && in_array($gset, $group['disabledactions']) ? '' : 'checked="checked" ').'/></td>';
}
showtablefooter();
showsubmit('groupsubmit');
showformfooter();
} elseif($id != 1) {
if(!empty($gset)) {
list($act, $opr) = explode('_', $gset);
if(!array_key_exists($gset, $actionarray) && !in_array($opr, $actionarray[$act])) {
cpmsg('undefined_action', '', 'error');
}
$query = $db->query("SELECT admingid, disabledactions FROM {$tablepre}adminactions");
$groups = array();
while($group = $db->fetch_array($query)) {
$group['disabledactions'] = unserialize($group['disabledactions']);
if(!in_array($group['admingid'], $gsetnew)) {
$group['disabledactions'][] = $gset;
} else {
$group['disabledactions'] = array_diff($group['disabledactions'], array($gset));
}
$db->query("UPDATE {$tablepre}adminactions SET disabledactions='".addslashes(serialize($group['disabledactions']))."' WHERE admingid='".$group['admingid']."'");
}
cpmsg('admingroups_edit_succeed', $BASESCRIPT.'?action=admingroups&operation=edit&gset='.$gset, 'succeed');
}
$group = $db->fetch_first("SELECT groupid, radminid FROM {$tablepre}usergroups WHERE groupid='$id'");
if(!$group) {
cpmsg('undefined_action', '', 'error');
}
if($group['radminid'] == 1) {
$actions = array();
foreach($actionarray as $key => $val) {
$actions[] = $key;
if(!empty($val) && is_array($val)) {
foreach ($val as $temp) {
$actions[] = "{$key}_{$temp}";
}
}
}
$dactionarray = array_diff($actions, $disabledactionnew);
$db->query("REPLACE INTO {$tablepre}adminactions (admingid, disabledactions)
VALUES ('$group[groupid]', '".addslashes(serialize($dactionarray))."')");
}
$db->query("UPDATE {$tablepre}admingroups SET alloweditpost='$alloweditpostnew', alloweditpoll='$alloweditpollnew', allowedittrade='$allowedittradenew', allowremovereward='$allowremoverewardnew', alloweditactivity='$alloweditactivitynew',
allowstickthread='$allowstickthreadnew', allowmodpost='$allowmodpostnew', allowbanpost='$allowbanpostnew', allowdelpost='$allowdelpostnew',
allowmassprune='$allowmassprunenew', allowrefund='$allowrefundnew', allowcensorword='$allowcensorwordnew',
allowviewip='$allowviewipnew', allowbanip='$allowbanipnew', allowedituser='$alloweditusernew', allowbanuser='$allowbanusernew',
allowmoduser='$allowmodusernew', allowpostannounce='$allowpostannouncenew', allowhighlightthread='$allowhighlightthreadnew',
allowdigestthread='$allowdigestthreadnew', allowrecommendthread='$allowrecommendthreadnew', allowbumpthread='$allowbumpthreadnew',
allowclosethread='$allowclosethreadnew', allowmovethread='$allowmovethreadnew', allowedittypethread='$allowedittypethreadnew',
allowstampthread='$allowstampthreadnew', allowcopythread='$allowcopythreadnew', allowmergethread='$allowmergethreadnew',
allowsplitthread='$allowsplitthreadnew', allowrepairthread='$allowrepairthreadnew', allowwarnpost='$allowwarnpostnew',
allowviewreport='$allowviewreportnew', alloweditforum='$alloweditforumnew', allowviewlog='$allowviewlognew',
disablepostctrl='$disablepostctrlnew' WHERE admingid='$group[groupid]'");
updatecache('usergroups');
updatecache('admingroups');
cpmsg('admingroups_edit_succeed', $BASESCRIPT.'?action=admingroups&operation=edit&id='.$group['groupid'].'&anchor='.$anchor, 'succeed');
}
}
function deletegroupcache($groupidarray) {
if(!empty($groupidarray) && is_array($groupidarray)) {
foreach ($groupidarray as $id) {
if(is_numeric($id) && $id = intval($id)) {
@unlink(DISCUZ_ROOT.'./forumdata/cache/usergroup_'.$id.'.php');
@unlink(DISCUZ_ROOT.'./forumdata/cache/admingroup_'.$id.'.php');
}
}
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/admingroups.inc.php | PHP | asf20 | 24,436 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: quickqueries.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$simplequeries = array(
array('comment' => '快速开启论坛版块功能', 'sql' => ''),
array('comment' => '开启 所有版块 主题回收站', 'sql' => 'UPDATE {tablepre}forums SET recyclebin=\'1\''),
array('comment' => '开启 所有版块 Discuz! 代码”', 'sql' => 'UPDATE {tablepre}forums SET allowbbcode=\'1\''),
array('comment' => '开启 所有版块 [IMG] 代码”', 'sql' => 'UPDATE {tablepre}forums SET allowimgcode=\'1\''),
array('comment' => '开启 所有版块 Smilies 代码', 'sql' => 'UPDATE {tablepre}forums SET allowsmilies=\'1\''),
array('comment' => '开启 所有版块 内容干扰码', 'sql' => 'UPDATE {tablepre}forums SET jammer=\'1\''),
array('comment' => '开启 所有版块 允许匿名发贴”', 'sql' => 'UPDATE {tablepre}forums SET allowanonymous=\'1\''),
array('comment' => '快速关闭论坛版块功能', 'sql' => ''),
array('comment' => '关闭 所有版块 主题回收站', 'sql' => 'UPDATE {tablepre}forums SET recyclebin=\'0\''),
array('comment' => '关闭 所有版块 HTML 代码', 'sql' => 'UPDATE {tablepre}forums SET allowhtml=\'0\''),
array('comment' => '关闭 所有版块 Discuz! 代码', 'sql' => 'UPDATE {tablepre}forums SET allowbbcode=\'0\''),
array('comment' => '关闭 所有版块 [IMG] 代码', 'sql' => 'UPDATE {tablepre}forums SET allowimgcode=\'0\''),
array('comment' => '关闭 所有版块 Smilies 代码', 'sql' => 'UPDATE {tablepre}forums SET allowsmilies=\'0\''),
array('comment' => '关闭 所有版块 内容干扰码', 'sql' => 'UPDATE {tablepre}forums SET jammer=\'0\''),
array('comment' => '关闭 所有版块 允许匿名发贴', 'sql' => 'UPDATE {tablepre}forums SET allowanonymous=\'0\''),
array('comment' => '会员操作相关', 'sql' => ''),
array('comment' => '清除 所有会员 自定义风格', 'sql' => 'UPDATE {tablepre}members SET styleid=\'0\''),
array('comment' => '清空 所有会员 积分交易记录', 'sql' => 'TRUNCATE {tablepre}creditslog;'),
array('comment' => '清空 所有会员 收藏夹', 'sql' => 'TRUNCATE {tablepre}favorites;'),
);
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/quickqueries.inc.php | PHP | asf20 | 2,372 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: creditwizard.inc.php 18655 2009-07-08 10:28:06Z wangjinbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$step = in_array($step, array(1, 2, 3)) ? $step : 1;
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable IN ('extcredits', 'initcredits', 'creditspolicy', 'creditsformula', 'creditsformulaexp', 'creditstrans', 'creditstax', 'transfermincredits', 'exchangemincredits', 'maxincperthread', 'maxchargespan')");
while($setting = $db->fetch_array($query)) {
$$setting['variable'] = $setting['value'];
}
$extcredits = unserialize($extcredits);
$initcredits = explode(',', $initcredits);
$creditspolicy = unserialize($creditspolicy);
cpheader();
if($step == 1) {
if($resetcredit >= 1 && $resetcredit <= 8) {
$initcredits[$resetcredit] = intval($initcredits[$resetcredit]);
if(!submitcheck('confirmed')) {
cpmsg('creditwizard_resetusercredit_warning', $BASESCRIPT.'?action=creditwizard&step=1&resetcredit='.$resetcredit, 'form');
} else {
$db->query("UPDATE {$tablepre}members SET extcredits$resetcredit = $initcredits[$resetcredit]", 'UNBUFFERED');
cpmsg('creditwizard_resetusercredit_ok', $BASESCRIPT.'?action=creditwizard&step=1', 'succeed');
}
exit;
}
if(!$credit) {
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', $step == 1),
array('creditwizard_step_menu_2', 'creditwizard&step=2', $step == 2),
array('creditwizard_step_menu_3', 'creditwizard&step=3', $step == 3),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
array('ec_tenpay', 'ec&operation=tenpay&from=creditwizard', 0),
));
showtableheader();
showsubtitle(array('credits_id', 'credits_title', 'creditwizard_status', ''));
for($i = 1; $i <= 8; $i++) {
showtablerow('', array('class="td21"'), array(
'extcredits'.$i,
$extcredits[$i]['title'].($i == $creditstrans ? $lang['creditwizard_iscreditstrans'] : ''),
$extcredits[$i]['available'] ? '<div class="staton">√</div>' : '<div class="statoff">-</div>',
'<a href="'.$BASESCRIPT.'?action=creditwizard&step=1&credit='.$i.'" class="act">'.$lang['detail'].'</a><a href="'.$BASESCRIPT.'?action=creditwizard&step=1&resetcredit='.$i.'" class="act">'.$lang['reset'].'</a>'
));
}
showtablefooter();
} else {
if(!submitcheck('settingsubmit')) {
$credit = $credit >=1 && $credit <= 8 ? $credit : 1;
$type = $type >=1 && $type <= 3 ? $type : 1;
$typeselected = array($type => ' selected="selected"');
$typeselect = '<select onchange="location.href=\''.$BASESCRIPT.'?action=creditwizard&step=1&credit='.$credit.'&type=\' + this.value"><option value="1"'.$typeselected[1].'>'.$lang['creditwizard_settingtype_global'].'</option><option value="2"'.$typeselected[2].'>'.$lang['creditwizard_settingtype_forum'].'</option><option value="3"'.$typeselected[3].'>'.$lang['creditwizard_settingtype_usergroup'].'</option></select>';
$creditselect = '<select onchange="location.href=\''.$BASESCRIPT.'?action=creditwizard&step=1&type='.$type.'&credit=\' + this.value">';
for($i = 1;$i <= 8;$i++) {
$creditselect .= '<option value="'.$i.'"'.($credit == $i ? ' selected="selected"' : '').'>extcredits'.$i.($extcredits[$i]['title'] ? ' ('.$extcredits[$i]['title'].')' : '').'</option>';
}
$creditselect .= '</select>';
$tips = 'creditwizard_settingtype_'.(empty($type) || $type == 1 ? 'global' : ($type == 2 ? 'forum' : ($type == 3 ? 'usergroup' : 'global'))).'_tips';
shownav('tools', 'nav_creditwizard');
showsubmenu('<a href="'.$BASESCRIPT.'?action=creditwizard&step=1">'.$lang['creditwizard_step_menu_1'].'</a> - extcredits'.$credit.($extcredits[$credit]['title'] ? '('.$extcredits[$credit]['title'].')' : ''));
showtips($tips);
showformheader("creditwizard&step=1&credit=$credit&type=$type");
showtableheader();
showtablerow('', 'class="lineheight" colspan="15"', "$lang[select]: $creditselect $typeselect");
if($type == 1) {
showtitle('settings_credits_extended');
showsetting('creditwizard_credit_title', 'settingsnew[title]', $extcredits[$credit]['title'], 'text');
showsetting('creditwizard_credits_unit', 'settingsnew[unit]', $extcredits[$credit]['unit'], 'text');
showsetting('creditwizard_credits_ratio', 'settingsnew[ratio]', $extcredits[$credit]['ratio'], 'text');
showsetting('creditwizard_credits_init', 'settingsnew[init]', intval($initcredits[$credit]), 'text');
showsetting('creditwizard_credits_available', 'settingsnew[available]', intval($extcredits[$credit]['available']), 'radio');
showsetting('creditwizard_credits_show_in_thread', 'settingsnew[showinthread]', intval($extcredits[$credit]['showinthread']), 'radio');
showsetting('settings_credits_export', 'settingsnew[allowexchangeout]', intval($extcredits[$credit]['allowexchangeout']), 'radio');
showsetting('settings_credits_import', 'settingsnew[allowexchangein]', intval($extcredits[$credit]['allowexchangein']), 'radio');
showtitle('settings_credits_policy');
showsetting('settings_credits_policy_post', 'settingsnew[policy_post]', intval($creditspolicy['post'][$credit]), 'text');
showsetting('settings_credits_policy_reply', 'settingsnew[policy_reply]', intval($creditspolicy['reply'][$credit]), 'text');
showsetting('settings_credits_policy_digest', 'settingsnew[policy_digest]', intval($creditspolicy['digest'][$credit]), 'text');
showsetting('settings_credits_policy_postattach', 'settingsnew[policy_postattach]', intval($creditspolicy['postattach'][$credit]), 'text');
showsetting('settings_credits_policy_getattach', 'settingsnew[policy_getattach]', intval($creditspolicy['getattach'][$credit]), 'text');
showsetting('settings_credits_policy_search', 'settingsnew[policy_search]', intval($creditspolicy['search'][$credit]), 'text');
showsetting('settings_credits_policy_promotion_visit', 'settingsnew[policy_promotion_visit]', intval($creditspolicy['promotion_visit'][$credit]), 'text');
showsetting('settings_credits_policy_promotion_register', 'settingsnew[policy_promotion_register]', intval($creditspolicy['promotion_register'][$credit]), 'text');
showsetting('settings_credits_policy_tradefinished', 'settingsnew[policy_tradefinished]', intval($creditspolicy['tradefinished'][$credit]), 'text');
showsetting('settings_credits_policy_votepoll', 'settingsnew[policy_votepoll]', intval($creditspolicy['votepoll'][$credit]), 'text');
showsetting('settings_credits_policy_lowerlimit', 'settingsnew[lowerlimit]', intval($extcredits[$credit]['lowerlimit']), 'text');
showtablerow('', 'class="lineheight" colspan="2"', $lang['settings_credits_policy_comment']);
showsubmit('settingsubmit', 'submit', '<input type="reset" class="btn" name="settingsubmit" value="'.$lang['reset'].'" />');
showtablefooter();
showformfooter();
} elseif($type == 2) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$fids = implode(',', array_keys($_DCACHE['forums']));
$query = $db->query("SELECT fid, postcredits, replycredits, getattachcredits, postattachcredits, digestcredits
FROM {$tablepre}forumfields WHERE fid in ($fids)");
while($forumcredit = $db->fetch_array($query)) {
$forumcredit['postcreditsstatus'] = $forumcredit['postcredits'] ? 'checked' : '';
$forumcredit['postcredits'] = $forumcredit['postcredits'] ? unserialize($forumcredit['postcredits']) : array();
$forumcredit['postcredits'] = intval($forumcredit['postcredits'][$credit]);
$forumcredit['replycreditsstatus'] = $forumcredit['replycredits'] ? 'checked' : '';
$forumcredit['replycredits'] = $forumcredit['replycredits'] ? unserialize($forumcredit['replycredits']) : array();
$forumcredit['replycredits'] = intval($forumcredit['replycredits'][$credit]);
$forumcredit['getattachcreditsstatus'] = $forumcredit['getattachcredits'] ? 'checked' : '';
$forumcredit['getattachcredits'] = $forumcredit['getattachcredits'] ? unserialize($forumcredit['getattachcredits']) : array();
$forumcredit['getattachcredits'] = intval($forumcredit['getattachcredits'][$credit]);
$forumcredit['postattachcreditsstatus'] = $forumcredit['postattachcredits'] ? 'checked' : '';
$forumcredit['postattachcredits'] = $forumcredit['postattachcredits'] ? unserialize($forumcredit['postattachcredits']) : array();
$forumcredit['postattachcredits'] = intval($forumcredit['postattachcredits'][$credit]);
$forumcredit['digestcreditsstatus'] = $forumcredit['digestcredits'] ? 'checked' : '';
$forumcredit['digestcredits'] = $forumcredit['digestcredits'] ? unserialize($forumcredit['digestcredits']) : array();
$forumcredit['digestcredits'] = intval($forumcredit['digestcredits'][$credit]);
$forumcredits[$forumcredit['fid']] = $forumcredit;
}
$credittable = '';
foreach($_DCACHE['forums'] as $fid => $forum) {
if($forum['type'] != 'group') {
$credittable .= showtablerow('', array('', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), array(
"<input class=\"checkbox\" title=\"$lang[select_all]\" type=\"checkbox\" name=\"chkallv$fid\" onclick=\"checkAll('value', this.form, $fid, 'chkallv$fid')\">".
($forum['type'] == 'forum' ? '' : ' ').
" <a href=\"$BASESCRIPT?frames=yes&action=forums&operation=edit&fid=$fid&anchor=credits\" target=\"_blank\">$forum[name]</a>",
"<input class=\"checkbox\" type=\"checkbox\" name=\"postcreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][postcreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"postcredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][postcredits]}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"replycreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][replycreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"replycredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][replycredits]}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"digestcreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][digestcreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"digestcredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][digestcredits]}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"postattachcreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][postattachcreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"postattachcredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][postattachcredits]}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"getattachcreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][getattachcreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"getattachcredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][getattachcredits]}\">"
), TRUE);
}
}
showtitle('creditwizard_forum_creditspolicy');
?>
<tr ><td><?=$lang['forum']?></td>
<td><input class="checkbox" type="checkbox" name="chkall1" id="chkall1" onclick="checkAll('prefix', this.form, 'postcreditsstatus', 'chkall1')" /><label for="chkall1"> <?=$lang['settings_credits_policy_post']?></label></td>
<td><input class="checkbox" type="checkbox" name="chkall2" id="chkall2" onclick="checkAll('prefix', this.form, 'replycreditsstatus', 'chkall2')" /><label for="chkall2"> <?=$lang['settings_credits_policy_reply']?></label></td>
<td><input class="checkbox" type="checkbox" name="chkall3" id="chkall3" onclick="checkAll('prefix', this.form, 'digestcreditsstatus', 'chkall3')" /><label for="chkall3"> <?=$lang['settings_credits_policy_digest']?></label></td>
<td><input class="checkbox" type="checkbox" name="chkall4" id="chkall4" onclick="checkAll('prefix', this.form, 'postattachcreditsstatus', 'chkall4')" /><label for="chkall4"> <?=$lang['settings_credits_policy_postattach']?></label></td>
<td><input class="checkbox" type="checkbox" name="chkall5" id="chkall5" onclick="checkAll('prefix', this.form, 'getattachcreditsstatus', 'chkall5')" /><label for="chkall5"> <?=$lang['settings_credits_policy_getattach']?></label></td></tr>
<?
echo $credittable;
showsubmit('settingsubmit', 'submit', '<input type="button" class="btn" value="'.$lang['creditwizard_return'].'" onclick="location.href=\''.$BASESCRIPT.'?action=creditwizard&step=1\'" /> <input type="reset" class="btn" name="settingsubmit" value="'.$lang['reset'].'" />');
showtablefooter();
showformfooter();
} else {
$query = $db->query("SELECT groupid, grouptitle, raterange FROM {$tablepre}usergroups ORDER BY type DESC, groupid");
$raterangetable = '';
while($group = $db->fetch_array($query)) {
$ratemin = $ratemax = $ratemrpd = '';
foreach(explode("\n", $group['raterange']) as $range) {
$range = explode("\t", $range);
if($range[0] == $credit) {
$ratemin = $range[1];$ratemax = $range[2];$ratemrpd = $range[3];break;
}
}
$raterangetable .= showtablerow('', array('', 'class="td28"', 'class="td28"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"raterangestatus[$group[groupid]]\" value=\"1\" ".($ratemin && $ratemax && $ratemax ? 'checked' : '')."> <a href=\"$BASESCRIPT?frames=yes&action=groups&operation=user&do=edit&id=$group[groupid]&anchor=exempt\" target=\"_blank\">$group[grouptitle]</a>",
"<input type=\"text\" class=\"txt\" name=\"ratemin[$group[groupid]]\" size=\"3\" value=\"$ratemin\">",
"<input type=\"text\" class=\"txt\" name=\"ratemax[$group[groupid]]\" size=\"3\" value=\"$ratemax\">",
"<input type=\"text\" class=\"txt\" name=\"ratemrpd[$group[groupid]]\" size=\"3\" value=\"$ratemrpd\">"
), TRUE);
}
showtitle('creditwizard_forum_groupraterange');
showsubtitle(array('forum', 'usergroups_edit_raterange_min', 'usergroups_edit_raterange_max', 'usergroups_edit_raterange_mrpd'));
echo $raterangetable;
showsubmit('settingsubmit', 'submit', '<input type="reset" class="btn" name="settingsubmit" value="'.$lang['reset'].'" />');
showtablefooter();
showformfooter();
}
} else {
if($type == 1) {
if($creditstrans == $credit && empty($settingsnew['available'])) {
cpmsg('settings_creditstrans_invalid', '', 'error');
}
$initcredits[$credit] = intval($settingsnew['init']);
$initcredits = implode(',', $initcredits);
$extcredits[$credit] = array(
'title' => dhtmlspecialchars(stripslashes($settingsnew['title'])),
'unit' => dhtmlspecialchars(stripslashes($settingsnew['unit'])),
'ratio' => ($settingsnew['ratio'] > 0 ? (float)$settingsnew['ratio'] : 0),
'available' => $settingsnew['available'],
'showinthread' => $settingsnew['showinthread'],
'allowexchangeout' => $settingsnew['allowexchangeout'],
'allowexchangein' => $settingsnew['allowexchangein'],
'lowerlimit' => intval($settingsnew['lowerlimit']));
$extcredits = addslashes(serialize($extcredits));
$creditspolicy['post'][$credit] = intval($settingsnew['policy_post']);
$creditspolicy['reply'][$credit] = intval($settingsnew['policy_reply']);
$creditspolicy['digest'][$credit] = intval($settingsnew['policy_digest']);
$creditspolicy['postattach'][$credit] = intval($settingsnew['policy_postattach']);
$creditspolicy['getattach'][$credit] = intval($settingsnew['policy_getattach']);
$creditspolicy['pm'][$credit] = intval($settingsnew['policy_pm']);
$creditspolicy['search'][$credit] = intval($settingsnew['policy_search']);
$creditspolicy['promotion_visit'][$credit] = intval($settingsnew['policy_promotion_visit']);
$creditspolicy['promotion_register'][$credit] = intval($settingsnew['policy_promotion_register']);
$creditspolicy['tradefinished'][$credit] = intval($settingsnew['policy_tradefinished']);
$creditspolicy['votepoll'][$credit] = intval($settingsnew['policy_votepoll']);
$creditspolicy = serialize($creditspolicy);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('initcredits', '$initcredits')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('extcredits', '$extcredits')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditspolicy', '$creditspolicy')");
updatecache('settings');
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=1&credit='.$credit.'&type=1', 'succeed');
} elseif($type == 2) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$fids = implode(',', array_keys($_DCACHE['forums']));
$query = $db->query("SELECT fid, postcredits, replycredits, getattachcredits, postattachcredits, digestcredits
FROM {$tablepre}forumfields WHERE fid in ($fids)");
$sqls = array();
while($forumcredit = $db->fetch_array($query)) {
$forumcredit['postcredits'] = $forumcredit['postcredits'] ? unserialize($forumcredit['postcredits']) : array();
$forumcredit['postcredits'][$credit] = intval($postcredits[$forumcredit['fid']]);
$forumcredit['postcredits'][$credit] = $forumcredit['postcredits'][$credit] < -99 ? -99 : $forumcredit['postcredits'][$credit];
$forumcredit['postcredits'][$credit] = $forumcredit['postcredits'][$credit] > 99 ? 99 : $forumcredit['postcredits'][$credit];
$sql = "postcredits='".($postcreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['postcredits'])) : '')."'";
$forumcredit['replycredits'] = $forumcredit['replycredits'] ? unserialize($forumcredit['replycredits']) : array();
$forumcredit['replycredits'][$credit] = intval($replycredits[$forumcredit['fid']]);
$forumcredit['replycredits'][$credit] = $forumcredit['replycredits'][$credit] < -99 ? -99 : $forumcredit['replycredits'][$credit];
$forumcredit['replycredits'][$credit] = $forumcredit['replycredits'][$credit] > 99 ? 99 : $forumcredit['replycredits'][$credit];
$sql .= ",replycredits='".($replycreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['replycredits'])) : '')."'";
$forumcredit['getattachcredits'] = $forumcredit['getattachcredits'] ? unserialize($forumcredit['getattachcredits']) : array();
$forumcredit['getattachcredits'][$credit] = intval($getattachcredits[$forumcredit['fid']]);
$forumcredit['getattachcredits'][$credit] = $forumcredit['getattachcredits'][$credit] < -99 ? -99 : $forumcredit['getattachcredits'][$credit];
$forumcredit['getattachcredits'][$credit] = $forumcredit['getattachcredits'][$credit] > 99 ? 99 : $forumcredit['getattachcredits'][$credit];
$sql .= ",getattachcredits='".($getattachcreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['getattachcredits'])) : '')."'";
$forumcredit['postattachcredits'] = $forumcredit['postattachcredits'] ? unserialize($forumcredit['postattachcredits']) : array();
$forumcredit['postattachcredits'][$credit] = intval($postattachcredits[$forumcredit['fid']]);
$forumcredit['postattachcredits'][$credit] = $forumcredit['postattachcredits'][$credit] < -99 ? -99 : $forumcredit['postattachcredits'][$credit];
$forumcredit['postattachcredits'][$credit] = $forumcredit['postattachcredits'][$credit] > 99 ? 99 : $forumcredit['postattachcredits'][$credit];
$sql .= ",postattachcredits='".($postattachcreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['postattachcredits'])) : '')."'";
$forumcredit['digestcredits'] = $forumcredit['digestcredits'] ? unserialize($forumcredit['digestcredits']) : array();
$forumcredit['digestcredits'][$credit] = intval($digestcredits[$forumcredit['fid']]);
$forumcredit['digestcredits'][$credit] = $forumcredit['digestcredits'][$credit] < -99 ? -99 : $forumcredit['digestcredits'][$credit];
$forumcredit['digestcredits'][$credit] = $forumcredit['digestcredits'][$credit] > 99 ? 99 : $forumcredit['digestcredits'][$credit];
$sql .= ",digestcredits='".($digestcreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['digestcredits'])) : '')."'";
$db->query("UPDATE {$tablepre}forumfields SET $sql WHERE fid=$forumcredit[fid]", 'UNBUFFERED');
}
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=1&credit='.$credit.'&type=2', 'succeed');
} else {
$query = $db->query("SELECT groupid, grouptitle, raterange FROM {$tablepre}usergroups");
$raterangetable = '';
while($group = $db->fetch_array($query)) {
$raterangenew = '';
$rangearray = array();
foreach(explode("\n", $group['raterange']) as $range) {
$ranges = explode("\t", $range);
$rangearray[$ranges[0]] = $range;
}
$range = array();
if($raterangestatus[$group['groupid']]) {
$range[0] = $credit;
$range[1] = intval($ratemin[$group['groupid']] < -999 ? -999 : $ratemin[$group['groupid']]);
$range[2] = intval($ratemax[$group['groupid']] > 999 ? 999 : $ratemax[$group['groupid']]);
$range[3] = intval($ratemrpd[$group['groupid']] > 99999 ? 99999 : $ratemrpd[$group['groupid']]);
if(!$range[3] || $range[2] <= $range[1] || $range[3]< max(abs($range[1]), abs($range[2]))) {
cpmsg('creditwizard_edit_rate_invalid', '', 'error');
}
$rangearray[$credit] = implode("\t", $range);
} else {
unset($rangearray[$credit]);
}
$raterangenew = $rangearray ? implode("\n", $rangearray) : '';
$db->query("UPDATE {$tablepre}usergroups SET raterange='$raterangenew' WHERE groupid=$group[groupid]", 'UNBUFFERED');
}
updatecache('usergroups');
updatecache('admingroups');
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=1&credit='.$credit.'&type=3', 'succeed');
}
}
}
} elseif($step == 2) {
if(!submitcheck('settingsubmit')) {
$formulareplace .= '\'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\',\'<u>'.$lang['settings_credits_formula_posts'].'</u>\',\'<u>'.$lang['settings_credits_formula_threads'].'</u>\',\'<u>'.$lang['settings_credits_formula_oltime'].'</u>\',\'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\'';
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, textend) {
$('creditsformulanew').focus();
textend = isUndefined(textend) ? '' : textend;
if(!isUndefined($('creditsformulanew').selectionStart)) {
var opn = $('creditsformulanew').selectionStart + 0;
if(textend != '') {
text = text + $('creditsformulanew').value.substring($('creditsformulanew').selectionStart, $('creditsformulanew').selectionEnd) + textend;
}
$('creditsformulanew').value = $('creditsformulanew').value.substr(0, $('creditsformulanew').selectionStart) + text + $('creditsformulanew').value.substr($('creditsformulanew').selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
if(textend != '') {
text = text + sel.text + textend;
}
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$('creditsformulanew').value += text;
}
formulaexp();
}
var formulafind = new Array('digestposts', 'posts', 'threads', 'oltime', 'pageviews');
var formulareplace = new Array(<?=$formulareplace?>);
function formulaexp() {
var result = $('creditsformulanew').value;
<?
$extcreditsbtn = '';
for($i = 1; $i <= 8; $i++) {
$extcredittitle = $extcredits[$i]['available'] ? $extcredits[$i]['title'] : $lang['settings_credits_formula_extcredits'].$i;
echo 'result = result.replace(/extcredits'.$i.'/g, \'<u>'.$extcredittitle.'</u>\');';
$extcreditsbtn .= '<a href="###" onclick="insertunit(\'extcredits'.$i.'\')">'.$extcredittitle.'</a> ';
}
echo 'result = result.replace(/digestposts/g, \'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\');';
echo 'result = result.replace(/posts/g, \'<u>'.$lang['settings_credits_formula_posts'].'</u>\');';
echo 'result = result.replace(/threads/g, \'<u>'.$lang['settings_credits_formula_threads'].'</u>\');';
echo 'result = result.replace(/oltime/g, \'<u>'.$lang['settings_credits_formula_oltime'].'</u>\');';
echo 'result = result.replace(/pageviews/g, \'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\');';
?>
$('creditsformulaexp').innerHTML = '<u><?=$lang['settings_credits_formula_credits']?></u>=' + result;
}
</script>
<?
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', $step == 1),
array('creditwizard_step_menu_2', 'creditwizard&step=2', $step == 2),
array('creditwizard_step_menu_3', 'creditwizard&step=3', $step == 3),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
array('ec_tenpay', 'ec&operation=tenpay&from=creditwizard', 0),
));
showtips('creditwizard_tips_formula');
showformheader('creditwizard&step=2');
showtableheader();
showtitle('settings_credits_formula');
showtablerow('', 'colspan="2"', '<div class="extcredits">'.$extcreditsbtn.'<br /><a href="###" onclick="insertunit(\'digestposts\')">'.$lang['settings_credits_formula_digestposts'].'</a> <a href="###" onclick="insertunit(\'posts\')">'.$lang['settings_credits_formula_posts'].'</a> <a href="###" onclick="insertunit(\'threads\')">'.$lang['settings_credits_formula_threads'].'</a> <a href="###" onclick="insertunit(\'oltime\')">'.$lang['settings_credits_formula_oltime'].'</a> <a href="###" onclick="insertunit(\'pageviews\')">'.$lang['settings_credits_formula_pageviews'].'</a> <a href="###" onclick="insertunit(\'+\')"> + </a> <a href="###" onclick="insertunit(\'-\')"> - </a> <a href="###" onclick="insertunit(\'*\')"> * </a> <a href="###" onclick="insertunit(\'/\')"> / </a> <a href="###" onclick="insertunit(\'(\', \')\')"> ( ) </a></div><div id="creditsformulaexp" class="marginbot diffcolor2">'.$creditsformulaexp.'</div><textarea name="creditsformulanew" id="creditsformulanew" style="width: 80%" rows="3" onkeyup="formulaexp()">'.dhtmlspecialchars($creditsformula).'</textarea>');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
} else {
if(!preg_match("/^([\+\-\*\/\.\d\(\)]|((extcredits[1-8]|digestposts|posts|threads|pageviews|oltime)([\+\-\*\/\(\)]|$)+))+$/", $creditsformulanew) || !is_null(@eval(preg_replace("/(digestposts|posts|threads|pageviews|oltime|extcredits[1-8])/", "\$\\1", $creditsformulanew).';'))) {
cpmsg('settings_creditsformula_invalid', '', 'error');
}
$creditsformulaexpnew = $creditsformulanew;
foreach(array('digestposts', 'posts', 'threads', 'oltime', 'pageviews', 'extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8') as $var) {
if($extcredits[$creditsid = preg_replace("/^extcredits(\d{1})$/", "\\1", $var)]['available']) {
$replacement = $extcredits[$creditsid]['title'];
} else {
$replacement = $lang['settings_credits_formula_'.$var];
}
$creditsformulaexpnew = str_replace($var, '<u>'.$replacement.'</u>', $creditsformulaexpnew);
}
$creditsformulaexpnew = addslashes('<u>'.$lang['settings_credits_formula_credits'].'</u>='.$creditsformulaexpnew);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditsformula', '".addslashes($creditsformulanew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditsformulaexp', '".addslashes($creditsformulaexpnew)."')");
updatecache('settings');
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=2', 'succeed');
}
} else {
if(!submitcheck('settingsubmit')) {
$creditstransselect = '';
$creditstrans = explode(',', $creditstrans);
for($i = 0; $i <= 8; $i++) {
if($i == 0 || $extcredits[$i]['available']) {
$creditstransselect .= '<option value="'.$i.'" '.($i == intval($creditstrans[0]) ? 'selected' : '').'>'.($i ? 'extcredits'.$i.' ('.$extcredits[$i]['title'].')' : $lang['none']).'</option>';
}
}
function showtextradio($textname, $textvalue, $radioname, $radioes = array()) {
$a = '<input type="text" class="txt marginbot" name="'.$textname.'" id="'.$textname.'" value="'.$textvalue.'" /><ul style="width: 340px;" onmouseover="altStyle(this);">';
if(is_array($radioes)) {
foreach($radioes as $radio) {
$a .= '<li><input type="radio" name="'.$radioname.'" value="'.$radio[1].'" class="radio" onclick="$(\''.$textname.'\').value = this.value"'.($radio[2] ? ' checked="checked"' : '').' /> '.$radio[0].'</li>';
}
}
$a .= '</ul>';
return $a;
}
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', $step == 1),
array('creditwizard_step_menu_2', 'creditwizard&step=2', $step == 2),
array('creditwizard_step_menu_3', 'creditwizard&step=3', $step == 3),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
array('ec_tenpay', 'ec&operation=tenpay&from=creditwizard', 0),
));
showtips('creditwizard_tips_creditsuse');
showformheader('creditwizard&step=3');
showtableheader('creditwizard_step_menu_3');
showsetting('settings_credits_trans', '', '', '<select onchange="$(\'allowcreditstrans\').style.display = this.value != 0 ? \'\' : \'none\'" name="creditstransnew">'.$creditstransselect.'</select>');
showsetting('settings_credits_tax', '', '', showtextradio('creditstaxnew', $creditstax, 'creditstaxradio', array(
array($lang['low'].' (0.01)', '0.01', $creditstax == '0.01'),
array($lang['middle'].' (0.1)', '0.1', $creditstax == '0.1'),
array($lang['high'].' (0.5)', '0.5', $creditstax == '0.5')
)));
showsetting('settings_credits_minexchange', '', '', showtextradio('exchangemincreditsnew', $exchangemincredits, 'exchangemincreditsradio', array(
array($lang['low'].' (100)', 100, $exchangemincredits == 100),
array($lang['middle'].' (1000)', 1000, $exchangemincredits == 1000),
array($lang['high'].' (5000)', 5000, $exchangemincredits == 5000)
)));
showtagheader('tbody', 'allowcreditstrans', $creditstrans);
showtitle('creditwizard_allowcreditstrans');
showsetting('settings_credits_mintransfer', '', '', showtextradio('transfermincreditsnew', $transfermincredits, 'transfermincreditsradio', array(
array($lang['low'].' (100)', 100, $transfermincredits == 100),
array($lang['middle'].' (1000)', 1000, $transfermincredits == 1000),
array($lang['high'].' (5000)', 5000, $transfermincredits == 5000)
)));
showsetting('settings_credits_maxincperthread', '', '', showtextradio('maxincperthreadnew', $maxincperthread, 'maxincperthreadradio', array(
array($lang['nolimit'].' (0)', 0, $maxincperthread == 0),
array($lang['low'].' (10)', 10, $maxincperthread == 10),
array($lang['middle'].' (50)', 50, $maxincperthread == 50),
array($lang['high'].' (100)', 100, $maxincperthread == 100)
)));
showsetting('settings_credits_maxchargespan', '', '', showtextradio('maxchargespannew', $maxchargespan, 'maxchargespanradio', array(
array($lang['nolimit'].' (0)', 0, $maxchargespan == 0),
array($lang['low'].' (5)', 5, $maxchargespan == 5),
array($lang['middle'].' (24)', 24, $maxchargespan == 24),
array($lang['high'].' (48)', 48, $maxchargespan == 48)
)));
showtagfooter('tbody');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
} else {
if($creditstaxnew < 0 || $creditstaxnew >= 1) {
$creditstaxnew = 0;
}
$creditstrans = explode(',', $creditstrans);
$creditstrans[0] = (float)$creditstransnew;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditstrans', '".implode(',', $creditstrans)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditstax', '".((float)$creditstaxnew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('transfermincredits', '".((float)$transfermincreditsnew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('exchangemincredits', '".((float)$exchangemincreditsnew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('maxincperthread', '".((float)$maxincperthreadnew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('maxchargespan', '".((float)$maxchargespannew)."')");
updatecache('settings');
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=3', 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/creditwizard.inc.php | PHP | asf20 | 33,606 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: qihoo.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='qihoo'");
$qihoo = ($qihoo = $db->result($query, 0)) ? unserialize($qihoo) : array();
$operation = !empty($operation) ? $operation : 'config';
if($operation == 'config') {
if(!submitcheck('qihoosubmit')) {
$checks = array();
$checkstatus = array($qihoo['status'] => 'checked');
$checklocation = array($qihoo['location'] => 'checked');
$qihoo['searchbox'] = sprintf('%03b', $qihoo['searchbox']);
for($i = 1; $i <= 3; $i++) {
$checks[$i] = $qihoo['searchbox'][3 - $i] ? 'checked' : '';
}
shownav('extended', 'nav_qihoo');
showsubmenu('nav_qihoo', array(
array('nav_qihoo_config', 'qihoo&operation=config', 1),
array('nav_qihoo_topics', 'qihoo&operation=topics', 0),
array('nav_qihoo_relatedthreads', 'qihoo&operation=relatedthreads', 0)
));
showtips('qihoo_tips');
showformheader('qihoo&operation=config');
showtableheader();
showtitle('qihoo');
showsetting('qihoo_status', '', '', '<ul class="nofloat" onmouseover="altStyle(this);"><li'.($checkstatus[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="qihoonew[status]" value="1" '.$checkstatus[1].'> '.$lang['qihoo_status_enable'].'</li><li'.($checkstatus[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="qihoonew[status]" value="2" '.$checkstatus[2].'> '.$lang['qihoo_status_enable_default'].'</li><li'.($checkstatus[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="qihoonew[status]" value="0" '.$checkstatus[0].'> '.$lang['qihoo_status_disable'].'</li></ul>');
showsetting('qihoo_searchbox', '', '', '<ul class="nofloat" onmouseover="altStyle(this);"><li'.($checks[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="qihoonew[searchbox][1]" value="1" '.$checks[1].'> '.$lang['qihoo_searchbox_index'].'</li><li'.($checks[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="qihoonew[searchbox][2]" value="1" '.$checks[2].'> '.$lang['qihoo_searchbox_forumdisplay'].'</li></ul>');
showsetting('qihoo_summary', 'qihoonew[summary]', $qihoo['summary'], 'radio');
showsetting('qihoo_jammer_allow', 'qihoonew[jammer]', $qihoo['jammer'], 'radio');
showsetting('qihoo_maxtopics', 'qihoonew[maxtopics]', $qihoo['maxtopics'], 'text');
showsetting('qihoo_keywords', 'qihoonew[keywords]', $qihoo['keywords'], 'textarea');
showsetting('qihoo_adminemail', 'qihoonew[adminemail]', $qihoo['adminemail'], 'text');
showsubmit('qihoosubmit');
showtablefooter();
showformfooter();
} else {
$qihoonew['searchbox'] = bindec(intval($qihoonew['searchbox'][3]).intval($qihoonew['searchbox'][2]).intval($qihoonew['searchbox'][1]));
$qihoonew['validity'] = $qihoonew['validity'] < 1 ? 1 : intval($qihoonew['validity']);
if($qihoonew['status'] && $qihoonew['adminemail']) {
if(!isemail($qihoonew['adminemail'])) {
cpmsg('qihoo_adminemail_invalid', '', 'error');
}
if($qihoonew['adminemail'] != $qihoo['adminemail']) {
dfopen('http://search.qihoo.com/corp/discuz.html?site='.site().'&key='.md5(site().'qihoo_discuz'.gmdate("Ymd", $timestamp)).'&email='.$qihoonew['adminemail']);
}
}
foreach((array)$qihoonew as $key => $value) {
$qihoo[$key] = in_array($key, array('keywords', 'adminemail')) ? $value : intval($value);
}
$db->query("UPDATE {$tablepre}settings SET value='".addslashes(serialize($qihoo))."' WHERE variable='qihoo'");
updatecache('settings');
cpmsg('qihoo_succeed', $BASESCRIPT.'?action=qihoo&operation=config', 'succeed');
}
} elseif($operation == 'relatedthreads') {
if(!submitcheck('qihoosubmit')) {
$checktype = array();
$settings = is_array($qihoo['relatedthreads']) ? $qihoo['relatedthreads'] : array();
foreach((array)$settings['type'] as $type) {
$checktype[$type] = 'checked';
}
shownav('extended', 'nav_qihoo');
showsubmenu('nav_qihoo', array(
array('nav_qihoo_config', 'qihoo&operation=config', 0),
array('nav_qihoo_topics', 'qihoo&operation=topics', 0),
array('nav_qihoo_relatedthreads', 'qihoo&operation=relatedthreads', 1)
));
showtips('qihoo_tips');
showformheader('qihoo&operation=relatedthreads');
showtableheader();
showsetting('qihoo_relatedthreads', 'settingsnew[bbsnum]', $settings['bbsnum'], 'text');
showsetting('qihoo_relatedthreads_web', 'settingsnew[webnum]', $settings['webnum'], 'radio');
showsetting('qihoo_relatedthreads_type', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">'.
'<li'.($checktype['news'] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="settingsnew[type][news]" value="news" '.$checktype['news'].'> '.$lang['qihoo_relatedthreads_type_news'].'</li>'.
'<li'.($checktype['bbs'] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="settingsnew[type][bbs]" value="bbs" '.$checktype['bbs'].'> '.$lang['qihoo_relatedthreads_type_bbs']).'</li></ul>';
showsetting('qihoo_relatedthreads_banurl', 'settingsnew[banurl]', $settings['banurl'], 'textarea');
showsetting('qihoo_relatedthreads_position', array('settingsnew[position]', array(
array(0, $lang['qihoo_relatedthreads_position_mode_top']),
array(1, $lang['qihoo_relatedthreads_position_mode_under'])
)), $settings['position'], 'mradio');
//showsetting('qihoo_relatedthreads_validity', 'settingsnew[validity]', $settings['validity'], 'text');
showsubmit('qihoosubmit');
showtablefooter();
showformfooter();
} else {
$qihoo['relatedthreads'] = array();
foreach((array)$settingsnew as $key => $value) {
$qihoo['relatedthreads'][$key] = in_array($key, array('bbsnum', 'webnum', 'position', 'order', 'validity')) ? intval($value) : $value;
}
$db->query("UPDATE {$tablepre}settings SET value='".addslashes(serialize($qihoo))."' WHERE variable='qihoo'");
updatecache('settings');
cpmsg('qihoo_succeed', $BASESCRIPT.'?action=qihoo&operation=relatedthreads', 'succeed');
}
} elseif($operation == 'topics') {
if(!submitcheck('topicsubmit')) {
showsubmenu('nav_qihoo', array(
array('nav_qihoo_config', 'qihoo&operation=config', 0),
array('nav_qihoo_topics', 'qihoo&operation=topics', 1),
array('nav_qihoo_relatedthreads', 'qihoo&operation=relatedthreads', 0)
));
showtips('qihoo_topics_tips');
showformheader('qihoo&operation=topics');
showtableheader('qihoo_topics_list');
showsubtitle(array('', 'qihoo_topics_name', 'qihoo_topics_keywords', 'qihoo_topics_length', 'qihoo_topics_type', 'qihoo_topics_orderby', ''));
foreach((is_array($qihoo['topics']) ? $qihoo['topics'] : array()) as $key => $value) {
$checkstype = array($value['stype'] => 'selected="selected"');
$checkrelate = array($value['relate'] => 'selected="selected"');
showtablerow('', array('class="td25"', '', 'class="td29"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$key]\" value=\"".$value['topic']."\">",
"<input type=\"text\" class=\"txt\" size=\"20\" name=\"qihoo_topics[$key][topic]\" id=\"qihoo_topics[$key][topic]\" value=\"$value[topic]\">",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"qihoo_topics[$key][keyword]\" id=\"qihoo_topics[$key][keyword]\" value=\"$value[keyword]\">",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"qihoo_topics[$key][length]\" id=\"qihoo_topics[$key][length]\" value=\"$value[length]\">",
"<select name=\"qihoo_topics[$key][stype]\" id=\"qihoo_topics[$key][stype]\"><option value=\"0\" $checkstype[0]>$lang[qihoo_topics_type_fulltext]</option><option value=\"title\" $checkstype[title]>$lang[qihoo_topics_type_title]</option></select>",
"<select name=\"qihoo_topics[$key][relate]\" id=\"qihoo_topics[$key][relate]\"><option value=\"score\" $checkrelate[score]>$lang[qihoo_topics_orderby_relation]</option><option value=\"pdate\" $checkrelate[pdate]>$lang[qihoo_topics_orderby_dateline]</option><option value=\"rdate\" $checkrelate[rdate]>$lang[qihoo_topics_orderby_lastpost]</option></select>",
"<a href=\"###\" onClick=\"window.open('topic.php?topic='+$('qihoo_topics[$key][topic]').value+'&keyword='+$('qihoo_topics[$key][keyword]').value+'&stype='+$('qihoo_topics[$key][stype]').value+'&length='+$('qihoo_topics[$key][length]').value+'&relate='+$('qihoo_topics[$key][relate]').value+'');\" class=\"act\">".lang('preview')."</a>"
));
}
showtablerow('', array('class="td25"', '', 'class="td29"'), array(
lang('add_new'),
'<input type="text" class="txt" size="20" name="newtopic" id="newtopic">',
'<input type="text" class="txt" size="30" name="newkeyword" id="newkeyword">',
'<input type="text" class="txt" size="10" name="newlength" id="newlength" value="0">',
'<select name="newstype" id="newstype"><option value="0" selected>'.lang('qihoo_topics_type_fulltext').'</option><option value="1">'.lang('qihoo_topics_type_title').'</option></select>',
'<select name="newrelate" id="newrelate"><option value="score">'.lang('qihoo_topics_orderby_relation').'</option><option value="pdate">'.lang('qihoo_topics_orderby_dateline').'</option><option value="rdate">'.lang('qihoo_topics_orderby_lastpost').'</option></select>',
'<a href="###" onClick="window.open(\'topic.php?topic=\'+$(\'newtopic\').value+\'&keyword=\'+$(\'newkeyword\').value+\'&stype=\'+$(\'newstype\').value+\'&length=\'+$(\'newlength\').value+\'&relate=\'+$(\'newrelate\').value);" class="act">'.lang('preview').'</a>'
));
showsubmit('topicsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
$qihoo['topics'] = array();
foreach((array)$qihoo_topics as $key => $value) {
if(isset($delete[$key])) {
unset($qihoo['topics'][$key]);
} else {
$qihoo['topics'][$key] = array(
'topic' => dhtmlspecialchars(stripslashes($value['topic'])),
'keyword' => $value['keyword'] = trim($value['keyword']) ? dhtmlspecialchars(stripslashes($value['keyword'])) : $value['topic'],
'length' => intval($value['length']),
'stype' => $value['stype'],
'relate' => $value['relate']
);
}
}
if($newtopic) {
$qihoo['topics'][] = array(
'topic' => dhtmlspecialchars(stripslashes($newtopic)),
'keyword' => $newkeyword = trim($newkeyword) ? dhtmlspecialchars(stripslashes($newkeyword)) : $newtopic,
'length' => intval($newlength),
'stype' => $newstype > 1 ? 1 : intval($newstype),
'relate' => $newrelate
);
}
$db->query("UPDATE {$tablepre}settings SET value='".addslashes(serialize($qihoo))."' WHERE variable='qihoo'");
updatecache('settings');
cpmsg('qihoo_topics_succeed', $BASESCRIPT.'?action=qihoo&operation=topics', 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/qihoo.inc.php | PHP | asf20 | 11,080 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: usergroups.inc.php 20965 2009-11-04 06:37:32Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(!submitcheck('groupsubmit')) {
$sgroups = $smembers = array();
$sgroupids = '0';
$smembernum = $membergroup = $specialgroup = $sysgroup = $membergroupoption = $specialgroupoption = '';
$query = $db->query("SELECT groupid, radminid, type, grouptitle, creditshigher, creditslower, stars, color, groupavatar FROM {$tablepre}usergroups ORDER BY creditshigher");
while($group = $db->fetch_array($query)) {
if($group['type'] == 'member') {
$membergroupoption .= "<option value=\"g{$group[groupid]}\">$group[grouptitle]</option>";
$membergroup .= showtablerow('', array('class="td25"', '', 'class="td28"', 'class=td28'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$group[groupid]]\" value=\"$group[groupid]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"groupnew[$group[groupid]][grouptitle]\" value=\"$group[grouptitle]\">",
"<input type=\"text\" class=\"txt\" size=\"6\" name=\"groupnew[$group[groupid]][creditshigher]\" value=\"$group[creditshigher]\" /> ~ <input type=\"text\" class=\"txt\" size=\"6\" name=\"groupnew[$group[groupid]][creditslower]\" value=\"$group[creditslower]\" disabled />",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"groupnew[$group[groupid]][stars]\" value=\"$group[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\" name=\"groupnew[$group[groupid]][color]\" value=\"$group[color]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"groupnew[$group[groupid]][groupavatar]\" value=\"$group[groupavatar]\">",
"<a href=\"$BASESCRIPT?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
} elseif($group['type'] == 'system') {
$sysgroup .= showtablerow('', array('', '', 'class="td28"'), array(
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_title[$group[groupid]]\" value=\"$group[grouptitle]\">",
$lang['usergroups_system_'.$group['groupid']],
"<input type=\"text\" class=\"txt\" size=\"2\"name=\"group_stars[$group[groupid]]\" value=\"$group[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\"name=\"group_color[$group[groupid]]\" value=\"$group[color]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_avatar[$group[groupid]]\" value=\"$group[groupavatar]\">",
"<a href=\"$BASESCRIPT?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
} elseif($group['type'] == 'special' && $group['radminid'] == '0') {
$specialgroupoption .= "<option value=\"g{$group[groupid]}\">$group[grouptitle]</option>";
$sgroups[] = $group;
$sgroupids .= ','.$group['groupid'];
}
}
$projectselect = $membergroupoption.'<option value=""> ------------ </option>';
$specialprojectselect = $specialgroupoption.'<option value=""> ------------ </option>';
$project = array();
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='group'");
while($project = $db->fetch_array($query)) {
$projectselect = $specialprojectselect .= '<option value="'.$project['id'].'">'.$project['name'].'</option>';
}
foreach($sgroups as $group) {
if(is_array($smembers[$group['groupid']])) {
$num = count($smembers[$group['groupid']]);
$specifiedusers = implode('', $smembers[$group['groupid']]).($num > $smembernum[$group['groupid']] ? '<br /><div style="float: right; clear: both; margin:5px"><a href="'.$BASESCRIPT.'?action=members&submit=yes&usergroupid[]='.$group['groupid'].'" style="text-align: right;">'.$lang['more'].'»</a> </div>' : '<br /><br/>');
unset($smembers[$group['groupid']]);
} else {
$specifiedusers = '';
$num = 0;
}
$specifiedusers = "<style>#specifieduser span{width: 9em; height: 2em; float: left; overflow: hidden; margin: 2px;}</style><div id=\"specifieduser\">$specifiedusers</div>";
$specialgroup .= showtablerow('', array('class="td25"', '', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$group[groupid]]\" value=\"$group[groupid]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_title[$group[groupid]]\" value=\"$group[grouptitle]\">",
"<input type=\"text\" class=\"txt\" size=\"2\"name=\"group_stars[$group[groupid]]\" value=\"$group[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\"name=\"group_color[$group[groupid]]\" value=\"$group[color]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_avatar[$group[groupid]]\" value=\"$group[groupavatar]\">",
"<a href=\"$BASESCRIPT?action=usergroups&operation=viewsgroup&sgroupid=$group[groupid]\" onclick=\"ajaxget(this.href, 'sgroup_$group[groupid]', 'sgroup_$group[groupid]', 'auto');doane(event);\" class=\"act\">$lang[view]</a>",
"<a href=\"$BASESCRIPT?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
$specialgroup .= showtablerow('', array('', 'colspan="6" id="sgroup_'.$group['groupid'].'" style="display: none"'), array(
'',
''
), TRUE);
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" size="12" name="groupnewadd[grouptitle][]">'],
[1,'<input type="text" class="txt" size="6" name="groupnewadd[creditshigher][]">', 'td28'],
[1,'<input type="text" class="txt" size="2" name="groupnewadd[stars][]">', 'td28'],
[4,'<select name="groupnewadd[projectid][]"><option value="">$lang[usergroups_project]</option><option value="0">------------</option>$projectselect</select>']
],
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" size="12" name="grouptitlenewadd[]">'],
[1,'<input type="text" class="txt" size="2" name="starsnewadd[]">', 'td28'],
[1,'<input type="text" class="txt" size="6" name="colornewadd[]">'],
[1,'<select name="groupnewaddproject[]"><option value="">$lang[usergroups_project]</option><option value="0">------------</option>$specialprojectselect</select>'],
[2, '']
]
];
</script>
EOT;
shownav('user', 'nav_usergroups');
showsubmenuanchors('nav_usergroups', array(
array('usergroups_member', 'membergroups', !$type || $type == 'member'),
array('usergroups_special', 'specialgroups', $type == 'special'),
array('usergroups_system', 'systemgroups', $type == 'system')
));
showtips('usergroups_tips');
showformheader('usergroups&type=member');
showtableheader('usergroups_member', 'fixpadding', 'id="membergroups"'.($type && $type != 'member' ? ' style="display: none"' : ''));
showsubtitle(array('', 'usergroups_title', 'usergroups_creditsrange', 'usergroups_stars', 'usergroups_color', 'usergroups_avatar', ''));
echo $membergroup;
echo '<tr><td> </td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['usergroups_add'].'</a></div></td></tr>';
showsubmit('groupsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showformheader('usergroups&type=special');
showtableheader('usergroups_special', 'fixpadding', 'id="specialgroups"'.($type != 'special' ? ' style="display: none"' : ''));
showsubtitle(array('', 'usergroups_title', 'usergroups_stars', 'usergroups_color', 'usergroups_avatar', '', ''));
echo $specialgroup;
echo '<tr><td> </td><td colspan="8"><div><a href="###" onclick="addrow(this, 1)" class="addtr">'.$lang['usergroups_sepcial_add'].'</a></div></td></tr>';
showsubmit('groupsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showformheader('usergroups&type=system');
showtableheader('usergroups_system', 'fixpadding', 'id="systemgroups"'.($type != 'system' ? ' style="display: none"' : ''));
showsubtitle(array('usergroups_title', 'usergroups_status', 'usergroups_stars', 'usergroups_color', 'usergroups_avatar', ''));
echo $sysgroup;
showsubmit('groupsubmit');
showtablefooter();
showformfooter();
} else {
if(empty($type) || !in_array($type, array('member', 'special', 'system'))) {
cpmsg('usergroups_type_nonexistence');
}
$oldgroups = $extadd = array();
$query = $db->query("SELECT * FROM {$tablepre}usergroups WHERE `type`='$type'");
while ($gp = $db->fetch_array($query)) {
$oldgroups[$gp['groupid']] = $gp;
}
$sqladd = '';
$query = $db->query("SELECT * FROM {$tablepre}projects WHERE type='group'");
while($project = $db->fetch_array($query)) {
$sqladd = '';
$project['value'] = unserialize($project['value']);
foreach($project['value'] as $k=>$v) {
$v = addslashes($v);
$k = addslashes($k);
$sqladd .= ",`$k`='$v'";
}
$project['sqladd'] = $sqladd;
$extadd[$project['id']] = $project['sqladd'];
}
foreach($oldgroups as $id => $vals) {
$sqladd = '';
foreach($vals as $k => $v) {
$v = addslashes($v);
if(!in_array($k, array('groupid', 'radminid', 'type', 'system', 'grouptitle', 'creditshigher', 'creditslower', 'stars', 'color', 'groupavatar'))) {
$sqladd .= ",`$k`='$v'";
}
}
$extadd['g'.$id] = $sqladd;
}
if($type == 'member') {
$groupnewadd = array_flip_keys($groupnewadd);
foreach($groupnewadd as $k => $v) {
if(!$v['grouptitle'] || !$v['creditshigher']) {
unset($groupnewadd[$k]);
}
}
$groupnewkeys = array_keys($groupnew);
$maxgroupid = max($groupnewkeys);
foreach($groupnewadd as $k=>$v) {
$groupnew[$k+$maxgroupid+1] = $v;
}
$orderarray = array();
if(is_array($groupnew)) {
foreach($groupnew as $id => $group) {
if((is_array($delete) && in_array($id, $delete)) || ($id == 0 && (!$group['grouptitle'] || $group['creditshigher'] == ''))) {
unset($groupnew[$id]);
} else {
$orderarray[$group['creditshigher']] = $id;
}
}
}
if(empty($orderarray[0]) || min(array_flip($orderarray)) >= 0) {
cpmsg('usergroups_update_credits_invalid', '', 'error');
}
ksort($orderarray);
$rangearray = array();
$lowerlimit = array_keys($orderarray);
for($i = 0; $i < count($lowerlimit); $i++) {
$rangearray[$orderarray[$lowerlimit[$i]]] = array
(
'creditshigher' => isset($lowerlimit[$i - 1]) ? $lowerlimit[$i] : -999999999,
'creditslower' => isset($lowerlimit[$i + 1]) ? $lowerlimit[$i + 1] : 999999999
);
}
foreach($groupnew as $id => $group) {
$creditshighernew = $rangearray[$id]['creditshigher'];
$creditslowernew = $rangearray[$id]['creditslower'];
if($creditshighernew == $creditslowernew) {
cpmsg('usergroups_update_credits_duplicate', '', 'error');
}
if(in_array($id, $groupnewkeys)) {
$db->query("UPDATE {$tablepre}usergroups SET grouptitle='$group[grouptitle]', creditshigher='$creditshighernew', creditslower='$creditslowernew', stars='$group[stars]', color='$group[color]', groupavatar='$group[groupavatar]' WHERE groupid='$id' AND type='member'");
} elseif($group['grouptitle'] && $group['creditshigher'] != '') {
$sqladd = !empty($group['projectid']) && !empty($extadd[$group['projectid']]) ? $extadd[$group['projectid']] : '';
$db->query("INSERT INTO {$tablepre}usergroups SET grouptitle='$group[grouptitle]', creditshigher='$creditshighernew', creditslower='$creditslowernew', stars='$group[stars]' $sqladd");
if($sqladd) {
$newgid = $db->insert_id();
$query = $db->query("SELECT fid, viewperm, postperm, replyperm, getattachperm, postattachperm FROM {$tablepre}forumfields");
while($row = $db->fetch_array($query)) {
$upforumperm = array();
$projectid = substr($group['projectid'], 1);
if($row['viewperm'] && in_array($projectid, explode("\t", $row['viewperm']))) {
$upforumperm[] = "viewperm='$row[viewperm]$newgid\t'";
}
if($row['postperm'] && in_array($projectid, explode("\t", $row['postperm']))) {
$upforumperm[] = "postperm='$row[postperm]$newgid\t'";
}
if($row['replyperm'] && in_array($projectid, explode("\t", $row['replyperm']))) {
$upforumperm[] = "replyperm='$row[replyperm]$newgid\t'";
}
if($row['getattachperm'] && in_array($projectid, explode("\t", $row['getattachperm']))) {
$upforumperm[] = "getattachperm='$row[getattachperm]$newgid\t'";
}
if($row['postattachperm'] && in_array($projectid, explode("\t", $row['postattachperm']))) {
$upforumperm[] = "postattachperm='$row[postattachperm]$newgid\t'";
}
if($upforumperm) {
$db->query("UPDATE {$tablepre}forumfields SET ".implode(',', $upforumperm)." WHERE fid='$row[fid]'");
}
}
}
}
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}usergroups WHERE groupid IN ($ids) AND type='member'");
deletegroupcache($delete);
}
} elseif($type == 'special') {
if(is_array($grouptitlenewadd)) {
foreach($grouptitlenewadd as $k => $v) {
if($v) {
$sqladd = !empty($groupnewaddproject[$k]) && !empty($extadd[$groupnewaddproject[$k]]) ? $extadd[$groupnewaddproject[$k]] : '';
$db->query("INSERT INTO {$tablepre}usergroups SET type='special', grouptitle='$grouptitlenewadd[$k]', color='$colornewadd[$k]', stars='$starsnewadd[$k]' $sqladd");
}
}
}
if(is_array($group_title)) {
foreach($group_title as $id => $title) {
if(!$delete[$id]) {
$db->query("UPDATE {$tablepre}usergroups SET grouptitle='$group_title[$id]', stars='$group_stars[$id]', color='$group_color[$id]', groupavatar='$group_avatar[$id]' WHERE groupid='$id'");
}
}
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}usergroups WHERE groupid IN ($ids) AND type='special'");
$db->query("DELETE FROM {$tablepre}admingroups WHERE admingid IN ($ids)");
$db->query("DELETE FROM {$tablepre}adminactions WHERE admingid IN ($ids)");
$newgroupid = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditslower>'0' ORDER BY creditslower LIMIT 1");
$db->query("UPDATE {$tablepre}members SET groupid='$newgroupid', adminid='0' WHERE groupid IN ($ids)", 'UNBUFFERED');
deletegroupcache($delete);
}
} elseif($type == 'system') {
if(is_array($group_title)) {
foreach($group_title as $id => $title) {
$db->query("UPDATE {$tablepre}usergroups SET grouptitle='$group_title[$id]', stars='$group_stars[$id]', color='$group_color[$id]', groupavatar='$group_avatar[$id]' WHERE groupid='$id'");
}
}
}
updatecache('usergroups');
cpmsg('usergroups_update_succeed', $BASESCRIPT.'?action=usergroups&type='.$type, 'succeed');
}
} elseif($operation == 'viewsgroup') {
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}members WHERE groupid='$sgroupid'");
$query = $db->query("SELECT uid, username FROM {$tablepre}members WHERE groupid='$sgroupid' LIMIT 80");
$sgroups = '';
while($member = $db->fetch_array($query)) {
$sgroups .= '<li><a href="space.php?uid='.$member['uid'].'" target="_blank">'.$member['username'].'</a></li>';
}
ajaxshowheader();
echo '<ul class="userlist"><li class="unum">'.$lang['usernum'].$num.($num > 80 ? ' <a href="'.$BASESCRIPT.'?action=members&submit=yes&usergroupid[]='.$sgroupid.'">'.$lang['more'].'»</a>' : '').'</li>'.$sgroups.'</ul>';
ajaxshowfooter();
exit;
} elseif($operation == 'edit') {
$return = isset($return) && $return ? 'admin' : '';
if(empty($id)) {
$grouplist = "<select name=\"id\" style=\"width:150px\">\n";
$conditions = !empty($anchor) && $anchor == 'system' ? "WHERE type='special'" : '';
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups $conditions");
while($group = $db->fetch_array($query)) {
$grouplist .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
}
$grouplist .= '</select>';
cpmsg('usergroups_edit_nonexistence', $BASESCRIPT.'?action=usergroups&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : '').(!empty($highlight) ? "&anchor=$anchor" : ''), 'form', $grouplist);
}
$group = $db->fetch_first("SELECT * FROM {$tablepre}usergroups WHERE groupid='$id'");
if($group['radminid'] > 0 && !isfounder()) {
if(!checkacpaction('admingroups', '', false)) {
cpmsg('usergroups_edit_fail', '', 'error');
}
}
$group['allowthreadplugin'] = $threadplugins ? unserialize($db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='allowthreadplugin'")) : array();
if(!submitcheck('detailsubmit') && !submitcheck('saveconfigsubmit')) {
$projectselect = "<select name=\"projectid\" onchange=\"window.location='$BASESCRIPT?action=usergroups&operation=edit&id=$id&projectid='+this.options[this.options.selectedIndex].value\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='group'");
while($project = $db->fetch_array($query)) {
$projectselect .= "<option value=\"$project[id]\" ".($project['id'] == $projectid ? 'selected="selected"' : NULL).">$project[name]</option>";
}
$projectselect .= '</select>';
if(!empty($projectid)) {
$group = @array_merge($group, unserialize($db->result_first("SELECT value FROM {$tablepre}projects WHERE id='$projectid'")));
}
$group['exempt'] = strrev(sprintf('%0'.strlen($group['exempt']).'b', $group['exempt']));
$query = $db->query("SELECT type, groupid, grouptitle, radminid FROM {$tablepre}usergroups ORDER BY (creditshigher<>'0' || creditslower<>'0'), creditslower, groupid");
$grouplist = array();
while($ggroup = $db->fetch_array($query)) {
$ggroup['type'] = $ggroup['type'] == 'special' && $ggroup['radminid'] ? 'specialadmin' : $ggroup['type'];
$grouplist[$ggroup['type']] .= '<a href="###" onclick="location.href=\''.$BASESCRIPT.'?action=usergroups&operation=edit&switch=yes&id='.$ggroup['groupid'].'&anchor=\'+currentAnchor+\'&scrolltop=\'+document.documentElement.scrollTop"'.($id == $ggroup['groupid'] ? ' class="current"' : '').'>'.$ggroup['grouptitle'].'</a>';
}
$gselect = '<span id="ugselect" class="right popupmenu_dropmenu" onmouseover="showMenu({\'ctrlid\':this.id,\'pos\':\'34\'});$(\'ugselect_menu\').style.top=(parseInt($(\'ugselect_menu\').style.top)-document.documentElement.scrollTop)+\'px\'">'.$lang['usergroups_switch'].'<em> </em></span>'.
'<div id="ugselect_menu" class="popupmenu_popup" style="display:none">'.
'<em>'.$lang['usergroups_member'].'</em>'.$grouplist['member'].'<br />'.
($grouplist['special'] ? '<em>'.$lang['usergroups_special'].'</em>'.$grouplist['special'].'<br />' : '').
($grouplist['specialadmin'] ? '<em>'.$lang['usergroups_specialadmin'].'</em>'.$grouplist['specialadmin'].'<br />' : '').
'<em>'.$lang['usergroups_system'].'</em>'.$grouplist['system'].'</div>';
$anchor = in_array($anchor, array('basic', 'system', 'special', 'post', 'attach', 'magic', 'invite', 'credit')) ? $anchor : 'basic';
showsubmenuanchors(lang('usergroups_edit').' - '.$group['grouptitle'], array(
array('usergroups_edit_basic', 'basic', $anchor == 'basic'),
$group['type'] == 'special' && $group['radminid'] < 1 ? array('usergroups_edit_system', 'system', $anchor == 'system') : array(),
array('usergroups_edit_special', 'special', $anchor == 'special'),
array('usergroups_edit_post', 'post', $anchor == 'post'),
array('usergroups_edit_attach', 'attach', $anchor == 'attach'),
array('usergroups_edit_magic', 'magic', $anchor == 'magic'),
array('usergroups_edit_invite', 'invite', $anchor == 'invite'),
array('usergroups_edit_credit', 'credit', $anchor == 'credit')
), $gselect);
if(!empty($switch)) {
echo '<script type="text/javascript">showMenu({\'ctrlid\':\'ugselect\',\'pos\':\'34\'});</script>';
}
if($group['type'] == 'special' && $group['radminid'] < 1) {
showtips('usergroups_edit_system_tips', 'system_tips', $anchor == 'system');
}
showtips('usergroups_edit_magic_tips', 'magic_tips', $anchor == 'magic');
showtips('usergroups_edit_invite_tips', 'invite_tips', $anchor == 'invite');
showformheader("usergroups&operation=edit&id=$id&return=$return");
showtableheader();
if($group['type'] == 'special' && $group['radminid'] < 1) {
showtagheader('tbody', 'system', $anchor == 'system');
if($group['system'] == 'private') {
$system = array('public' => 0, 'dailyprice' => 0, 'minspan' => 0);
} else {
$system = array('public' => 1, 'dailyprice' => 0, 'minspan' => 0);
list($system['dailyprice'], $system['minspan']) = explode("\t", $group['system']);
}
showsetting('usergroups_edit_system_public', 'system_publicnew', $system['public'], 'radio');
showsetting('usergroups_edit_system_dailyprice', 'system_dailypricenew', $system['dailyprice'], 'text');
showsetting('usergroups_edit_system_minspan', 'system_minspannew', $system['minspan'], 'text');
showtagfooter('tbody');
}
showtagheader('tbody', 'basic', $anchor == 'basic');
showtitle('usergroups_edit_basic');
showsetting('usergroups_edit_basic_title', 'grouptitlenew', $group['grouptitle'], 'text');
showsetting('usergroups_edit_basic_scheme', '', '', $projectselect);
if(in_array($group['groupid'], array(1, 7))) {
echo '<input type="hidden" name="allowvisitnew" value="1">';
} else {
showsetting('usergroups_edit_basic_visit', 'allowvisitnew', $group['allowvisit'], 'radio');
}
showsetting('usergroups_edit_basic_read_access', 'readaccessnew', $group['readaccess'], 'text');
showsetting('usergroups_edit_basic_view_profile', 'allowviewpronew', $group['allowviewpro'], 'radio');
showsetting('usergroups_edit_basic_view_stats', 'allowviewstatsnew', $group['allowviewstats'], 'radio');
showsetting('usergroups_edit_basic_invisible', 'allowinvisiblenew', $group['allowinvisible'], 'radio');
showsetting('usergroups_edit_basic_multigroups', 'allowmultigroupsnew', $group['allowmultigroups'], 'radio');
showsetting('usergroups_edit_basic_allowtransfer', 'allowtransfernew', $group['allowtransfer'], 'radio');
showsetting('usergroups_edit_basic_allowsendpm', 'allowsendpmnew', $group['allowsendpm'], 'radio');
showsetting('usergroups_edit_basic_search', array('allowsearchnew', array(
array(0, $lang['usergroups_edit_basic_search_disable']),
array(1, $lang['usergroups_edit_basic_search_thread']),
array(2, $lang['usergroups_edit_basic_search_post'])
)), $group['allowsearch'], 'mradio');
showsetting('usergroups_edit_basic_reasonpm', array('reasonpmnew', array(
array(0, $lang['usergroups_edit_basic_reasonpm_none']),
array(1, $lang['usergroups_edit_basic_reasonpm_reason']),
array(2, $lang['usergroups_edit_basic_reasonpm_pm']),
array(3, $lang['usergroups_edit_basic_reasonpm_both'])
)), $group['reasonpm'], 'mradio');
showsetting('usergroups_edit_basic_nickname', 'allownicknamenew', $group['allownickname'], 'radio');
showsetting('usergroups_edit_basic_cstatus', 'allowcstatusnew', $group['allowcstatus'], 'radio');
showsetting('usergroups_edit_basic_disable_periodctrl', 'disableperiodctrlnew', $group['disableperiodctrl'], 'radio');
showsetting('usergroups_edit_basic_hour_posts', 'maxpostsperhournew', $group['maxpostsperhour'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'special', $anchor == 'special');
showtitle('usergroups_edit_special');
showsetting('usergroups_edit_special_activity', 'allowpostactivitynew', $group['allowpostactivity'], 'radio');
showsetting('usergroups_edit_special_poll', 'allowpostpollnew', $group['allowpostpoll'], 'radio');
showsetting('usergroups_edit_special_vote', 'allowvotenew', $group['allowvote'], 'radio');
showsetting('usergroups_edit_special_reward', 'allowpostrewardnew', $group['allowpostreward'], 'radio');
showsetting('usergroups_edit_special_reward_min', 'minrewardpricenew', $group['minrewardprice'], "text");
showsetting('usergroups_edit_special_reward_max', 'maxrewardpricenew', $group['maxrewardprice'], "text");
showsetting('usergroups_edit_special_trade', 'allowposttradenew', $group['allowposttrade'], 'radio');
showsetting('usergroups_edit_special_trade_min', 'mintradepricenew', $group['mintradeprice'], "text");
showsetting('usergroups_edit_special_trade_max', 'maxtradepricenew', $group['maxtradeprice'], "text");
showsetting('usergroups_edit_special_trade_stick', 'tradesticknew', $group['tradestick'], "text");
showsetting('usergroups_edit_special_debate', 'allowpostdebatenew', $group['allowpostdebate'], "radio");
showsetting('usergroups_edit_special_rushreply', 'allowpostrushreplynew', $group['allowpostrushreply'], "radio");
$threadpluginselect = '';
if(is_array($threadplugins)) foreach($threadplugins as $tpid => $data) {
$threadpluginselect .= '<input class="checkbox" type="checkbox" name="allowthreadpluginnew[]" value="'.$tpid.'" '.(@in_array($tpid, $group['allowthreadplugin'][$id]) ? 'checked' : '').'> '.$data['name'].'<br />';
}
if($threadpluginselect) {
showsetting('usergroups_edit_special_allowthreadplugin', '', '', $threadpluginselect);
}
showtagfooter('tbody');
showtagheader('tbody', 'post', $anchor == 'post');
showtitle('usergroups_edit_post');
showsetting('usergroups_edit_post_new', 'allowpostnew', $group['allowpost'], 'radio');
showsetting('usergroups_edit_post_reply', 'allowreplynew', $group['allowreply'], 'radio');
showsetting('usergroups_edit_post_direct', array('allowdirectpostnew', array(
array(0, $lang['usergroups_edit_post_direct_none']),
array(1, $lang['usergroups_edit_post_direct_reply']),
array(2, $lang['usergroups_edit_post_direct_thread']),
array(3, $lang['usergroups_edit_post_direct_all'])
)), $group['allowdirectpost'], 'mradio');
showsetting('usergroups_edit_post_url', array('allowposturlnew', array(
array(0, $lang['usergroups_edit_post_url_banned']),
array(1, $lang['usergroups_edit_post_url_mod']),
array(2, $lang['usergroups_edit_post_url_unhandle']),
array(3, $lang['usergroups_edit_post_url_enable'])
)), $group['allowposturl'], 'mradio');
showsetting('usergroups_edit_post_anonymous', 'allowanonymousnew', $group['allowanonymous'], 'radio');
showsetting('usergroups_edit_post_set_read_perm', 'allowsetreadpermnew', $group['allowsetreadperm'], 'radio');
showsetting('usergroups_edit_post_maxprice', 'maxpricenew', $group['maxprice'], 'text');
showsetting('usergroups_edit_post_hide_code', 'allowhidecodenew', $group['allowhidecode'], 'radio');
showsetting('usergroups_edit_post_html', 'allowhtmlnew', $group['allowhtml'], 'radio');
showsetting('usergroups_edit_post_custom_bbcode', 'allowcusbbcodenew', $group['allowcusbbcode'], 'radio');
showsetting('usergroups_edit_post_bio_bbcode', 'allowbiobbcodenew', $group['allowbiobbcode'], 'radio');
showsetting('usergroups_edit_post_bio_img_code', 'allowbioimgcodenew', $group['allowbioimgcode'], 'radio');
showsetting('usergroups_edit_post_max_bio_size', 'maxbiosizenew', $group['maxbiosize'], 'text');
showsetting('usergroups_edit_post_sig_bbcode', 'allowsigbbcodenew', $group['allowsigbbcode'], 'radio');
showsetting('usergroups_edit_post_sig_img_code', 'allowsigimgcodenew', $group['allowsigimgcode'], 'radio');
showsetting('usergroups_edit_post_max_sig_size', 'maxsigsizenew', $group['maxsigsize'], 'text');
if($group['groupid'] != 7) {
showsetting('usergroups_edit_post_recommend', 'allowrecommendnew', $group['allowrecommend'], 'text');
}
showsetting('usergroups_edit_post_edit_time_limit', 'edittimelimitnew', $group['edittimelimit'], 'text');
showtagfooter('tbody');
$group['maxattachsize'] = intval($group['maxattachsize'] / 1024);
$group['maxsizeperday'] = intval($group['maxsizeperday'] / 1024);
showtagheader('tbody', 'attach', $anchor == 'attach');
showtitle('usergroups_edit_attach');
showsetting('usergroups_edit_attach_get', 'allowgetattachnew', $group['allowgetattach'], 'radio');
showsetting('usergroups_edit_attach_post', 'allowpostattachnew', $group['allowpostattach'], 'radio');
showsetting('usergroups_edit_attach_set_perm', 'allowsetattachpermnew', $group['allowsetattachperm'], 'radio');
showsetting('usergroups_edit_attach_max_size', 'maxattachsizenew', $group['maxattachsize'], 'text');
showsetting('usergroups_edit_attach_max_size_per_day', 'maxsizeperdaynew', $group['maxsizeperday'], 'text');
showsetting('usergroups_edit_attach_max_number_per_day', 'maxattachnumnew', $group['maxattachnum'], 'text');
showsetting('usergroups_edit_attach_ext', 'attachextensionsnew', $group['attachextensions'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'magic', $anchor == 'magic');
showtitle('usergroups_edit_magic');
showsetting('usergroups_edit_magic_permission', array('allowmagicsnew', array(
array(0, $lang['usergroups_edit_magic_unallowed']),
array(1, $lang['usergroups_edit_magic_allow']),
array(2, $lang['usergroups_edit_magic_allow_and_pass'])
)), $group['allowmagics'], 'mradio');
showsetting('usergroups_edit_magic_discount', 'magicsdiscountnew', $group['magicsdiscount'], 'text');
showsetting('usergroups_edit_magic_max', 'maxmagicsweightnew', $group['maxmagicsweight'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'invite', $anchor == 'invite');
showtitle('usergroups_edit_invite');
showsetting('usergroups_edit_invite_permission', 'allowinvitenew', $group['allowinvite'], 'radio');
showsetting('usergroups_edit_invite_send_permission', 'allowmailinvitenew', $group['allowmailinvite'], 'radio');
showsetting('usergroups_edit_invite_price', 'invitepricenew', $group['inviteprice'], 'text');
showsetting('usergroups_edit_invite_buynum', 'maxinvitenumnew', $group['maxinvitenum'], 'text');
showsetting('usergroups_edit_invite_maxinviteday', 'maxinvitedaynew', $group['maxinviteday'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'credit', $anchor == 'credit');
showtitle('usergroups_edit_credit');
showsetting('usergroups_edit_credit_exempt_sendpm', 'exemptnew[0]', $group['exempt'][0], 'radio');
showsetting('usergroups_edit_credit_exempt_search', 'exemptnew[1]', $group['exempt'][1], 'radio');
if($group['radminid']) {
if($group['radminid'] == 3) {
showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_getattch'], 'exemptnew[2]', $group['exempt'][2], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_getattch'], 'exemptnew[5]', $group['exempt'][5], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_attachpay'], 'exemptnew[3]', $group['exempt'][3], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_attachpay'], 'exemptnew[6]', $group['exempt'][6], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_threadpay'], 'exemptnew[4]', $group['exempt'][4], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_threadpay'], 'exemptnew[7]', $group['exempt'][7], 'radio');
} else {
echo '<input name="exemptnew[2]" type="hidden" value="1" /><input name="exemptnew[3]" type="hidden" value="1" /><input name="exemptnew[4]" type="hidden" value="1" />'.
'<input name="exemptnew[5]" type="hidden" value="1" /><input name="exemptnew[6]" type="hidden" value="1" /><input name="exemptnew[7]" type="hidden" value="1" />';
}
} else {
showsetting('usergroups_edit_credit_exempt_getattch', 'exemptnew[2]', $group['exempt'][2], 'radio');
showsetting('usergroups_edit_credit_exempt_attachpay', 'exemptnew[3]', $group['exempt'][3], 'radio');
showsetting('usergroups_edit_credit_exempt_threadpay', 'exemptnew[4]', $group['exempt'][4], 'radio');
}
echo '<tr><td colspan="2">'.$lang['usergroups_edit_credit_exempt_comment'].'</td></tr>';
$raterangearray = array();
foreach(explode("\n", $group['raterange']) as $range) {
$range = explode("\t", $range);
$raterangearray[$range[0]] = array('min' => $range[1], 'max' => $range[2], 'mrpd' => $range[3]);
}
echo '<tr><td colspan="2">';
showtableheader('usergroups_edit_credit_allowrate', 'noborder');
showsubtitle(array('', 'credits_id', 'credits_title', 'usergroups_edit_credit_rate_min', 'usergroups_edit_credit_rate_max', 'usergroups_edit_credit_rate_mrpd'));
for($i = 1; $i <= 8; $i++) {
if(isset($extcredits[$i])) {
echo '<tr><td><input class="checkbox" type="checkbox" name="raterangenew['.$i.'][allowrate]" value="1" '.(empty($raterangearray[$i]) ? '' : 'checked').'></td>'.
'<td>extcredits'.$i.'</td>'.
'<td>'.$extcredits[$i]['title'].'</td>'.
'<td><input type="text" class="txt" name="raterangenew['.$i.'][min]" size="3" value="'.$raterangearray[$i]['min'].'"></td>'.
'<td><input type="text" class="txt" name="raterangenew['.$i.'][max]" size="3" value="'.$raterangearray[$i]['max'].'"></td>'.
'<td><input type="text" class="txt" name="raterangenew['.$i.'][mrpd]" size="3" value="'.$raterangearray[$i]['mrpd'].'"></td></tr>';
}
}
echo '<tr><td colspan="6">'.$lang['usergroups_edit_credit_allowrate_comment'].'</td></tr></td></tr>';
showtablefooter();
echo '</td></tr>';
showtagfooter('tbody');
showsubmit('detailsubmit', 'submit', '', "<input type=\"submit\" class=\"btn\" name=\"saveconfigsubmit\" value=\"".$lang['saveconf']."\">");
showtablefooter();
showformfooter();
} else {
$systemnew = 'private';
if($group['type'] == 'special' && $group['radminid'] > 0) {
$radminidnew = $group['radminid'];
} elseif($group['type'] == 'special') {
$radminidnew = '0';
if($system_publicnew) {
if($system_dailypricenew > 0) {
if(!$creditstrans) {
cpmsg('usergroups_edit_creditstrans_disabled', '', 'error');
} else {
$system_minspannew = $system_minspannew <= 0 ? 1 : $system_minspannew;
$systemnew = intval($system_dailypricenew)."\t".intval($system_minspannew);
}
} else {
$systemnew = "0\t0";
}
}
} else {
$radminidnew = in_array($group['groupid'], array(1, 2, 3)) ? $group['groupid'] : 0;
}
if(is_array($raterangenew)) {
foreach($raterangenew as $key => $rate) {
if($key >= 1 && $key <= 8 && $rate['allowrate']) {
$rate['min'] = intval($rate['min'] < -999 ? -999 : $rate['min']);
$rate['max'] = intval($rate['max'] > 999 ? 999 : $rate['max']);
$rate['mrpd'] = intval($rate['mrpd'] > 99999 ? 99999 : $rate['mrpd']);
if(!$rate['mrpd'] || $rate['max'] <= $rate['min'] || $rate['mrpd'] < max(abs($rate['min']), abs($rate['max']))) {
cpmsg('usergroups_edit_rate_invalid', '', 'error');
} else {
$raterangenew[$key] = implode("\t", array($key, $rate['min'], $rate['max'], $rate['mrpd']));
}
} else {
unset($raterangenew[$key]);
}
}
}
if(in_array($group['groupid'], array(1, 7))) {
$allowvisitnew = 1;
}
$raterangenew = $raterangenew ? implode("\n", $raterangenew) : '';
$maxpricenew = $maxpricenew < 0 ? 0 : intval($maxpricenew);
$maxpostsperhournew = $maxpostsperhournew > 255 ? 255 : intval($maxpostsperhournew);
$extensionarray = array();
foreach(explode(',', $attachextensionsnew) as $extension) {
if($extension = trim($extension)) {
$extensionarray[] = $extension;
}
}
$attachextensionsnew = implode(', ', $extensionarray);
if($maxtradepricenew == $mintradepricenew || $maxtradepricenew < 0 || $mintradepricenew <= 0 || ($maxtradepricenew && $maxtradepricenew < $mintradepricenew)) {
cpmsg('trade_fee_error', '', 'error');
} elseif(($maxrewardpricenew != 0 && $minrewardpricenew >= $maxrewardpricenew) || $minrewardpricenew < 1 || $minrewardpricenew< 0 || $maxrewardpricenew < 0) {
cpmsg('reward_credits_error', '', 'error');
}
$exemptnewbin = '';
for($i = 0;$i < 8;$i++) {
$exemptnewbin = intval($exemptnew[$i]).$exemptnewbin;
}
$exemptnew = bindec($exemptnewbin);
$tradesticknew = $tradesticknew > 0 ? intval($tradesticknew) : 0;
$maxinvitedaynew = $maxinvitedaynew > 0 ? intval($maxinvitedaynew) : 10;
$maxattachsizenew = $maxattachsizenew > 0 ? intval($maxattachsizenew * 1024) : 0;
$maxsizeperdaynew = $maxsizeperdaynew > 0 ? intval($maxsizeperdaynew * 1024) : 0;
$maxattachnumnew = $maxattachnumnew > 0 ? intval($maxattachnumnew) : 0;
$allowrecommendnew = $allowrecommendnew > 0 ? intval($allowrecommendnew) : 0;
$edittimelimitnew = $edittimelimitnew > 0 ? intval($edittimelimitnew) : 0;
$db->query("UPDATE {$tablepre}usergroups SET grouptitle='$grouptitlenew', radminid='$radminidnew', system='$systemnew', allowvisit='$allowvisitnew',
readaccess='$readaccessnew', allowmultigroups='$allowmultigroupsnew', allowtransfer='$allowtransfernew', allowsendpm='$allowsendpmnew', allowviewpro='$allowviewpronew',
allowviewstats='$allowviewstatsnew', allowinvisible='$allowinvisiblenew', allowsearch='$allowsearchnew',
reasonpm='$reasonpmnew', allownickname='$allownicknamenew', allowcstatus='$allowcstatusnew',
disableperiodctrl='$disableperiodctrlnew', maxpostsperhour='$maxpostsperhournew', maxinvitenum='$maxinvitenumnew', maxinviteday='$maxinvitedaynew', allowpost='$allowpostnew', allowreply='$allowreplynew',
allowanonymous='$allowanonymousnew', allowsetreadperm='$allowsetreadpermnew', maxprice='$maxpricenew', allowhidecode='$allowhidecodenew',
allowhtml='$allowhtmlnew', allowpostpoll='$allowpostpollnew', allowdirectpost='$allowdirectpostnew', allowposturl='$allowposturlnew', allowvote='$allowvotenew',
allowcusbbcode='$allowcusbbcodenew', allowsigbbcode='$allowsigbbcodenew', allowsigimgcode='$allowsigimgcodenew', allowinvite='$allowinvitenew', allowmailinvite='$allowmailinvitenew', raterange='$raterangenew',
maxsigsize='$maxsigsizenew', allowrecommend='$allowrecommendnew', allowgetattach='$allowgetattachnew', allowpostattach='$allowpostattachnew',
edittimelimit='$edittimelimitnew',
allowsetattachperm='$allowsetattachpermnew', allowpostreward='$allowpostrewardnew', maxrewardprice='$maxrewardpricenew', minrewardprice='$minrewardpricenew', inviteprice='$invitepricenew',
maxattachsize='$maxattachsizenew', maxsizeperday='$maxsizeperdaynew', maxattachnum='$maxattachnumnew', attachextensions='$attachextensionsnew',
allowbiobbcode='$allowbiobbcodenew', allowbioimgcode='$allowbioimgcodenew', maxbiosize='$maxbiosizenew', exempt='$exemptnew',
maxtradeprice='$maxtradepricenew', mintradeprice='$mintradepricenew', tradestick='$tradesticknew', allowposttrade='$allowposttradenew',
allowpostactivity='$allowpostactivitynew', allowmagics='$allowmagicsnew', maxmagicsweight='$maxmagicsweightnew', magicsdiscount='$magicsdiscountnew', allowpostdebate='$allowpostdebatenew', allowpostrushreply='$allowpostrushreplynew' WHERE groupid='$id'");
if($allowinvisiblenew == 0 && $group['allowinvisible'] != $allowinvisiblenew) {
$db->query("UPDATE {$tablepre}members SET invisible='0' WHERE groupid='$id'");
}
if($threadplugins) {
$group['allowthreadplugin'][$id] = $allowthreadpluginnew;
$allowthreadpluginnew = addslashes(serialize($group['allowthreadplugin']));
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('allowthreadplugin', '$allowthreadpluginnew')");
}
updatecache('usergroups');
if(submitcheck('saveconfigsubmit')) {
$projectid = intval($projectid);
dheader("Location: $boardurl$BASESCRIPT?action=project&operation=add&id=$id&type=group&projectid=$projectid");
} elseif($return == 'admin') {
cpmsg('usergroups_edit_succeed', $BASESCRIPT.'?action=admingroups', 'succeed');
} else {
cpmsg('usergroups_edit_succeed', $BASESCRIPT.'?action=usergroups&operation=edit&id='.$id.'&anchor='.$anchor, 'succeed');
}
}
}
function array_flip_keys($arr) {
$arr2 = array();
$arrkeys = @array_keys($arr);
list(, $first) = @each(array_slice($arr, 0, 1));
if($first) {
foreach($first as $k=>$v) {
foreach($arrkeys as $key) {
$arr2[$k][$key] = $arr[$key][$k];
}
}
}
return $arr2;
}
function deletegroupcache($groupidarray) {
if(!empty($groupidarray) && is_array($groupidarray)) {
foreach ($groupidarray as $id) {
if(is_numeric($id) && $id = intval($id)) {
@unlink(DISCUZ_ROOT.'./forumdata/cache/usergroup_'.$id.'.php');
@unlink(DISCUZ_ROOT.'./forumdata/cache/admingroup_'.$id.'.php');
}
}
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/usergroups.inc.php | PHP | asf20 | 41,211 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: runwizard.inc.php 19960 2009-09-15 23:18:37Z wangjinbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$step = in_array($step, array(1, 2, 3, 4)) ? $step : 1;
$runwizardhistory = array();
$runwizardfile = DISCUZ_ROOT.'./forumdata/logs/runwizardlog.php';
if($fp = @fopen($runwizardfile, 'r')) {
fseek($fp, 13);
$runwizardhistory = @unserialize(fread($fp, 99999));
fclose($fp);
}
cpheader();
shownav('tools', 'nav_runwizard');
showsubmenusteps('nav_runwizard', array(
array('runwizard_step_1', $step == 1),
array('runwizard_step_2', $step == 2),
array('runwizard_step_3', $step == 3),
array('runwizard_step_4', $step == 4)
));
showtips('runwizard_tips');
if($step == 1) {
$sizecheckedid = isset($runwizardhistory['step1']['size']) ? $runwizardhistory['step1']['size'] : 1;
$safecheckedid = isset($runwizardhistory['step1']['safe']) ? $runwizardhistory['step1']['safe'] : 0;
$funccheckedid = isset($runwizardhistory['step1']['func']) ? $runwizardhistory['step1']['func'] : 1;
showformheader('runwizard&step=2');
showtableheader();
showsetting('runwizard_forum_scope', array('size', array(
array(0, $lang['runwizard_forum_scope_small']),
array(1, $lang['runwizard_forum_scope_midding']),
array(2, $lang['runwizard_forum_scope_big'])
)), $sizecheckedid, 'mradio');
showsetting('runwizard_security', array('safe', array(
array(2, $lang['runwizard_security_high']),
array(1, $lang['runwizard_security_midding']),
array(0, $lang['runwizard_security_low'])
)), $safecheckedid, 'mradio');
showsetting('runwizard_hobby', array('func', array(
array(0, $lang['runwizard_hobby_concision']),
array(1, $lang['runwizard_hobby_commonly']),
array(2, $lang['runwizard_hobby_abundance'])
)), $funccheckedid, 'mradio');
showsubmit('step1submit', 'nextstep');
showtablefooter();
showformfooter();
$db->query("DELETE FROM {$tablepre}settings WHERE variable='runwizard'");
updatecache('settings');
} elseif($step == 2) {
if(submitcheck('step1submit')) {
$runwizardhistory['step1']['size'] = $size;
$runwizardhistory['step1']['safe'] = $safe;
$runwizardhistory['step1']['func'] = $func;
saverunwizardhistory();
}
$settings = &$_DCACHE['settings'];
$settings['bbname'] = empty($runwizard) && $runwizardhistory['step2']['bbname'] ? $runwizardhistory['step2']['bbname'] : $settings['bbname'];
$settings['sitename'] = empty($runwizard) && $runwizardhistory['step2']['sitename'] ? $runwizardhistory['step2']['sitename'] : $settings['sitename'];
$settings['siteurl'] = empty($runwizard) && $runwizardhistory['step2']['siteurl'] ? $runwizardhistory['step2']['siteurl'] : $settings['siteurl'];
showformheader('runwizard&step=3');
showtableheader();
showsetting('settings_basic_bbname', 'settingsnew[bbname]', $settings['bbname'], 'text');
showsetting('settings_basic_sitename', 'settingsnew[sitename]', $settings['sitename'], 'text');
showsetting('settings_basic_siteurl', 'settingsnew[siteurl]', $settings['siteurl'], 'text');
showsubmit('step2submit', 'nextstep', '<input type="button" class="btn" name="step2submit" value="'.lang('laststep').'" onclick="history.back();">');
showtablefooter();
showformfooter();
} elseif($step == 3) {
if(submitcheck('step2submit')) {
$runwizardhistory['step2']['bbname'] = $settingsnew['bbname'];
$runwizardhistory['step2']['sitename'] = $settingsnew['sitename'];
$runwizardhistory['step2']['siteurl'] = $settingsnew['siteurl'];
saverunwizardhistory();
}
showformheader('runwizard&step=4');
showtableheader('', 'fixpadding');
for($i = 1; $i < 4; $i++) {
showtablerow('', '', '<div class="parentboard"><input type="text" name="newcat['.$i.']" value="'.lang('runwizard_cat').' '.$i.'" class="txt" /></div>');
for($j = 1; $j < 4; $j++) {
showtablerow('', '', '<div class="'.($j == 3 ? 'lastboard' : 'board').'"><input type="text" name="newforum['.$i.'][]" value="'.lang('runwizard_forum').' '.$i.'.'.$j.'" class="txt" /></div>');
}
}
showsubmit('step3submit', 'nextstep', '<input type="button" class="btn" name="step2submit" value="'.$lang['laststep'].'" onclick="history.back();">');
showtablefooter();
showformfooter();
} elseif($step == 4) {
if(submitcheck('step3submit')) {
foreach($newcat as $k=>$catename) {
if(!$catename) {
unset($newcat[$k]);
unset($newforum[$k]);
} else {
foreach($newforum[$k] as $k2=>$forumname) {
if(!$forumname) {
unset($newforum[$k][$k2]);
}
}
}
}
$runwizardhistory['step3']['cates'] = $newcat ? $newcat : array();
$runwizardhistory['step3']['forums'] = $newforum ? $newforum : array();
saverunwizardhistory();
}
showtableheader('', 'nobottom fixpadding');
echo '<tr><td>';
if($confirm != 'yes') {
?>
<br /><?=$lang['runwizard_forum_initialization']?>
<ul class="tpllist">
<li><h4><?=$lang['runwizard_forum_scope']?></b> <?=$lang['runwizard_size_'.$runwizardhistory['step1']['size']]?><h4></li>
<li><h4><?=$lang['runwizard_security']?></b> <?=$lang['runwizard_safe_'.$runwizardhistory['step1']['safe']]?><h4></li>
<li><h4><?=$lang['runwizard_hobby']?></b> <?=$lang['runwizard_func_'.$runwizardhistory['step1']['func']]?><h4></li>
<li><h4><?=$lang['settings_bbname']?></b> <?=$runwizardhistory['step2']['bbname']?><h4></li>
<li><h4><?=$lang['settings_sitename']?></b> <?=$runwizardhistory['step2']['sitename']?><h4></li>
<li><h4><?=$lang['settings_siteurl']?></b> <?=$runwizardhistory['step2']['siteurl']?><h4></li>
<li><h4><?=$lang['runwizard_forum_add']?><h4>
<?
if($runwizardhistory['step3']['cates']) {
echo '<ul class="tpllist2">';
foreach($runwizardhistory['step3']['cates'] as $id=>$catename) {
echo '<li><h5>'.$catename.'</h5><ul class="tpllist3">';
foreach($runwizardhistory['step3']['forums'][$id] as $forumname) {
echo '<li>'.$forumname.'</li>';
}
echo '</ul></li>';
}
echo '</ul>';
} else {
echo $lang['none'];
}
echo '</li></ul></td></tr>';
showtablefooter();
showformheader('runwizard&step=4&confirm=yes');
showtableheader('', 'notop');
showsubmit('step4submit', 'submit', '<input type="button" class="btn" " value="'.$lang['laststep'].'" onclick="history.back();">');
showtablefooter();
showformfooter();
} else {
$sizesettings = array(
'attachsave' => array('1', '3', '4'),
'delayviewcount' => array('0', '0', '3'),
'fullmytopics' => array('1', '0', '0'),
'maxonlines' => array('500', '5000', '50000'),
'pvfrequence' => array('30', '60', '100'),
'qihoo_status' => array('0', '0', '1'),
'searchctrl' => array('10', '30', '60'),
'hottopic' => array('10', '20', '50'),
'losslessdel' => array('365', '200', '100'),
'maxmodworksmonths' => array('5', '3', '1'),
'maxsearchresults' => array('200', '500', '1000'),
'statscachelife' => array('90', '180', '360'),
'moddisplay' => array('flat', 'flat', 'selectbox'),
'topicperpage' => array('30', '20', '15'),
'postperpage' => array('20', '15', '10'),
'maxpolloptions' => array('10', '10', '15'),
'maxpostsize' => array('10000', '10000', '20000'),
'myrecorddays' => array('100', '60', '30'),
'maxfavorites' => array('500', '200', '100'),
);
$safesettings = array(
'attachrefcheck' => array('', '1', '1'),
'bannedmessages' => array('', '1', '1'),
'doublee' => array('1', '0', '0'),
'dupkarmarate' => array('1', '0', '0'),
'hideprivate' => array('0', '1', '1'),
'memliststatus' => array('1', '1', '0'),
'seccodestatus' => array('0', '1', '1'),
'bbrules' => array('0', '1', '1'),
'edittimelimit' => array('0', '20', '10'),
'floodctrl' => array('0', '10', '30'),
'karmaratelimit' => array('0', '1', '4'),
'newbiespan' => array('', '1', '4'),
'showemail' => array('0', '1', '1'),
'maxchargespan' => array('0', '1', '2'),
'regctrl' => array('0', '12', '48'),
'regfloodctrl' => array('0', '100', '50'),
'regstatus' => array('1', '1', '1'),
'regverify' => array('0', '1', '2'),
);
$funcsettings = array(
'archiverstatus' => array('0', '1', '1'),
'bdaystatus' => array('0', '0', '1'),
'fastpost' => array('0', '1', '1'),
'editedby' => array('0', '1', '1'),
'forumjump' => array('0', '1', '1'),
'gzipcompress' => array('', '', '1'),
'newsletter' => array('', '', '1'),
'modworkstatus' => array('0', '0', '1'),
'reportpost' => array('0', '1', '1'),
'rewritestatus' => array('0', '0', '0'),
'rssstatus' => array('0', '1', '1'),
'wapstatus' => array('0', '1', '1'),
'maxbdays' => array('0', '100', '500'),
'statstatus' => array('0', '0', '1'),
'stylejump' => array('0', '0', '1'),
'subforumsindex' => array('0', '0', '1'),
'transsidstatus' => array('0', '0', '1'),
'visitedforums' => array('0', '10', '20'),
'vtonlinestatus' => array('0', '1', '1'),
'welcomemsg' => array('0', '0', '1'),
'jsstatus' => array('0', '0', '1'),
'watermarkstatus' => array('0', '0', '1'),
'whosonlinestatus' => array('0', '1', '1'),
'debug' => array('0', '1', '1'),
'regadvance' => array('0', '0', '1'),
'jsmenustatus' => array('0', '1', '15'),
'showsettings' => array('0', '7', '7'),
'editoroptions' => array('0', '1', '1'),
);
$safeforums = array(
'modnewposts' => array('0', '0', '1'),
'recyclebin' => array('0', '1', '1'),
'jammer' => array('0', '0', '1'),
);
$funcforums = array(
'allowsmilies' => array('0', '1', '1'),
'allowbbcode' => array('0', '1', '1'),
'allowimgcode' => array('0', '1', '1'),
'allowanonymous' => array('0', '0', '1'),
'allowpostspecial' => array('', '1', '127'),
'disablewatermark' => array('1', '0', '0'),
'threadcaches' => array('0', '0', '1'),
'allowshare' => array('0', '1', '1'),
);
$sizeforums = array(
'threadcaches' => array('0', '0', '1'),
);
$sqladd = $comma = '';
foreach($sizesettings as $fieldname=>$val) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$fieldname', '{$val[$runwizardhistory[step1][size]]}')");
}
foreach($sizeforums as $fieldname=>$val) {
$sqladd .= $comma."$fieldname='".$val[$runwizardhistory['step1']['size']]."'";
$comma = ',';
}
foreach($safesettings as $fieldname=>$val) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$fieldname', '{$val[$runwizardhistory[step1][safe]]}')");
}
foreach($safeforums as $fieldname=>$val) {
$sqladd .= $comma."$fieldname='".$val[$runwizardhistory['step1']['safe']]."'";
}
foreach($funcsettings as $fieldname=>$val) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$fieldname', '{$val[$runwizardhistory[step1][func]]}')");
}
foreach($funcforums as $fieldname=>$val) {
$sqladd .= $comma."$fieldname='".$val[$runwizardhistory['step1']['func']]."'";
}
$db->query("UPDATE {$tablepre}forums SET $sqladd");
$maxonlines = $sizesettings['maxonlines'][$runwizardhistory['step1']['size']];
$db->query("ALTER TABLE {$tablepre}sessions MAX_ROWS=$maxonlines");
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('bbname', '{$runwizardhistory[step2][bbname]}')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('sitename', '{$runwizardhistory[step2][sitename]}')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('siteurl', '{$runwizardhistory[step2][siteurl]}')");
updatecache('settings');
foreach($runwizardhistory['step3']['cates'] as $id=>$catename) {
$db->query("INSERT INTO {$tablepre}forums (type, name, status)
VALUES ('group', '$catename', '1')");
$fup = $fid = $db->insert_id();
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
foreach($runwizardhistory['step3']['forums'][$id] as $forumname) {
$db->query("INSERT INTO {$tablepre}forums (fup, type, name, status, allowsmilies, allowbbcode, allowimgcode, allowshare, allowpostspecial)
VALUES ('$fup', 'forum', '$forumname', '1', '1', '1', '1', '1', '15')");
$fid = $db->insert_id();
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
}
}
updatecache('forums');
$runwizardhistory['step3']['cates'] = array();
$runwizardhistory['step3']['forums'] = array();
saverunwizardhistory();
?>
<ul class="tpllist"><li>
<h4><?=$lang['runwizard_succeed']?></h4>
<ul class="tpllist2">
<li><a href="<?=$BASESCRIPT?>?action=settings&operation=basic"><?=$lang['runwizard_particular']?></a></li>
<li><a href="<?=$BASESCRIPT?>?action=forums"><?=$lang['forums_admin_add_forum']?></a></li>
<li><a href="<?=$BASESCRIPT?>?action=tools&operation=fileperms"><?=$lang['nav_fileperms']?></a></li>
</ul>
</li>
<li>
<h4><?=$lang['runwizard_database_backup']?></h4>
<ul class="tpllist2">
<li><a href="<?=$BASESCRIPT?>?action=db&operation=export"><?=$lang['db_export']?></a></li>
<li><a href="<?=$BASESCRIPT?>?action=db&operation=import"><?=$lang['db_import']?></a></li>
</ul>
</li>
</ul>
<?}?>
</td></tr></table>
<?
}
function saverunwizardhistory() {
global $runwizardfile, $runwizardhistory;
$fp = fopen($runwizardfile, 'w');
$s = '<?php exit;?>';
$s .= serialize($runwizardhistory);
fwrite($fp, $s);
fclose($fp);
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/runwizard.inc.php | PHP | asf20 | 13,641 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: threads.inc.php 21266 2009-11-24 05:35:06Z liulanbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./include/post.func.php';
cpheader();
$page = max(1, intval($page));
if(!$operation) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="inforum"><option value="all"> > '.$lang['all'].'</option>'.
'<option value=""> </option>'.forumselect(FALSE, 0, 0, TRUE).'</select>';
if(isset($inforum)) {
$forumselect = preg_replace("/(\<option value=\"$inforum\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
}
$typeselect = $sortselect = '';
$query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
if($type['special']) {
$sortselect .= '<option value="'.$type['typeid'].'"> > '.$type['name'].'</option>';
} else {
$typeselect .= '<option value="'.$type['typeid'].'"> > '.$type['name'].'</option>';
}
}
if(isset($insort)) {
$sortselect = preg_replace("/(\<option value=\"$insort\")(\>)/", "\\1 selected=\"selected\" \\2", $sortselect);
}
if(isset($intype)) {
$typeselect = preg_replace("/(\<option value=\"$intype\")(\>)/", "\\1 selected=\"selected\" \\2", $typeselect);
}
echo <<<EOT
<script src="include/js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('threadforum').page.value=number;
$('threadforum').searchsubmit.click();
}
</script>
EOT;
shownav('topic', 'nav_maint_threads');
showsubmenusteps('nav_maint_threads', array(
array('threads_search', !$searchsubmit),
array('nav_maint_threads', $searchsubmit)
));
showtips('threads_tips');
showtagheader('div', 'threadsearch', !submitcheck('searchsubmit'));
showformheader('threads', '', 'threadforum');
showhiddenfields(array('page' => $page));
showtableheader();
showsetting('threads_search_detail', 'detail', $detail, 'radio');
showsetting('threads_search_forum', '', '', $forumselect);
showsetting('threads_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
showsetting('threads_search_user', 'users', $users, 'text');
showsetting('threads_search_keyword', 'keywords', $keywords, 'text');
showtagheader('tbody', 'advanceoption');
showsetting('threads_search_type', '', '', '<select name="intype"><option value="all"> > '.$lang['all'].'</option><option value=""> </option><option value="0"> > '.$lang['threads_search_type_none'].'</option>'.$typeselect.'</select>');
showsetting('threads_search_sort', '', '', '<select name="insort"><option value="all"> > '.$lang['all'].'</option><option value=""> </option><option value="0"> > '.$lang['threads_search_type_none'].'</option>'.$sortselect.'</select>');
showsetting('threads_search_viewrange', array('viewsmore', 'viewsless'), array($viewsmore, $viewsless), 'range');
showsetting('threads_search_replyrange', array('repliesmore', 'repliesless'), array($repliesmore, $repliesless), 'range');
showsetting('threads_search_readpermmore', 'readpermmore', $readpermmore, 'text');
showsetting('threads_search_pricemore', 'pricemore', $pricemore, 'text');
showsetting('threads_search_noreplyday', 'noreplydays', $noreplydays, 'text');
showsetting('threads_search_type', array('specialthread', array(
array(0, lang('unlimited'), array('showspecial' => 'none')),
array(1, lang('threads_search_include_yes'), array('showspecial' => '')),
array(2, lang('threads_search_include_no'), array('showspecial' => '')),
), TRUE), $specialthread, 'mradio');
showtablerow('id="showspecial" style="display:'.($specialthread ? '' : 'none').'"', 'class="sub" colspan="2"', mcheckbox('special', array(
1 => lang('thread_poll'),
2 => lang('thread_trade'),
3 => lang('thread_reward'),
4 => lang('thread_activity'),
5 => lang('thread_debate')
), $special ? $special : array(0)));
showsetting('threads_search_sticky', array('sticky', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $sticky, 'mradio');
showsetting('threads_search_digest', array('digest', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $digest, 'mradio');
showsetting('threads_search_attach', array('attach', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $attach, 'mradio');
showsetting('threads_rate', array('rate', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $rate, 'mradio');
showsetting('threads_highlight', array('highlight', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $highlight, 'mradio');
showtagfooter('tbody');
showsubmit('searchsubmit', 'submit', '', 'more_options');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
$sql = '';
$sql .= $inforum != '' && $inforum != 'all' ? " AND fid='$inforum'" : '';
$sql .= $intype != '' && $intype != 'all' ? " AND typeid='$intype'" : '';
$sql .= $insort != '' && $insort != 'all' ? " AND sortid='$insort'" : '';
$sql .= $viewsless != '' ? " AND views<'$viewsless'" : '';
$sql .= $viewsmore != '' ? " AND views>'$viewsmore'" : '';
$sql .= $repliesless != '' ? " AND replies<'$repliesless'" : '';
$sql .= $repliesmore != '' ? " AND replies>'$repliesmore'" : '';
$sql .= $readpermmore != '' ? " AND readperm>'$readpermmore'" : '';
$sql .= $pricemore != '' ? " AND price>'$pricemore'" : '';
$sql .= $beforedays != '' ? " AND dateline<'$timestamp'-'$beforedays'*86400" : '';
$sql .= $noreplydays != '' ? " AND lastpost<'$timestamp'-'$noreplydays'*86400" : '';
$sql .= $starttime != '' ? " AND dateline>'".strtotime($starttime)."'" : '';
$sql .= $endtime != '' ? " AND dateline<='".strtotime($endtime)."'" : '';
if(trim($keywords)) {
$sqlkeywords = '';
$or = '';
$keywords = explode(',', str_replace(' ', '', $keywords));
for($i = 0; $i < count($keywords); $i++) {
$sqlkeywords .= " $or subject LIKE '%".$keywords[$i]."%'";
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
}
$sql .= trim($users) ? " AND author IN ('".str_replace(',', '\',\'', str_replace(' ', '', trim($users)))."')" : '';
if($sticky == 1) {
$sql .= " AND displayorder>'0'";
} elseif($sticky == 2) {
$sql .= " AND displayorder='0'";
}
if($digest == 1) {
$sql .= " AND digest>'0'";
} elseif($digest == 2) {
$sql .= " AND digest='0'";
}
if($attach == 1) {
$sql .= " AND attachment>'0'";
} elseif($attach == 2) {
$sql .= " AND attachment='0'";
}
if($rate == 1) {
$sql .= " AND rate>'0'";
} elseif($rate == 2) {
$sql .= " AND rate='0'";
}
if($highlight == 1) {
$sql .= " AND highlight>'0'";
} elseif($highlight == 2) {
$sql .= " AND highlight='0'";
}
if(!empty($special)) {
$specials = $comma = '';
foreach($special as $val) {
$specials .= $comma.'\''.$val.'\'';
$comma = ',';
}
if($specialthread == 1) {
$sql .= " AND special IN ($specials)";
} elseif($specialthread == 2) {
$sql .= " AND special NOT IN ($specials)";
}
}
$fids = array();
$tids = $threadcount = '0';
if($sql) {
$sql = "digest>='0' AND displayorder>='0' $sql";
if($detail) {
$pagetmp = $page;
do {
$query = $db->query("SELECT fid, tid, readperm, price, subject, authorid, author, views, replies, lastpost FROM {$tablepre}threads WHERE $sql LIMIT ".(($pagetmp - 1) * $tpp).",$tpp");
$pagetmp--;
} while(!$db->num_rows($query) && $pagetmp);
$threads = '';
while($thread = $db->fetch_array($query)) {
$fids[] = $thread['fid'];
$thread['lastpost'] = gmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600);
$threads .= showtablerow('', array('class="td25"', '', '', '', 'class="td25"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"tidarray[]\" value=\"$thread[tid]\" checked />",
"<a href=\"viewthread.php?tid=$thread[tid]\" target=\"_blank\">$thread[subject]</a>".($thread['readperm'] ? " - [$lang[threads_readperm] $thread[readperm]]" : '').($thread['price'] ? " - [$lang[threads_price] $thread[price]]" : ''),
"<a href=\"forumdisplay.php?fid=$thread[fid]\" target=\"_blank\">{$_DCACHE[forums][$thread[fid]][name]}</a>",
"<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a>",
$thread['replies'],
$thread['views'],
$thread['lastpost']
), TRUE);
}
$threadcount = $db->result_first("SELECT count(*) FROM {$tablepre}threads WHERE $sql");
$multi = multi($threadcount, $tpp, $page, "$BASESCRIPT?action=threads");
$multi = preg_replace("/href=\"$BASESCRIPT\?action=threads&page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location=$BASESCRIPT.'?action=threads&page='+this.value", "page(this.value)", $multi);
} else {
$query = $db->query("SELECT fid, tid FROM {$tablepre}threads WHERE $sql");
while($thread = $db->fetch_array($query)) {
$fids[] = $thread['fid'];
$tids .= ','.$thread['tid'];
}
$threadcount = $db->result_first("SELECT count(*) FROM {$tablepre}threads WHERE $sql");
$multi = '';
}
}
$fids = implode(',', array_unique($fids));
showtagheader('div', 'threadlist', TRUE);
showformheader('threads&frame=no', 'target="threadframe"');
showhiddenfields($detail ? array('fids' => $fids) : array('fids' => $fids, 'tids' => $tids));
showtableheader(lang('threads_result').' '.$threadcount.' <a href="###" onclick="$(\'threadlist\').style.display=\'none\';$(\'threadsearch\').style.display=\'\';" class="act lightlink normal">'.lang('research').'</a>', 'nobottom');
showsubtitle(array('', 'operation', 'option'));
if(!$threadcount) {
showtablerow('', 'colspan="3"', lang('threads_thread_nonexistence'));
} else {
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="moveforum" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_move_forum'],
'<select name="toforum">'.forumselect(FALSE, 0, 0, TRUE).'</select>'
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="movetype" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_move_type'],
'<select name="totype"><option value="0"> > '.$lang['threads_search_type_none'].'</option>'.$typeselect.'</select>'
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="movesort" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_move_sort'],
'<select name="tosort"><option value="0"> > '.$lang['threads_search_type_none'].'</option>'.$sortselect.'</select>'
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="delete" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_delete'],
'<input class="checkbox" type="checkbox" name="donotupdatemember" id="donotupdatemember" value="1" checked="checked" /><label for="donotupdatemember"> '.$lang['threads_delete_no_update_member'].'</label>'
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="stick" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_stick'],
'<input class="radio" type="radio" name="stick_level" value="0" checked> '.$lang['threads_remove'].' <input class="radio" type="radio" name="stick_level" value="1"> '.$lang['threads_stick_one'].' <input class="radio" type="radio" name="stick_level" value="2"> '.$lang['threads_stick_two'].' <input class="radio" type="radio" name="stick_level" value="3"> '.$lang['threads_stick_three']
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="adddigest" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_add_digest'],
'<input class="radio" type="radio" name="digest_level" value="0" checked> '.$lang['threads_remove'].' <input class="radio" type="radio" name="digest_level" value="1"> '.$lang['threads_digest_one'].' <input class="radio" type="radio" name="digest_level" value="2"> '.$lang['threads_digest_two'].' <input class="radio" type="radio" name="digest_level" value="3"> '.$lang['threads_digest_three']
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="addstatus" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_open_close'],
'<input class="radio" type="radio" name="status" value="0" checked> '.$lang['open'].' <input class="radio" type="radio" name="status" value="1"> '.$lang['closed']
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="deleteattach" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_delete_attach'],
''
));
if($detail) {
showtablefooter();
showtableheader('threads_list', 'notop');
showsubtitle(array('', 'subject', 'forum', 'author', 'threads_replies', 'threads_views', 'threads_lastpost'));
echo $threads;
}
}
showsubmit('modsubmit', 'submit', '<input name="chkall" id="chkall" type="checkbox" class="checkbox" checked="checked" onclick="checkAll(\'prefix\', this.form, \'tidarray\', \'chkall\')" /><label for="chkall">'.lang('select_all').'</label>', '', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="threadframe" style="display:none"></iframe>';
showtagfooter('div');
}
} else {
$tidsadd = isset($tids) ? 'tid IN ('.$tids.')' : 'tid IN ('.implodeids($tidarray).')';
if($operation == 'moveforum') {
if(!$db->result_first("SELECT fid FROM {$tablepre}forums WHERE type<>'group' AND fid='$toforum'")) {
cpmsg('threads_move_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}threads SET fid='$toforum' WHERE $tidsadd");
$db->query("UPDATE {$tablepre}posts SET fid='$toforum' WHERE $tidsadd");
foreach(explode(',', $fids.','.$toforum) as $fid) {
updateforumcount(intval($fid));
}
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'movetype') {
if($totype != 0) {
if(!$db->result_first("SELECT typeid FROM {$tablepre}threadtypes WHERE typeid='$totype' AND special='0'")) {
cpmsg('threads_move_invalid', '', 'error');
}
}
$db->query("UPDATE {$tablepre}threads SET typeid='$totype' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'movesort') {
if($tosort != 0) {
if(!$db->result_first("SELECT typeid FROM {$tablepre}threadtypes WHERE typeid='$tosort' AND special='1'")) {
cpmsg('threads_move_invalid', '', 'error');
}
}
$db->query("UPDATE {$tablepre}threads SET sortid='$tosort' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'delete') {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE $tidsadd");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
if(!$donotupdatemember) {
$query = $db->query("SELECT fid, first, authorid FROM {$tablepre}posts WHERE $tidsadd");
while($post = $db->fetch_array($query)) {
$forumposts[$post['fid']][] = $post;
}
foreach($forumposts as $fid => $postarray) {
$query = $db->query("SELECT postcredits, replycredits FROM {$tablepre}forumfields WHERE fid='$fid'");
if($forum = $db->fetch_array($query)) {
$forum['postcredits'] = !empty($forum['postcredits']) ? unserialize($forum['postcredits']) : array();
$forum['replycredits'] = !empty($forum['replycredits']) ? unserialize($forum['replycredits']) : array();
}
$postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
$replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
$tuidarray = $ruidarray = array();
foreach($postarray as $post) {
if($post['first']) {
$tuidarray[] = $post['authorid'];
} else {
$ruidarray[] = $post['authorid'];
}
}
if($tuidarray) {
updatepostcredits('-', $tuidarray, $postcredits);
}
if($ruidarray) {
updatepostcredits('-', $ruidarray, $replycredits);
}
}
}
$db->query("DELETE FROM {$tablepre}attachments WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}posts WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threads WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polloptions WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polls WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activities WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activityapplies WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}debates WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}debateposts WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadsmod WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}relatedthreads WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}postposition WHERE $tidsadd", 'UNBUFFERED');
if($globalstick) {
updatecache('globalstick');
}
foreach(explode(',', $fids) as $fid) {
updateforumcount(intval($fid));
}
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'deleteattach') {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE $tidsadd");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE $tidsadd");
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE $tidsadd");
$db->query("UPDATE {$tablepre}threads SET attachment='0' WHERE $tidsadd");
$db->query("UPDATE {$tablepre}posts SET attachment='0' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'stick') {
$db->query("UPDATE {$tablepre}threads SET displayorder='$stick_level' WHERE $tidsadd");
if($globalstick) {
updatecache('globalstick');
}
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'adddigest') {
$query = $db->query("SELECT tid, authorid, digest FROM {$tablepre}threads WHERE $tidsadd");
while($thread = $db->fetch_array($query)) {
updatecredits($thread['authorid'], $creditspolicy['digest'], $digest_level - $thread['digest'], 'digestposts=digestposts+\'-1\'');
}
$db->query("UPDATE {$tablepre}threads SET digest='$digest_level' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'addstatus') {
$db->query("UPDATE {$tablepre}threads SET closed='$status' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'forumstick') {
shownav('topic', 'threads_forumstick');
@include DISCUZ_ROOT . '/forumdata/cache/cache_forums.php';
$forumstickthreads = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='forumstickthreads'");
$forumstickthreads = isset($forumstickthreads) ? unserialize($forumstickthreads) : array();
if(!submitcheck('forumsticksubmit')) {
showsubmenu('threads_forumstick', array(
array('admin', 'threads&operation=forumstick', !$do),
array('add', 'threads&operation=forumstick&do=add', $do == 'add'),
));
showtips('threads_forumstick_tips');
if(!$do) {
showformheader('threads&operation=forumstick');
showtableheader('admin', 'fixpadding');
showsubtitle(array('', 'subject', 'forum', 'edit'));
if(is_array($forumstickthreads)) {
foreach($forumstickthreads as $k => $v) {
$forumnames = array();
foreach($v['forums'] as $forum_id){
$forumnames[] = $_DCACHE['forums'][$forum_id]['name'];
}
showtablerow('', array('class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$k\">",
"<a href=\"viewthread.php?tid=$v[tid]\" target=\"_blank\">$v[subject]</a>",
implode(', ', $forumnames),
"<a href=\"$BASESCRIPT?action=threads&operation=forumstick&do=edit&id=$k\">$lang[threads_forumstick_targets_change]</a>",
));
}
}
showsubmit('forumsticksubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} elseif($do == 'add') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
showformheader('threads&operation=forumstick&do=add');
showtableheader('add', 'fixpadding');
showsetting('threads_forumstick_threadurl', 'forumstick_url', '', 'text');
$targetsselect = '<select name="forumsticktargets[]" size="10" multiple="multiple">'.forumselect(FALSE, 0, 0, TRUE).'</select>';
showsetting('threads_forumstick_targets', '', '', $targetsselect);
echo '<input type="hidden" value="add" name="do" />';
showsubmit('forumsticksubmit', 'submit');
showtablefooter();
showformfooter();
} elseif($do == 'edit') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
showformheader("threads&operation=forumstick&do=edit&id=$id");
showtableheader('edit', 'fixpadding');
$targetsselect = '<select name="forumsticktargets[]" size="10" multiple="multiple">'.forumselect(FALSE, 0, 0, TRUE).'</select>';
foreach($forumstickthreads[$id]['forums'] as $target) {
$targetsselect = preg_replace("/(\<option value=\"$target\")([^\>]*)(\>)/", "\\1 \\2 selected=\"selected\" \\3", $targetsselect);
}
showsetting('threads_forumstick_targets', '', '', $targetsselect);
echo '<input type="hidden" value="edit" name="do" />';
echo "<input type=\"hidden\" value=\"$id\" name=\"id\" />";
showsubmit('forumsticksubmit', 'submit');
showtablefooter();
showformfooter();
}
} else {
if(!$do) {
$do = 'del';
}
if($do == 'del') {
$del_tids = '0';
foreach($delete as $del_tid){
unset($forumstickthreads[$del_tid]);
$del_tids .= ", $del_tid";
}
$db->query("UPDATE {$tablepre}threads SET displayorder='0' WHERE tid IN ($del_tids)");
} elseif($do == 'add') {
if(preg_match('/(tid=|thread-)(\d+)/i', $forumstick_url, $matches)) {
$forumstick_tid = $matches[2];
} else {
cpmsg('threads_forumstick_url_invalid', "$BASESCRIPT?action=threads&operation=forumstick&do=add", 'error');
}
if(empty($forumsticktargets)) {
cpmsg('threads_forumstick_targets_empty', "$BASESCRIPT?action=threads&operation=forumstick&do=add", 'error');
}
$stickthread_tmp = array(
'subject' => $db->result_first("SELECT subject FROM {$tablepre}threads WHERE tid='$forumstick_tid'"),
'tid' => $forumstick_tid,
'forums' => $forumsticktargets,
);
$forumstickthreads[$forumstick_tid] = $stickthread_tmp;
$db->query("UPDATE {$tablepre}threads SET displayorder='4' WHERE tid='$forumstick_tid'");
} elseif($do == 'edit') {
if(empty($forumsticktargets)) {
cpmsg('threads_forumstick_targets_empty', "$BASESCRIPT?action=threads&operation=forumstick&do=edit&id=$id", 'error');
}
$forumstickthreads[$id]['forums'] = $forumsticktargets;
$db->query("UPDATE {$tablepre}threads SET displayorder='4' WHERE tid='$forumstick_tid'");
}
$forumstickthreads = serialize($forumstickthreads);
$db->query("REPLACE INTO {$tablepre}settings(variable, value) VALUES('forumstickthreads', '$forumstickthreads')");
updatecache('forumstick');
cpmsg("threads_forumstick_{$do}_succeed", "$BASESCRIPT?action=threads&operation=forumstick", 'succeed');
}
} elseif($operation == 'postposition') {
shownav('topic', 'threads_postposition');
if(!$do) {
if(submitcheck('delpositionsubmit')) {
delete_position($delete);
cpmsg('delete_position_succeed', $BASESCRIPT.'?action=threads&operation=postposition');
} elseif(submitcheck('delandaddsubmit')) {
delete_position($delete);
cpmsg('delete_position_gotu_add', $BASESCRIPT.'?action=threads&operation=postposition&do=add&addpositionsubmit=yes&formhash='.FORMHASH.'&tids='.urlencode(implode(',', $delete)));
} else {
showsubmenu('threads_postposition', array(
array('admin', 'threads&operation=postposition', !$do),
array('add', 'threads&operation=postposition&do=add', $do == 'add'),
));
showtips('threads_postposition_tips');
@include DISCUZ_ROOT . '/forumdata/cache/cache_forums.php';
showformheader('threads&operation=postposition');
showtableheader('admin', 'fixpadding');
showsubtitle(array('', 'ID', 'subject', 'forum', 'replies', 'dateline'));
$limit_start = 20 * ($page - 1);
if($count = $db->result_first("SELECT COUNT(DISTINCT(tid)) FROM {$tablepre}postposition")) {
$multipage = multi($count, 20, $page, "$BASESCRIPT?action=threads&operation=postposition");
$query = $db->query("SELECT DISTINCT(tid) FROM {$tablepre}postposition LIMIT $limit_start, 20");
$tids = 0;
while($row = $db->fetch_array($query)) {
$tids .= ", $row[tid]";
}
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid IN ($tids)");
while($v = $db->fetch_array($query)) {
showtablerow('', array('class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$v[tid]\">",
$v['tid'],
"<a href=\"viewthread.php?tid=$v[tid]\" target=\"_blank\">$v[subject]</a>",
'<a href="forumdisplay.php?fid='.$v['fid'].'" target="_blank">'.$_DCACHE['forums'][$v['fid']]['name'].'</a>',
$v['replies'],
dgmdate("$dateformat $timeformat", $v['dateline'] + $timeoffset * 3600)
));
}
}
showsubmit('delpositionsubmit', 'deleteposition', 'select_all', '<input type="submit" class="btn" name="delandaddsubmit" value="'.lang('delandadd').'" />', $multipage);
showtablefooter();
showformfooter();
}
} elseif($do == 'add') {
if(submitcheck('addpositionsubmit', 1)) {
$delete = isset($delete) && is_array($delete) ? $delete : explode(',', $tids);
if(empty($delete)) {
cpmsg('select_thread_empty');
}
$lastpid = create_position($delete, $lastpid);
if(empty($delete)) {
cpmsg('add_postposition_succeed', $BASESCRIPT.'?action=threads&operation=postposition');
}
cpmsg('addpostposition_continue', $BASESCRIPT.'?action=threads&operation=postposition&do=add&addpositionsubmit=yes&formhash='.FORMHASH.'&tids='.urlencode(implode(',', $delete)).'&lastpid='.$lastpid);
} else {
showsubmenu('threads_postposition', array(
array('admin', 'threads&operation=postposition', !$do),
array('add', 'threads&operation=postposition&do=add', $do == 'add'),
));
showtips('threads_postposition_tips');
showformheader('threads&operation=postposition&do=add');
showtableheader('srchthread', 'fixpadding');
echo '<tr><td>'.lang('srch_replies').'<label><input type="radio" name="replies" value="5000"'.($replies == 5000 ? ' checked="checked"' : '').' />5000</label> '.
'<label><input type="radio" name="replies" value="10000"'.($replies == 10000 ? ' checked="checked"' : '').' />10000</label> '.
'<label><input type="radio" name="replies" value="20000"'.($replies == 20000 ? ' checked="checked"' : '').' />20000</label> '.
'<label><input type="radio" name="replies" value="50000"'.($replies == 50000 ? ' checked="checked"' : '').' />50000</label> '.
'<label><input id="replies_other" type="radio" name="replies" value="0"'.(isset($replies) && $replies == 0 ? ' checked="checked"' : '').' onclick="$(\'above_replies\').focus()" />'.lang('threads_postposition_replies').'</label> '.
'<input id="above_replies" onclick="$(\'replies_other\').checked=true" type="text class="txt" name="above_replies" value="'.$above_replies.'" size="5" /> '.
' <label>'.lang('srch_tid').' <input type="text class="txt" name="srchtid" size="5" value="'.$srchtid.'" /></label> '.
' <input type="submit" class="btn" name="srchthreadsubmit" value="'.lang('submit').'" />';
showtablefooter();
showformfooter();
@include DISCUZ_ROOT . '/forumdata/cache/cache_forums.php';
showformheader('threads&operation=postposition&do=add');
showtableheader('addposition', 'fixpadding');
showsubtitle(array('', 'ID', 'subject', 'forum', 'replies', 'dateline'));
if(submitcheck('srchthreadsubmit', 1)) {
if($srchtid = max(0, intval($srchtid))) {
if($thread = $db->fetch_first("SELECT * FROM {$tablepre}threads WHERE tid='$srchtid'")) {
showtablerow('', array('class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$thread[tid]\">",
$thread['tid'],
"<a href=\"viewthread.php?tid=$thread[tid]\" target=\"_blank\">$thread[subject]</a>",
'<a href="forumdisplay.php?fid='.$thread['fid'].'" target="_blank">'.$_DCACHE['forums'][$thread['fid']]['name'].'</a>',
$thread['replies'],
dgmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600)
));
}
} else {
$r_replies = $replies ? $replies : $above_replies;
if($r_replies = max(0, intval($r_replies))) {
$limit_start = 2 * ($page - 1);
if($count = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE replies>'$r_replies'")) {
$multipage = multi($count, 2, $page, "$BASESCRIPT?action=threads&operation=postposition&do=add&srchthreadsubmit=yes&replies=$r_replies");
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE replies>'$r_replies' LIMIT $limit_start, 2");
$have = 0;
while($thread = $db->fetch_array($query)) {
if(getstatus($thread['status'], 1)) continue;
$have = 1;
showtablerow('', array('class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$thread[tid]\">",
$thread['tid'],
"<a href=\"viewthread.php?tid=$thread[tid]\" target=\"_blank\">$thread[subject]</a>",
'<a href="forumdisplay.php?fid='.$thread['fid'].'" target="_blank">'.$_DCACHE['forums'][$thread['fid']]['name'].'</a>',
$thread['replies'],
dgmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600)
));
}
if($have == 0) {
dheader("Location: $BASESCRIPT?action=threads&operation=postposition&do=add&srchthreadsubmit=yes&replies=$r_replies&page=".($page+1));
}
}
}
}
}
showsubmit('addpositionsubmit', 'addposition', 'select_all', '', $multipage);
showtablefooter();
showformfooter();
}
}
}
$tids && deletethreadcaches($tids);
$cpmsg = $cpmsg ? "alert('$cpmsg');" : '';
echo '<script type="text/JavaScript">'.$cpmsg.'if(parent.$(\'threadforum\')) parent.$(\'threadforum\').searchsubmit.click();</script>';
}
function delete_position($select) {
global $db, $tablepre;
if(empty($select) || !is_array($select)) {
cpmsg('select_thread_empty');
}
$tids = implodeids($select);
$db->query("DELETE FROM {$tablepre}postposition WHERE tid IN($tids)");
$db->query("UPDATE {$tablepre}threads SET status=status & '1111111111111110' WHERE tid IN ($tids)");
}
function create_position(&$select, $lastpid = 0) {
global $db, $tablepre;
if(empty($select) || !is_array($select)) {
return 0;
}
$round = 500;
$tid = $select[0];
$query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND pid>'$lastpid' ORDER BY pid ASC LIMIT 0, $round");
while($post = $db->fetch_array($query)) {
if(empty($post) || empty($post['pid'])) continue;
savepostposition($tid, $post['pid']);
}
if($db->num_rows($query) < $round) {
$db->query("UPDATE {$tablepre}threads SET status=status | '1' WHERE tid='$tid'");
unset($select[0]);
return 0;
} else {
return $post['pid'];
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/threads.inc.php | PHP | asf20 | 34,322 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: checktools.inc.php 20755 2009-10-19 01:36:56Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
if($operation == 'filecheck') {
$step = max(1, intval($step));
shownav('tools', 'nav_filecheck');
showsubmenusteps('nav_filecheck', array(
array('nav_filecheck_confirm', $step == 1),
array('nav_filecheck_verify', $step == 2),
array('nav_filecheck_completed', $step == 3)
));
if($step == 1) {
cpmsg($lang[filecheck_tips_step1], $BASESCRIPT.'?action=checktools&operation=filecheck&step=2', 'button', '', FALSE);
} elseif($step == 2) {
cpmsg(lang('filecheck_verifying'), "$BASESCRIPT?action=checktools&operation=filecheck&step=3", 'loading', '', FALSE);
} elseif($step == 3) {
if(!$discuzfiles = @file('admin/discuzfiles.md5')) {
cpmsg('filecheck_nofound_md5file', '', 'error');
}
$md5data = array();
$cachelist = checkcachefiles('forumdata/cache/');
checkfiles('./', '\.php', 0, 'config.inc.php');
checkfiles('include/', '\.php|\.htm|\.js');
checkfiles('templates/default/', '\.php|\.htm');
checkfiles('wap/', '\.php');
checkfiles('archiver/', '\.php');
checkfiles('api/', '\.php');
checkfiles('plugins/', '\.php');
checkfiles('admin/', '\.php');
checkfiles('modcp/', '\.php');
checkfiles('uc_client/', '\.php', 0);
checkfiles('uc_client/control/', '\.php');
checkfiles('uc_client/model/', '\.php');
checkfiles('uc_client/lib/', '\.php');
foreach($discuzfiles as $line) {
$file = trim(substr($line, 34));
$md5datanew[$file] = substr($line, 0, 32);
if($md5datanew[$file] != $md5data[$file]) {
$modifylist[$file] = $md5data[$file];
}
$md5datanew[$file] = $md5data[$file];
}
$weekbefore = $timestamp - 604800;
$addlist = @array_merge(@array_diff_assoc($md5data, $md5datanew), $cachelist[2]);
$dellist = @array_diff_assoc($md5datanew, $md5data);
$modifylist = @array_merge(@array_diff_assoc($modifylist, $dellist), $cachelist[1]);
$showlist = @array_merge($md5data, $md5datanew, $cachelist[0]);
$doubt = 0;
$dirlist = $dirlog = array();
foreach($showlist as $file => $md5) {
$dir = dirname($file);
if(@array_key_exists($file, $modifylist)) {
$fileststus = 'modify';
} elseif(@array_key_exists($file, $dellist)) {
$fileststus = 'del';
} elseif(@array_key_exists($file, $addlist)) {
$fileststus = 'add';
} else {
$filemtime = @filemtime($file);
if($filemtime > $weekbefore) {
$fileststus = 'doubt';
$doubt++;
} else {
$fileststus = '';
}
}
if(file_exists($file)) {
$filemtime = @filemtime($file);
$fileststus && $dirlist[$fileststus][$dir][basename($file)] = array(number_format(filesize($file)).' Bytes', date("$dateformat $timeformat", $filemtime));
} else {
$fileststus && $dirlist[$fileststus][$dir][basename($file)] = array('', '');
}
}
$result = $resultjs = '';
$dirnum = 0;
foreach($dirlist as $status => $filelist) {
$dirnum++;
$class = $status == 'modify' ? 'edited' : ($status == 'del' ? 'del' : 'unknown');
$result .= '<tbody id="status_'.$status.'" style="display:'.($status != 'modify' ? 'none' : '').'">';
foreach($filelist as $dir => $files) {
$result .= '<tr><td colspan="4"><div class="ofolder">'.$dir.'</div><div class="lightfont filenum left">';
foreach($files as $filename => $file) {
$result .= '<tr><td><em class="files bold">'.$filename.'</em></td><td style="text-align: right">'.$file[0].' </td><td>'.$file[1].'</td><td><em class="'.$class.'"> </em></td></tr>';
}
}
$result .= '</tbody>';
$resultjs .= '$(\'status_'.$status.'\').style.display=\'none\';';
}
$modifiedfiles = count($modifylist);
$deletedfiles = count($dellist);
$unknownfiles = count($addlist);
$doubt = intval($doubt);
$result .= '<script>function showresult(o) {'.$resultjs.'$(\'status_\' + o).style.display=\'\';}</script>';
showtips('filecheck_tips');
showtableheader('filecheck_completed');
showtablerow('', 'colspan="4"', "<div class=\"lightfont filenum left\">".
"<em class=\"edited\">$lang[filecheck_modify]: $modifiedfiles</em> ".($modifiedfiles > 0 ? "<a href=\"###\" onclick=\"showresult('modify')\">[$lang[view]]</a> " : '').
" <em class=\"del\">$lang[filecheck_delete]: $deletedfiles</em> ".($deletedfiles > 0 ? "<a href=\"###\" onclick=\"showresult('del')\">[$lang[view]]</a> " : '').
" <em class=\"unknown\">$lang[filecheck_unknown]: $unknownfiles</em> ".($unknownfiles > 0 ? "<a href=\"###\" onclick=\"showresult('add')\">[$lang[view]]</a> " : '').
($doubt > 0 ? " <em class=\"unknown\">$lang[filecheck_doubt]: $doubt</em> <a href=\"###\" onclick=\"showresult('doubt')\">[$lang[view]]</a> " : '').
"</div>");
showsubtitle(array('filename', '', 'lastmodified', ''));
echo $result;
showtablefooter();
}
} elseif($operation == 'ftpcheck') {
$alertmsg = '';
$testdir = substr(md5('Discuz!' + $timestamp), 12, 8);
$testfile = 'discuztest.txt';
$attach_dir = $attachdir;
if($attachsave) {
$attach_dir .= '/'.$testdir;
if(!@mkdir($attach_dir, 0777)) {
$alertmsg = lang('settings_attach_local_mderr');
}
}
if(!$alertmsg) {
if(!@fclose(fopen($attach_dir.'/'.$testfile, 'w'))) {
$alertmsg = lang('settings_attach_local_uperr');
} else {
@unlink($attach_dir.'/'.$testfile);
}
$attachsave && @rmdir($attach_dir);
}
if(!$alertmsg) {
require_once './include/ftp.func.php';
if(!empty($settingsnew['ftp']['password'])) {
$settings['ftp'] = unserialize($db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='ftp'"));
$settings['ftp']['password'] = authcode($settings['ftp']['password'], 'DECODE', md5($authkey));
$pwlen = strlen($settingsnew['ftp']['password']);
if($settingsnew['ftp']['password']{0} == $settings['ftp']['password']{0} && $settingsnew['ftp']['password']{$pwlen - 1} == $settings['ftp']['password']{strlen($settings['ftp']['password']) - 1} && substr($settingsnew['ftp']['password'], 1, $pwlen - 2) == '********') {
$settingsnew['ftp']['password'] = $settings['ftp']['password'];
}
}
$ftp['pasv'] = intval($settingsnew['ftp']['pasv']);
$ftp_conn_id = dftp_connect($settingsnew['ftp']['host'], $settingsnew['ftp']['username'], $settingsnew['ftp']['password'], $settingsnew['ftp']['attachdir'], $settingsnew['ftp']['port'], $settingsnew['ftp']['ssl'], 1);
switch($ftp_conn_id) {
case '-1':
$alertmsg = $lang['settings_attach_remote_conerr'];
break;
case '-2':
$alertmsg = $lang['settings_attach_remote_logerr'];
break;
case '-3':
$alertmsg = $lang['settings_attach_remote_pwderr'];
break;
case '-4':
$alertmsg = $lang['settings_attach_remote_ftpoff'];
break;
default:
$alertmsg = '';
}
}
if(!$alertmsg) {
if(!dftp_mkdir($ftp_conn_id, $testdir)) {
$alertmsg = $lang['settings_attach_remote_mderr'];
} else {
if(!(function_exists('ftp_chmod') && dftp_chmod($ftp_conn_id, 0777, $testdir)) && !dftp_site($ftp_conn_id, "'CHMOD 0777 $testdir'") && !@ftp_exec($ftp_conn_id, "SITE CHMOD 0777 $testdir")) {
$alertmsg = $lang['settings_attach_remote_chmoderr'].'\n';
}
$testfile = $testdir.'/'.$testfile;
if(!dftp_put($ftp_conn_id, $testfile, DISCUZ_ROOT.'./robots.txt', FTP_BINARY)) {
$alertmsg .= $lang['settings_attach_remote_uperr'];
dftp_delete($ftp_conn_id, $testfile);
dftp_delete($ftp_conn_id, $testfile.'.uploading');
dftp_delete($ftp_conn_id, $testfile.'.abort');
dftp_rmdir($ftp_conn_id, $testdir);
} else {
if(!@readfile($settingsnew['ftp']['attachurl'].'/'.$testfile)) {
$alertmsg .= $lang['settings_attach_remote_geterr'];
dftp_delete($ftp_conn_id, $testfile);
dftp_rmdir($ftp_conn_id, $testdir);
} else {
if(!dftp_delete($ftp_conn_id, $testfile)) {
$alertmsg .= $lang['settings_attach_remote_delerr'];
} else {
dftp_rmdir($ftp_conn_id, $testdir);
$alertmsg = $lang['settings_attach_remote_ok'];
}
}
}
}
}
echo '<script language="javascript">alert(\''.str_replace('\'', '\\\'', $alertmsg).'\');parent.$(\'cpform\').action=\''.$BASESCRIPT.'?action=settings&edit=yes\';parent.$(\'cpform\').target=\'_self\'</script>';
} elseif($operation == 'mailcheck') {
$oldmail = unserialize($mail);
$passwordmask = $oldmail['auth_password'] ? $oldmail['auth_password']{0}.'********'.substr($oldmail['auth_password'], -2) : '';
$settingsnew['mail']['auth_password'] = $settingsnew['mail']['auth_password'] == $passwordmask ? $oldmail['auth_password'] : $settingsnew['mail']['auth_password'];
$mail = serialize($settingsnew['mail']);
$test_tos = explode(',', $test_to);
$date = date('Y-m-d H:i:s');
$alertmsg = '';
$title = $lang['settings_mailcheck_title_'.$settingsnew['mail']['mailsend']];
$message = $lang['settings_mailcheck_message_'.$settingsnew['mail']['mailsend']].' '.$test_from.$lang['settings_mailcheck_date'].' '.$date;
$bbname = $lang['settings_mail_check_method_1'];
sendmail($test_tos[0], $title.' @ '.$date, "$bbname\n\n\n$message", $test_from);
$bbname = $lang['settings_mail_check_method_2'];
sendmail($test_to, $title.' @ '.$date, "$bbname\n\n\n$message", $test_from);
if(!$alertmsg) {
$alertmsg = $lang['settings_mail_check_success_1']."$title @ $date".$lang['settings_mail_check_success_2'];
} else {
$alertmsg = $lang['settings_mail_check_error'].$alertmsg;
}
echo '<script language="javascript">alert(\''.str_replace(array('\'', "\n", "\r"), array('\\\'', '\n', ''), $alertmsg).'\');parent.$(\'cpform\').action=\''.$BASESCRIPT.'?action=settings&edit=yes\';parent.$(\'cpform\').target=\'_self\'</script>';
} elseif($operation == 'imagepreview') {
if(!empty($previewthumb)) {
$thumbstatus = $settingsnew['thumbstatus'];
if(!$thumbstatus) {
cpmsg('thumbpreview_error', '', 'error');
}
$imagelib = $settingsnew['imagelib'];
$imageimpath = $settingsnew['imageimpath'];
$thumbwidth = $settingsnew['thumbwidth'];
$thumbheight = $settingsnew['thumbheight'];
$thumbquality = $settingsnew['thumbquality'];
require_once DISCUZ_ROOT.'./include/image.class.php';
@unlink(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg');
$image = new Image('images/admincp/watermarkpreview.jpg', 'images/admincp/watermarkpreview.jpg');
$image->Thumb($thumbwidth, $thumbheight, 1);
if(file_exists(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg')) {
showsubmenu('imagepreview_thumb');
$sizesource = filesize('images/admincp/watermarkpreview.jpg');
$sizetarget = filesize(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg');
echo '<img src="forumdata/watermark_temp.jpg?'.random(5).'"><br /><br />'.
$lang['imagepreview_imagesize_source'].' '.number_format($sizesource).' Bytes '.
$lang['imagepreview_imagesize_target'].' '.number_format($sizetarget).' Bytes ('.
(sprintf("%2.1f", $sizetarget / $sizesource * 100)).'%)';
} else {
cpmsg('thumbpreview_createerror', '', 'error');
}
} else {
$watermarkstatus = $settingsnew['watermarkstatus'];
if(!$watermarkstatus) {
cpmsg('watermarkpreview_error', '', 'error');
}
$imagelib = $settingsnew['imagelib'];
$imageimpath = $settingsnew['imageimpath'];
$watermarktype = $settingsnew['watermarktype'];
$watermarktrans = $settingsnew['watermarktrans'];
$watermarkquality = $settingsnew['watermarkquality'];
$watermarkminwidth = $settingsnew['watermarkminwidth'];
$watermarkminheight = $settingsnew['watermarkminheight'];
$settingsnew['watermarktext']['size'] = intval($settingsnew['watermarktext']['size']);
$settingsnew['watermarktext']['angle'] = intval($settingsnew['watermarktext']['angle']);
$settingsnew['watermarktext']['shadowx'] = intval($settingsnew['watermarktext']['shadowx']);
$settingsnew['watermarktext']['shadowy'] = intval($settingsnew['watermarktext']['shadowy']);
$settingsnew['watermarktext']['translatex'] = intval($settingsnew['watermarktext']['translatex']);
$settingsnew['watermarktext']['translatey'] = intval($settingsnew['watermarktext']['translatey']);
$settingsnew['watermarktext']['skewx'] = intval($settingsnew['watermarktext']['skewx']);
$settingsnew['watermarktext']['skewy'] = intval($settingsnew['watermarktext']['skewy']);
$settingsnew['watermarktext']['fontpath'] = str_replace(array('\\', '/'), '', $settingsnew['watermarktext']['fontpath']);
$settingsnew['watermarktext']['color'] = preg_replace('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/e', "hexdec('\\1').','.hexdec('\\2').','.hexdec('\\3')", $settingsnew['watermarktext']['color']);
$settingsnew['watermarktext']['shadowcolor'] = preg_replace('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/e', "hexdec('\\1').','.hexdec('\\2').','.hexdec('\\3')", $settingsnew['watermarktext']['shadowcolor']);
if($watermarktype == 2) {
if($settingsnew['watermarktext']['fontpath']) {
$fontpath = $settingsnew['watermarktext']['fontpath'];
$fontpathnew = 'ch/'.$fontpath;
$settingsnew['watermarktext']['fontpath'] = file_exists('images/fonts/'.$fontpathnew) ? $fontpathnew : '';
if(!$settingsnew['watermarktext']['fontpath']) {
$fontpathnew = 'en/'.$fontpath;
$settingsnew['watermarktext']['fontpath'] = file_exists('images/fonts/'.$fontpathnew) ? $fontpathnew : '';
}
if(!$settingsnew['watermarktext']['fontpath']) {
cpmsg('watermarkpreview_fontpath_error', '', 'error');
}
$settingsnew['watermarktext']['fontpath'] = 'images/fonts/'.$settingsnew['watermarktext']['fontpath'];
}
if($settingsnew['watermarktext']['text'] && strtoupper($charset) != 'UTF-8') {
include DISCUZ_ROOT.'include/chinese.class.php';
$c = new Chinese($charset, 'utf8');
$settingsnew['watermarktext']['text'] = $c->Convert($settingsnew['watermarktext']['text']);
}
$settingsnew['watermarktext']['text'] = bin2hex($settingsnew['watermarktext']['text']);
$watermarktext = $settingsnew['watermarktext'];
}
require_once DISCUZ_ROOT.'./include/image.class.php';
@unlink(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg');
$image = new Image('images/admincp/watermarkpreview.jpg', 'images/admincp/watermarkpreview.jpg');
$image->Watermark(1);
if(file_exists(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg')) {
showsubmenu('imagepreview_watermark');
$sizesource = filesize('images/admincp/watermarkpreview.jpg');
$sizetarget = filesize(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg');
echo '<img src="forumdata/watermark_temp.jpg?'.random(5).'"><br /><br />'.
$lang['imagepreview_imagesize_source'].' '.number_format($sizesource).' Bytes '.
$lang['imagepreview_imagesize_target'].' '.number_format($sizetarget).' Bytes ('.
(sprintf("%2.1f", $sizetarget / $sizesource * 100)).'%)';
} else {
cpmsg('watermarkpreview_createerror', '', 'error');
}
}
}
function checkfiles($currentdir, $ext = '', $sub = 1, $skip = '') {
global $md5data;
$dir = @opendir(DISCUZ_ROOT.$currentdir);
$exts = '/('.$ext.')$/i';
$skips = explode(',', $skip);
while($entry = @readdir($dir)) {
$file = $currentdir.$entry;
if($entry != '.' && $entry != '..' && (preg_match($exts, $entry) || $sub && is_dir($file)) && !in_array($entry, $skips)) {
if($sub && is_dir($file)) {
checkfiles($file.'/', $ext, $sub, $skip);
} else {
$md5data[$file] = md5_file($file);
}
}
}
}
function checkcachefiles($currentdir) {
global $authkey;
$dir = opendir($currentdir);
$exts = '/\.php$/i';
$showlist = $modifylist = $addlist = array();
while($entry = readdir($dir)) {
$file = $currentdir.$entry;
if($entry != '.' && $entry != '..' && preg_match($exts, $entry)) {
$fp = fopen($file, "rb");
$cachedata = fread($fp, filesize($file));
fclose($fp);
if(preg_match("/^<\?php\n\/\/Discuz! cache file, DO NOT modify me!\n\/\/Created: [\w\s,:]+\n\/\/Identify: (\w{32})\n\n(.+?)\?>$/s", $cachedata, $match)) {
$showlist[$file] = $md5 = $match[1];
$cachedata = $match[2];
if(md5($entry.$cachedata.$authkey) != $md5) {
$modifylist[$file] = $md5;
}
} else {
$showlist[$file] = $addlist[$file] = '';
}
}
}
return array($showlist, $modifylist, $addlist);
}
function checkmailerror($type, $error) {
global $alertmsg;
$alertmsg .= !$alertmsg ? $error : '';
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/checktools.inc.php | PHP | asf20 | 16,852 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: db.inc.php 19482 2009-09-02 07:09:38Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$tabletype = $db->version() > '4.1' ? 'Engine' : 'Type';
require_once DISCUZ_ROOT.'./include/attachment.func.php';
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$excepttables = array($tablepre.'adminsessions', $tablepre.'failedlogins', $tablepre.'pmsearchindex', $tablepre.'relatedthreads', $tablepre.'rsscaches', $tablepre.'searchindex', $tablepre.'spacecaches', $tablepre.'sessions');
if(!$backupdir = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='backupdir'")) {
$backupdir = random(6);
@mkdir('./forumdata/backup_'.$backupdir, 0777);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) values ('backupdir', '$backupdir')");
}
$backupdir = 'backup_'.$backupdir;
if(!is_dir('./forumdata/'.$backupdir)) {
mkdir('./forumdata/'.$backupdir, 0777);
}
if($operation == 'export') {
if(!submitcheck('exportsubmit', 1)) {
$shelldisabled = function_exists('shell_exec') ? '' : 'disabled';
$tables = '';
$dztables = array();
if($tables = $db->fetch_first("SELECT value FROM {$tablepre}settings WHERE variable='custombackup'")) {
$tables = unserialize($tables['value']);
$tables = is_array($tables) ? $tables : '';
}
$discuz_tables = fetchtablelist($tablepre);
$query = $db->query("SELECT datatables FROM {$tablepre}plugins WHERE datatables<>''");
while($plugin = $db->fetch_array($query)) {
foreach(explode(',', $plugin['datatables']) as $table) {
if($table = trim($table)) {
$discuz_tables[] = array('Name' => $table);
}
}
}
foreach($discuz_tables as $table) {
$dztables[$table[Name]] = $table[Name];
}
$defaultfilename = date('ymd').'_'.random(8);
shownav('tools', 'nav_db', 'nav_db_export');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 1),
array('nav_db_import', 'db&operation=import', 0),
array('nav_db_runquery', 'db&operation=runquery', 0),
array('nav_db_optimize', 'db&operation=optimize', 0),
array('nav_db_dbcheck', 'db&operation=dbcheck', 0)
));
showtips('db_export_tips');
showformheader('db&operation=export&setup=1');
showtableheader();
showsetting('db_export_type', array('type', array(
array('discuz', $lang['db_export_discuz'], array('showtables' => 'none')),
array('custom', $lang['db_export_custom'], array('showtables' => ''))
)), 'discuz', 'mradio');
showtagheader('tbody', 'showtables');
showtablerow('', '', '<input class="checkbox" name="chkall" onclick="checkAll(\'prefix\', this.form, \'customtables\', \'chkall\', true)" checked="checked" type="checkbox" id="chkalltables" /><label for="chkalltables"> '.lang('db_export_custom_select_all').' - '.lang('db_export_discuz_table')).'</label>';
showtablerow('', 'colspan="2"', mcheckbox('customtables', $dztables));
showtagfooter('tbody');
showtagheader('tbody', 'advanceoption');
showsetting('db_export_method', '', '', '<ul class="nofloat"><li><input class="radio" type="radio" name="method" value="shell" '.$shelldisabled.' onclick="if(\''.intval($db->version() < '4.1').'\') {if(this.form.sqlcompat[2].checked==true) this.form.sqlcompat[0].checked=true; this.form.sqlcompat[2].disabled=true; this.form.sizelimit.disabled=true;} else {this.form.sqlcharset[0].checked=true; for(var i=1; i<=5; i++) {if(this.form.sqlcharset[i]) this.form.sqlcharset[i].disabled=true;}}" id="method_shell" /><label="method_shell"> '.$lang['db_export_shell'].'</label></li><li><input class="radio" type="radio" name="method" value="multivol" checked="checked" onclick="this.form.sqlcompat[2].disabled=false; this.form.sizelimit.disabled=false; for(var i=1; i<=5; i++) {if(this.form.sqlcharset[i]) this.form.sqlcharset[i].disabled=false;}" id="method_multivol" /><label for="method_multivol"> '.$lang['db_export_multivol'].'</label> <input type="text" class="txt" size="40" name="sizelimit" value="2048" /></li></ul>');
showtitle('db_export_options');
showsetting('db_export_options_extended_insert', 'extendins', 0, 'radio');
showsetting('db_export_options_sql_compatible', array('sqlcompat', array(
array('', $lang['default']),
array('MYSQL40', 'MySQL 3.23/4.0.x'),
array('MYSQL41', 'MySQL 4.1.x/5.x')
)), '', 'mradio');
showsetting('db_export_options_charset', array('sqlcharset', array(
array('', lang('default')),
$dbcharset ? array($dbcharset, strtoupper($dbcharset)) : array(),
$db->version() > '4.1' && $dbcharset != 'utf8' ? array('utf8', 'UTF-8') : array()
), TRUE), 0, 'mradio');
showsetting('db_export_usehex', 'usehex', 1, 'radio');
if(function_exists('gzcompress')) {
showsetting('db_export_usezip', array('usezip', array(
array('1', $lang['db_export_zip_1']),
array('2', $lang['db_export_zip_2']),
array('0', $lang['db_export_zip_3'])
)), 0, 'mradio');
}
showsetting('db_export_filename', '', '', '<input type="text" class="txt" name="filename" value="'.$defaultfilename.'" />.sql');
showtagfooter('tbody');
showsubmit('exportsubmit', 'submit', '', 'more_options');
showtablefooter();
showformfooter();
} else {
$db->query('SET SQL_QUOTE_SHOW_CREATE=0', 'SILENT');
if(!$filename || preg_match("/(\.)(exe|jsp|asp|aspx|cgi|fcgi|pl)(\.|$)/i", $filename)) {
cpmsg('database_export_filename_invalid', '', 'error');
}
$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
if($type == 'discuz') {
$tables = arraykeys2(fetchtablelist($tablepre), 'Name');
} elseif($type == 'custom') {
$tables = array();
if(empty($setup)) {
if($tables = $db->fetch_first("SELECT value FROM {$tablepre}settings WHERE variable='custombackup'")) {
$tables = unserialize($tables['value']);
}
} else {
$customtablesnew = empty($customtables)? '' : addslashes(serialize($customtables));
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('custombackup', '$customtablesnew')");
$tables = & $customtables;
}
if( !is_array($tables) || empty($tables)) {
cpmsg('database_export_custom_invalid', '', 'error');
}
}
$query = $db->query("SELECT datatables FROM {$tablepre}plugins WHERE datatables<>''");
while($plugin = $db->fetch_array($query)) {
foreach(explode(',', $plugin['datatables']) as $table) {
if($table = trim($table)) {
$tables[] = $table;
}
}
}
$volume = intval($volume) + 1;
$idstring = '# Identify: '.base64_encode("$timestamp,$version,$type,$method,$volume")."\n";
$dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', $GLOBALS['charset']);
$setnames = ($sqlcharset && $db->version() > '4.1' && (!$sqlcompat || $sqlcompat == 'MYSQL41')) ? "SET NAMES '$dumpcharset';\n\n" : '';
if($db->version() > '4.1') {
if($sqlcharset) {
$db->query("SET NAMES '".$sqlcharset."';\n\n");
}
if($sqlcompat == 'MYSQL40') {
$db->query("SET SQL_MODE='MYSQL40'");
} elseif($sqlcompat == 'MYSQL41') {
$db->query("SET SQL_MODE=''");
}
}
$backupfilename = './forumdata/'.$backupdir.'/'.str_replace(array('/', '\\', '.'), '', $filename);
if($usezip) {
require_once DISCUZ_ROOT.'admin/zip.func.php';
}
if($method == 'multivol') {
$sqldump = '';
$tableid = intval($tableid);
$startfrom = intval($startfrom);
$complete = TRUE;
for(; $complete && $tableid < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $tableid++) {
$sqldump .= sqldumptable($tables[$tableid], $startfrom, strlen($sqldump));
if($complete) {
$startfrom = 0;
}
}
$dumpfile = $backupfilename."-%s".'.sql';
!$complete && $tableid--;
if(trim($sqldump)) {
$sqldump = "$idstring".
"# <?exit();?>\n".
"# Discuz! Multi-Volume Data Dump Vol.$volume\n".
"# Version: Discuz! $version\n".
"# Time: $time\n".
"# Type: $type\n".
"# Table Prefix: $tablepre\n".
"#\n".
"# Discuz! Home: http://www.discuz.com\n".
"# Please visit our website for newest infomation about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
"$setnames".
$sqldump;
$dumpfilename = sprintf($dumpfile, $volume);
@$fp = fopen($dumpfilename, 'wb');
@flock($fp, 2);
if(@!fwrite($fp, $sqldump)) {
@fclose($fp);
cpmsg('database_export_file_invalid', '', 'error');
} else {
fclose($fp);
if($usezip == 2) {
$fp = fopen($dumpfilename, "r");
$content = @fread($fp, filesize($dumpfilename));
fclose($fp);
$zip = new zipfile();
$zip->addFile($content, basename($dumpfilename));
$fp = fopen(sprintf($backupfilename."-%s".'.zip', $volume), 'w');
if(@fwrite($fp, $zip->file()) !== FALSE) {
@unlink($dumpfilename);
}
fclose($fp);
}
unset($sqldump, $zip, $content);
cpmsg('database_export_multivol_redirect', "$BASESCRIPT?action=db&operation=export&type=".rawurlencode($type)."&saveto=server&filename=".rawurlencode($filename)."&method=multivol&sizelimit=".rawurlencode($sizelimit)."&volume=".rawurlencode($volume)."&tableid=".rawurlencode($tableid)."&startfrom=".rawurlencode($startrow)."&extendins=".rawurlencode($extendins)."&sqlcharset=".rawurlencode($sqlcharset)."&sqlcompat=".rawurlencode($sqlcompat)."&exportsubmit=yes&usehex=$usehex&usezip=$usezip", 'loading');
}
} else {
$volume--;
$filelist = '<ul>';
cpheader();
if($usezip == 1) {
$zip = new zipfile();
$zipfilename = $backupfilename.'.zip';
$unlinks = '';
for($i = 1; $i <= $volume; $i++) {
$filename = sprintf($dumpfile, $i);
$fp = fopen($filename, "r");
$content = @fread($fp, filesize($filename));
fclose($fp);
$zip->addFile($content, basename($filename));
$unlinks .= "@unlink('$filename');";
$filelist .= "<li><a href=\"$filename\">$filename\n";
}
$fp = fopen($zipfilename, 'w');
if(@fwrite($fp, $zip->file()) !== FALSE) {
eval($unlinks);
} else {
cpmsg('database_export_multivol_succeed', '', 'succeed');
}
unset($sqldump, $zip, $content);
fclose($fp);
@touch('./forumdata/'.$backupdir.'/index.htm');
$filename = $zipfilename;
cpmsg('database_export_zip_succeed', '', 'succeed');
} else {
@touch('./forumdata/'.$backupdir.'/index.htm');
for($i = 1; $i <= $volume; $i++) {
$filename = sprintf($usezip == 2 ? $backupfilename."-%s".'.zip' : $dumpfile, $i);
$filelist .= "<li><a href=\"$filename\">$filename\n";
}
cpmsg('database_export_multivol_succeed', '', 'succeed');
}
}
} else {
$tablesstr = '';
foreach($tables as $table) {
$tablesstr .= '"'.$table.'" ';
}
require './config.inc.php';
list($dbhost, $dbport) = explode(':', $dbhost);
$query = $db->query("SHOW VARIABLES LIKE 'basedir'");
list(, $mysql_base) = $db->fetch_array($query, MYSQL_NUM);
$dumpfile = addslashes(dirname(dirname(__FILE__))).'/'.$backupfilename.'.sql';
@unlink($dumpfile);
$mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
@shell_exec($mysqlbin.'mysqldump --force --quick '.($db->version() > '4.1' ? '--skip-opt --create-options' : '-all').' --add-drop-table'.($extendins == 1 ? ' --extended-insert' : '').''.($db->version() > '4.1' && $sqlcompat == 'MYSQL40' ? ' --compatible=mysql40' : '').' --host="'.$dbhost.($dbport ? (is_numeric($dbport) ? ' --port='.$dbport : ' --socket="'.$dbport.'"') : '').'" --user="'.$dbuser.'" --password="'.$dbpw.'" "'.$dbname.'" '.$tablesstr.' > '.$dumpfile);
if(@file_exists($dumpfile)) {
if($usezip) {
require_once DISCUZ_ROOT.'admin/zip.func.php';
$zip = new zipfile();
$zipfilename = $backupfilename.'.zip';
$fp = fopen($dumpfile, "r");
$content = @fread($fp, filesize($dumpfile));
fclose($fp);
$zip->addFile($idstring."# <?exit();?>\n ".$setnames."\n #".$content, basename($dumpfile));
$fp = fopen($zipfilename, 'w');
@fwrite($fp, $zip->file());
fclose($fp);
@unlink($dumpfile);
@touch('./forumdata/'.$backupdir.'/index.htm');
$filename = $backupfilename.'.zip';
unset($sqldump, $zip, $content);
cpmsg('database_export_zip_succeed', '', 'succeed');
} else {
if(@is_writeable($dumpfile)) {
$fp = fopen($dumpfile, 'rb+');
@fwrite($fp, $idstring."# <?exit();?>\n ".$setnames."\n #");
fclose($fp);
}
@touch('./forumdata/'.$backupdir.'/index.htm');
$filename = $backupfilename.'.sql';
cpmsg('database_export_succeed', '', 'succeed');
}
} else {
cpmsg('database_shell_fail', '', 'error');
}
}
}
} elseif($operation == 'importzip') {
if(empty($datafile_server)) {
cpmsg('database_import_file_illegal', '', 'error');
} else {
$datafile_server = DISCUZ_ROOT.'./forumdata/'.$backupdir.'/'.basename($datafile_server);
if(!@file_exists($datafile_server)) {
cpmsg('database_import_file_illegal', '', 'error');
}
}
require_once DISCUZ_ROOT.'admin/zip.func.php';
$unzip = new SimpleUnzip();
$unzip->ReadFile($datafile_server);
if($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match("/\.sql$/i", $importfile = $unzip->GetName(0))) {
cpmsg('database_import_file_illegal', '', 'error');
}
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", substr($unzip->GetData(0), 0, 256))));
$confirm = !empty($confirm) ? 1 : 0;
if(!$confirm && $identify[1] != $version) {
cpmsg('database_import_confirm', $BASESCRIPT.'?action=db&operation=importzip&datafile_server=$datafile_server&importsubmit=yes&confirm=yes', 'form');
}
$sqlfilecount = 0;
foreach($unzip->Entries as $entry) {
if(preg_match("/\.sql$/i", $entry->Name)) {
$fp = fopen('./forumdata/'.$backupdir.'/'.$entry->Name, 'w');
fwrite($fp, $entry->Data);
fclose($fp);
$sqlfilecount++;
}
}
if(!$sqlfilecount) {
cpmsg('database_import_file_illegal', '', 'error');
}
$info = basename($datafile_server).'<br />'.$lang['version'].': '.$identify[1].'<br />'.$lang['type'].': '.$lang['db_export_'.$identify[2]].'<br />'.$lang['db_method'].': '.($identify[3] == 'multivol' ? $lang['db_multivol'] : $lang['db_shell']).'<br />';
if(isset($multivol)) {
$multivol++;
$datafile_server = preg_replace("/-(\d+)(\..+)$/", "-$multivol\\2", $datafile_server);
if(file_exists($datafile_server)) {
cpmsg('database_import_multivol_unzip_redirect', $BASESCRIPT.'?action=db&operation=importzip&multivol='.$multivol.'&datafile_vol1='.$datafile_vol1.'&datafile_server='.$datafile_server.'&importsubmit=yes&confirm=yes', 'loading');
} else {
cpmsg('database_import_multivol_confirm', $BASESCRIPT.'?action=db&operation=import&from=server&datafile_server='.$datafile_vol1.'&importsubmit=yes&delunzip=yes', 'form');
}
}
if($identify[3] == 'multivol' && $identify[4] == 1 && preg_match("/-1(\..+)$/", $datafile_server)) {
$datafile_vol1 = $datafile_server;
$datafile_server = preg_replace("/-1(\..+)$/", "-2\\1", $datafile_server);
if(file_exists($datafile_server)) {
cpmsg('database_import_multivol_unzip', $BASESCRIPT.'?action=db&operation=importzip&multivol=1&datafile_vol1=./forumdata/'.$backupdir.'/'.$importfile.'&datafile_server='.$datafile_server.'&importsubmit=yes&confirm=yes', 'form');
}
}
cpmsg('database_import_unzip', $BASESCRIPT.'?action=db&operation=import&from=server&datafile_server=./forumdata/'.$backupdir.'/'.$importfile.'&importsubmit=yes&delunzip=yes', 'form');
} elseif($operation == 'import') {
checkpermission('dbimport');
if(!submitcheck('importsubmit', 1) && !submitcheck('deletesubmit')) {
$exportlog = $exportsize = $exportziplog = array();
if(is_dir(DISCUZ_ROOT.'./forumdata/'.$backupdir)) {
$dir = dir(DISCUZ_ROOT.'./forumdata/'.$backupdir);
while($entry = $dir->read()) {
$entry = './forumdata/'.$backupdir.'/'.$entry;
if(is_file($entry)) {
if(preg_match("/\.sql$/i", $entry)) {
$filesize = filesize($entry);
$fp = fopen($entry, 'rb');
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
fclose($fp);
$key = preg_replace('/^(.+?)(\-\d+)\.sql$/i', '\\1', basename($entry));
$exportlog[$key][$identify[4]] = array(
'version' => $identify[1],
'type' => $identify[2],
'method' => $identify[3],
'volume' => $identify[4],
'filename' => $entry,
'dateline' => filemtime($entry),
'size' => $filesize
);
$exportsize[$key] += $filesize;
} elseif(preg_match("/\.zip$/i", $entry)) {
$filesize = filesize($entry);
$exportziplog[] = array(
'type' => 'zip',
'filename' => $entry,
'size' => filesize($entry),
'dateline' => filemtime($entry)
);
}
}
}
$dir->close();
} else {
cpmsg('database_export_dest_invalid', '', 'error');
}
shownav('tools', 'nav_db', 'nav_db_import');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 0),
array('nav_db_import', 'db&operation=import', 1),
array('nav_db_runquery', 'db&operation=runquery', 0),
array('nav_db_optimize', 'db&operation=optimize', 0),
array('nav_db_dbcheck', 'db&operation=dbcheck', 0)
));
showtips('db_import_tips');
showtableheader('db_import');
showformheader('db&operation=import', 'enctype');
showtablerow('', array('colspan="2" class="rowform"', 'colspan="7" class="rowform"'), array(
'<input class="radio" type="radio" name="from" value="server" checked="checked" onclick="this.form.datafile_server.disabled=!this.checked;this.form.datafile.disabled=this.checked" />'.$lang[db_import_from_server],
'<input type="text" class="txt" name="datafile_server" value="./forumdata/'.$backupdir.'/" style="width:245px;" />'
));
showtablerow('', array('colspan="2" class="rowform"', 'colspan="8" class="rowform"'), array(
'<input class="radio" type="radio" name="from" value="local" onclick="this.form.datafile_server.disabled=this.checked;this.form.datafile.disabled=!this.checked" />'.$lang[db_import_from_local],
'<input type="file" name="datafile" size="29" disabled="disabled" class="uploadbtn marginbot" />'
));
showsubmit('importsubmit');
showformfooter();
showformheader('db&operation=import');
showtitle('db_export_file');
showsubtitle(array('', 'filename', 'version', 'time', 'type', 'size', 'db_method', 'db_volume', ''));
foreach($exportlog as $key => $val) {
$info = $val[1];
$info['dateline'] = is_int($info['dateline']) ? gmdate("$dateformat $timeformat", $info['dateline'] + $timeoffset * 3600) : $lang['unknown'];
$info['size'] = sizecount($exportsize[$key]);
$info['volume'] = count($val);
$info['method'] = $info['type'] != 'zip' ? ($info['method'] == 'multivol' ? $lang['db_multivol'] : $lang['db_shell']) : '';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"".$key."\">",
"<a href=\"javascript:;\" onclick=\"display('exportlog_$key')\">".$key."</a>",
$info['version'],
$info['dateline'],
$lang['db_export_'.$info['type']],
$info['size'],
$info['method'],
$info['volume'],
$info['type'] == 'zip' ? "<a href=\"$BASESCRIPT?action=db&operation=importzip&datafile_server=$info[filename]&importsubmit=yes\" class=\"act\">$lang[db_import_unzip]</a>" : "<a class=\"act\" href=\"$BASESCRIPT?action=db&operation=import&from=server&datafile_server=$info[filename]&importsubmit=yes\"".($info['version'] != $version ? " onclick=\"return confirm('$lang[db_import_confirm]');\"" : '')." class=\"act\">$lang[import]</a>"
));
echo '<tbody id="exportlog_'.$key.'" style="display:none">';
foreach($val as $info) {
$info['dateline'] = is_int($info['dateline']) ? gmdate("$dateformat $timeformat", $info['dateline'] + $timeoffset * 3600) : $lang['unknown'];
$info['size'] = sizecount($info['size']);
showtablerow('', '', array(
'',
"<a href=\"$info[filename]\">".substr(strrchr($info['filename'], "/"), 1)."</a>",
$info['version'],
$info['dateline'],
'',
$info['size'],
'',
$info['volume'],
''
));
}
echo '</tbody>';
}
foreach($exportziplog as $info) {
$info['dateline'] = is_int($info['dateline']) ? gmdate("$dateformat $timeformat", $info['dateline'] + $timeoffset * 3600) : $lang['unknown'];
$info['size'] = sizecount($info['size']);
$info['method'] = $info['method'] == 'multivol' ? $lang['db_multivol'] : $lang['db_shell'];
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"".basename($info['filename'])."\">",
"<a href=\"$info[filename]\">".substr(strrchr($info['filename'], "/"), 1)."</a>",
'',
$info['dateline'],
$lang['db_export_'.$info['type']],
$info['size'],
$info['method'],
'',
"<a href=\"$BASESCRIPT?action=db&operation=importzip&datafile_server=$info[filename]&importsubmit=yes\" class=\"act\">$lang[db_import_unzip]</a>"
));
}
showsubmit('deletesubmit', 'submit', 'del');
showformfooter();
showtablefooter();
} elseif(submitcheck('importsubmit', 1)) {
$readerror = 0;
$datafile = '';
if($from == 'server') {
$datafile = DISCUZ_ROOT.'./'.$datafile_server;
}
if(@$fp = fopen($datafile, 'rb')) {
$sqldump = fgets($fp, 256);
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", $sqldump)));
$dumpinfo = array('method' => $identify[3], 'volume' => intval($identify[4]));
if($dumpinfo['method'] == 'multivol') {
$sqldump .= fread($fp, filesize($datafile));
}
fclose($fp);
} else {
if($autoimport) {
updatecache();
cpmsg('database_import_multivol_succeed', '', 'succeed');
} else {
cpmsg('database_import_file_illegal', '', 'error');
}
}
if($dumpinfo['method'] == 'multivol') {
$sqlquery = splitsql($sqldump);
unset($sqldump);
foreach($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset);
if($sql != '') {
$db->query($sql, 'SILENT');
if(($sqlerror = $db->error()) && $db->errno() != 1062) {
$db->halt('MySQL Query Error', $sql);
}
}
}
if($delunzip) {
@unlink($datafile_server);
}
$datafile_next = preg_replace("/-($dumpinfo[volume])(\..+)$/", "-".($dumpinfo['volume'] + 1)."\\2", $datafile_server);
if($dumpinfo['volume'] == 1) {
cpmsg('database_import_multivol_prompt',
"$BASESCRIPT?action=db&operation=import&from=server&datafile_server=$datafile_next&autoimport=yes&importsubmit=yes".(!empty($delunzip) ? '&delunzip=yes' : ''),
'form');
} elseif($autoimport) {
cpmsg('database_import_multivol_redirect', "$BASESCRIPT?action=db&operation=import&from=server&datafile_server=$datafile_next&autoimport=yes&importsubmit=yes".(!empty($delunzip) ? '&delunzip=yes' : ''), 'loading');
} else {
updatecache();
cpmsg('database_import_succeed', '', 'succeed');
}
} elseif($dumpinfo['method'] == 'shell') {
require './config.inc.php';
list($dbhost, $dbport) = explode(':', $dbhost);
$query = $db->query("SHOW VARIABLES LIKE 'basedir'");
list(, $mysql_base) = $db->fetch_array($query, MYSQL_NUM);
$mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
shell_exec($mysqlbin.'mysql -h"'.$dbhost.($dbport ? (is_numeric($dbport) ? ' -P'.$dbport : ' -S"'.$dbport.'"') : '').
'" -u"'.$dbuser.'" -p"'.$dbpw.'" "'.$dbname.'" < '.$datafile);
updatecache();
cpmsg('database_import_succeed', '', 'succeed');
} else {
cpmsg('database_import_format_illegal', '', 'error');
}
} elseif(submitcheck('deletesubmit')) {
if(is_array($delete)) {
foreach($delete as $filename) {
$file_path = './forumdata/'.$backupdir.'/'.str_replace(array('/', '\\'), '', $filename);
if(is_file($file_path)) {
@unlink($file_path);
} else {
$i = 1;
while(1) {
$file_path = './forumdata/'.$backupdir.'/'.str_replace(array('/', '\\'), '', $filename.'-'.$i.'.sql');
if(is_file($file_path)) {
@unlink($file_path);
$i++;
} else {
break;
}
}
}
}
cpmsg('database_file_delete_succeed', '', 'succeed');
} else {
cpmsg('database_file_delete_invalid', '', 'error');
}
}
} elseif($operation == 'runquery') {
$checkperm = checkpermission('runquery', 0);
$runquerys = array();
@include_once(DISCUZ_ROOT.'admin/quickqueries.inc.php');
if(!submitcheck('sqlsubmit')) {
$runqueryselect = '';
foreach($simplequeries as $key => $query) {
if(empty($query['sql'])) {
$runqueryselect .= "<optgroup label=\"$query[comment]\">";
} else {
$runqueryselect .= '<option value="'.$key.'">'.$query['comment'].'</option>';
}
}
if($runqueryselect) {
$runqueryselect = '<select name="queryselect" style="width:500px">'.$runqueryselect.'</select>';
}
$queries = $queryselect ? $runquerys[$queryselect] : '';
shownav('tools', 'nav_db', 'nav_db_runquery');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 0),
array('nav_db_import', 'db&operation=import', 0),
array('nav_db_runquery', 'db&operation=runquery', 1),
array('nav_db_optimize', 'db&operation=optimize', 0),
array('nav_db_dbcheck', 'db&operation=dbcheck', 0)
));
showtips('db_runquery_tips');
showtableheader();
showformheader('db&operation=runquery&option=simple');
showsetting('db_runquery_simply', '', '', $runqueryselect);
showsetting('', '', '', '<input type="checkbox" class="checkbox" name="createcompatible" value="1" checked="checked" />'.lang('db_runquery_createcompatible'));
showsubmit('sqlsubmit');
showformfooter();
if($checkperm) {
showformheader('db&operation=runquery&option=');
showsetting('db_runquery_sql', '', '', '<textarea cols="85" rows="10" name="queries" style="width:500px;">'.$queries.'</textarea>');
showsetting('', '', '', '<input type="checkbox" class="checkbox" name="createcompatible" value="1" checked="checked" />'.lang('db_runquery_createcompatible'));
showsubmit('sqlsubmit', 'submit', '', lang('db_runquery_comment'));
showformfooter();
}
showtablefooter();
} else {
if($option == 'simple') {
$queryselect = intval($queryselect);
$queries = isset($simplequeries[$queryselect]) && $simplequeries[$queryselect]['sql'] ? $simplequeries[$queryselect]['sql'] : '';
} elseif(!$checkperm) {
cpmsg('database_run_query_denied', '', 'error');
}
$sqlquery = splitsql(str_replace(array(' cdb_', ' {tablepre}', ' `cdb_'), array(' '.$tablepre, ' '.$tablepre, ' `'.$tablepre), $queries));
$affected_rows = 0;
foreach($sqlquery as $sql) {
if(trim($sql) != '') {
$sql = !empty($createcompatible) ? syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset) : $sql;
$db->query(stripslashes($sql), 'SILENT');
if($sqlerror = $db->error()) {
break;
} else {
$affected_rows += intval($db->affected_rows());
}
}
}
$sqlerror ? cpmsg('database_run_query_invalid', '', 'error') : cpmsg('database_run_query_succeed', '', 'succeed');
}
} elseif($operation == 'optimize') {
$optimizetable = '';
$totalsize = 0;
$tablearray = array( 0 =>$tablepre);
shownav('tools', 'nav_db', 'nav_db_optimize');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 0),
array('nav_db_import', 'db&operation=import', 0),
array('nav_db_runquery', 'db&operation=runquery', 0),
array('nav_db_optimize', 'db&operation=optimize', 1),
array('nav_db_dbcheck', 'db&operation=dbcheck', 0)
));
showtips('db_optimize_tips');
showformheader('db&operation=optimize');
showtableheader('db_optimize_tables');
showsubtitle(array('', 'db_optimize_table_name', 'type', 'db_optimize_rows', 'db_optimize_data', 'db_optimize_index', 'db_optimize_frag'));
if(!submitcheck('optimizesubmit')) {
foreach($tablearray as $tp) {
$query = $db->query("SHOW TABLE STATUS LIKE '$tp%'", 'SILENT');
while($table = $db->fetch_array($query)) {
if($table['Data_free'] && $table[$tabletype] == 'MyISAM') {
$checked = $table[$tabletype] == 'MyISAM' ? 'checked' : 'disabled';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"optimizetables[]\" value=\"$table[Name]\" $checked>",
$table[Name],
$table[$tabletype],
$table[Rows],
$table[Data_length],
$table[Index_length],
$table[Data_free],
));
$totalsize += $table['Data_length'] + $table['Index_length'];
}
}
}
if(empty($totalsize)) {
showtablerow('', 'colspan="6"', $lang['db_optimize_done']);
} else {
showtablerow('', 'colspan="6"', $lang['db_optimize_used'].' '.sizecount($totalsize));
showsubmit('optimizesubmit', 'submit', '<input name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form)" checked="checked" type="checkbox" /><label for="chkall">'.$lang[db_optimize_opt].'</label>');
}
} else {
//$db->query("DELETE FROM {$tablepre}subscriptions", 'UNBUFFERED');
//$db->query("UPDATE {$tablepre}memberfields SET authstr=''", 'UNBUFFERED');
foreach($tablearray as $tp) {
$query = $db->query("SHOW TABLE STATUS LIKE '$tp%'", 'SILENT');
while($table = $db->fetch_array($query)) {
if(is_array($optimizetables) && in_array($table['Name'], $optimizetables)) {
$db->query("OPTIMIZE TABLE $table[Name]");
}
showtablerow('', '', array(
$table[Name],
$db->version() > '4.1' ? $table['Engine'] : $table['Type'],
$table[Rows],
$table[Data_length],
$table[Index_length],
0
));
$totalsize += $table['Data_length'] + $table['Index_length'];
}
}
showtablerow('', 'colspan="6"', $lang['db_optimize_used'].' '.sizecount($totalsize));
}
showtablefooter();
showformfooter();
} elseif($operation == 'dbcheck') {
if(!$db->query("SHOW FIELDS FROM {$tablepre}settings", 'SILENT')) {
cpmsg('dbcheck_permissions_invalid', '', 'error');
}
$step = max(1, intval($step));
if($step == 3) {
if(!file_exists('admin/discuzdb.md5')) {
cpmsg('dbcheck_nofound_md5file', '', 'error');
}
include DISCUZ_ROOT.'./config.inc.php';
$dbcharset = empty($dbcharset) ? $charset : $dbcharset;
unset($dbuser, $dbpw, $dbname);
$fp = fopen(DISCUZ_ROOT.'./admin/discuzdb.md5', "rb");
$discuzdb = fread($fp, filesize(DISCUZ_ROOT.'./admin/discuzdb.md5'));
fclose($fp);
$dbmd5 = substr($discuzdb, 0, 32);
$discuzdb = unserialize(substr($discuzdb, 34));
$settingsdata = $discuzdb[1];
$discuzdb = $discuzdb[0][0];
$repair = !empty($repair) ? $repair : array();
$setting = !empty($setting) ? $setting : array();
$missingtable = !empty($missingtable) ? $missingtable : array();
$repairtable = is_array($repairtable) && !empty($repairtable) ? $repairtable : array();
$except = array('threads' => array('sgid'));
$query = $db->query("SELECT fieldid FROM {$tablepre}profilefields");
while($profilefields = $db->fetch_array($query)) {
$except['memberfields'][] = 'field_'.$profilefields[$fieldid];
}
if(submitcheck('repairsubmit') && (!empty($repair) || !empty($setting) || !empty($repairtable) || !empty($missingtable))) {
$error = '';$errorcount = 0;
$alter = $fielddefault = array();
foreach($missingtable as $value) {
if(!isset($installdata)) {
$fp = fopen(DISCUZ_ROOT.'./install/discuz.sql', "rb");
$installdata = fread($fp, filesize(DISCUZ_ROOT.'./install/discuz.sql'));
fclose($fp);
}
preg_match("/CREATE TABLE ".$tablepre.$value."\s+\(.+?;/is", $installdata, $a);
$db->query(createtable($a[0], $dbcharset));
}
foreach($repair as $value) {
if(!in_array($r_table, $repairtable)) {
list($r_table, $r_field, $option) = explode('|', $value);
if(!isset($repairrtable[$r_table]) && $fieldsquery = $db->query("SHOW FIELDS FROM $tablepre$r_table", 'SILENT')) {
while($fields = $db->fetch_array($fieldsquery)) {
$fielddefault[$r_table][$fields['Field']] = $fields['Default'];
}
}
$field = $discuzdb[$r_table][$r_field];
$altersql = '`'.$field['Field'].'` '.$field['Type'];
$altersql .= $field['Null'] == 'NO' ? ' NOT NULL' : '';
$altersql .= in_array($fielddefault[$r_table][$field['Field']], array('', '0')) && in_array($field['Default'], array('', '0')) ||
$field['Null'] == 'NO' && $field['Default'] == '' ||
preg_match('/text/i', $field['Type']) || preg_match('/auto_increment/i', $field['Extra']) ?
'' : ' default \''.$field['Default'].'\'';
$altersql .= $field['Extra'] != '' ? ' '.$field['Extra'] : '';
$altersql = $option == 'modify' ? "MODIFY COLUMN ".$altersql : "ADD COLUMN ".$altersql;
$alter[$r_table][] = $altersql;
}
}
foreach($alter as $r_table => $sqls) {
$db->query("ALTER TABLE `$tablepre$r_table` ".implode(',', $sqls), 'SILENT');
if($sqlerror = $db->error()) {
$errorcount += count($sqls);
$error .= $sqlerror.'<br /><br />';
}
}
$alter = array();
foreach($repairtable as $value) {
foreach($discuzdb[$value] as $field) {
if(!isset($fielddefault[$value]) && $fieldsquery = $db->query("SHOW FIELDS FROM $tablepre$value", 'SILENT')) {
while($fields = $db->fetch_array($fieldsquery)) {
$fielddefault[$value][$fields['Field']] = $fields['Default'];
}
}
$altersql = '`'.$field['Field'].'` '.$field['Type'];
$altersql .= $field['Null'] == 'NO' ? ' NOT NULL' : '';
$altersql .= in_array($fielddefault[$value][$field['Field']], array('', '0')) && in_array($field['Default'], array('', '0')) ||
$field['Null'] == 'NO' && $field['Default'] == '' ||
preg_match('/text/i', $field['Type']) || preg_match('/auto_increment/i', $field['Extra']) ?
'' : ' default \''.$field['Default'].'\'';
$altersql .= $field['Extra'] != '' ? ' '.$field['Extra'] : '';
$altersql = "MODIFY COLUMN ".$altersql;
$alter[$value][] = $altersql;
}
}
foreach($alter as $r_table => $sqls) {
$db->query("ALTER TABLE `$tablepre$r_table` ".implode(',', $sqls), 'SILENT');
if($sqlerror = $db->error()) {
$errorcount += count($sqls);
$error .= $sqlerror.'<br /><br />';
}
}
if(!empty($setting)) {
$settingsdatanow = array();
$settingsquery = $db->query("SELECT variable FROM {$tablepre}settings WHERE SUBSTRING(variable, 1, 9)<>'jswizard_' ORDER BY variable");
while($settings = $db->fetch_array($settingsquery)) {
$settingsdatanew[] = $settings['variable'];
}
$settingsdellist = @array_diff($settingsdata, $settingsdatanew);
if($setting['del'] && is_array($settingsdellist)) {
foreach($settingsdellist as $variable) {
$db->query("INSERT INTO {$tablepre}settings (variable, value) VALUES ('$variable', '')", 'SILENT');
}
}
updatecache('settings');
}
if($errorcount) {
cpmsg('dbcheck_repair_error', '', 'error');
} else {
cpmsg('dbcheck_repair_completed', $BASESCRIPT.'?action=db&operation=dbcheck&step=3', 'succeed');
}
}
$installexists = file_exists(DISCUZ_ROOT.'./install/discuz.sql');
$discuzdbnew = $deltables = $excepttables = $missingtables = $charseterror = array();
foreach($discuzdb as $dbtable => $fields) {
if($fieldsquery = $db->query("SHOW FIELDS FROM $tablepre$dbtable", 'SILENT')) {
while($fields = $db->fetch_array($fieldsquery)) {
$r = '/^'.$tablepre.'/';
$cuttable = preg_replace($r, '', $dbtable);
if($db->version() < '4.1' && $cuttable == 'sessions' && $fields['Field'] == 'sid') {
$fields['Type'] = str_replace(' binary', '', $fields['Type']);
}
if($cuttable == 'memberfields' && preg_match('/^field\_\d+$/', $fields['Field'])) {
unset($discuzdbnew[$cuttable][$fields['Field']]);
continue;
}
$discuzdbnew[$cuttable][$fields['Field']]['Field'] = $fields['Field'];
$discuzdbnew[$cuttable][$fields['Field']]['Type'] = $fields['Type'];
$discuzdbnew[$cuttable][$fields['Field']]['Null'] = $fields['Null'] == '' ? 'NO' : $fields['Null'];
$discuzdbnew[$cuttable][$fields['Field']]['Extra'] = $fields['Extra'];
$discuzdbnew[$cuttable][$fields['Field']]['Default'] = $fields['Default'] == '' || $fields['Default'] == '0' ? '' : $fields['Default'];
}
ksort($discuzdbnew[$cuttable]);
} else {
$missingtables[] = '<span style="float:left;width:33%">'.(($installexists ? '<input name="missingtable[]" type="checkbox" class="checkbox" value="'.$dbtable.'">' : '').$tablepre.$dbtable).'</span>';
$excepttables[] = $dbtable;
}
}
if($db->version() > '4.1') {
$dbcharset = strtoupper($dbcharset) == 'UTF-8' ? 'UTF8' : strtoupper($dbcharset);
$query = $db->query("SHOW TABLE STATUS LIKE '$tablepre%'");
while($tables = $db->fetch_array($query)) {
$r = '/^'.$tablepre.'/';
$cuttable = preg_replace($r, '', $tables['Name']);
$tabledbcharset = substr($tables['Collation'], 0, strpos($tables['Collation'], '_'));
if($dbcharset != strtoupper($tabledbcharset)) {
$charseterror[] = '<span style="float:left;width:33%">'.$tablepre.$cuttable.'('.$tabledbcharset.')</span>';
}
}
}
$dbmd5new = md5(serialize($discuzdbnew));
$settingsdatanow = array();
$settingsquery = $db->query("SELECT variable FROM {$tablepre}settings WHERE SUBSTRING(variable, 1, 9)<>'jswizard_' ORDER BY variable");
while($settings = $db->fetch_array($settingsquery)) {
$settingsdatanew[] = $settings['variable'];
}
$settingsdellist = @array_diff($settingsdata, $settingsdatanew);
if($dbmd5 == $dbmd5new && empty($charseterror) && empty($settingsdellist)) {
cpmsg('dbcheck_ok', '', 'succeed');
}
$showlist = $addlists = '';
foreach($discuzdb as $dbtable => $fields) {
$addlist = $modifylist = $dellist = array();
if($fields != $discuzdbnew[$dbtable]) {
foreach($discuzdb[$dbtable] as $key => $value) {
if(is_array($missingtables) && in_array($tablepre.$dbtable, $missingtables)) {
} elseif(!isset($discuzdbnew[$dbtable][$key])) {
$dellist[] = $value;
} elseif($value != $discuzdbnew[$dbtable][$key]) {
$modifylist[] = $value;
}
}
if(is_array($discuzdbnew[$dbtable])) {
foreach($discuzdbnew[$dbtable] as $key => $value) {
if(!isset($discuzdb[$dbtable][$key]) && !@in_array($value['Field'], $except[$dbtable])) {
$addlist[] = $value;
}
}
}
}
if(($modifylist || $dellist) && !in_array($dbtable, $excepttables)) {
$showlist .= showtablerow('', '', array("<span class=\"diffcolor3\">$tablepre$dbtable</span> $lang[dbcheck_field]", $lang[dbcheck_org_field], $lang[dbcheck_status]), TRUE);
foreach($modifylist as $value) {
$slowstatus = slowcheck($discuzdbnew[$dbtable][$value['Field']]['Type'], $value['Type']);
$showlist .= "<tr><td><input name=\"repair[]\" class=\"checkbox\" type=\"checkbox\" value=\"$dbtable|$value[Field]|modify\"> <b>".$value['Field']."</b> ".
$discuzdbnew[$dbtable][$value['Field']]['Type'].
($discuzdbnew[$dbtable][$value['Field']]['Null'] == 'NO' ? ' NOT NULL' : '').
(!preg_match('/auto_increment/i', $discuzdbnew[$dbtable][$value['Field']]['Extra']) && !preg_match('/text/i', $discuzdbnew[$dbtable][$value['Field']]['Type']) ? ' default \''.$discuzdbnew[$dbtable][$value['Field']]['Default'].'\'' : '').
' '.$discuzdbnew[$dbtable][$value['Field']]['Extra'].
"</td><td><b>".$value['Field']."</b> ".$value['Type'].
($value['Null'] == 'NO' ? ' NOT NULL' : '').
(!preg_match('/auto_increment/i', $value['Extra']) && !preg_match('/text/i', $value['Type']) ? ' default \''.$value['Default'].'\'' : '').
' '.$value['Extra']."</td><td>".
(!$slowstatus ? "<em class=\"edited\">$lang[dbcheck_modify]</em></td></tr>" : "<em class=\"unknown\">$lang[dbcheck_slow]</em>")."</td></tr>";
}
if($modifylist) {
$showlist .= showtablerow('', 'colspan="3"', "<input onclick=\"setrepaircheck(this, this.form, '$dbtable')\" name=\"repairtable[]\" class=\"checkbox\" type=\"checkbox\" value=\"$dbtable\"> <b>$lang[dbcheck_repairtable]</b>", TRUE);
}
foreach($dellist as $value) {
$showlist .= "<tr><td><input name=\"repair[]\" class=\"checkbox\" type=\"checkbox\" value=\"$dbtable|$value[Field]|add\"> <strike><b>".$value['Field']."</b></strike></td><td> <b>".$value['Field']."</b> ".$value['Type'].($value['Null'] == 'NO' ? ' NOT NULL' : '')."</td><td>".
"<em class=\"del\">$lang[dbcheck_delete]</em></td></tr>";
}
}
if($addlist) {
$addlists .= "<tr><td colspan=\"3\"><b>$tablepre$dbtable</b> $lang[dbcheck_new_field]</td></tr>";
foreach($addlist as $value) {
$addlists .= "<tr><td colspan=\"3\"> <b>".$value['Field']."</b> ".$discuzdbnew[$dbtable][$value['Field']]['Type'].($discuzdbnew[$dbtable][$value['Field']]['Null'] == 'NO' ? ' NOT NULL' : '')."</td></tr>";
}
}
}
if($showlist) {
$showlist = showtablerow('', 'colspan="3" class="partition"', $lang['dbcheck_errorfields_tables'], TRUE).$showlist;
}
if($missingtables) {
$showlist .= showtablerow('', 'colspan="3" class="partition"', $lang['dbcheck_missing_tables'], TRUE);
$showlist .= showtablerow('', 'colspan="3" class="partition"', implode('', $missingtables), TRUE);
}
if($settingsdellist) {
$showlist .= "<tr class=\"partition\"><td colspan=\"3\">$lang[dbcheck_settings]</td></tr>";
$showlist .= '<tr><td colspan="3">';
$showlist .= "<input name=\"setting[del]\" class=\"checkbox\" type=\"checkbox\" value=\"1\"> ".implode(', ', $settingsdellist).'<br />';
$showlist .= '</td></tr>';
}
if($showlist) {
$showlist .= '<tr><td colspan="3"><input class="btn" type="submit" value="'.$lang['dbcheck_repair'].'" name="repairsubmit"></td></tr>';
}
if($charseterror) {
$showlist .= "<tr><td class=\"partition\" colspan=\"3\">$lang[dbcheck_charseterror_tables] ($lang[dbcheck_charseterror_notice] $dbcharset)</td></tr>";
$showlist .= '<tr><td colspan="3">'.implode('', $charseterror).'</td></tr>';
}
if($addlists) {
$showlist .= '<tr><td class="partition" colspan="3">'.$lang['dbcheck_userfields'].'</td></tr>'.$addlists;
}
}
shownav('tools', 'nav_db', 'nav_db_dbcheck');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 0),
array('nav_db_import', 'db&operation=import', 0),
array('nav_db_runquery', 'db&operation=runquery', 0),
array('nav_db_optimize', 'db&operation=optimize', 0),
array('nav_db_dbcheck', 'db&operation=dbcheck', 1)
));
showsubmenusteps('', array(
array('nav_filecheck_confirm', $step == 1),
array('nav_filecheck_verify', $step == 2),
array('nav_filecheck_completed', $step == 3)
));
if($step == 1) {
cpmsg($lang[dbcheck_tips_step1], $BASESCRIPT.'?action=db&operation=dbcheck&step=2', 'button', '', FALSE);
} elseif($step == 2) {
cpmsg(lang('dbcheck_verifying'), "$BASESCRIPT?action=db&operation=dbcheck&step=3", 'loading', '', FALSE);
} elseif($step == 3) {
showtips('dbcheck_tips');
echo <<<EOT
<script type="text/JavaScript">
function setrepaircheck(obj, form, table) {
eval('var rem = /^' + table + '\\\\|.+?\\\\|modify$/;');
eval('var rea = /^' + table + '\\\\|.+?\\\\|add$/;');
for(var i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if(e.type == 'checkbox' && e.name == 'repair[]') {
if(rem.exec(e.value) != null) {
if(obj.checked) {
e.checked = false;
e.disabled = true;
} else {
e.checked = false;
e.disabled = false;
}
}
if(rea.exec(e.value) != null) {
if(obj.checked) {
e.checked = true;
e.disabled = false;
} else {
e.checked = false;
e.disabled = false;
}
}
}
}
}
</script>
EOT;
showformheader('db&operation=dbcheck&step=3', 'fixpadding');
showtableheader();
echo $showlist;
showtablefooter();
showformfooter();
}
}
function createtable($sql, $dbcharset) {
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
(mysql_get_server_info() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
}
function fetchtablelist($tablepre = '') {
global $db;
$arr = explode('.', $tablepre);
$dbname = $arr[1] ? $arr[0] : '';
$tablepre = str_replace('_', '\_', $tablepre);
$sqladd = $dbname ? " FROM $dbname LIKE '$arr[1]%'" : "LIKE '$tablepre%'";
$tables = $table = array();
$query = $db->query("SHOW TABLE STATUS $sqladd");
while($table = $db->fetch_array($query)) {
$table['Name'] = ($dbname ? "$dbname." : '').$table['Name'];
$tables[] = $table;
}
return $tables;
}
function arraykeys2($array, $key2) {
$return = array();
foreach($array as $val) {
$return[] = $val[$key2];
}
return $return;
}
function syntablestruct($sql, $version, $dbcharset) {
if(strpos(trim(substr($sql, 0, 18)), 'CREATE TABLE') === FALSE) {
return $sql;
}
$sqlversion = strpos($sql, 'ENGINE=') === FALSE ? FALSE : TRUE;
if($sqlversion === $version) {
return $sqlversion && $dbcharset ? preg_replace(array('/ character set \w+/i', '/ collate \w+/i', "/DEFAULT CHARSET=\w+/is"), array('', '', "DEFAULT CHARSET=$dbcharset"), $sql) : $sql;
}
if($version) {
return preg_replace(array('/TYPE=HEAP/i', '/TYPE=(\w+)/is'), array("ENGINE=MEMORY DEFAULT CHARSET=$dbcharset", "ENGINE=\\1 DEFAULT CHARSET=$dbcharset"), $sql);
} else {
return preg_replace(array('/character set \w+/i', '/collate \w+/i', '/ENGINE=MEMORY/i', '/\s*DEFAULT CHARSET=\w+/is', '/\s*COLLATE=\w+/is', '/ENGINE=(\w+)(.*)/is'), array('', '', 'ENGINE=HEAP', '', '', 'TYPE=\\1\\2'), $sql);
}
}
function sqldumptable($table, $startfrom = 0, $currsize = 0) {
global $db, $sizelimit, $startrow, $extendins, $sqlcompat, $sqlcharset, $dumpcharset, $usehex, $complete, $excepttables;
$offset = 300;
$tabledump = '';
$tablefields = array();
$query = $db->query("SHOW FULL COLUMNS FROM $table", 'SILENT');
if(strexists($table, 'adminsessions')) {
return ;
} elseif(!$query && $db->errno() == 1146) {
return;
} elseif(!$query) {
$usehex = FALSE;
} else {
while($fieldrow = $db->fetch_array($query)) {
$tablefields[] = $fieldrow;
}
}
if(!$startfrom) {
$createtable = $db->query("SHOW CREATE TABLE $table", 'SILENT');
if(!$db->error()) {
$tabledump = "DROP TABLE IF EXISTS $table;\n";
} else {
return '';
}
$create = $db->fetch_row($createtable);
if(strpos($table, '.') !== FALSE) {
$tablename = substr($table, strpos($table, '.') + 1);
$create[1] = str_replace("CREATE TABLE $tablename", 'CREATE TABLE '.$table, $create[1]);
}
$tabledump .= $create[1];
if($sqlcompat == 'MYSQL41' && $db->version() < '4.1') {
$tabledump = preg_replace("/TYPE\=(.+)/", "ENGINE=\\1 DEFAULT CHARSET=".$dumpcharset, $tabledump);
}
if($db->version() > '4.1' && $sqlcharset) {
$tabledump = preg_replace("/(DEFAULT)*\s*CHARSET=.+/", "DEFAULT CHARSET=".$sqlcharset, $tabledump);
}
$tablestatus = $db->fetch_first("SHOW TABLE STATUS LIKE '$table'");
$tabledump .= ($tablestatus['Auto_increment'] ? " AUTO_INCREMENT=$tablestatus[Auto_increment]" : '').";\n\n";
if($sqlcompat == 'MYSQL40' && $db->version() >= '4.1' && $db->version() < '5.1') {
if($tablestatus['Auto_increment'] <> '') {
$temppos = strpos($tabledump, ',');
$tabledump = substr($tabledump, 0, $temppos).' auto_increment'.substr($tabledump, $temppos);
}
if($tablestatus['Engine'] == 'MEMORY') {
$tabledump = str_replace('TYPE=MEMORY', 'TYPE=HEAP', $tabledump);
}
}
}
if(!in_array($table, $excepttables)) {
$tabledumped = 0;
$numrows = $offset;
$firstfield = $tablefields[0];
if($extendins == '0') {
while($currsize + strlen($tabledump) + 500 < $sizelimit * 1000 && $numrows == $offset) {
if($firstfield['Extra'] == 'auto_increment') {
$selectsql = "SELECT * FROM $table WHERE $firstfield[Field] > $startfrom LIMIT $offset";
} else {
$selectsql = "SELECT * FROM $table LIMIT $startfrom, $offset";
}
$tabledumped = 1;
$rows = $db->query($selectsql);
$numfields = $db->num_fields($rows);
$numrows = $db->num_rows($rows);
while($row = $db->fetch_row($rows)) {
$comma = $t = '';
for($i = 0; $i < $numfields; $i++) {
$t .= $comma.($usehex && !empty($row[$i]) && (strexists($tablefields[$i]['Type'], 'char') || strexists($tablefields[$i]['Type'], 'text')) ? '0x'.bin2hex($row[$i]) : '\''.mysql_escape_string($row[$i]).'\'');
$comma = ',';
}
if(strlen($t) + $currsize + strlen($tabledump) + 500 < $sizelimit * 1000) {
if($firstfield['Extra'] == 'auto_increment') {
$startfrom = $row[0];
} else {
$startfrom++;
}
$tabledump .= "INSERT INTO $table VALUES ($t);\n";
} else {
$complete = FALSE;
break 2;
}
}
}
} else {
while($currsize + strlen($tabledump) + 500 < $sizelimit * 1000 && $numrows == $offset) {
if($firstfield['Extra'] == 'auto_increment') {
$selectsql = "SELECT * FROM $table WHERE $firstfield[Field] > $startfrom LIMIT $offset";
} else {
$selectsql = "SELECT * FROM $table LIMIT $startfrom, $offset";
}
$tabledumped = 1;
$rows = $db->query($selectsql);
$numfields = $db->num_fields($rows);
if($numrows = $db->num_rows($rows)) {
$t1 = $comma1 = '';
while($row = $db->fetch_row($rows)) {
$t2 = $comma2 = '';
for($i = 0; $i < $numfields; $i++) {
$t2 .= $comma2.($usehex && !empty($row[$i]) && (strexists($tablefields[$i]['Type'], 'char') || strexists($tablefields[$i]['Type'], 'text'))? '0x'.bin2hex($row[$i]) : '\''.mysql_escape_string($row[$i]).'\'');
$comma2 = ',';
}
if(strlen($t1) + $currsize + strlen($tabledump) + 500 < $sizelimit * 1000) {
if($firstfield['Extra'] == 'auto_increment') {
$startfrom = $row[0];
} else {
$startfrom++;
}
$t1 .= "$comma1 ($t2)";
$comma1 = ',';
} else {
$tabledump .= "INSERT INTO $table VALUES $t1;\n";
$complete = FALSE;
break 2;
}
}
$tabledump .= "INSERT INTO $table VALUES $t1;\n";
}
}
}
$startrow = $startfrom;
$tabledump .= "\n";
}
return $tabledump;
}
function splitsql($sql) {
$sql = str_replace("\r", "\n", $sql);
$ret = array();
$num = 0;
$queriesarray = explode(";\n", trim($sql));
unset($sql);
foreach($queriesarray as $query) {
$queries = explode("\n", trim($query));
foreach($queries as $query) {
$ret[$num] .= $query[0] == "#" ? NULL : $query;
}
$num++;
}
return($ret);
}
function slowcheck($type1, $type2) {
$t1 = explode(' ', $type1);$t1 = $t1[0];
$t2 = explode(' ', $type2);$t2 = $t2[0];
$arr = array($t1, $t2);
sort($arr);
if($arr == array('mediumtext', 'text')) {
return TRUE;
} elseif(substr($arr[0], 0, 4) == 'char' && substr($arr[1], 0, 7) == 'varchar') {
return TRUE;
}
return FALSE;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/db.inc.php | PHP | asf20 | 52,538 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: addons.inc.php 20401 2009-09-25 09:26:17Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
define('ADDONS_SERVER', 'http://addons.discuz.com');
cpheader();
if(!$operation) {
shownav('addons');
showsubmenu('addons', array(
array('addons_list', 'addons', 1),
array('addons_add', 'addons&operation=add', 0)
));
showtips('addons_tips');
$query = $db->query("SELECT * FROM {$tablepre}addons ORDER BY `system` DESC,`key` ASC");
while($addon = $db->fetch_array($query)) {
showproviderinfo($addon, 0);
}
echo '<input class="btn" type="button" onclick="location.href=\''.$BASESCRIPT.'?action=addons&operation=add\'" value="'.$lang['addons_more'].'" />';
} elseif($operation == 'list') {
require_once DISCUZ_ROOT.'./discuz_version.php';
$baseparm = 'version='.rawurlencode(DISCUZ_VERSION).'&release='.rawurlencode(DISCUZ_RELEASE).'&charset='.rawurlencode($charset).'&boardurl='.rawurlencode($boardurl);
$addon = dstrip_tags($db->fetch_first("SELECT * FROM {$tablepre}addons WHERE `key`='$provider'"));
if(!$addon) {
cpmsg('addons_provider_nonexistence', '', 'error');
}
$providerapi = trim(dfopen(ADDONS_SERVER, 0, $baseparm.'&key='.rawurlencode($provider)));
if(!$providerapi) {
cpmsg('addons_provider_disabled', '', 'error');
}
$extra = !empty($category) ? '&category='.rawurlencode($category) : '';
$data = dfopen($providerapi, 0, $baseparm.$extra);
require_once DISCUZ_ROOT.'./include/xml.class.php';
if(strtoupper($charset) != 'UTF-8') {
require_once DISCUZ_ROOT.'include/chinese.class.php';
$c = new Chinese('utf8', $charset, TRUE);
$data = $c->Convert($data);
}
$data = xml2array($data);
if(!is_array($data) || !$data || $data['Key'] != $provider) {
cpmsg('addons_provider_apiinvalid', $BASESCRIPT.'?action=addons', 'error');
}
checkinfoupdate();
$data = dstrip_tags($data);
shownav('addons', $data['Title']);
showsubmenu($data['Title']);
showproviderinfo($addon, 1);
showtableheader('', 'noborder');
echo '<tr><td valign="top" width="150" style="padding-top:0"><ul class="menu">';
foreach($data['Category'] as $categoryid => $Category) {
echo '<li class="a"><a'.($category == $categoryid ? ' class="tabon"' : '').' href="'.$BASESCRIPT.'?action=addons&operation=list&provider='.$provider.'&category='.$categoryid.'">'.$Category.'</a></li>';
}
echo '</ul></td><td valign="top" style="padding-top:0">';
if($data['Searchlink'] != '') {
echo '<form method="post" action="'.$data['Searchlink'].'" target="_blank">'.
'<input type="hidden" name="version" value="'.DISCUZ_VERSION.'" />'.
'<input type="hidden" name="release" value="'.DISCUZ_RELEASE.'" />'.
'<input type="hidden" name="charset" value="'.$charset.'" />'.
'<input type="hidden" name="boardurl" value="'.$boardurl.'" />'.
'<input name="keyword" /><input name="submit" class="btn" style="margin: -4px 0 0 2px" type="submit" value="'.$lang['addons_search'].'" />'.
'</form>';
}
$count = 0;
showtableheader('', 'fixpadding', 'style="margin-top:0"');
if(is_array($data['Data'])) foreach($data['Data'] as $row) {
$count++;
$Charset = explode(',', $row['Charset']);
foreach($Charset as $k => $v) {
if(preg_match('/^SC\_GBK$/i', $v)) {
$Charset[$k] = '简体中文';
if(strtoupper($charset) == 'GBK') {
$Charset[$k] = '<b>'.$Charset[$k].'</b>';
}
} elseif(preg_match('/^SC\_UTF8$/i', $v)) {
$Charset[$k] = '简体中文UTF8';
if(strtoupper($charset) == 'UTF-8') {
$Charset[$k] = '<b>'.$Charset[$k].'</b>';
}
} elseif(preg_match('/^TC\_BIG5$/i', $v)) {
$Charset[$k] = '繁體中文';
if(strtoupper($charset) == 'BIG5') {
$Charset[$k] = '<b>'.$Charset[$k].'</b>';
}
} elseif(preg_match('/^TC\_UTF8$/i', $v)) {
$Charset[$k] = '繁體中文UTF8';
if(strtoupper($charset) == 'UTF-8') {
$Charset[$k] = '<b>'.$Charset[$k].'</b>';
}
}
}
echo '<tr><th colspan="3" class="partition">'.($row['Time'] != '' ? '<div class="right">'.$row['Time'].'</div>' : '').'<a href="'.$row['Url'].'" target="_blank">'.($row['Greenplugin'] ? '<img class="vmiddle" title="'.$lang['addons_greenplugin'].'" src="images/admincp/greenplugin.gif" /> ' : '').$row['Name'].($row['Version'] != '' ? ' '.$row['Version'] : '').'</a></th></tr>'.
'<tr><td width="110">'.($row['Thumb'] != '' ? '<a href="'.$row['Url'].'" target="_blank"><img onerror="this.src=\'images/common/none.gif\'" src="'.$row['Thumb'].'" width="100" /></a>' : '').'</td>'.
'<td width="90%" class="lineheight" valign="top">'.($row['Charset'] != '' ? $lang['addons_charset'].implode(', ', $Charset).'<br />' : '').($row['Description'] != '' ? nl2br($row['Description']) : '').'</td></tr>';
if($count == 20) {
break;
}
}
showtablefooter();
if($data['Morelink'] != '') {
showtableheader('', 'fixpadding');
echo '<tr><td class="partition"><a href="'.$data['Morelink'].'" target="_blank">'.$lang['addons_more'].'</a></td></tr>';
showtablefooter();
}
echo '</td></tr>';
showtablefooter();
} elseif($operation == 'remove') {
$addon = $db->fetch_first("SELECT * FROM {$tablepre}addons WHERE `key`='$provider'");
if(!$addon) {
cpmsg('addons_provider_nonexistence', '', 'error');
}
$db->query("DELETE FROM {$tablepre}addons WHERE `key`='$provider' AND system='0'");
cpmsg('addons_provider_removesucceed', $BASESCRIPT.'?action=addons', 'succeed');
} elseif($operation == 'add') {
if(empty($providerkey)) {
$extra = !empty($category) ? '&category='.rawurlencode($category) : '';
$data = dfopen(ADDONS_SERVER.'/list.xml');
require_once DISCUZ_ROOT.'./include/xml.class.php';
if(strtoupper($charset) != 'UTF-8') {
require_once DISCUZ_ROOT.'include/chinese.class.php';
$c = new Chinese('utf8', $charset, TRUE);
$data = $c->Convert($data);
}
$data = xml2array($data);
shownav('addons');
showsubmenu('addons', array(
array('addons_list', 'addons', 0),
array('addons_add', 'addons&operation=add', 1)
));
showtips('addons_add_tips');
showtableheader();
if(is_array($data) && $data) {
$data = dstrip_tags($data);
showsubtitle(array('addons_recommend', ''));
echo '<tr><td>';
foreach($data as $row) {
echo '<div class="hover" style="float:left;width:20%"><div style="text-align:center"><a href="'.$BASESCRIPT.'?action=addons&operation=add&providerkey='.$row['key'].'">'.
($row['logo'] ? '<img width="100" height="50" src="'.$row['logo'].'" />' : '<img width="100" height="50" src="images/common/none.gif" />').
'</a><br /><a href="'.$BASESCRIPT.'?action=addons&operation=add&providerkey='.$row['key'].'">'.$row['sitename'].'</a></div></div>';
}
echo '</td></tr>';
} else {
echo '<tr><td>'.$lang['addons_provider_listinvalid'].'</td></tr>';
}
showtablefooter();
showformheader('addons&operation=add');
showtableheader('addons_add_input');
showsetting('addons_provider_key', 'providerkey', '', 'text');
showsubmit('newsubmit');
showtablefooter();
showformfooter();
} else {
if(!$providerkey) {
cpmsg('addons_provider_nonexistence', '', 'error');
}
$addon = $db->fetch_first("SELECT * FROM {$tablepre}addons WHERE `key`='$providerkey'");
if($addon) {
cpmsg('addons_provider_exists', $BASESCRIPT.'?action=addons&operation=list&provider='.rawurlencode($providerkey), 'succeed');
}
require_once DISCUZ_ROOT.'./discuz_version.php';
$baseparm = 'version='.rawurlencode(DISCUZ_VERSION).'&release='.rawurlencode(DISCUZ_RELEASE).'&charset='.rawurlencode($charset);
$providerapi = trim(dfopen(ADDONS_SERVER, 0, $baseparm.'&key='.rawurlencode($providerkey)));
if(!$providerapi) {
cpmsg('addons_provider_disabled', '', 'error');
}
$db->query("INSERT INTO {$tablepre}addons (`key`) VALUES ('$providerkey')");
cpmsg('addons_provider_addsucceed', $BASESCRIPT.'?action=addons&operation=list&provider='.rawurlencode($providerkey), 'succeed');
}
}
function showproviderinfo($addon, $simple) {
$contact = $addon['contact'];
$contact = preg_replace("/(((https?){1}:\/\/|www\.).+?)(\s|$)/ies", "parsetaga('\\1', '\\4', 0)", $contact);
$contact = preg_replace("/(([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+))(\s|$)/ies", "parsetaga('\\1', '\\4', 1)", $contact);
if($simple) {
echo '<div class="colorbox">';
}
showtableheader('', $simple ? 'noborder' : '');
echo (!$simple ? '<tr><th colspan="3" class="partition"><a href="'.$BASESCRIPT.'?action=addons&operation=list&provider='.$addon['key'].'">'.$addon['title'].'</a></th></tr>' : '').
'<tr><td width="110"><a href="'.$BASESCRIPT.'?action=addons&operation=list&provider='.$addon['key'].'"><img onerror="this.src=\'images/common/none.gif\'" src="'.$addon['logo'].'" width="100" height="50" /></a></td>'.
'<td valign="top">'.nl2br($addon['description']).'<br />'.
lang('addons_provider').'<a href="'.$addon['siteurl'].'" target="_blank">'.$addon['sitename'].'</a><br />'.
lang('addons_contact').$contact.'</td>'.
(!$simple ? '<td align="right" width="50">'.(!$addon['system'] ? '<a href="'.$BASESCRIPT.'?action=addons&operation=remove&provider='.$addon['key'].'" onclick="return confirm(\''.lang('addons_delete_confirm').'\')">'.lang('delete').'</a>' : '').' </td>' : '').'</tr>';
showtablefooter();
if($simple) {
echo '</div>';
}
}
function checkinfoupdate() {
global $db, $tablepre, $data, $addon, $provider;
$update = array();
if($data['Title'] != $addon['title']) {
$update[] = "title='".addslashes($data['Title'])."'";
}
if($data['Sitename'] != $addon['sitename']) {
$update[] = "sitename='".addslashes($data['Sitename'])."'";
}
if($data['Siteurl'] != $addon['siteurl']) {
$update[] = "siteurl='".addslashes($data['Siteurl'])."'";
}
if($data['Description'] != $addon['description']) {
$update[] = "description='".addslashes($data['Description'])."'";
}
if($data['Contact'] != $addon['contact']) {
$update[] = "contact='".addslashes($data['Contact'])."'";
}
if($data['Logo'] != $addon['logo']) {
$update[] = "logo='".addslashes($data['Logo'])."'";
}
if($update) {
$db->query("UPDATE {$tablepre}addons SET ".implode(',', $update)." WHERE `key`='$provider'");
}
$addon = $db->fetch_first("SELECT * FROM {$tablepre}addons WHERE `key`='$provider'");
}
function parsetaga($href, $s, $mailto) {
return '<a href="'.($mailto ? 'mailto:' : '').$href.'" target="_blank">'.$href.'</a>'.$s;
}
function dstrip_tags($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = dstrip_tags($val);
}
} else {
$string = strip_tags($string);
}
return $string;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/addons.inc.php | PHP | asf20 | 11,024 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: importdata.func.php 20026 2009-09-17 02:39:58Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
function import_request($importrewrite = 2) {
global $db, $tablepre;
$importarray = getimportdata('Discuz! Request', 0);
$keys = implode("','", array_keys($importarray));
if($importrewrite != 2) {
$query = $db->query("SELECT variable FROM {$tablepre}request WHERE variable IN ('$keys')");
$existkeyarray = array();
while($existkey = $db->fetch_array($query)) {
if($importrewrite == 1) {
unset($importarray[$existkey['variable']]);
} else {
$existkeyarray[] = $existkey['variable'];
}
}
if($importrewrite == 0 && $existkeyarray) {
$existkeys = implode(", ", $existkeyarray);
cpmsg('jswizard_import_exist', '', 'error');
}
}
foreach($importarray as $key => $value) {
$value = unserialize($value);
$type = $value['type'];
unset($value['type']);
$value = addslashes(serialize($value));
$db->query("REPLACE INTO {$tablepre}request (variable, value, `type`) VALUES ('$key', '$value', '$type')");
}
updatecache('request');
}
function import_project() {
global $db, $tablepre, $version;
$projectarray = getimportdata('Discuz! Project');
$db->query("INSERT INTO {$tablepre}projects (name, type, description, value) VALUES ('$projectarray[name]', '$projectarray[type]', '$projectarray[description]', '$projectarray[value]')");
}
function import_smilies() {
global $db, $tablepre;
$smileyarray = getimportdata('Discuz! Smilies');
$renamed = 0;
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}imagetypes WHERE type='smiley' AND name='$smileyarray[name]'")) {
$smileyarray['name'] .= '_'.random(4);
$renamed = 1;
}
$db->query("INSERT INTO {$tablepre}imagetypes (name, type, directory)
VALUES ('$smileyarray[name]', 'smiley', '$smileyarray[directory]')");
$typeid = $db->insert_id();
foreach($smileyarray['smilies'] as $key => $smiley) {
$db->query("INSERT INTO {$tablepre}smilies (type, typeid, displayorder, code, url)
VALUES ('smiley', '$typeid', '$smiley[displayorder]', '', '$smiley[url]')");
}
$db->query("UPDATE {$tablepre}smilies SET code=CONCAT('{:', typeid, '_', id, ':}') WHERE typeid='$typeid'");
updatecache(array('smileytypes', 'smilies', 'smileycodes', 'smilies_js'));
return $renamed;
}
function import_styles($ignoreversion = 1, $dir = '') {
global $db, $tablepre, $version, $importtxt, $stylearray;
if(!isset($dir)) {
$stylearrays = array(getimportdata('Discuz! Style'));
} else {
$dir = str_replace(array('/', '\\'), '', $dir);
$templatedir = DISCUZ_ROOT.'./templates/'.$dir;
$searchdir = dir($templatedir);
$stylearrays = array();
while($searchentry = $searchdir->read()) {
if(substr($searchentry, 0, 13) == 'discuz_style_' && fileext($searchentry) == 'xml') {
$importfile = $templatedir.'/'.$searchentry;
$importtxt = implode('', file($importfile));
$stylearrays[] = getimportdata('Discuz! Style');
}
}
}
foreach($stylearrays as $stylearray) {
if(empty($ignoreversion) && strip_tags($stylearray['version']) != strip_tags($version)) {
cpmsg('styles_import_version_invalid', '', 'error');
}
$renamed = 0;
if($stylearray['templateid'] != 1) {
$templatedir = DISCUZ_ROOT.'./'.$stylearray['directory'];
if(!is_dir($templatedir)) {
if(!@mkdir($templatedir, 0777)) {
$basedir = dirname($stylearray['directory']);
cpmsg('styles_import_directory_invalid', '', 'error');
}
}
if(!($templateid = $db->result_first("SELECT templateid FROM {$tablepre}templates WHERE name='$stylearray[tplname]'"))) {
$db->query("INSERT INTO {$tablepre}templates (name, directory, copyright)
VALUES ('$stylearray[tplname]', '$stylearray[directory]', '$stylearray[copyright]')");
$templateid = $db->insert_id();
}
} else {
$templateid = 1;
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}styles WHERE name='$stylearray[name]'")) {
$stylearray['name'] .= '_'.random(4);
$renamed = 1;
}
$db->query("INSERT INTO {$tablepre}styles (name, templateid)
VALUES ('$stylearray[name]', '$templateid')");
$styleidnew = $db->insert_id();
foreach($stylearray['style'] as $variable => $substitute) {
$substitute = @htmlspecialchars($substitute);
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$styleidnew', '$variable', '$substitute')");
}
}
updatecache('styles');
updatecache('settings');
return $renamed;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/importdata.func.php | PHP | asf20 | 4,754 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: home.inc.php 20858 2009-10-28 00:59:31Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(@file_exists(DISCUZ_ROOT.'./install/index.php')) {
@unlink(DISCUZ_ROOT.'./install/index.php');
if(@file_exists(DISCUZ_ROOT.'./install/index.php')) {
dexit('Please delete install/index.php via FTP!');
}
}
@include_once DISCUZ_ROOT.'./discuz_version.php';
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$siteuniqueid = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='siteuniqueid'");
if(empty($siteuniqueid) || strlen($siteuniqueid) < 16) {
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$siteuniqueid = $chars[date('y')%60].$chars[date('n')].$chars[date('j')].$chars[date('G')].$chars[date('i')].$chars[date('s')].substr(md5($onlineip.$discuz_user.$timestamp), 0, 4).random(6);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('siteuniqueid', '$siteuniqueid')");
}
if(empty($_DCACHE['settings']['authkey']) || strlen($_DCACHE['settings']['authkey']) < 16) {
$authkey = $_DCACHE['settings']['authkey'] = substr(md5($siteuniqueid.$bbname.$timestamp), 8, 8).random(8);
$db->query("REPLACE INTO {$tablepre}settings SET variable='authkey', value='$authkey'");
updatesettings();
}
if(submitcheck('notesubmit', 1)) {
if($noteid) {
$db->query("DELETE FROM {$tablepre}adminnotes WHERE id='$noteid' AND (admin='$discuz_user' OR adminid>='$adminid')");
}
if($newmessage) {
$newaccess[$adminid] = 1;
$newaccess = bindec(intval($newaccess[1]).intval($newaccess[2]).intval($newaccess[3]));
$newexpiration = strtotime($newexpiration);
$newmessage = nl2br(dhtmlspecialchars($newmessage));
$db->query("INSERT INTO {$tablepre}adminnotes (admin, access, adminid, dateline, expiration, message)
VALUES ('$discuz_user', '$newaccess', '$adminid', '$timestamp', '$newexpiration', '$newmessage')");
}
}
$serverinfo = PHP_OS.' / PHP v'.PHP_VERSION;
$serverinfo .= @ini_get('safe_mode') ? ' Safe Mode' : NULL;
$serversoft = $_SERVER['SERVER_SOFTWARE'];
$dbversion = $db->result_first("SELECT VERSION()");
if(@ini_get('file_uploads')) {
$fileupload = ini_get('upload_max_filesize');
} else {
$fileupload = '<font color="red">'.$lang['no'].'</font>';
}
//$groupselect = '';
//$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups ORDER BY creditslower, groupid");
//while($group = $db->fetch_array($query)) {
// $groupselect .= '<option value="'.$group['groupid'].'">'.$group['grouptitle'].'</option>';
//}
$dbsize = 0;
$query = $db->query("SHOW TABLE STATUS LIKE '$tablepre%'", 'SILENT');
while($table = $db->fetch_array($query)) {
$dbsize += $table['Data_length'] + $table['Index_length'];
}
$dbsize = $dbsize ? sizecount($dbsize) : $lang['unknown'];
if(isset($attachsize)) {
$attachsize = $db->result($db->query("SELECT SUM(filesize) FROM {$tablepre}attachments"), 0);
$attachsize = is_numeric($attachsize) ? sizecount($attachsize) : $lang['unknown'];
} else {
$attachsize = '<a href="admincp.php?action=home&attachsize">[ '.$lang['detail'].' ]</a>';
}
$membersmod = $db->result_first("SELECT COUNT(*) FROM {$tablepre}validating WHERE status='0'");
$postsmod = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE first='0' AND invisible='-2'");
$threadsdel = $threadsmod = 0;
$query = $db->query("SELECT displayorder FROM {$tablepre}threads WHERE displayorder<'0'");
while($thread = $db->fetch_array($query)) {
if($thread['displayorder'] == -1) {
$threadsdel++;
} elseif($thread['displayorder'] == -2) {
$threadsmod++;
}
}
cpheader();
shownav();
showsubmenu('home_welcome');
$save_mastermobile = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='mastermobile'");
$save_mastermobile = !empty($save_mastermobile) ? authcode($save_mastermobile, 'DECODE', $authkey) : '';
$securityadvise = '';
$securityadvise .= !$discuz_secques ? $lang['home_secques_invalid'] : '';
$securityadvise .= empty($forumfounders) ? $lang['home_security_nofounder'] : '';
$securityadvise .= $admincp['tpledit'] ? $lang['home_security_tpledit'] : '';
$securityadvise .= $admincp['runquery'] ? $lang['home_security_runquery'] : '';
if(isfounder()) {
if($securyservice) {
$new_mastermobile = trim($new_mastermobile);
if(empty($new_mastermobile)) {
$save_mastermobile = $new_mastermobile;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('mastermobile', '$new_mastermobile')");
} elseif($save_mastermobile != $new_mastermobile && strlen($new_mastermobile) == 11 && is_numeric($new_mastermobile) && (substr($new_mastermobile, 0, 2) == '13' || substr($new_mastermobile, 0, 2) == '15')) {
$save_mastermobile = $new_mastermobile;
$new_mastermobile = authcode($new_mastermobile, 'ENCODE', $authkey);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('mastermobile', '$new_mastermobile')");
}
}
$view_mastermobile = !empty($save_mastermobile) ? substr($save_mastermobile, 0 , 3).'*****'.substr($save_mastermobile, -3) : '';
$securityadvise = '<li><p>'.lang('home_security_service_info').'</p><form method="post" action="'.$BASESCRIPT.'?action=home&securyservice=yes">'.lang('home_security_service_mobile').': <input type="text" class="txt" name="new_mastermobile" value="'.$view_mastermobile.'" size="30" /> <input type="submit" class="btn" name="securyservice" value="'.lang($view_mastermobile ? 'submit' : 'home_security_service_open').'" /> <span class="lightfont">'.lang($view_mastermobile ? 'home_security_service_mobile_save' : 'home_security_service_mobile_none').'</span></form></li>'.$securityadvise;
}
showtableheader('home_security_tips', '', '', 0);
showtablerow('', 'class="tipsblock"', '<ul>'.$securityadvise.'</ul>');
showtablefooter();
//showsubmenu('home_security_tips');
//echo '<ul class="safelist">'.$securityadvise.'</ul>';
echo '<div id="boardnews"></div>';
showtableheader('', 'nobottom fixpadding');
if($membersmod || $threadsmod || $postsmod || $threadsdel) {
showtablerow('', '', '<h3 class="left margintop">'.lang('home_mods').': </h3><p class="left difflink">'.
($membersmod ? '<a href="'.$BASESCRIPT.'?action=moderate&operation=members">'.lang('home_mod_members').'</a>(<em class="lightnum">'.$membersmod.'</em>)' : '').
($threadsmod ? '<a href="'.$BASESCRIPT.'?action=moderate&operation=threads">'.lang('home_mod_threads').'</a>(<em class="lightnum">'.$threadsmod.'</em>)' : '').
($postsmod ? '<a href="'.$BASESCRIPT.'?action=moderate&operation=replies">'.lang('home_mod_posts').'</a>(<em class="lightnum">'.$postsmod.'</em>)' : '').
($threadsdel ? '<a href="'.$BASESCRIPT.'?action=recyclebin">'.lang('home_del_threads').'</a>(<em class="lightnum">'.$threadsdel.'</em>)' : '').
'</p><div class="clear"></div>'
);
}
showtablefooter();
showformheader('home');
showtableheader('home_notes', 'fixpadding"', '', '3');
$query = $db->query("SELECT * FROM {$tablepre}adminnotes ORDER BY dateline DESC");
while($note = $db->fetch_array($query)) {
if($note['expiration'] < $timestamp) {
$db->query("DELETE FROM {$tablepre}adminnotes WHERE id='$note[id]'");
} else {
$note['adminenc'] = rawurlencode($note['admin']);
$note['dateline'] = gmdate($dateformat, $note['dateline'] + $timeoffset * 3600);
$note['expiration'] = gmdate($dateformat, $note['expiration'] + $timeoffset * 3600);
showtablerow('', array('', '', ''), array(
'<a href="'.$BASESCRIPT.'?action=home¬esubmit=yes¬eid='.$note['id'].'"><img src="images/admincp/close.gif" width="7" height="8" title="'.lang('delete').'" /></a>',
"<span class=\"bold\"><a href=\"space.php?username=$note[adminenc]\" target=\"_blank\">$note[admin]</a>: </span>$note[message]",
"$note[dateline] ~ $note[expiration]"
));
}
}
showtablerow('', array(), array(
lang('home_notes_add'),
'<input type="text" class="txt" name="newmessage" value="" style="width:300px;" />',
lang('validity').': <input type="text" class="txt" name="newexpiration" value="'.gmdate('Y-n-j', $timestamp + $timeoffset * 3600 + 86400 * 30).'" size="8" /><input name="notesubmit" value="'.lang('submit').'" type="submit" class="btn" />'
));
showtablefooter();
showformfooter();
include_once DISCUZ_ROOT.'./uc_client/client.php';
showtableheader('home_sys_info', 'fixpadding');
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_discuz_version'),
'Discuz! '.DISCUZ_VERSION.' Release '.DISCUZ_RELEASE.' <a href="http://faq.comsenz.com/checkversion.php?product=Discuz&version='.DISCUZ_VERSION.'&release='.DISCUZ_RELEASE.'&charset='.$charset.'&dbcharset='.$dbcharset.'" class="lightlink smallfont" target="_blank">'.lang('home_check_newversion').'</a> <a href="http://www.comsenz.com/purchase/discuz/" class="lightlink smallfont" target="_blank">专业支持与服务</a> <a href="http://idc.comsenz.com" class="lightlink smallfont" target="_blank">Discuz!专用主机</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_ucclient_version'),
'UCenter '.UC_CLIENT_VERSION.' Release '.UC_CLIENT_RELEASE
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_environment'),
$serverinfo
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_serversoftware'),
$serversoft
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_database'),
$dbversion
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_upload_perm'),
$fileupload
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_database_size'),
$dbsize
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_attach_size'),
$attachsize
));
showtablefooter();
showtableheader('home_dev', 'fixpadding');
showtablerow('', array('class="vtop td24 lineheight"'), array(
lang('home_dev_copyright'),
'<span class="bold"><a href="http://www.comsenz.com" class="lightlink2" target="_blank">康盛创想(北京)科技有限公司 (Comsenz Inc.)</a></span>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_dev_manager'),
'<a href="http://www.discuz.net/space.php?uid=1" class="lightlink smallfont" target="_blank">戴志康 (Kevin \'Crossday\' Day)</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_dev_team'),
'<a href="http://www.discuz.net/space.php?uid=2691" class="lightlink smallfont" target="_blank">Liang \'Readme\' Chen</a>,
<a href="http://www.discuz.net/space.php?uid=1519" class="lightlink smallfont" target="_blank">Yang \'Summer\' Xia</a>,
<a href="http://www.discuz.net/space.php?uid=859" class="lightlink smallfont" target="_blank">Hypo \'cnteacher\' Wang</a>,
<a href="http://www.discuz.net/space.php?uid=16678" class="lightlink smallfont" target="_blank">Yang \'Dokho\' Song</a>,
<a href="http://www.discuz.net/space.php?uid=10407" class="lightlink smallfont" target="_blank">Qiang Liu</a>,
<a href="http://www.discuz.net/space.php?uid=80629" class="lightlink smallfont" target="_blank">Ning \'Monkey\' Hou</a>,
<a href="http://www.discuz.net/space.php?uid=15104" class="lightlink smallfont" target="_blank">Xiongfei \'Redstone\' Zhao</a>,
<a href="http://www.discuz.net/space.php?uid=632268" class="lightlink smallfont" target="_blank">Jinbo \'Ggggqqqqihc\' Wang</a>,
<a href="http://www.discuz.net/space.php?uid=246213" class="lightlink smallfont" target="_blank">Lanbo Liu</a>,
<a href="http://www.discuz.net/space.php?uid=598685" class="lightlink smallfont" target="_blank">Guoquan Zhao</a>,
<a href="http://www.discuz.net/space.php?uid=492114" class="lightlink smallfont" target="_blank">Liang \'Metthew\' Xu</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight"'), array(
lang('home_dev_skins'),
'<a href="http://www.discuz.net/space.php?uid=294092" class="lightlink smallfont" target="_blank">Fangming \'Lushnis\' Li</a>,
<a href="http://www.discuz.net/space.php?uid=674006" class="lightlink smallfont" target="_blank">Jizhou \'Iavav\' Yuan</a>,
<a href="http://www.discuz.net/space.php?uid=362790" class="lightlink smallfont" target="_blank">Defeng \'Dfox\' Xu</a>,
<a href="http://www.discuz.net/space.php?uid=717854" class="lightlink smallfont" target="_blank">Ruitao \'Pony.M\' Ma</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight"'), array(
lang('home_dev_thanks'),
'<a href="http://www.discuz.net/space.php?uid=122246" class="lightlink smallfont" target="_blank">Heyond</a>,
<a href="http://www.discuz.net/space.php?uid=210272" class="lightlink smallfont" target="_blank">XiaoDun \'Kenshine\' Fang</a>,
<a href="http://www.discuz.net/space.php?uid=86282" class="lightlink smallfont" target="_blank">Jianxieshui</a>,
<a href="http://www.discuz.net/space.php?uid=9600" class="lightlink smallfont" target="_blank">Theoldmemory</a>,
<a href="http://www.discuz.net/space.php?uid=2629" class="lightlink smallfont" target="_blank">Rain5017</a>,
<a href="http://www.discuz.net/space.php?uid=26926" class="lightlink smallfont" target="_blank">Snow Wolf</a>,
<a href="http://www.discuz.net/space.php?uid=17149" class="lightlink smallfont" target="_blank">Hehechuan</a>,
<a href="http://www.discuz.net/space.php?uid=9132" class="lightlink smallfont" target="_blank">Pk0909</a>,
<a href="http://www.discuz.net/space.php?uid=248" class="lightlink smallfont" target="_blank">feixin</a>,
<a href="http://www.discuz.net/space.php?uid=675" class="lightlink smallfont" target="_blank">Laobing Jiuba</a>,
<a href="http://www.discuz.net/space.php?uid=13877" class="lightlink smallfont" target="_blank">Artery</a>,
<a href="http://www.discuz.net/space.php?uid=233" class="lightlink smallfont" target="_blank">Huli Hutu</a>,
<a href="http://www.discuz.net/space.php?uid=122" class="lightlink smallfont" target="_blank">Lao Gui</a>,
<a href="http://www.discuz.net/space.php?uid=159" class="lightlink smallfont" target="_blank">Tyc</a>,
<a href="http://www.discuz.net/space.php?uid=177" class="lightlink smallfont" target="_blank">Stoneage</a>,
<a href="http://www.discuz.net/space.php?uid=7155" class="lightlink smallfont" target="_blank">Gregry</a>,
<a href="http://www.7dps.com" class="lightlink smallfont" target="_blank">Discuz! Product Support</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight"'), array(
lang('home_dev_links'),
'<a href="http://www.comsenz.com" class="lightlink" target="_blank">公司网站</a>, <a href="http://idc.comsenz.com" class="lightlink" target="_blank">虚拟主机</a>, <a href="http://www.comsenz.com/category-51" class="lightlink" target="_blank">购买授权</a>, <a href="http://www.discuz.com/" class="lightlink" target="_blank">Discuz! 产品</a>, <a href="http://www.comsenz.com/downloads/styles/discuz" class="lightlink" target="_blank">模板</a>, <a href="http://www.comsenz.com/downloads/plugins/discuz" class="lightlink" target="_blank">插件</a>, <a href="http://faq.comsenz.com" class="lightlink" target="_blank">文档</a>, <a href="http://www.discuz.net/" class="lightlink" target="_blank">讨论区</a>'
));
showtablefooter();
echo '</div>';
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/home.inc.php | PHP | asf20 | 16,215 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: global.func.php 21350 2010-01-06 12:23:28Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
@set_time_limit(0);
function istpldir($dir) {
return is_dir(DISCUZ_ROOT.'./'.$dir) && !in_array(substr($dir, -1, 1), array('/', '\\')) &&
strpos(realpath(DISCUZ_ROOT.'./'.$dir), realpath(DISCUZ_ROOT.'./templates')) === 0;
}
function isplugindir($dir) {
return !$dir || (!preg_match("/(\.\.|[\\\\]+$)/", $dir) && substr($dir, -1) =='/');
}
function ispluginkey($key) {
return preg_match("/^[a-z]+[a-z0-9_]*$/i", $key);
}
function dir_writeable($dir) {
if(!is_dir($dir)) {
@mkdir($dir, 0777);
}
if(is_dir($dir)) {
if($fp = @fopen("$dir/test.txt", 'w')) {
@fclose($fp);
@unlink("$dir/test.txt");
$writeable = 1;
} else {
$writeable = 0;
}
}
return $writeable;
}
function filemtimesort($a, $b) {
if($a['filemtime'] == $b['filemtime']) {
return 0;
}
return ($a['filemtime'] > $b['filemtime']) ? 1 : -1;
}
function checkpermission($action, $break = 1) {
if(!isset($GLOBALS['admincp'])) {
cpmsg('action_access_noexists', '', 'error');
} elseif($break && !$GLOBALS['admincp'][$action]) {
cpmsg('action_noaccess_config', '', 'error');
} else {
return $GLOBALS['admincp'][$action];
}
}
function bbsinformation() {
global $db, $timestamp, $tablepre, $charset, $bbname, $_SERVER, $siteuniqueid, $save_mastermobile, $msn;
$update = array('uniqueid' => $siteuniqueid, 'version' => DISCUZ_VERSION, 'release' => DISCUZ_RELEASE, 'php' => PHP_VERSION, 'mysql' => $db->version(), 'charset' => $charset, 'bbname' => $bbname, 'mastermobile' => $save_mastermobile);
$updatetime = @filemtime(DISCUZ_ROOT.'./forumdata/updatetime.lock');
if(empty($updatetime) || ($timestamp - $updatetime > 3600 * 4)) {
@touch(DISCUZ_ROOT.'./forumdata/updatetime.lock');
$update['members'] = $db->result_first("SELECT COUNT(*) FROM {$tablepre}members");
$update['threads'] = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads");
$update['posts'] = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts");
$query = $db->query("SELECT special, count(*) AS spcount FROM {$tablepre}threads GROUP BY special");
while($thread = $db->fetch_array($query)) {
$thread['special'] = intval($thread['special']);
$update['spt_'.$thread['special']] = $thread['spcount'];
}
if($msn['on'] && $msn['domain']) {
$update['msn_domain'] = $msn['domain'];
}
}
$data = '';
foreach($update as $key => $value) {
$data .= $key.'='.rawurlencode($value).'&';
}
return 'update='.rawurlencode(base64_encode($data)).'&md5hash='.substr(md5($_SERVER['HTTP_USER_AGENT'].implode('', $update).$timestamp), 8, 8).'×tamp='.$timestamp;
}
function isfounder($user = '') {
$user = empty($user) ? array('uid' => $GLOBALS['discuz_uid'], 'adminid' => $GLOBALS['adminid'], 'username' => $GLOBALS['discuz_userss']) : $user;
$founders = str_replace(' ', '', $GLOBALS['forumfounders']);
if($user['adminid'] <> 1) {
return FALSE;
} elseif(empty($founders)) {
return TRUE;
} elseif(strexists(",$founders,", ",$user[uid],")) {
return TRUE;
} elseif(!is_numeric($user['username']) && strexists(",$founders,", ",$user[username],")) {
return TRUE;
} else {
return FALSE;
}
}
function lang($name, $force = true) {
global $lang;
return isset($lang[$name]) ? $lang[$name] : ($force ? $name : '');
}
function admincustom($title, $url, $sort = 0) {
global $db, $tablepre, $discuz_uid, $timestamp, $BASESCRIPT;
$url = $BASESCRIPT.'?'.$url;
$id = $db->result_first("SELECT id FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='$sort' AND url='$url'");
if($id) {
$db->query("UPDATE {$tablepre}admincustom SET title='$title', clicks=clicks+1, dateline='$timestamp' WHERE id='$id'");
} else {
$db->query("INSERT INTO {$tablepre}admincustom (title, url, sort, uid, dateline) VALUES ('$title', '$url', '$sort', '$discuz_uid', '$timestamp')");
$id = $db->insert_id();
}
return $id;
}
function cpurl($type = 'parameter', $filters = array('sid', 'frames')) {
parse_str($_SERVER['QUERY_STRING'], $getarray);
$extra = $and = '';
foreach($getarray as $key => $value) {
if(!in_array($key, $filters)) {
@$extra .= $and.$key.($type == 'parameter' ? '%3D' : '=').rawurlencode($value);
$and = $type == 'parameter' ? '%26' : '&';
}
}
return $extra;
}
function showheader($key, $url) {
echo '<li><em><a href="javascript:;" id="header_'.$key.'" hidefocus="true" onclick="toggleMenu(\''.$key.'\', \''.$url.'\');">'.lang('header_'.$key).'</a></em></li>';
}
function shownav($header = '', $menu = '', $nav = '') {
global $action, $operation, $BASESCRIPT;
$title = 'cplog_'.$action.($operation ? '_'.$operation : '');
if(in_array($action, array('home', 'custommenu'))) {
$customtitle = '';
} elseif(lang($title, false)) {
$customtitle = $title;
} elseif(lang('nav_'.($header ? $header : 'index'), false)) {
$customtitle = 'nav_'.$header;
} else {
$customtitle = rawurlencode($nav ? $nav : ($menu ? $menu : ''));
}
echo '<script type="text/JavaScript">if(parent.$(\'admincpnav\')) parent.$(\'admincpnav\').innerHTML=\''.lang('nav_'.($header ? $header : 'index')).
($menu ? ' » '.lang($menu) : '').
($nav ? ' » '.lang($nav) : '').'\';'.
'if(parent.$(\'add2custom\')) parent.$(\'add2custom\').innerHTML='.($customtitle ? '\'<a href="'.$BASESCRIPT.'?action=misc&operation=custommenu&do=add&title='.$customtitle.'&url='.cpurl().'" target="main"><img src="images/admincp/btn_add2menu.gif" title="'.lang('custommenu_add').'" width="19" height="18" /></a>\';' : '\'\';').
($customtitle ? 'if(parent.$(\'custombar_add\')) parent.$(\'custombar_add\').innerHTML='.($customtitle ? '\'<span onclick="ajaxget(\\\''.$BASESCRIPT.'?action=misc&operation=custombar&title='.$customtitle.'&url='.cpurl().'\\\', \\\'custombar\\\', \\\'\\\', \\\'\\\', \\\'\\\', function () { top.custombar_resize();});" title="'.lang('custombar_add_tips').'" /> '.lang('custombar_add').'</span>\';' : '\'\';') : '').
'top.custombar_resize();'.
'</script>';
}
function showmenu($key, $menus) {
global $BASESCRIPT;
echo '<ul id="menu_'.$key.'" style="display: none">';
if(is_array($menus)) {
foreach($menus as $menu) {
if($menu[0] && $menu[1]) {
echo '<li><a href="'.(substr($menu[1], 0, 4) == 'http' ? $menu[1] : $BASESCRIPT.'?action='.$menu[1]).'" hidefocus="true" target="'.($menu[2] ? $menu[2] : 'main').'"'.($menu[3] ? $menu[3] : '').'>'.lang($menu[0]).'</a></li>';
}
}
}
echo '</ul>';
}
function cpmsg($message, $url = '', $type = '', $extra = '', $halt = TRUE) {
extract($GLOBALS, EXTR_SKIP);
include language('admincp.msg');
$vars = explode(':', $message);
if(count($vars) == 2 && isset($scriptlang[$vars[0]][$vars[1]])) {
@eval("\$message = \"".str_replace('"', '\"', $scriptlang[$vars[0]][$vars[1]])."\";");
} else {
@eval("\$message = \"".(isset($msglang[$message]) ? $msglang[$message] : $message)."\";");
}
switch($type) {
case 'succeed': $classname = 'infotitle2';break;
case 'error': $classname = 'infotitle3';break;
case 'loading': $classname = 'infotitle1';break;
default: $classname = 'marginbot normal';break;
}
$message = "<h4 class=\"$classname\">$message</h4>";
$url .= !empty($scrolltop) ? '&scrolltop='.intval($scrolltop) : '';
if($type == 'form') {
$message = "<form method=\"post\" action=\"$url\"><input type=\"hidden\" name=\"formhash\" value=\"".FORMHASH."\">".
"<br />$message$extra<br />".
"<p class=\"margintop\"><input type=\"submit\" class=\"btn\" name=\"confirmed\" value=\"$lang[ok]\"> \n".
"<input type=\"button\" class=\"btn\" value=\"$lang[cancel]\" onClick=\"history.go(-1);\"></p></form><br />";
} elseif($type == 'loadingform') {
$message = "<form method=\"post\" action=\"$url\" id=\"loadingform\"><input type=\"hidden\" name=\"formhash\" value=\"".FORMHASH."\"><br />$message$extra<img src=\"images/admincp/ajax_loader.gif\" class=\"marginbot\" /><br />".
'<p class="marginbot"><a href="###" onclick="$(\'loadingform\').submit();return false;" class="lightlink">'.lang('message_redirect').'</a></p></form><br /><script type="text/JavaScript">setTimeout("$(\'loadingform\').submit();", 2000);</script>';
} else {
$message .= $extra.($type == 'loading' ? '<img src="images/admincp/ajax_loader.gif" class="marginbot" />' : '');
if($url) {
if($type == 'button') {
$message = "<br />$message<br /><p class=\"margintop\"><input type=\"submit\" class=\"btn\" name=\"submit\" value=\"$lang[start]\" onclick=\"location.href='$url'\" />";
} else {
$message .= '<p class="marginbot"><a href="'.$url.'" class="lightlink">'.lang('message_redirect').'</a></p>';
$url = transsid($url);
$message .= "<script type=\"text/JavaScript\">setTimeout(\"redirect('$url');\", 2000);</script>";
}
} elseif(strpos($message, $lang['return'])) {
$message .= '<p class="marginbot"><a href="javascript:history.go(-1);" class="lightlink">'.lang('message_return').'</a></p>';
}
}
if($halt) {
echo '<h3>'.lang('discuz_message').'</h3><div class="infobox">'.$message.'</div>';
cpfooter();
dexit();
} else {
echo '<div class="infobox">'.$message.'</div>';
}
}
function cpheader() {
global $charset, $frame, $BASESCRIPT;
if(!defined('DISCUZ_CP_HEADER_OUTPUT')) {
define('DISCUZ_CP_HEADER_OUTPUT', true);
} else {
return true;
}
$IMGDIR = IMGDIR;
$STYLEID = STYLEID;
$VERHASH = VERHASH;
$frame = $frame != 'no' ? 1 : 0;
echo <<< EOT
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=$charset">
<meta http-equiv="x-ua-compatible" content="ie=7" />
<link href="./images/admincp/admincp.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script type="text/JavaScript">
var admincpfilename = '$BASESCRIPT', IMGDIR = '$IMGDIR', STYLEID = '$STYLEID', VERHASH = '$VERHASH', IN_ADMINCP = true, ISFRAME = $frame;
</script>
<script src="include/js/common.js" type="text/javascript"></script>
<script src="images/admincp/admincp.js" type="text/javascript"></script>
<script type="text/javascript">
if(ISFRAME && !parent.document.getElementById('leftmenu')) {
redirect(admincpfilename + '?frames=yes&' + document.URL.substr(document.URL.indexOf(admincpfilename) + 12));
}
</script>
<div id="append_parent"></div>
<div class="container" id="cpcontainer">
EOT;
}
function showsubmenu($title, $menus = array(), $right = '') {
global $BASESCRIPT;
if(empty($menus)) {
$s = '<div class="itemtitle">'.$right.'<h3>'.lang($title).'</h3></div>';
} elseif(is_array($menus)) {
$s = '<div class="itemtitle">'.$right.'<h3>'.lang($title).'</h3>';
if(is_array($menus)) {
$s .= '<ul class="tab1">';
foreach($menus as $k => $menu) {
if(is_array($menu[0])) {
$s .= '<li id="addjs'.$k.'" class="'.($menu[2] ? ' current' : 'hasdropmenu').'" onmouseover="dropmenu(this);"><a href="#"><span>'.lang($menu[0]['menu']).'<em> </em></span></a><div id="addjs'.$k.'child" class="dropmenu" style="display:none;">';
if(is_array($menu[0]['submenu'])) {
foreach($menu[0]['submenu'] as $submenu) {
$s .= '<a href="'.$BASESCRIPT.'?action='.$submenu[1].'">'.lang($submenu[0]).'</a>';
}
}
$s .= '</div></li>';
} else {
$s .= '<li'.($menu[2] ? ' class="current"' : '').'><a href="'.$BASESCRIPT.'?action='.$menu[1].'"'.($menu[3] ? ' target="_blank"' : '').'><span>'.lang($menu[0]).'</span></a></li>';
}
}
$s .= '</ul>';
}
$s .= '</div>';
}
echo !empty($menus) ? '<div class="floattop">'.$s.'</div><div class="floattopempty"></div>' : $s;
}
function showsubmenusteps($title, $menus = array()) {
$s = '<div class="itemtitle">'.($title ? '<h3>'.lang($title).'</h3>' : '');
if(is_array($menus)) {
$s .= '<ul class="stepstat">';
$i = 0;
foreach($menus as $menu) {
$i++;
$s .= '<li'.($menu[1] ? ' class="current"' : '').' id="step'.$i.'">'.$i.'.'.lang($menu[0]).'</li>';
}
$s .= '</ul>';
}
$s .= '</div>';
echo $s;
}
function showsubmenuanchors($title, $menus = array(), $right = '') {
global $BASESCRIPT;
if(!$title || !$menus || !is_array($menus)) {
return;
}
echo <<<EOT
<script type="text/JavaScript">var currentAnchor = '$GLOBALS[anchor]';</script>
EOT;
$s = '<div class="itemtitle">'.$right.'<h3>'.lang($title).'</h3>';
$s .= '<ul class="tab1" id="submenu">';
foreach($menus as $menu) {
if($menu && is_array($menu)) {
$s .= '<li'.(!$menu[3] ? ' id="nav_'.$menu[1].'" onclick="showanchor(this)"' : '').($menu[2] ? ' class="current"' : '').'><a href="'.($menu[3] ? $BASESCRIPT.'?action='.$menu[1] : '#').'"><span>'.lang($menu[0]).'</span></a></li>';
}
}
$s .= '</ul>';
$s .= '</div>';
echo !empty($menus) ? '<div class="floattop">'.$s.'</div><div class="floattopempty"></div>' : $s;
echo '<script type="text/JavaScript">'.
'if(parent.$(\'custombar_add\')) parent.$(\'custombar_add\').innerHTML=\'<span onclick="ajaxget(\\\''.$BASESCRIPT.'?action=misc&operation=custombar&title='.rawurlencode($title).'&url='.cpurl().'\\\', \\\'custombar\\\', \\\'\\\', \\\'\\\', \\\'\\\', function () { top.custombar_resize();});doane(event);" title="'.lang('custombar_add_tips').'" /> '.lang('custombar_add').'</span>\';'.
'top.custombar_resize();'.
'</script>';
}
function showtips($tips, $id = 'tips', $display = TRUE) {
extract($GLOBALS, EXTR_SKIP);
if(lang($tips, false)) {
eval('$tips = "'.str_replace('"', '\\"', $lang[$tips]).'";');
}
$tmp = explode('</li><li>', substr($tips, 4, -5));
if(count($tmp) > 4) {
$tips = '<li>'.$tmp[0].'</li><li>'.$tmp[1].'</li><li id="'.$id.'_more" style="border: none; background: none; margin-bottom: 6px;"><a href="###" onclick="var tiplis = $(\''.$id.'lis\').getElementsByTagName(\'li\');for(var i = 0; i < tiplis.length; i++){tiplis[i].style.display=\'\'}$(\''.$id.'_more\').style.display=\'none\';">'.lang('tips_all').'...</a></li>';
foreach($tmp AS $k => $v) {
if($k > 1) {
$tips .= '<li style="display: none">'.$v.'</li>';
}
}
}
unset($tmp);
showtableheader('tips', '', 'id="'.$id.'"'.(!$display ? ' style="display: none;"' : ''), 0);
showtablerow('', 'class="tipsblock"', '<ul id="'.$id.'lis">'.$tips.'</ul>');
showtablefooter();
}
function showformheader($action, $extra = '', $name = 'cpform') {
global $BASESCRIPT;
echo '<form name="'.$name.'" method="post" action="'.$BASESCRIPT.'?action='.$action.'" id="'.$name.'"'.($extra == 'enctype' ? ' enctype="multipart/form-data"' : " $extra").'>'.
'<input type="hidden" name="formhash" value="'.FORMHASH.'" />'.
'<input type="hidden" id="formscrolltop" name="scrolltop" value="" />'.
'<input type="hidden" name="anchor" value="'.htmlspecialchars($GLOBALS['anchor']).'" />';
}
function showhiddenfields($hiddenfields = array()) {
if(is_array($hiddenfields)) {
foreach($hiddenfields as $key => $val) {
$val = is_string($val) ? htmlspecialchars($val) : $val;
echo "\n<input type=\"hidden\" name=\"$key\" value=\"$val\">";
}
}
}
function showtableheader($title = '', $classname = '', $extra = '', $titlespan = 15) {
$classname = str_replace(array('nobottom', 'notop'), array('nobdb', 'nobdt'), $classname);
echo "\n".'<table class="tb tb2 '.$classname.'"'.($extra ? " $extra" : '').'>';
if($title) {
$span = $titlespan ? 'colspan="'.$titlespan.'"' : '';
echo "\n".'<tr><th '.$span.' class="partition">'.lang($title).'</th></tr>';
}
}
function showtagheader($tagname, $id, $display = FALSE, $classname = '') {
echo '<'.$tagname.($classname ? " class=\"$classname\"" : '').' id="'.$id.'"'.($display ? '' : ' style="display: none"').'>';
}
function showtitle($title, $extra = '') {
echo "\n".'<tr'.($extra ? " $extra" : '').'><th colspan="15" class="partition">'.lang($title).'</th></tr>';
}
function showsubtitle($title = array(), $rowclass='header') {
if(is_array($title)) {
$subtitle = "\n<tr class=\"$rowclass\">";
foreach($title as $v) {
if($v !== NULL) {
$subtitle .= '<th>'.lang($v).'</th>';
}
}
$subtitle .= '</tr>';
echo $subtitle;
}
}
function showtablerow($trstyle = '', $tdstyle = array(), $tdtext = array(), $return = FALSE) {
if(!preg_match('/class\s*=\s*[\'"]([^\'"<>]+)[\'"]/i', $trstyle, $matches)) {
$rowswapclass = is_array($tdtext) && count($tdtext) > 2 ? ' class="hover"' : '';
} else {
if(is_array($tdtext) && count($tdtext) > 2) {
$rowswapclass = " class=\"{$matches[1]} hover\"";
$trstyle = preg_replace('/class\s*=\s*[\'"]([^\'"<>]+)[\'"]/i', '', $trstyle);
}
}
$cells = "\n".'<tr'.($trstyle ? ' '.$trstyle : '').$rowswapclass.'>';
if(isset($tdtext)) {
if(is_array($tdtext)) {
foreach($tdtext as $key => $td) {
$cells .= '<td'.(is_array($tdstyle) && !empty($tdstyle[$key]) ? ' '.$tdstyle[$key] : '').'>'.$td.'</td>';
}
} else {
$cells .= '<td'.(!empty($tdstyle) && is_string($tdstyle) ? ' '.$tdstyle : '').'>'.$tdtext.'</td>';
}
}
$cells .= '</tr>';
if($return) {
return $cells;
}
echo $cells;
}
function showsetting($setname, $varname, $value, $type = 'radio', $disabled = '', $hidden = 0, $comment = '', $extra = '') {
$s = "\n";
$check = array();
$check['disabled'] = $disabled ? ' disabled' : '';
if($type == 'radio') {
$value ? $check['true'] = "checked" : $check['false'] = "checked";
$value ? $check['false'] = '' : $check['true'] = '';
$check['hidden1'] = $hidden ? ' onclick="$(\'hidden_'.$setname.'\').style.display = \'\';"' : '';
$check['hidden0'] = $hidden ? ' onclick="$(\'hidden_'.$setname.'\').style.display = \'none\';"' : '';
$s .= '<ul onmouseover="altStyle(this);">'.
'<li'.($check['true'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="'.$varname.'" value="1" '.$check['true'].$check['hidden1'].$check['disabled'].'> '.lang('yes').'</li>'.
'<li'.($check['false'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="'.$varname.'" value="0" '.$check['false'].$check['hidden0'].$check['disabled'].'> '.lang('no').'</li>'.
'</ul>';
} elseif($type == 'text' || $type == 'password' || $type == 'number') {
$s .= '<input name="'.$varname.'" value="'.dhtmlspecialchars($value).'" type="'.$type.'" class="txt" '.$check['disabled'].' '.$extra.' />';
} elseif($type == 'file') {
$s .= '<input name="'.$varname.'" value="" type="file" class="txt uploadbtn marginbot" '.$check['disabled'].' '.$extra.' />';
} elseif($type == 'textarea') {
$readonly = $disabled ? 'readonly' : '';
$s .= "<textarea $readonly rows=\"6\" ondblclick=\"textareasize(this, 1)\" onkeyup=\"textareasize(this, 0)\" name=\"$varname\" id=\"$varname\" cols=\"50\" class=\"tarea\" '.$extra.'>".dhtmlspecialchars($value)."</textarea>";
} elseif($type == 'select') {
$s .= '<select name="'.$varname[0].'" '.$extra.'>';
foreach($varname[1] as $option) {
$selected = $option[0] == $value ? 'selected="selected"' : '';
$s .= "<option value=\"$option[0]\" $selected>".$option[1]."</option>\n";
}
$s .= '</select>';
} elseif($type == 'mradio') {
if(is_array($varname)) {
$radiocheck = array($value => ' checked');
$s .= '<ul'.(empty($varname[2]) ? ' class="nofloat"' : '').' onmouseover="altStyle(this);">';
foreach($varname[1] as $varary) {
if(is_array($varary) && !empty($varary)) {
$onclick = '';
if(!empty($varary[2])) {
foreach($varary[2] as $ctrlid => $display) {
$onclick .= '$(\''.$ctrlid.'\').style.display = \''.$display.'\';';
}
}
$onclick && $onclick = ' onclick="'.$onclick.'"';
$s .= '<li'.($radiocheck[$varary[0]] ? ' class="checked"' : '').'><input class="radio" type="radio" name="'.$varname[0].'" value="'.$varary[0].'"'.$radiocheck[$varary[0]].$check['disabled'].$onclick.'> '.$varary[1].'</li>';
}
}
$s .= '</ul>';
}
} elseif($type == 'mcheckbox') {
$s .= '<ul class="nofloat" onmouseover="altStyle(this);">';
foreach($varname[1] as $varary) {
if(is_array($varary) && !empty($varary)) {
$onclick = !empty($varary[2]) ? ' onclick="$(\''.$varary[2].'\').style.display = $(\''.$varary[2].'\').style.display == \'none\' ? \'\' : \'none\';"' : '';
$checked = is_array($value) && in_array($varary[0], $value) ? ' checked' : '';
$s .= '<li'.($checked ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="'.$varname[0].'[]" value="'.$varary[0].'"'.$checked.$check['disabled'].$onclick.'> '.$varary[1].'</li>';
}
}
$s .= '</ul>';
} elseif($type == 'binmcheckbox') {
$checkboxs = count($varname[1]);
$value = sprintf('%0'.$checkboxs.'b', $value);$i = 1;
$s .= '<ul class="nofloat" onmouseover="altStyle(this);">';
foreach($varname[1] as $key => $var) {
$s .= '<li'.($value{$checkboxs - $i} ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="'.$varname[0].'['.$i.']" value="1"'.($value{$checkboxs - $i} ? ' checked' : '').' '.(!empty($varname[2][$key]) ? $varname[2][$key] : '').'> '.$var.'</li>';
$i++;
}
$s .= '</ul>';
} elseif($type == 'mselect') {
$s .= '<select name="'.$varname[0].'" multiple="multiple" size="10" '.$extra.'>';
foreach($varname[1] as $option) {
$selected = is_array($value) && in_array($option[0], $value) ? 'selected="selected"' : '';
$s .= "<option value=\"$option[0]\" $selected>".$option[1]."</option>\n";
}
$s .= '</select>';
} elseif($type == 'color') {
global $stylestuff;
$preview_varname = str_replace('[', '_', str_replace(']', '', $varname));
$code = explode(' ', $value);
$css = '';
for($i = 0; $i <= 1; $i++) {
if($code[$i] != '') {
if($code[$i]{0} == '#') {
$css .= strtoupper($code[$i]).' ';
} elseif(preg_match('/^http:\/\//i', $code[$i])) {
$css .= 'url(\''.$code[$i].'\') ';
} else {
$css .= 'url(\''.$stylestuff['imgdir']['subst'].'/'.$code[$i].'\') ';
}
}
}
$background = trim($css);
$colorid = ++$GLOBALS['coloridcount'];
$s .= "<input id=\"c{$colorid}_v\" type=\"text\" class=\"txt\" style=\"float:left; width:200px;\" value=\"$value\" name=\"$varname\" onchange=\"updatecolorpreview('c{$colorid}')\">\n".
"<input id=\"c$colorid\" onclick=\"c{$colorid}_frame.location='images/admincp/getcolor.htm?c{$colorid}';showMenu({'ctrlid':'c$colorid'})\" type=\"button\" class=\"colorwd\" value=\"\" style=\"background: $background\"><span id=\"c{$colorid}_menu\" style=\"display: none\"><iframe name=\"c{$colorid}_frame\" src=\"\" frameborder=\"0\" width=\"166\" height=\"186\" scrolling=\"no\"></iframe></span>\n$extra";
} elseif($type == 'calendar') {
$s .= "<input type=\"text\" class=\"txt\" name=\"$varname\" value=\"".dhtmlspecialchars($value)."\" onclick=\"showcalendar(event, this".($extra ? ', 1' : '').")\">\n";
} elseif(in_array($type, array('multiply', 'range', 'daterange'))) {
$onclick = $type == 'daterange' ? ' onclick="showcalendar(event, this)"' : '';
$s .= "<input type=\"text\" class=\"txt\" name=\"$varname[0]\" value=\"".dhtmlspecialchars($value[0])."\" style=\"width: 108px; margin-right: 5px;\"$onclick>".($type == 'multiply' ? ' X ' : ' -- ')."<input type=\"text\" class=\"txt\" name=\"$varname[1]\" value=\"".dhtmlspecialchars($value[1])."\"class=\"txt\" style=\"width: 108px; margin-left: 5px;\"$onclick>";
} else {
$s .= $type;
}
showtablerow('', 'colspan="2" class="td27"', lang($setname));
showtablerow('class="noborder"', array('class="vtop rowform"', 'class="vtop tips2"'), array(
$s,
($comment ? $comment : lang($setname.'_comment', 0)).($type == 'textarea' ? '<br />'.lang('tips_textarea') : '').
($disabled ? '<br /><span class="smalltxt" style="color:#FF0000">'.lang($setname.'_disabled', 0).'</span>' : NULL)
));
if($hidden) {
showtagheader('tbody', 'hidden_'.$setname, $value, 'sub');
}
}
function mradio($name, $items = array(), $checked = '', $float = TRUE) {
$list = '<ul'.($float ? '' : ' class="nofloat"').' onmouseover="altStyle(this);">';
if(is_array($items)) {
foreach($items as $value => $item) {
$list .= '<li'.($checked == $value ? ' class="checked"' : '').'><input type="radio" name="'.$name.'" value="'.$value.'" class="radio"'.($checked == $value ? ' checked="checked"' : '').' /> '.$item.'</li>';
}
}
$list .= '</ul>';
return $list;
}
function mcheckbox($name, $items = array(), $checked = array()) {
$list = '<ul class="dblist" onmouseover="altStyle(this);">';
if(is_array($items)) {
foreach($items as $value => $item) {
$list .= '<li'.(empty($checked) || in_array($value, $checked) ? ' class="checked"' : '').'><input type="checkbox" name="'.$name.'[]" value="'.$value.'" class="checkbox"'.(empty($checked) || in_array($value, $checked) ? ' checked="checked"' : '').' /> '.$item.'</li>';
}
}
$list .= '</ul>';
return $list;
}
function showsubmit($name = '', $value = 'submit', $before = '', $after = '', $floatright = '') {
$str = '<tr>';
$str .= $name && in_array($before, array('del', 'select_all', 'td')) ? '<td class="td25">'.($before != 'td' ? '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'delete\')" /><label for="chkall">'.lang($before) : '').'</label></td>' : '';
$str .= '<td colspan="15">';
$str .= $floatright ? '<div class="cuspages right">'.$floatright.'</div>' : '';
$str .= '<div class="fixsel">';
$str .= $before && !in_array($before, array('del', 'select_all', 'td')) ? $before.' ' : '';
$str .= $name ? '<input type="submit" class="btn" id="submit_'.$name.'" name="'.$name.'" title="'.lang('submit_tips').'" value="'.lang($value).'" />' : '';
$after = $after == 'more_options' ? '<input class="checkbox" type="checkbox" value="1" onclick="$(\'advanceoption\').style.display = $(\'advanceoption\').style.display == \'none\' ? \'\' : \'none\'; this.value = this.value == 1 ? 0 : 1; this.checked = this.value == 1 ? false : true" id="btn_more" /><label for="btn_more">'.lang('more_options').'</label>' : $after;
$str = $after ? $str.(($before && $before != 'del') || $name ? ' ' : '').$after : $str;
$str .= '</div></td>';
$str .= '</tr>';
echo $str.($name ? '<script type="text/JavaScript">_attachEvent(document.documentElement, \'keydown\', function (e) { entersubmit(e, \''.$name.'\'); });</script>' : '');
}
function showtagfooter($tagname) {
echo '</'.$tagname.'>';
}
function showtablefooter() {
echo '</table>'."\n";
}
function showformfooter() {
global $scrolltop;
echo '</form>'."\n";
if($scrolltop) {
echo '<script type="text/JavaScript">_attachEvent(window, \'load\', function () { scroll(0,'.intval($scrolltop).') }, document);</script>';
}
}
function cpfooter() {
global $version, $adminid, $db, $tablepre, $action, $bbname, $charset, $timestamp, $isfounder, $dbcharset;
?>
</div>
</body>
<?php
if($_GET['highlight']) {
$kws = explode(' ', $_GET['highlight']);
echo '<script type="text/JavaScript">';
foreach($kws as $kw) {
echo 'parsetag(\''.$kw.'\');';
}
echo '</script>';
}
?>
</html>
<?
if($adminid == 1 && $action == 'home') {
echo '<img src="admincp.php?action=misc&operation=checkstat" width="0" height="0">';
$newsurl = 'ht'.'tp:/'.'/cus'.'tome'.'r.disc'.'uz.n'.'et/n'.'ews'.'.p'.'hp?'.bbsinformation();
//$newsurl = 'http://localhost/com/n'.'ews'.'.p'.'hp?'.bbsinformation();
?>
<script type="text/javascript">
var newhtml = '';
newhtml += '<table class="tb tb2"><tr><th class="partition edited">您当前使用的 Discuz! 程序版本有重要更新,请参照以下提示进行及时升级</th></tr>';
newhtml += '<tr><td class="tipsblock"><a href="http://faq.comsenz.com/checkversion.php?product=Discuz&version=<?=DISCUZ_VERSION?>&release=<?=DISCUZ_RELEASE?>&charset=<?=$charset?>&dbcharset=<?=$dbcharset?>" target="_blank"><img src="<?=$newsurl?>" onload="shownews()" /></a></td></tr></table>';
$('boardnews').style.display = 'none';
$('boardnews').innerHTML = newhtml;
function shownews() {
$('boardnews').style.display = '';
}
</script>
<?php
}
updatesession();
}
if(!function_exists('ajaxshowheader')) {
function ajaxshowheader() {
global $charset, $inajax;
ob_end_clean();
@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
header("Content-type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"$charset\"?>\n<root><![CDATA[";
}
}
if(!function_exists('ajaxshowfooter')) {
function ajaxshowfooter() {
echo ']]></root>';
}
}
function checkacpaction($action, $operation = '', $halt = true) {
global $radminid, $groupid, $dactionarray;
$ret = ($dactionarray && ($radminid != $groupid) && (in_array($action, $dactionarray) || ($operation && in_array($action.'_'.$operation, $dactionarray)))) ? false : true;
if($halt && !$ret || in_array('_readonly', $dactionarray) && !empty($_POST)) {
cpheader();
cpmsg('action_noaccess');
}
return $ret;
}
function showimportdata() {
showsetting('import_type', array('importtype', array(
array('file', lang('import_type_file'), array('importfile' => '', 'importtxt' => 'none')),
array('txt', lang('import_type_txt'), array('importfile' => 'none', 'importtxt' => ''))
)), 'file', 'mradio');
showtagheader('tbody', 'importfile', TRUE);
showsetting('import_file', 'importfile', '', 'file');
showtagfooter('tbody');
showtagheader('tbody', 'importtxt');
showsetting('import_txt', 'importtxt', '', 'textarea');
showtagfooter('tbody');
}
function getimportdata($name = '', $addslashes = 1, $ignoreerror = 0) {
if($GLOBALS['importtype'] == 'file') {
$data = @implode('', file($_FILES['importfile']['tmp_name']));
@unlink($_FILES['importfile']['tmp_name']);
} else {
$data = $_POST['importtxt'] && MAGIC_QUOTES_GPC ? stripslashes($_POST['importtxt']) : $GLOBALS['importtxt'];
}
include_once DISCUZ_ROOT.'./include/xml.class.php';
$xmldata = xml2array($data);
if(!is_array($xmldata) || !$xmldata) {
if($name && !strexists($data, '# '.$name)) {
if(!$ignoreerror) {
cpmsg('import_data_typeinvalid', '', 'error');
} else {
return array();
}
}
$data = preg_replace("/(#.*\s+)*/", '', $data);
$data = unserialize(base64_decode($data));
if(!is_array($data) || !$data) {
if(!$ignoreerror) {
cpmsg('import_data_invalid', '', 'error');
} else {
return array();
}
}
} else {
if($name && $name != $xmldata['Title']) {
if(!$ignoreerror) {
cpmsg('import_data_typeinvalid', '', 'error');
} else {
return array();
}
}
$data = exportarray($xmldata['Data'], 0);
}
if($addslashes) {
$data = daddslashes($data, 1);
}
return $data;
}
function exportdata($name, $filename, $data) {
include_once DISCUZ_ROOT.'./include/xml.class.php';
$root = array(
'Title' => $name,
'Version' => $GLOBALS['version'],
'Time' => gmdate("Y-m-d H:i", $GLOBALS['timestamp'] + $GLOBALS['timeoffset'] * 3600),
'From' => $GLOBALS['bbname'].' ('.$GLOBALS['boardurl'].')',
'Data' => exportarray($data, 1)
);
$filename = strtolower(str_replace(array('!', ' '), array('', '_'), $name)).'_'.$filename.'.xml';
$plugin_export = array2xml($root, 1);
ob_end_clean();
dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
dheader('Cache-Control: no-cache, must-revalidate');
dheader('Pragma: no-cache');
dheader('Content-Encoding: none');
dheader('Content-Length: '.strlen($plugin_export));
dheader('Content-Disposition: attachment; filename='.$filename);
dheader('Content-Type: text/xml');
echo $plugin_export;
exit();
}
function exportarray($array, $method) {
$tmp = $array;
if($method) {
foreach($array as $k => $v) {
if(is_array($v)) {
$tmp[$k] = exportarray($v, 1);
} else {
$uv = unserialize($v);
if($uv && is_array($uv)) {
$tmp['__'.$k] = exportarray($uv, 1);
unset($tmp[$k]);
} else {
$tmp[$k] = $v;
}
}
}
} else {
foreach($array as $k => $v) {
if(is_array($v)) {
if(substr($k, 0, 2) == '__') {
$tmp[substr($k, 2)] = serialize(exportarray($v, 0));
unset($tmp[$k]);
} else {
$tmp[$k] = exportarray($v, 0);
}
} else {
$tmp[$k] = $v;
}
}
}
return $tmp;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/global.func.php | PHP | asf20 | 33,273 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: moderate.inc.php 20913 2009-10-29 08:51:23Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
cpheader();
if($operation == 'members') {
$do = empty($do) ? 'mod' : $do;
if($do == 'mod') {
if(!submitcheck('modsubmit')) {
$query = $db->query("SELECT status, COUNT(*) AS count FROM {$tablepre}validating GROUP BY status");
while($num = $db->fetch_array($query)) {
$count[$num['status']] = $num['count'];
}
$sendemail = isset($sendemail) ? $sendemail : 1;
$checksendemail = $sendemail ? 'checked' : '';
$page = max(1, intval($page));
$start_limit = ($page - 1) * $memberperpage;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}validating WHERE status='0'");
$multipage = multi($db->result($query, 0), $memberperpage, $page, $BASESCRIPT.'?action=moderate&operation=members&sendemail=$sendemail');
$vuids = '0';
$members = '';
$query = $db->query("SELECT m.uid, m.username, m.groupid, m.email, m.regdate, m.regip, v.message, v.submittimes, v.submitdate, v.moddate, v.admin, v.remark
FROM {$tablepre}validating v, {$tablepre}members m
WHERE v.status='0' AND m.uid=v.uid ORDER BY v.submitdate DESC LIMIT $start_limit, $memberperpage");
while($member = $db->fetch_array($query)) {
if($member['groupid'] != 8) {
$vuids .= ','.$member['uid'];
continue;
}
$member['regdate'] = gmdate("$dateformat $timeformat", $member['regdate'] + $timeoffset * 3600);
$member['submitdate'] = gmdate("$dateformat $timeformat", $member['submitdate'] + $timeoffset * 3600);
$member['moddate'] = $member['moddate'] ? gmdate("$dateformat $timeformat", $member['moddate'] + $timeoffset * 3600) : $lang['none'];
$member['admin'] = $member['admin'] ? "<a href=\"space.php?username=".rawurlencode($member['admin'])."\" target=\"_blank\">$member[admin]</a>" : $lang['none'];
$members .= "<tr class=\"smalltxt\"><td><input class=\"radio\" type=\"radio\" name=\"mod[$member[uid]]\" value=\"invalidate\"> $lang[invalidate]<br /><input class=\"radio\" type=\"radio\" name=\"mod[$member[uid]]\" value=\"validate\" checked> $lang[validate]<br />\n".
"<input class=\"radio\" type=\"radio\" name=\"mod[$member[uid]]\" value=\"delete\"> $lang[delete]<br /><input class=\"radio\" type=\"radio\" name=\"mod[$member[uid]]\" value=\"ignore\"> $lang[ignore]</td><td><b><a href=\"space.php?uid=$member[uid]\" target=\"_blank\">$member[username]</a></b>\n".
"<br />$lang[members_edit_regdate] $member[regdate]<br />$lang[members_edit_regip] $member[regip]<br />Email: $member[email]</td>\n".
"<td align=\"center\"><textarea rows=\"4\" name=\"remark[$member[uid]]\" style=\"width: 95%; word-break: break-all\">$member[message]</textarea></td>\n".
"<td>$lang[moderate_members_submit_times]: $member[submittimes]<br />$lang[moderate_members_submit_time]: $member[submitdate]<br />$lang[moderate_members_admin]: $member[admin]<br />\n".
"$lang[moderate_members_mod_time]: $member[moddate]</td><td><textarea rows=\"4\" name=\"remark[$member[uid]]\" style=\"width: 95%; word-break: break-all\">$member[remark]</textarea></td></tr>\n";
}
if($vuids) {
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($vuids)", 'UNBUFFERED');
}
shownav('user', 'nav_modmembers');
showsubmenu('nav_moderate_users', array(
array('nav_moderate_users_mod', 'moderate&operation=members&do=mod', 1),
array('clean', 'moderate&operation=members&do=del', 0)
));
showtips('moderate_members_tips');
showformheader('moderate&operation=members&do=mod');
showtableheader('moderate_members', 'fixpadding');
showsubtitle(array('operation', 'members_edit_info', 'moderate_members_message', 'moderate_members_info', 'moderate_members_remark'));
echo $members;
showsubmit('modsubmit', 'submit', '', '<a href="#all" onclick="checkAll(\'option\', $(\'cpform\'), \'invalidate\')">'.lang('moderate_all_invalidate').'</a> <a href="#all" onclick="checkAll(\'option\', $(\'cpform\'), \'validate\')">'.lang('moderate_all_validate').'</a> <a href="#all" onclick="checkAll(\'option\', $(\'cpform\'), \'delete\')">'.lang('moderate_all_delete').'</a> <a href="#all" onclick="checkAll(\'option\', $(\'cpform\'), \'ignore\')">'.lang('moderate_all_ignore').'</a> <input class="checkbox" type="checkbox" name="sendemail" id="sendemail" value="1" '.$checksendemail.' /><label for="sendemail"> '.lang('moderate_members_email').'</label>', $multipage);
showtablefooter();
showformfooter();
} else {
$moderation = array('invalidate' => array(), 'validate' => array(), 'delete' => array(), 'ignore' => array());
$uids = 0;
if(is_array($mod)) {
foreach($mod as $uid => $act) {
$uid = intval($uid);
$uids .= ','.$uid;
$moderation[$act][] = $uid;
}
}
$members = array();
$uidarray = array(0);
$query = $db->query("SELECT v.*, m.uid, m.username, m.email, m.regdate FROM {$tablepre}validating v, {$tablepre}members m
WHERE v.uid IN ($uids) AND m.uid=v.uid AND m.groupid='8'");
while($member = $db->fetch_array($query)) {
$members[$member['uid']] = $member;
$uidarray[] = $member['uid'];
}
$uids = implode(',', $uidarray);
$numdeleted = $numinvalidated = $numvalidated = 0;
if(!empty($moderation['delete']) && is_array($moderation['delete'])) {
$deleteuids = '\''.implode('\',\'', $moderation['delete']).'\'';
$db->query("DELETE FROM {$tablepre}members WHERE uid IN ($deleteuids) AND uid IN ($uids)");
$numdeleted = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($deleteuids) AND uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($deleteuids) AND uid IN ($uids)");
} else {
$moderation['delete'] = array();
}
if(!empty($moderation['validate']) && is_array($moderation['validate'])) {
$newgroupid = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE creditshigher<=0 AND 0<creditslower LIMIT 1");
$validateuids = '\''.implode('\',\'', $moderation['validate']).'\'';
$db->query("UPDATE {$tablepre}members SET adminid='0', groupid='$newgroupid' WHERE uid IN ($validateuids) AND uid IN ($uids)");
$numvalidated = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($validateuids) AND uid IN ($uids)");
} else {
$moderation['validate'] = array();
}
if(!empty($moderation['invalidate']) && is_array($moderation['invalidate'])) {
foreach($moderation['invalidate'] as $uid) {
$numinvalidated++;
$db->query("UPDATE {$tablepre}validating SET moddate='$timestamp', admin='$discuz_user', status='1', remark='".dhtmlspecialchars($remark[$uid])."' WHERE uid='$uid' AND uid IN ($uids)");
}
} else {
$moderation['invalidate'] = array();
}
if($sendemail) {
foreach(array('delete', 'validate', 'invalidate') as $o) {
foreach($moderation[$o] as $uid) {
if(isset($members[$uid])) {
$member = $members[$uid];
$member['regdate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $member['regdate'] + $_DCACHE['settings']['timeoffset'] * 3600);
$member['submitdate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $member['submitdate'] + $_DCACHE['settings']['timeoffset'] * 3600);
$member['moddate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $timestamp + $_DCACHE['settings']['timeoffset'] * 3600);
$member['operation'] = $o;
$member['remark'] = $remark[$uid] ? dhtmlspecialchars($remark[$uid]) : $lang['none'];
sendmail("$member[username] <$member[email]>", 'moderate_member_subject', 'moderate_member_message');
}
}
}
}
cpmsg('moderate_members_succeed', "$BASESCRIPT?action=moderate&operation=members&page=$page", 'succeed');
}
} elseif($do == 'del') {
if(!submitcheck('prunesubmit', 1)) {
shownav('user', 'nav_modmembers');
showsubmenu('nav_moderate_users', array(
array('nav_moderate_users_mod', 'moderate&operation=members&do=mod', 0),
array('clean', 'moderate&operation=members&do=del', 1)
));
showtips('moderate_members_tips');
showformheader('moderate&operation=members&do=del');
showtableheader('moderate_members_prune');
showsetting('moderate_members_prune_submitmore', 'submitmore', '5', 'text');
showsetting('moderate_members_prune_regbefore', 'regbefore', '30', 'text');
showsetting('moderate_members_prune_modbefore', 'modbefore', '15', 'text');
showsetting('moderate_members_prune_regip', 'regip', '', 'text');
showsubmit('prunesubmit');
showtablefooter();
showformfooter();
} else {
$sql = '1';
$sql .= $submitmore ? " AND v.submittimes>'$submitmore'" : '';
$sql .= $regbefore ? " AND m.regdate<'".($timestamp - $regbefore * 86400)."'" : '';
$sql .= $modbefore ? " AND v.moddate<'".($timestamp - $modbefore * 86400)."'" : '';
$sql .= $regip ? " AND m.regip LIKE '$regip%'" : '';
$query = $db->query("SELECT v.uid FROM {$tablepre}validating v, {$tablepre}members m
WHERE $sql AND m.uid=v.uid AND m.groupid='8'");
if(!$membernum = $db->num_rows($query)) {
cpmsg('members_search_noresults', '', 'error');
} elseif(!$confirmed) {
cpmsg('members_delete_confirm', "$BASESCRIPT?action=moderate&operation=members&do=del&submitmore=".rawurlencode($submitmore)."®before=".rawurlencode($regbefore)."®ip=".rawurlencode($regip)."&prunesubmit=yes", 'form');
} else {
$uids = 0;
while($member = $db->fetch_array($query)) {
$uids .= ','.$member['uid'];
}
$db->query("DELETE FROM {$tablepre}members WHERE uid IN ($uids)");
$numdeleted = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($uids)");
cpmsg('members_delete_succeed', '', 'succeed');
}
}
}
} else {
require_once DISCUZ_ROOT.'./include/forum.func.php';
require_once DISCUZ_ROOT.'./include/post.func.php';
$modfid = !empty($modfid) ? intval($modfid) : 0;
$fids = 0;
$recyclebins = $forumlist = array();
if($adminid == 3) {
$query = $db->query("SELECT m.fid, f.name, f.recyclebin FROM {$tablepre}moderators m LEFT JOIN {$tablepre}forums f ON f.fid=m.fid WHERE m.uid='$discuz_uid'");
while($forum = $db->fetch_array($query)) {
$fids .= ','.$forum['fid'];
$recyclebins[$forum['fid']] = $forum['recyclebin'];
$forumlist[$forum['fid']] = strip_tags($forum['name']);
}
if(empty($forumlist)) {
cpmsg('moderate_posts_no_access_all', '', 'error');
} elseif($modfid && empty($forumlist[$modfid])) {
cpmsg('moderate_posts_no_access_this', '', 'error');
}
} else {
$query = $db->query("SELECT fid, name, recyclebin FROM {$tablepre}forums WHERE status='1' AND type<>'group'");
while($forum = $db->fetch_array($query)) {
$recyclebins[$forum['fid']] = $forum['recyclebin'];
$forumlist[$forum['fid']] = $forum['name'];
}
}
if($modfid) {
$fidadd = array('fids' => "fid='$modfid'", 'and' => ' AND ', 't' => 't.', 'p' => 'p.');
} else {
$fidadd = $fids ? array('fids' => "fid IN ($fids)", 'and' => ' AND ', 't' => 't.', 'p' => 'p.') : array();
}
if(isset($filter) && $filter == 'ignore') {
$displayorder = -3;
$filteroptions = '<option value="normal">'.$lang['moderate_none'].'</option><option value="ignore" selected>'.$lang['moderate_ignore'].'</option>';
} else {
$displayorder = -2;
$filter = 'normal';
$filteroptions = '<option value="normal" selected>'.$lang['moderate_none'].'</option><option value="ignore">'.$lang['moderate_ignore'].'</option>';
}
$forumoptions = '<option value="all"'.(empty($modfid) ? ' selected' : '').'>'.$lang['moderate_all_fields'].'</option>';
foreach($forumlist as $fid => $forumname) {
$selected = $modfid == $fid ? ' selected' : '';
$forumoptions .= '<option value="'.$fid.'" '.$selected.'>'.$forumname.'</option>'."\n";
}
require_once DISCUZ_ROOT.'./include/misc.func.php';
$modreasonoptions = '<option value="">'.$lang['none'].'</option><option value="">--------</option>'.modreasonselect(1);
echo <<<EOT
<style type="text/css">
.mod_validate td{ background: #FFFFFF !important; }
.mod_delete td{ background: #FFEBE7 !important; }
.mod_ignore td{ background: #EEEEEE !important; }
</style>
<script type="text/JavaScript">
function mod_setbg(tid, value) {
$('mod_' + tid + '_row1').className = 'mod_' + value;
$('mod_' + tid + '_row2').className = 'mod_' + value;
$('mod_' + tid + '_row3').className = 'mod_' + value;
}
function mod_setbg_all(value) {
checkAll('option', $('cpform'), value);
var trs = $('cpform').getElementsByTagName('TR');
for(var i in trs) {
if(trs[i].id && trs[i].id.substr(0, 4) == 'mod_') {
trs[i].className = 'mod_' + value;
}
}
}
function attachimg() {}
</script>
EOT;
}
if($operation == 'threads') {
if(!submitcheck('modsubmit')) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$tpp = 10;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$modcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE $fidadd[fids]$fidadd[and] displayorder='$displayorder'");
$multipage = multi($modcount, $tpp, $page, "$BASESCRIPT?action=moderate&operation=threads&filter=$filter&modfid=$modfid");
shownav('topic', $lang['moderate_threads']);
showsubmenu('nav_moderate_posts', array(
array('nav_moderate_threads', 'moderate&operation=threads', 1),
array('nav_moderate_replies', 'moderate&operation=replies', 0)
));
showformheader("moderate&operation=threads&page=$page");
showhiddenfields(array('ignore' => $ignore, 'filter' => $filter, 'modfid' => $modfid));
showtableheader("$lang[select]: <select style=\"margin: 0px;\" onchange=\"if(this.options[this.selectedIndex].value != '') {window.location='$BASESCRIPT?action=moderate&operation=threads&modfid=$modfid&filter='+this.options[this.selectedIndex].value;}\">$filteroptions</select>
<select style=\"margin: 0px;\" onchange=\"if(this.options[this.selectedIndex].value != '') {window.location='$BASESCRIPT?action=moderate&operation=threads&filter=$filter&modfid='+this.options[this.selectedIndex].value;}\">$forumoptions</select>");
$query = $db->query("SELECT f.name AS forumname, f.allowsmilies, f.allowhtml, f.allowbbcode, f.allowimgcode,
t.tid, t.fid, t.sortid, t.author, t.authorid, t.subject, t.dateline, t.attachment,
p.pid, p.message, p.useip, p.attachment, p.htmlon, p.smileyoff, p.bbcodeoff
FROM {$tablepre}threads t
LEFT JOIN {$tablepre}posts p ON p.tid=t.tid AND p.first=1
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
WHERE $fidadd[t]$fidadd[fids]$fidadd[and] t.displayorder='$displayorder'
ORDER BY t.dateline DESC LIMIT $start_limit, $tpp");
while($thread = $db->fetch_array($query)) {
$threadsortinfo = '';
if($thread['authorid'] && $thread['author']) {
$thread['author'] = "<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a>";
} elseif($thread['authorid'] && !$thread['author']) {
$thread['author'] = "<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$lang[anonymous]</a>";
} else {
$thread['author'] = $lang['guest'];
}
$thread['dateline'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
$thread['message'] = discuzcode($thread['message'], $thread['smileyoff'], $thread['bbcodeoff'], sprintf('%00b', $thread['htmlon']), $thread['allowsmilies'], $thread['allowbbcode'], $thread['allowimgcode'], $thread['allowhtml']);
$thread['modthreadkey'] = modthreadkey($thread['tid']);
if($thread['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$queryattach = $db->query("SELECT aid, filename, filetype, filesize, attachment, isimage, remote FROM {$tablepre}attachments WHERE tid='$thread[tid]'");
while($attach = $db->fetch_array($queryattach)) {
$attachurl = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
$attach['url'] = $attach['isimage']
? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"$attachurl/$attach[attachment]\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">"
: "<a href=\"$attachurl/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
$thread['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($thread['filename'])."\t".$attach['filetype']).$attach['url'];
}
}
$optiondata = $optionlist = array();
if($thread['sortid']) {
if(@include DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$thread['sortid'].'.php') {
$sortquery = $db->query("SELECT optionid, value FROM {$tablepre}typeoptionvars WHERE tid='$thread[tid]'");
while($option = $db->fetch_array($sortquery)) {
$optiondata[$option['optionid']] = $option['value'];
}
foreach($_DTYPE as $optionid => $option) {
$optionlist[$option['identifier']]['title'] = $_DTYPE[$optionid]['title'];
if($_DTYPE[$optionid]['type'] == 'checkbox') {
$optionlist[$option['identifier']]['value'] = '';
foreach(explode("\t", $optiondata[$optionid]) as $choiceid) {
$optionlist[$option['identifier']]['value'] .= $_DTYPE[$optionid]['choices'][$choiceid].' ';
}
} elseif(in_array($_DTYPE[$optionid]['type'], array('radio', 'select'))) {
$optionlist[$option['identifier']]['value'] = $_DTYPE[$optionid]['choices'][$optiondata[$optionid]];
} elseif($_DTYPE[$optionid]['type'] == 'image') {
$maxwidth = $_DTYPE[$optionid]['maxwidth'] ? 'width="'.$_DTYPE[$optionid]['maxwidth'].'"' : '';
$maxheight = $_DTYPE[$optionid]['maxheight'] ? 'height="'.$_DTYPE[$optionid]['maxheight'].'"' : '';
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\"><img src=\"$optiondata[$optionid]\" $maxwidth $maxheight border=\"0\"></a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'url') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\">$optiondata[$optionid]</a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'textarea') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? nl2br($optiondata[$optionid]) : '';
} else {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid];
}
}
}
foreach($optionlist as $option) {
$threadsortinfo .= $option['title'].' '.$option['value']."<br />";
}
}
showtablerow("id=\"mod_$thread[tid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
"<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_1\" value=\"validate\" checked=\"checked\" onclick=\"mod_setbg($thread[tid], 'validate');\"><label for=\"mod_$thread[tid]_1\">$lang[validate]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_2\" value=\"delete\" onclick=\"mod_setbg($thread[tid], 'delete');\"><label for=\"mod_$thread[tid]_2\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_3\" value=\"ignore\" onclick=\"mod_setbg($thread[tid], 'ignore');\"><label for=\"mod_$thread[tid]_3\">$lang[ignore]</label></li></ul>",
"<h3><a href=\"forumdisplay.php?fid=$thread[fid]\" target=\"_blank\">$thread[forumname]</a> » <a href=\"viewthread.php?tid=$thread[tid]&modthreadkey=$thread[modthreadkey]\" target=\"_blank\">$thread[subject]</a></h3><p><span class=\"bold\">$lang[author]:</span> $thread[author] ($thread[useip]) <span class=\"bold\">$lang[time]:</span> $thread[dateline]</p>"
));
showtablerow("id=\"mod_$thread[tid]_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:120px; word-break: break-all;">'.$thread['message'].'<br /><br />'.$threadsortinfo.'</div>');
showtablerow("id=\"mod_$thread[tid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "<a href=\"post.php?action=edit&fid=$thread[fid]&tid=$thread[tid]&pid=$thread[pid]&page=1&modthreadkey=$thread[modthreadkey]\" target=\"_blank\">".$lang['moderate_edit_thread']."</a> | ".$lang['moderate_reasonpm']." <input type=\"text\" class=\"txt\" name=\"pm_$thread[tid]\" id=\"pm_$thread[tid]\" style=\"margin: 0px;\"> <select style=\"margin: 0px;\" onchange=\"$('pm_$thread[tid]').value=this.value\">$modreasonoptions</select>");
}
showsubmit('modsubmit', 'submit', '', '<a href="#all" onclick="mod_setbg_all(\'validate\')">'.lang('moderate_all_validate').'</a> <a href="#all" onclick="mod_setbg_all(\'delete\')">'.lang('moderate_all_delete').'</a> <a href="#all" onclick="mod_setbg_all(\'ignore\')">'.lang('moderate_all_ignore').'</a>', $multipage);
showtablefooter();
showformfooter();
} else {
$validates = $ignores = $recycles = $deletes = 0;
$validatedthreads = $pmlist = array();
$moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
if(is_array($mod)) {
foreach($mod as $tid => $act) {
$moderation[$act][] = intval($tid);
}
}
if($moderation['ignore']) {
$ignoretids = '\''.implode('\',\'', $moderation['ignore']).'\'';
$db->query("UPDATE {$tablepre}threads SET displayorder='-3' WHERE tid IN ($ignoretids) AND displayorder='-2'");
$ignores = $db->affected_rows();
}
if($moderation['delete']) {
$deletetids = '0';
$recyclebintids = '0';
$query = $db->query("SELECT tid, fid, authorid, subject FROM {$tablepre}threads WHERE tid IN ('".implode('\',\'', $moderation['delete'])."') AND displayorder='$displayorder' $fidadd[and]$fidadd[fids]");
while($thread = $db->fetch_array($query)) {
if($recyclebins[$thread['fid']]) {
$recyclebintids .= ','.$thread['tid'];
} else {
$deletetids .= ','.$thread['tid'];
}
$pm = 'pm_'.$thread['tid'];
if(isset($$pm) && $$pm <> '' && $thread['authorid']) {
$pmlist[] = array(
'action' => 'modthreads_delete',
'authorid' => $thread['authorid'],
'thread' => $thread['subject'],
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($recyclebintids) {
$db->query("UPDATE {$tablepre}threads SET displayorder='-1', moderated='1' WHERE tid IN ($recyclebintids)");
$recycles = $db->affected_rows();
updatemodworks('MOD', $recycles);
$db->query("UPDATE {$tablepre}posts SET invisible='-1' WHERE tid IN ($recyclebintids)");
updatemodlog($recyclebintids, 'DEL');
}
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($deletetids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($deletetids)", 'UNBUFFERED');
$deletes = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}posts WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ($deletetids)");
$db->query("DELETE FROM {$tablepre}polls WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE tid IN ($deletetids)", 'UNBUFFERED');
}
if($moderation['validate']) {
$forums = array();
$validatetids = '\''.implode('\',\'', $moderation['validate']).'\'';
$tids = $comma = $comma2 = '';
$authoridarray = $moderatedthread = array();
$query = $db->query("SELECT t.fid, t.tid, t.authorid, t.subject, t.author, t.dateline, ff.postcredits FROM {$tablepre}threads t
LEFT JOIN {$tablepre}forumfields ff USING(fid)
WHERE t.tid IN ($validatetids) AND t.displayorder='$displayorder' $fidadd[and]$fidadd[t]$fidadd[fids]");
while($thread = $db->fetch_array($query)) {
$tids .= $comma.$thread['tid'];
$comma = ',';
if($thread['postcredits']) {
updatepostcredits('+', $thread['authorid'], unserialize($thread['postcredits']));
} else {
$authoridarray[] = $thread['authorid'];
}
$forums[] = $thread['fid'];
$validatedthreads[] = $thread;
$pm = 'pm_'.$thread['tid'];
if(isset($$pm) && $$pm <> '' && $thread['authorid']) {
$pmlist[] = array(
'action' => 'modthreads_validate',
'authorid' => $thread['authorid'],
'tid' => $thread['tid'],
'thread' => $thread['subject'],
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($tids) {
if($authoridarray) {
updatepostcredits('+', $authoridarray, $creditspolicy['post']);
}
$db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE tid IN ($tids)");
$db->query("UPDATE {$tablepre}threads SET displayorder='0', moderated='1' WHERE tid IN ($tids)");
$validates = $db->affected_rows();
foreach(array_unique($forums) as $fid) {
updateforumcount($fid);
}
updatemodworks('MOD', $validates);
updatemodlog($tids, 'MOD');
}
}
if($pmlist) {
foreach($pmlist as $pm) {
$reason = $pm['reason'];
$threadsubject = $pm['thread'];
$tid = intval($pm['tid']);
sendnotice($pm['authorid'], $pm['action'], 'systempm');
}
}
if($validates) {
eval("\$lang[moderate_validate_list] = \"".$lang['moderate_validate_list']."\";");
showsubmenu('nav_moderate_posts', array(
array('nav_moderate_threads', 'moderate&operation=threads', 0),
array('nav_moderate_replies', 'moderate&operation=replies', 0)
));
echo '<form id="topicadmin" name="topicadmin" method="post" action="topicadmin.php" target="_blank">';
showhiddenfields(array('action'=> '', 'fid'=> '', 'tid'=> ''));
showtableheader();
showtablerow('', 'class="lineheight" colspan="5"', lang('moderate_validate_list'));
showsubtitle(array('Tid', 'subject', 'author', 'dateline', 'admin'));
if(!empty($validatedthreads)) {
foreach($validatedthreads as $thread) {
showtablerow('', '', array(
$thread['tid'],
'<a href="viewthread.php?tid='.$thread['tid'].'&modthreadkey='.modthreadkey($thread['tid']).'" target="_blank">'.$thread['subject'].'</a>',
'<a href="space.php?uid='.$thread['authorid'].'" target="_blank">'.$thread['author'].'</a>',
gmdate("$dateformat $timeformat", $thread['dateline'] + 3600 * $timeoffset),
'<select name="action2" id="action2" onchange="if(this.options[this.selectedIndex].value != \'\') {$(\'topicadmin\').action.value= this.options[this.selectedIndex].value; $(\'topicadmin\').tid.value='.$thread['tid'].'; $(\'topicadmin\').fid.value='.$thread['fid'].'; $(\'topicadmin\').submit();}">
<option value="" selected>'.$lang['select'].'</option>
<option value="delete">'.$lang['moderate_delthread'].'</option>
<option value="close">'.$lang['moderate_close'].'</option>
<option value="move">'.$lang['moderate_move'].'</option>
<option value="copy">'.$lang['moderate_copy'].'</option>
<option value="highlight">'.$lang['moderate_highlight'].'</option>
<option value="digest">'.$lang['moderate_digest'].'</option>
<option value="stick">'.$lang['moderate_stick'].'</option>
<option value="merge">'.$lang['moderate_merge'].'</option>
<option value="bump">'.$lang['moderate_bump'].'</option>
<option value="repair">'.$lang['moderate_repair'].'</option>
</select>'
));
}
}
showtablefooter();
showformfooter();
} else {
cpmsg('moderate_threads_succeed', $BASESCRIPT.'?action=moderate&operation=threads', 'succeed');
}
}
} elseif($operation == 'replies') {
if(!submitcheck('modsubmit')) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$ppp = 10;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $ppp;
$modcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE invisible='$displayorder' AND first='0' $fidadd[and]$fidadd[fids]");
$multipage = multi($modcount, $ppp, $page, "$BASESCRIPT?action=moderate&operation=replies&filter=$filter&modfid=$modfid");
shownav('topic', $lang['moderate_replies']);
showsubmenu('nav_moderate_posts', array(
array('nav_moderate_threads', 'moderate&operation=threads', 0),
array('nav_moderate_replies', 'moderate&operation=replies', 1)
));
showformheader("moderate&operation=replies&page=$page");
showhiddenfields(array('filter' => $filter, 'modfid' => $modfid));
showtableheader("$lang[select]: <select style=\"margin: 0px;\" onchange=\"if(this.options[this.selectedIndex].value != '') {window.location='$BASESCRIPT?action=moderate&operation=replies&modfid=$modfid&filter='+this.options[this.selectedIndex].value+'&sid=5ScwCd';}\">$filteroptions</select> <select style=\"margin: 0px;\" onchange=\"if(this.options[this.selectedIndex].value != '') {window.location='$BASESCRIPT?action=moderate&operation=replies&filter=$filter&modfid='+this.options[this.selectedIndex].value+'&sid=5ScwCd';}\">$forumoptions</select>");
$query = $db->query("SELECT f.name AS forumname, f.allowsmilies, f.allowhtml, f.allowbbcode, f.allowimgcode,
p.pid, p.fid, p.tid, p.author, p.authorid, p.subject, p.dateline, p.message, p.useip, p.attachment,
p.htmlon, p.smileyoff, p.bbcodeoff, t.subject AS tsubject
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
LEFT JOIN {$tablepre}forums f ON f.fid=p.fid
WHERE p.invisible='$displayorder' AND p.first='0' $fidadd[and]$fidadd[p]$fidadd[fids]
ORDER BY p.dateline DESC LIMIT $start_limit, $ppp");
while($post = $db->fetch_array($query)) {
$post['dateline'] = gmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
$post['subject'] = $post['subject'] ? '<b>'.$post['subject'].'</b>' : '<i>'.$lang['nosubject'].'</i>';
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $post['allowsmilies'], $post['allowbbcode'], $post['allowimgcode'], $post['allowhtml']);
$post['modthreadkey'] = modthreadkey($post['tid']);
if($post['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$queryattach = $db->query("SELECT aid, filename, filetype, filesize, attachment, isimage, remote FROM {$tablepre}attachments WHERE pid='$post[pid]'");
while($attach = $db->fetch_array($queryattach)) {
$attachurl = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
$attach['url'] = $attach['isimage']
? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"$attachurl/$attach[attachment]\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">"
: "<a href=\"$attachurl/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
$post['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($attach['filename'])."\t".$attach['filetype']).$attach['url'];
}
}
showtablerow("id=\"mod_$post[pid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
"<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"mod[$post[pid]]\" id=\"mod_$post[pid]_1\" value=\"validate\" checked=\"checked\" onclick=\"mod_setbg($post[pid], 'validate');\"><label for=\"mod_$post[pid]_1\">$lang[validate]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$post[pid]]\" id=\"mod_$post[pid]_2\" value=\"delete\" onclick=\"mod_setbg($post[pid], 'delete');\"><label for=\"mod_$post[pid]_2\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$post[pid]]\" id=\"mod_$post[pid]_3\" value=\"ignore\" onclick=\"mod_setbg($post[pid], 'ignore');\"><label for=\"mod_$post[pid]_3\">$lang[ignore]</label></li></ul>",
"<h3><a href=\"forumdisplay.php?fid=$post[fid]\" target=\"_blank\">$post[forumname]</a> » <a href=\"viewthread.php?tid=$post[tid]&modthreadkey=$post[modthreadkey]\" target=\"_blank\">$post[tsubject]</a> » <b>$post[subject]</b></h3><p><span class=\"bold\">$lang[author]:</span> $post[author] ($post[useip]) <span class=\"bold\">$lang[time]:</span> $post[dateline]</p>"
));
showtablerow("id=\"mod_$post[pid]_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:100px; word-break: break-all;">'.$post[message].'</div>');
showtablerow("id=\"mod_$post[pid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "<a href=\"post.php?action=edit&fid=$post[fid]&tid=$post[tid]&pid=$post[pid]&page=1&modthreadkey=$post[modthreadkey]\" target=\"_blank\">".$lang['moderate_edit_post']."</a> | ".$lang['moderate_reasonpm']." <input type=\"text\" class=\"txt\" name=\"pm_$post[pid]\" id=\"pm_$post[pid]\" style=\"margin: 0px;\"> <select style=\"margin: 0px;\" onchange=\"$('pm_$post[pid]').value=this.value\">$modreasonoptions</select>");
}
showsubmit('modsubmit', 'submit', '', '<a href="#all" onclick="mod_setbg_all(\'validate\')">'.lang('moderate_all_validate').'</a> <a href="#all" onclick="mod_setbg_all(\'delete\')">'.lang('moderate_all_delete').'</a> <a href="#all" onclick="mod_setbg_all(\'ignore\')">'.lang('moderate_all_ignore').'</a>', $multipage);
showtablefooter();
showformfooter();
} else {
$moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
$pmlist = array();
$validates = $ignores = $deletes = 0;
if(is_array($mod)) {
foreach($mod as $pid => $act) {
$moderation[$act][] = intval($pid);
}
}
if($ignorepids = implodeids($moderation['ignore'])) {
$db->query("UPDATE {$tablepre}posts SET invisible='-3' WHERE pid IN ($ignorepids) AND invisible='-2' AND first='0' $fidadd[and]$fidadd[fids]");
$ignores = $db->affected_rows();
}
if($deletepids = implodeids($moderation['delete'])) {
$query = $db->query("SELECT pid, authorid, tid, message FROM {$tablepre}posts WHERE pid IN ($deletepids) AND invisible='$displayorder' AND first='0' $fidadd[and]$fidadd[fids]", 'UNBUFFERED');
$pids = '0';
while($post = $db->fetch_array($query)) {
$pids .= ','.$post['pid'];
$pm = 'pm_'.$post['pid'];
if(isset($$pm) && $$pm <> '' && $post['authorid']) {
$pmlist[] = array(
'action' => 'modreplies_delete',
'authorid' => $post['authorid'],
'tid' => $post['tid'],
'post' => dhtmlspecialchars(cutstr($post['message'], 30)),
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($pids) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE pid IN ($deletepids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE pid IN ($pids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pids)", 'UNBUFFERED');
$deletes = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}trades WHERE pid IN ($pids)", 'UNBUFFERED');
}
updatemodworks('DLP', count($moderation['delete']));
}
if($validatepids = implodeids($moderation['validate'])) {
$forums = $threads = $lastpost = $attachments = $pidarray = $authoridarray = array();
$query = $db->query("SELECT t.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous, ff.replycredits
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}forumfields ff ON ff.fid=p.fid
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
WHERE p.pid IN ($validatepids) AND p.invisible='$displayorder' AND first='0' $fidadd[and]$fidadd[p]$fidadd[fids]");
while($post = $db->fetch_array($query)) {
$pidarray[] = $post['pid'];
if($post['replycredits']) {
updatepostcredits('+', $post['authorid'], unserialize($post['replycredits']));
} else {
$authoridarray[] = $post['authorid'];
}
$forums[] = $post['fid'];
$threads[$post['tid']]['posts']++;
$threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ?
", lastpost='$post[dateline]', lastposter='".($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author]))."'" : '';
$threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : '';
$pm = 'pm_'.$post['pid'];
if(isset($$pm) && $$pm <> '' && $post['authorid']) {
$pmlist[] = array(
'action' => 'modreplies_validate',
'authorid' => $post['authorid'],
'tid' => $post['tid'],
'post' => dhtmlspecialchars(cutstr($post['message'], 30)),
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($authoridarray) {
updatepostcredits('+', $authoridarray, $creditspolicy['reply']);
}
foreach($threads as $tid => $thread) {
$db->query("UPDATE {$tablepre}threads SET replies=replies+$thread[posts] $thread[lastpostadd] $thread[attachadd] WHERE tid='$tid'", 'UNBUFFERED');
}
foreach(array_unique($forums) as $fid) {
updateforumcount($fid);
}
if(!empty($pidarray)) {
$db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE pid IN (0,".implode(',', $pidarray).")");
$validates = $db->affected_rows();
updatemodworks('MOD', $validates);
} else {
updatemodworks('MOD', 1);
}
}
if($pmlist) {
foreach($pmlist as $pm) {
$reason = $pm['reason'];
$post = $pm['post'];
$tid = intval($pm['tid']);
sendnotice($pm['authorid'], $pm['action'], 'systempm');
}
}
cpmsg('moderate_replies_succeed', "$BASESCRIPT?action=moderate&operation=replies&page=$page&filter=$filter&modfid=$modfid", 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/moderate.inc.php | PHP | asf20 | 39,266 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: plugins.inc.php 21070 2009-11-10 06:59:40Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!empty($identifier) && !empty($mod)) {
$operation = 'config';
}
$pluginid = !empty($_GET['pluginid']) ? intval($_GET['pluginid']) : 0;
if(!$operation) {
if(!submitcheck('submit')) {
shownav('plugin', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('plugins_list', 'plugins', 1),
array('import', 'plugins&operation=import', 0)
));
showformheader('plugins');
showtableheader();
showsubtitle(array('enable', 'plugins_name', 'version', 'copyright', 'plugins_directory', 'display_order', ''));
$query = $db->query("SELECT * FROM {$tablepre}plugins ORDER BY available DESC, pluginid DESC");
$installsdir = array();
while($plugin = $db->fetch_array($query)) {
$hookexists = FALSE;
$plugin['modules'] = unserialize($plugin['modules']);
if(is_array($plugin['modules'])) {
foreach($plugin['modules'] as $k => $module) {
if($module['type'] == 11) {
$hookorder = $module['displayorder'];
$hookexists = $k;
break;
}
}
}
showtablerow('style="height:20px"', array('class="td25"', ($plugin['available'] ? 'class="bold"' : ''), 'class="td25"', '', '', 'class="td28 td23"', 'class="td24"'), array(
"<input class=\"checkbox\"".($hookexists !== FALSE ? " onclick=\"display('displayorder_$plugin[pluginid]')\"" : '')." type=\"checkbox\" name=\"availablenew[$plugin[pluginid]]\" value=\"1\" ".(!$plugin['name'] || !$plugin['identifier'] ? 'disabled' : ($plugin['available'] ? 'checked' : '')).">",
"<a href=\"$BASESCRIPT?action=plugins&operation=config&pluginid=$plugin[pluginid]\">".dhtmlspecialchars($plugin['name'])."</a>",
dhtmlspecialchars($plugin['version']),
dhtmlspecialchars($plugin['copyright']),
$plugin['directory'],
($hookexists !== FALSE ? "<input class=\"txt\" type=\"text\" id=\"displayorder_$plugin[pluginid]\" name=\"displayordernew[$plugin[pluginid]][$hookexists]\" value=\"$hookorder\" style=\"".(!$plugin['available'] ? 'display:none' : '')."\" />" : ''),
"<a href=\"$BASESCRIPT?action=plugins&operation=delete&pluginid=$plugin[pluginid]\" class=\"act\">$lang[plugins_config_uninstall]</a> ".
"<a href=\"$BASESCRIPT?action=plugins&operation=edit&pluginid=$plugin[pluginid]\" class=\"act\">$lang[plugins_editlink]</a>"
));
$installsdir[] = $plugin['directory'];
}
$plugindir = DISCUZ_ROOT.'./plugins';
$pluginsdir = dir($plugindir);
$newplugins = array();
while($entry = $pluginsdir->read()) {
if(!in_array($entry, array('.', '..')) && is_dir($plugindir.'/'.$entry) && !in_array($entry.'/', $installsdir)) {
$entrydir = DISCUZ_ROOT.'./plugins/'.$entry;
$d = dir($entrydir);
$filemtime = filemtime($entrydir);
while($f = $d->read()) {
if(preg_match('/^discuz\_plugin\_'.$entry.'(\_\w+)?\.xml$/', $f)) {
$entrytitle = $entry;
$entryversion = $entrycopyright = '';
if(file_exists($entrydir.'/discuz_plugin_'.$entry.'.xml')) {
$importtxt = @implode('', file($entrydir.'/discuz_plugin_'.$entry.'.xml'));
$pluginarray = getimportdata('Discuz! Plugin', 1, 1);
if(!empty($pluginarray['plugin']['name'])) {
$entrytitle = dhtmlspecialchars($pluginarray['plugin']['name']);
$entryversion = dhtmlspecialchars($pluginarray['plugin']['version']);
$entrycopyright = dhtmlspecialchars($pluginarray['plugin']['copyright']);
}
}
$file = $entrydir.'/'.$f;
echo '<tr><td></td><td>'.$entrytitle.($filemtime > $timestamp - 86400 ? ' <font color="red">New!</font>' : '').'</td><td>'.$entryversion.'</td><td>'.$entrycopyright.'</td><td colspan="2">'.$entry.'/</td><td><a href="'.$BASESCRIPT.'?action=plugins&operation=import&dir='.$entry.'" class="act">'.$lang['plugins_config_install'].'</a></td></tr>';
break;
}
}
}
}
showsubmit('submit', 'submit', '', '<a href="'.$BASESCRIPT.'?action=plugins&operation=add">'.$lang['plugins_add'].'</a> <a href="'.$BASESCRIPT.'?action=plugins&operation=hooklist">'.$lang['plugins_hooklist'].'</a>');
showtablefooter();
showformfooter();
} else {
$db->query("UPDATE {$tablepre}plugins SET available='0'");
if(is_array($availablenew)) {
$query = $db->query("SELECT pluginid, modules FROM {$tablepre}plugins WHERE pluginid IN (".implodeids(array_keys($availablenew)).")");
while($plugin = $db->fetch_array($query)) {
if(!empty($displayordernew[$plugin['pluginid']])) {
$plugin['modules'] = unserialize($plugin['modules']);
$k = array_keys($displayordernew[$plugin['pluginid']]);
$v = array_values($displayordernew[$plugin['pluginid']]);
$plugin['modules'][$k[0]]['displayorder'] = $v[0];
$plugin['modules'] = addslashes(serialize($plugin['modules']));
$moduleadd = "modules='".$plugin['modules']."', ";
} else {
$moduleadd = '';
}
$db->query("UPDATE {$tablepre}plugins SET {$moduleadd}available='".$availablenew[$plugin['pluginid']]."' WHERE pluginid='$plugin[pluginid]'");
}
}
updatecache('plugins');
updatecache('settings');
updatemenu();
cpmsg('plugins_edit_succeed', $BASESCRIPT.'?action=plugins', 'succeed');
}
} elseif($operation == 'hooklist') {
shownav('plugin', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('plugins_list', 'plugins', 0),
array('import', 'plugins&operation=import', 0),
array('plugins_hooklist', 'plugins&operation=hooklist', 1)
));
$plugins = $funcs = array();
$query = $db->query("SELECT pluginid, name, identifier FROM {$tablepre}plugins WHERE available='1'");
while($plugin = $db->fetch_array($query)) {
$plugins[$plugin['identifier']] = $plugin;
}
showtableheader();
$rows = '';
if($hookscript) {
foreach($hookscript as $script => $value) {
if($script == 'plugin') {
continue;
}
$funcs = array();
$scripttitle = in_array($script, array('index', 'profile', 'global')) ? $lang['plugins_hooklist_script_'.$script] : (file_exists(DISCUZ_ROOT.'./'.$script.'.php') ? $script.'.php' : $script);
showsubtitle(array($scripttitle, ''));
if(is_array($value['funcs'])) {
foreach($value['funcs'] as $hookkey => $hookfuncs) {
foreach($hookfuncs as $hookfunc) {
$funcs[$hookfunc[1]][] = $hookfunc[0];
}
}
}
if(is_array($value['outputfuncs'])) {
foreach($value['outputfuncs'] as $hookkey => $hookfuncs) {
foreach($hookfuncs as $hookfunc) {
$hookfunc[1] = preg_replace('/\_output$/', '', $hookfunc[1]);
$funcs[$hookfunc[1]][] = $hookfunc[0];
}
}
}
foreach($funcs as $func => $v) {
echo '<tr><td valign="top" width="30%">';
$first = 0;
$v = array_unique($v);
foreach($v as $plugin) {
if(!$first++) {
echo (isset($lang['plugins_hooklist__'.$func]) ? $lang['plugins_hooklist__'.$func] : $lang['plugins_hooklist_userdefine'].':'.$func).'</td><td>';
}
echo '<a href="'.$BASESCRIPT.'?action=plugins&operation=config&pluginid='.$plugins[$plugin]['pluginid'].'">'.$plugins[$plugin]['name'].'</a><br>';
}
echo '</td></tr>';
}
}
} else {
echo '<div class="infobox"><h4 class="infotitle2">'.$lang['plugins_hooklist_empty'].'</h4></div>';
}
showtablefooter();
} elseif($operation == 'export' && $pluginid) {
$plugin = $db->fetch_first("SELECT * FROM {$tablepre}plugins WHERE pluginid='$pluginid'");
if(!$plugin) {
cpheader();
cpmsg('undefined_action', '', 'error');
}
unset($plugin['pluginid']);
$pluginarray = array();
$pluginarray['plugin'] = $plugin;
$pluginarray['version'] = strip_tags($version);
$query = $db->query("SELECT * FROM {$tablepre}pluginhooks WHERE pluginid='$pluginid'");
while($hook = $db->fetch_array($query)) {
unset($hook['pluginhookid'], $hook['pluginid']);
$pluginarray['hooks'][] = $hook;
}
$query = $db->query("SELECT * FROM {$tablepre}pluginvars WHERE pluginid='$pluginid'");
while($var = $db->fetch_array($query)) {
unset($var['pluginvarid'], $var['pluginid']);
$pluginarray['vars'][] = $var;
}
$modules = unserialize($pluginarray['plugin']['modules']);
if($modules['extra']['langexists'] && file_exists($file = DISCUZ_ROOT.'./forumdata/plugins/'.$pluginarray['plugin']['identifier'].'.lang.php')) {
include $file;
if(!empty($scriptlang[$pluginarray['plugin']['identifier']])) {
$pluginarray['language']['scriptlang'] = $scriptlang[$pluginarray['plugin']['identifier']];
}
if(!empty($templatelang[$pluginarray['plugin']['identifier']])) {
$pluginarray['language']['templatelang'] = $templatelang[$pluginarray['plugin']['identifier']];
}
if(!empty($installlang[$pluginarray['plugin']['identifier']])) {
$pluginarray['language']['installlang'] = $installlang[$pluginarray['plugin']['identifier']];
}
}
unset($modules['extra']);
$pluginarray['plugin']['modules'] = serialize($modules);
exportdata('Discuz! Plugin', $plugin['identifier'], $pluginarray);
} elseif($operation == 'import') {
if(!submitcheck('importsubmit') && !isset($dir)) {
shownav('plugin', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('plugins_list', 'plugins', 0),
array('import', 'plugins&operation=import', 1)
));
showformheader('plugins&operation=import', 'enctype');
showtableheader('plugins_import', 'fixpadding');
showimportdata();
showtablerow('', '', '<input type="checkbox" name="ignoreversion" value="1" class="checkbox" /> '.lang('plugins_import_ignore_version'));
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
if(!isset($dir)) {
$pluginarray = getimportdata('Discuz! Plugin');
} elseif(!isset($installtype)) {
$pdir = DISCUZ_ROOT.'./plugins/'.$dir;
$d = dir($pdir);
$xmls = '';$count = 0;
while($f = $d->read()) {
if(preg_match('/^discuz\_plugin_'.$dir.'(\_\w+)?\.xml$/', $f, $a)) {
$extratxt = $extra = substr($a[1], 1);
if(preg_match('/^SC\_GBK$/i', $extra)) {
$extratxt = '简体中文版';
} elseif(preg_match('/^SC\_UTF8$/i', $extra)) {
$extratxt = '简体中文UTF8版';
} elseif(preg_match('/^TC\_BIG5$/i', $extra)) {
$extratxt = '繁體中文版';
} elseif(preg_match('/^TC\_UTF8$/i', $extra)) {
$extratxt = '繁體中文UTF8版';
}
$url = $BASESCRIPT.'?action=plugins&operation=import&dir='.$dir.'&installtype='.$extra.(!empty($referer) ? '&referer='.rawurlencode($referer) : '');
$xmls .= ' <input type="button" class="btn" onclick="location.href=\''.$url.'\'" value="'.($extra ? $extratxt : $lang['plugins_import_default']).'"> ';
$count++;
}
}
$xmls .= '<br /><br /><input class="btn" onclick="location.href=\''.$BASESCRIPT.'?action=plugins\'" type="button" value="'.$lang['cancel'].'"/>';
if($count == 1) {
dheader('location: '.$url);
}
echo '<div class="infobox"><h4 class="infotitle2">'.$lang['plugins_import_installtype_1'].' '.$dir.' '.$lang['plugins_import_installtype_2'].' '.$count.' '.$lang['plugins_import_installtype_3'].'</h4>'.$xmls.'</div>';
exit;
} else {
$extra = $installtype ? '_'.$installtype : '';
$importfile = DISCUZ_ROOT.'./plugins/'.$dir.'/discuz_plugin_'.$dir.$extra.'.xml';
$importtxt = @implode('', file($importfile));
$pluginarray = getimportdata('Discuz! Plugin');
if(empty($license) && $pluginarray['license']) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$pluginarray['license'] = discuzcode(stripslashes(strip_tags($pluginarray['license'])), 1, 0);
echo '<div class="infobox"><h4 class="infotitle2">'.$pluginarray['plugin']['name'].' '.$pluginarray['plugin']['version'].' '.$lang['plugins_import_license'].'</h4><div style="text-align:left;line-height:25px;">'.$pluginarray['license'].'</div><br /><br /><center>'.
'<button onclick="location.href=\''.$BASESCRIPT.'?action=plugins&operation=import&dir='.$dir.'&installtype='.$installtype.'&license=yes\'">'.$lang['plugins_import_agree'].'</button> '.
'<button onclick="location.href=\''.$BASESCRIPT.'?action=plugins\'">'.$lang['plugins_import_pass'].'</button></center></div>';
exit;
}
}
if(!ispluginkey($pluginarray['plugin']['identifier'])) {
cpmsg('plugins_edit_identifier_invalid', '', 'error');
}
if(!ispluginkey($pluginarray['plugin']['identifier'])) {
cpmsg('plugins_edit_identifier_invalid', '', 'error');
}
if(is_array($pluginarray['hooks'])) {
foreach($pluginarray['hooks'] as $config) {
if(!ispluginkey($config['title'])) {
cpmsg('plugins_import_hooks_title_invalid', '', 'error');
}
}
}
if(is_array($pluginarray['vars'])) {
foreach($pluginarray['vars'] as $config) {
if(!ispluginkey($config['variable'])) {
cpmsg('plugins_import_var_invalid', '', 'error');
}
}
}
$langexists = FALSE;
if(!empty($pluginarray['language'])) {
@mkdir('./forumdata/plugins/', 0777);
$file = DISCUZ_ROOT.'./forumdata/plugins/'.$pluginarray['plugin']['identifier'].'.lang.php';
if($fp = @fopen($file, 'wb')) {
$scriptlangstr = !empty($pluginarray['language']['scriptlang']) ? "\$scriptlang['".$pluginarray['plugin']['identifier']."'] = ".langeval($pluginarray['language']['scriptlang']) : '';
$templatelangstr = !empty($pluginarray['language']['templatelang']) ? "\$templatelang['".$pluginarray['plugin']['identifier']."'] = ".langeval($pluginarray['language']['templatelang']) : '';
$installlangstr = !empty($pluginarray['language']['installlang']) ? "\$installlang['".$pluginarray['plugin']['identifier']."'] = ".langeval($pluginarray['language']['installlang']) : '';
fwrite($fp, "<?php\n".$scriptlangstr.$templatelangstr.$installlangstr.'?>');
fclose($fp);
}
$langexists = TRUE;
}
if(empty($ignoreversion) && strip_tags($pluginarray['version']) != strip_tags($version)) {
if(isset($dir)) {
cpmsg('plugins_import_version_invalid_confirm', $BASESCRIPT.'?action=plugins&operation=import&ignoreversion=yes&dir='.$dir.'&installtype='.$installtype.'&license='.$license, 'form');
} else {
cpmsg('plugins_import_version_invalid', '', 'error');
}
}
$plugin = $db->fetch_first("SELECT name, pluginid FROM {$tablepre}plugins WHERE identifier='{$pluginarray[plugin][identifier]}' LIMIT 1");
if($plugin) {
cpmsg('plugins_import_identifier_duplicated', '', 'error');
}
if(!empty($pluginarray['intro']) || $langexists) {
$pluginarray['plugin']['modules'] = unserialize(stripslashes($pluginarray['plugin']['modules']));
if(!empty($pluginarray['intro'])) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$pluginarray['plugin']['modules']['extra']['intro'] = discuzcode(stripslashes(strip_tags($pluginarray['intro'])), 1, 0);
}
$langexists && $pluginarray['plugin']['modules']['extra']['langexists'] = 1;
$pluginarray['plugin']['modules'] = addslashes(serialize($pluginarray['plugin']['modules']));
}
$sql1 = $sql2 = $comma = '';
foreach($pluginarray['plugin'] as $key => $val) {
if($key == 'directory') {
$val .= (!empty($val) && substr($val, -1) != '/') ? '/' : '';
} elseif($key == 'available') {
$val = 0;
}
$sql1 .= $comma.$key;
$sql2 .= $comma.'\''.$val.'\'';
$comma = ',';
}
$db->query("INSERT INTO {$tablepre}plugins ($sql1) VALUES ($sql2)");
$pluginid = $db->insert_id();
foreach(array('hooks', 'vars') as $pluginconfig) {
if(is_array($pluginarray[$pluginconfig])) {
foreach($pluginarray[$pluginconfig] as $config) {
$sql1 = 'pluginid';
$sql2 = '\''.$pluginid.'\'';
foreach($config as $key => $val) {
$sql1 .= ','.$key;
$sql2 .= ',\''.$val.'\'';
}
$db->query("INSERT INTO {$tablepre}plugin$pluginconfig ($sql1) VALUES ($sql2)");
}
}
}
if(!empty($dir) && !empty($pluginarray['importfile'])) {
require_once DISCUZ_ROOT.'./admin/importdata.func.php';
foreach($pluginarray['importfile'] as $importtype => $file) {
if(in_array($importtype, array('request', 'project', 'smilies', 'styles'))) {
$files = explode(',', $file);
foreach($files as $file) {
if(file_exists($file = DISCUZ_ROOT.'./plugins/'.$dir.'/'.$file)) {
$importtxt = @implode('', file($file));
$imporfun = 'import_'.$importtype;
$imporfun();
}
}
}
}
}
updatecache('plugins');
updatecache('settings');
updatemenu();
if(!empty($dir) && !empty($pluginarray['installfile']) && preg_match('/^[\w\.]+$/', $pluginarray['installfile'])) {
dheader('location: '.$BASESCRIPT.'?action=plugins&operation=plugininstall&dir='.$dir.'&installtype='.$installtype);
}
pluginstat('install', $pluginarray['plugin']);
cpmsg(!empty($dir) ? 'plugins_install_succeed' : 'plugins_import_succeed', !empty($referer) ? $referer : $BASESCRIPT.'?action=plugins', 'succeed');
}
} elseif($operation == 'plugininstall' || $operation == 'pluginuninstall' || $operation == 'pluginupgrade') {
$finish = FALSE;
$dir = str_replace('/', '', $dir);
$installtype = str_replace('/', '', $installtype);
$extra = $installtype ? '_'.$installtype : '';
$xmlfile = !empty($xmlfile) && preg_match('/^[\w\.]+$/', $xmlfile) ? $xmlfile : 'discuz_plugin_'.$dir.$extra.'.xml';
$importfile = DISCUZ_ROOT.'./plugins/'.$dir.'/'.$xmlfile;
if(!file_exists($importfile)) {
cpmsg('undefined_action', '', 'error');
}
$importtxt = @implode('', file($importfile));
$pluginarray = getimportdata('Discuz! Plugin');
if($operation == 'plugininstall') {
$filename = $pluginarray['installfile'];
} elseif($operation == 'pluginuninstall') {
$filename = $pluginarray['uninstallfile'];
} else {
$filename = $pluginarray['upgradefile'];
$toversion = $pluginarray['plugin']['version'];
}
if(file_exists($langfile = DISCUZ_ROOT.'./forumdata/plugins/'.$dir.'.lang.php')) {
@include $langfile;
}
if(!empty($filename) && preg_match('/^[\w\.]+$/', $filename)) {
$filename = DISCUZ_ROOT.'./plugins/'.$dir.'/'.$filename;
if(file_exists($filename)) {
@include_once $filename;
} else {
$finish = TRUE;
}
} else {
$finish = TRUE;
}
if($finish) {
updatecache('settings');
updatemenu();
if($operation == 'plugininstall') {
pluginstat('install', $pluginarray['plugin']);
cpmsg('plugins_install_succeed', "$BASESCRIPT?action=plugins", 'succeed');
} if($operation == 'pluginuninstall') {
@unlink($langfile);
pluginstat('uninstall', $pluginarray['plugin']);
cpmsg('plugins_delete_succeed', "$BASESCRIPT?action=plugins", 'succeed');
} else {
pluginstat('upgrade', $pluginarray['plugin']);
cpmsg('plugins_upgrade_succeed', "$BASESCRIPT?action=plugins", 'succeed');
}
}
} elseif($operation == 'upgrade' && preg_match('/^[\w\.]+$/', $xmlfile)) {
$plugin = $db->fetch_first("SELECT directory, modules, version FROM {$tablepre}plugins WHERE pluginid='$pluginid'");
$importfile = DISCUZ_ROOT.'./plugins/'.$plugin['directory'].$xmlfile;
if(!file_exists($importfile)) {
cpmsg('undefined_action', '', 'error');
}
$importtxt = @implode('', file($importfile));
$pluginarray = getimportdata('Discuz! Plugin');
if(!ispluginkey($pluginarray['plugin']['identifier'])) {
cpmsg('plugins_edit_identifier_invalid', '', 'error');
}
if(is_array($pluginarray['hooks'])) {
foreach($pluginarray['hooks'] as $config) {
if(!ispluginkey($config['title'])) {
cpmsg('plugins_upgrade_hooks_title_invalid', '', 'error');
}
}
}
if(is_array($pluginarray['vars'])) {
foreach($pluginarray['vars'] as $config) {
if(!ispluginkey($config['variable'])) {
cpmsg('plugins_upgrade_var_invalid', '', 'error');
}
}
}
if(is_array($pluginarray['hooks'])) {
$db->query("DELETE FROM {$tablepre}pluginhooks WHERE pluginid='$pluginid'");
foreach($pluginarray['hooks'] as $config) {
$sql1 = 'pluginid';
$sql2 = '\''.$pluginid.'\'';
foreach($config as $key => $val) {
$sql1 .= ','.$key;
$sql2 .= ',\''.$val.'\'';
}
$db->query("INSERT INTO {$tablepre}pluginhooks ($sql1) VALUES ($sql2)");
}
}
if(is_array($pluginarray['vars'])) {
$query = $db->query("SELECT variable FROM {$tablepre}pluginvars WHERE pluginid='$pluginid'");
$pluginvars = $pluginvarsnew = array();
while($pluginvar = $db->fetch_array($query)) {
$pluginvars[] = $pluginvar['variable'];
}
foreach($pluginarray['vars'] as $config) {
if(!in_array($config['variable'], $pluginvars)) {
$sql1 = 'pluginid';
$sql2 = '\''.$pluginid.'\'';
foreach($config as $key => $val) {
$sql1 .= ','.$key;
$sql2 .= ',\''.$val.'\'';
}
$db->query("INSERT INTO {$tablepre}pluginvars ($sql1) VALUES ($sql2)");
} else {
$sql = $comma = '';
foreach($config as $key => $val) {
if($key != 'value') {
$sql .= $comma.$key.'=\''.$val.'\'';
$comma = ',';
}
}
if($sql) {
$db->query("UPDATE {$tablepre}pluginvars SET $sql WHERE pluginid='$pluginid' AND variable='$config[variable]'");
}
}
$pluginvarsnew[] = $config['variable'];
}
$pluginvardiff = array_diff($pluginvars, $pluginvarsnew);
if($pluginvardiff) {
$db->query("DELETE FROM {$tablepre}pluginvars WHERE pluginid='$pluginid' AND variable IN (".implodeids($pluginvardiff).")");
}
}
$langexists = FALSE;
if(!empty($pluginarray['language'])) {
@mkdir('./forumdata/plugins/', 0777);
$file = DISCUZ_ROOT.'./forumdata/plugins/'.$pluginarray['plugin']['identifier'].'.lang.php';
if($fp = @fopen($file, 'wb')) {
$scriptlangstr = !empty($pluginarray['language']['scriptlang']) ? "\$scriptlang['".$pluginarray['plugin']['identifier']."'] = ".langeval($pluginarray['language']['scriptlang']) : '';
$templatelangstr = !empty($pluginarray['language']['templatelang']) ? "\$templatelang['".$pluginarray['plugin']['identifier']."'] = ".langeval($pluginarray['language']['templatelang']) : '';
$installlangstr = !empty($pluginarray['language']['installlang']) ? "\$installlang['".$pluginarray['plugin']['identifier']."'] = ".langeval($pluginarray['language']['installlang']) : '';
fwrite($fp, "<?php\n".$scriptlangstr.$templatelangstr.$installlangstr.'?>');
fclose($fp);
}
$langexists = TRUE;
}
if(!empty($pluginarray['intro']) || $langexists) {
$pluginarray['plugin']['modules'] = unserialize(stripslashes($pluginarray['plugin']['modules']));
if(!empty($pluginarray['intro'])) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$pluginarray['plugin']['modules']['extra']['intro'] = discuzcode(stripslashes(strip_tags($pluginarray['intro'])), 1, 0);
}
$langexists && $pluginarray['plugin']['modules']['extra']['langexists'] = 1;
$pluginarray['plugin']['modules'] = addslashes(serialize($pluginarray['plugin']['modules']));
}
$modulenew = $pluginarray['modules'];
$db->query("UPDATE {$tablepre}plugins SET version='{$pluginarray[plugin][version]}', modules='{$pluginarray[plugin][modules]}' WHERE pluginid='$pluginid'");
updatecache('plugins');
updatecache('settings');
if(!empty($plugin['directory']) && !empty($pluginarray['upgradefile']) && preg_match('/^[\w\.]+$/', $pluginarray['upgradefile'])) {
dheader('location: '.$BASESCRIPT.'?action=plugins&operation=pluginupgrade&dir='.$plugin['directory'].'&xmlfile='.rawurlencode($xmlfile).'&fromversion='.$plugin['version']);
}
$toversion = $pluginarray['plugin']['version'];
pluginstat('upgrade', $pluginarray['plugin']);
cpmsg('plugins_upgrade_succeed', "$BASESCRIPT?action=plugins", 'succeed');
} elseif($operation == 'config') {
$plugin = $db->fetch_first("SELECT * FROM {$tablepre}plugins WHERE ".($identifier ? "identifier='$identifier'" : "pluginid='$pluginid'"));
if(!$plugin) {
cpmsg('undefined_action', '', 'error');
} else {
$pluginid = $plugin['pluginid'];
}
$plugin['modules'] = unserialize($plugin['modules']);
$pluginvars = array();
$query = $db->query("SELECT * FROM {$tablepre}pluginvars WHERE pluginid='$pluginid' ORDER BY displayorder");
while($var = $db->fetch_array($query)) {
$pluginvars[$var['variable']] = $var;
}
$anchor = in_array($anchor, array('home', 'vars')) ? $anchor : 'home';
if(!$mod) {
$submenuitem = array(array('plugins_home', 'home', $anchor == 'home'));
if($pluginvars) {
$submenuitem[] = array('config', 'vars', $anchor == 'vars');
}
} else {
$submenuitem = array(array('plugins_home', "plugins&operation=config&pluginid=$pluginid&anchor=home", 0));
if($pluginvars) {
$submenuitem[] = array('config', "plugins&operation=config&pluginid=$pluginid&anchor=vars", 0);
}
}
if(is_array($plugin['modules'])) {
foreach($plugin['modules'] as $module) {
if($module['type'] == 3) {
$submenuitem[] = array($module['menu'], "plugins&operation=config&identifier=$plugin[identifier]&mod=$module[name]", $mod == $module['name'], !$mod ? 1 : 0);
}
}
}
if(empty($mod)) {
if(!submitcheck('editsubmit')) {
$operation = '';
shownav('plugin', 'nav_plugins', $plugin['name']);
showsubmenuanchors($plugin['name'].(!$plugin['available'] ? ' ('.$lang['plugins_unavailable'].')' : ''), $submenuitem);
showtagheader('div', 'home', $anchor == 'home');
if($plugin['description'] || $plugin['copyright'] || $plugin['modules']['extra']['intro']) {
echo '<div class="colorbox" style="line-height:25px">'.(!empty($plugin['modules']['extra']['intro']) ? $plugin['modules']['extra']['intro'].'<br />' : '').nl2br($plugin['description']).'<br /><div style="width:95%;height:30px !important;" style="clear:both"><div style="float:right">'.$plugin['copyright'].'</div></div></div><br /><br />';
}
showtagfooter('div');
showtagheader('div', 'vars', $anchor == 'vars');
if($pluginvars) {
showformheader("plugins&operation=config&pluginid=$pluginid");
showtableheader();
showtitle($lang['plugins_config']);
$extra = array();
foreach($pluginvars as $var) {
$var['variable'] = 'varsnew['.$var['variable'].']';
if($var['type'] == 'number') {
$var['type'] = 'text';
} elseif($var['type'] == 'select') {
$var['type'] = "<select name=\"$var[variable]\">\n";
foreach(explode("\n", $var['extra']) as $key => $option) {
$option = trim($option);
if(strpos($option, '=') === FALSE) {
$key = $option;
} else {
$item = explode('=', $option);
$key = trim($item[0]);
$option = trim($item[1]);
}
$var['type'] .= "<option value=\"".dhtmlspecialchars($key)."\" ".($var['value'] == $key ? 'selected' : '').">$option</option>\n";
}
$var['type'] .= "</select>\n";
$var['variable'] = $var['value'] = '';
} elseif($var['type'] == 'date') {
$var['type'] = 'calendar';
$extra['date'] = '<script type="text/javascript" src="include/js/calendar.js"></script>';
} elseif($var['type'] == 'datetime') {
$var['type'] = 'calendar';
$var['extra'] = 1;
$extra['date'] = '<script type="text/javascript" src="include/js/calendar.js"></script>';
} elseif($var['type'] == 'forum') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$var['type'] = '<select name="'.$var['variable'].'"><option value="">'.lang('plugins_empty').'</option>'.forumselect(FALSE, 0, $var['value'], TRUE).'</select>';
$var['variable'] = $var['value'] = '';
} elseif($var['type'] == 'forums') {
$var['description'] = ($var['description'] ? (isset($lang[$var['description']]) ? $lang[$var['description']] : $var['description']).'<br />' : '').$lang['plugins_edit_vars_multiselect_comment'].'<br />'.$var['comment'];
$var['value'] = unserialize($var['value']);
$var['value'] = is_array($var['value']) ? $var['value'] : array();
require_once DISCUZ_ROOT.'./include/forum.func.php';
$var['type'] = '<select name="'.$var['variable'].'[]" size="10" multiple="multiple"><option value="">'.lang('plugins_empty').'</option>'.forumselect(FALSE, 0, 0, TRUE).'</select>';
foreach($var['value'] as $v) {
$var['type'] = str_replace('<option value="'.$v.'">', '<option value="'.$v.'" selected>', $var['type']);
}
$var['variable'] = $var['value'] = '';
} elseif(substr($var['type'], 0, 5) == 'group') {
if($var['type'] == 'groups') {
$var['description'] = ($var['description'] ? (isset($lang[$var['description']]) ? $lang[$var['description']] : $var['description']).'<br />' : '').$lang['plugins_edit_vars_multiselect_comment'].'<br />'.$var['comment'];
$var['value'] = unserialize($var['value']);
$var['type'] = '<select name="'.$var['variable'].'[]" size="10" multiple="multiple"><option value=""'.(@in_array('', $var['value']) ? ' selected' : '').'>'.lang('plugins_empty').'</option>';
} else {
$var['type'] = '<select name="'.$var['variable'].'"><option value="">'.lang('plugins_empty').'</option>';
}
$var['value'] = is_array($var['value']) ? $var['value'] : array($var['value']);
$query = $db->query("SELECT type, groupid, grouptitle, radminid FROM {$tablepre}usergroups ORDER BY (creditshigher<>'0' || creditslower<>'0'), creditslower, groupid");
$groupselect = array();
while($group = $db->fetch_array($query)) {
$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
$groupselect[$group['type']] .= '<option value="'.$group['groupid'].'"'.(@in_array($group['groupid'], $var['value']) ? ' selected' : '').'>'.$group['grouptitle'].'</option>';
}
$var['type'] .= '<optgroup label="'.$lang['usergroups_member'].'">'.$groupselect['member'].'</optgroup>'.
($groupselect['special'] ? '<optgroup label="'.$lang['usergroups_special'].'">'.$groupselect['special'].'</optgroup>' : '').
($groupselect['specialadmin'] ? '<optgroup label="'.$lang['usergroups_specialadmin'].'">'.$groupselect['specialadmin'].'</optgroup>' : '').
'<optgroup label="'.$lang['usergroups_system'].'">'.$groupselect['system'].'</optgroup></select>';
$var['variable'] = $var['value'] = '';
} elseif($var['type'] == 'extcredit') {
$var['type'] = '<select name="'.$var['variable'].'"><option value="">'.lang('plugins_empty').'</option>';
foreach($extcredits as $id => $credit) {
$var['type'] .= '<option value="'.$id.'"'.($var['value'] == $id ? ' selected' : '').'>'.$credit['title'].'</option>';
}
$var['type'] .= '</select>';
$var['variable'] = $var['value'] = '';
}
showsetting(isset($lang[$var['title']]) ? $lang[$var['title']] : $var['title'], $var['variable'], $var['value'], $var['type'], '', 0, isset($lang[$var['description']]) ? $lang[$var['description']] : nl2br($var['description']), $var['extra']);
}
showsubmit('editsubmit');
showtablefooter();
showformfooter();
echo implode('', $extra);
}
} else {
if(is_array($varsnew)) {
foreach($varsnew as $variable => $value) {
if(isset($pluginvars[$variable])) {
if($pluginvars[$variable]['type'] == 'number') {
$value = (float)$value;
} elseif(in_array($pluginvars[$variable]['type'], array('forums', 'groups'))) {
$value = addslashes(serialize($value));
}
$db->query("UPDATE {$tablepre}pluginvars SET value='$value' WHERE pluginid='$pluginid' AND variable='$variable'");
}
}
}
updatecache('plugins');
cpmsg('plugins_settings_succeed', $BASESCRIPT.'?action=plugins&operation=config&pluginid='.$pluginid.'&anchor='.$anchor, 'succeed');
}
} else {
$modfile = '';
if(is_array($plugin['modules'])) {
foreach($plugin['modules'] as $module) {
if($module['type'] == 3 && $module['name'] == $mod) {
$plugin['directory'] .= (!empty($plugin['directory']) && substr($plugin['directory'], -1) != '/') ? '/' : '';
$modfile = './plugins/'.$plugin['directory'].$module['name'].'.inc.php';
break;
}
}
}
if($modfile) {
if(!empty($plugin['modules']['extra']['langexists'])) {
@include_once DISCUZ_ROOT.'./forumdata/plugins/'.$plugin['identifier'].'.lang.php';
}
shownav('plugin', 'nav_plugins', $plugin['name']);
showsubmenu($plugin['name'].(!$plugin['available'] ? ' ('.$lang['plugins_unavailable'] : ''), $submenuitem);
if(!@include DISCUZ_ROOT.$modfile) {
cpmsg('plugins_settings_module_nonexistence', '', 'error');
} else {
dexit();
}
} else {
cpmsg('undefined_action', '', 'error');
}
}
} elseif($operation == 'add') {
if(!submitcheck('addsubmit')) {
shownav('plugin', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('plugins_list', 'plugins', 0),
array('import', 'plugins&operation=import', 0),
array('plugins_add', 'plugins&operation=add', 1)
));
showtips('plugins_add_tips');
showformheader("plugins&operation=add", '', 'configform');
showtableheader();
showsetting('plugins_edit_name', 'namenew', '', 'text');
showsetting('plugins_edit_copyright', 'copyrightnew', '', 'text');
showsetting('plugins_edit_identifier', 'identifiernew', '', 'text');
showsubmit('addsubmit');
showtablefooter();
showformfooter();
} else {
$namenew = dhtmlspecialchars(trim($namenew));
$identifiernew = trim($identifiernew);
$copyrightnew = dhtmlspecialchars($copyrightnew);
if(!$namenew) {
cpmsg('plugins_edit_name_invalid', '', 'error');
} else {
$query = $db->query("SELECT pluginid FROM {$tablepre}plugins WHERE identifier='$identifiernew' LIMIT 1");
if($db->num_rows($query) || !ispluginkey($identifiernew)) {
cpmsg('plugins_edit_identifier_invalid', '', 'error');
}
}
$db->query("INSERT INTO {$tablepre}plugins (name, identifier, directory, available, copyright) VALUES ('$namenew', '$identifiernew', '$identifiernew/', '0', '$copyrightnew')");
$pluginid = $db->insert_id();
updatecache('plugins');
cpmsg('plugins_add_succeed', "$BASESCRIPT?action=plugins&operation=edit&pluginid=$pluginid", 'succeed');
}
} elseif($operation == 'edit') {
if(empty($pluginid) ) {
$pluginlist = '<select name="pluginid">';
$query = $db->query("SELECT pluginid, name FROM {$tablepre}plugins");
while($plugin = $db->fetch_array($query)) {
$pluginlist .= '<option value="'.$plugin['pluginid'].'">'.$plugin['name'].'</option>';
}
$pluginlist .= '</select>';
cpmsg('plugins_nonexistence', $BASESCRIPT.'?action=plugins&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $pluginlist);
} else {
$condition = !empty($uid) ? "uid='$uid'" : "username='$username'";
}
$plugin = $db->fetch_first("SELECT * FROM {$tablepre}plugins WHERE pluginid='$pluginid'");
if(!$plugin) {
cpmsg('undefined_action', '', 'error');
}
$plugin['modules'] = unserialize($plugin['modules']);
if(!submitcheck('editsubmit')) {
$adminidselect = array($plugin['adminid'] => 'selected');
shownav('plugin', 'nav_plugins');
$anchor = in_array($anchor, array('config', 'modules', 'hooks', 'vars')) ? $anchor : 'config';
showsubmenuanchors($lang['plugins_edit'].' - '.$plugin['name'], array(
array('plugins_list', 'plugins', 0, 1),
array('config', 'config', $anchor == 'config'),
array('plugins_config_module', 'modules', $anchor == 'modules'),
array('plugins_config_hooks', 'hooks', $anchor == 'hooks'),
array('plugins_config_vars', 'vars', $anchor == 'vars'),
array('export', 'plugins&operation=export&pluginid='.$plugin['pluginid'], 0, 1),
));
showtips('plugins_edit_tips');
showtagheader('div', 'config', $anchor == 'config');
showformheader("plugins&operation=edit&type=common&pluginid=$pluginid", '', 'configform');
showtableheader();
showsetting('plugins_edit_name', 'namenew', $plugin['name'], 'text');
if(!$plugin['copyright']) {
showsetting('plugins_edit_copyright', 'copyrightnew', $plugin['copyright'], 'text');
}
showsetting('plugins_edit_identifier', 'identifiernew', $plugin['identifier'], 'text');
showsetting('plugins_edit_adminid', '', '', '<select name="adminidnew"><option value="1" '.$adminidselect[1].'>'.$lang['usergroups_system_1'].'</option><option value="2" '.$adminidselect[2].'>'.$lang['usergroups_system_2'].'</option><option value="3" '.$adminidselect[3].'>'.$lang['usergroups_system_3'].'</option></select>');
showsetting('plugins_edit_directory', 'directorynew', $plugin['directory'], 'text');
showsetting('plugins_edit_datatables', 'datatablesnew', $plugin['datatables'], 'text');
showsetting('plugins_edit_description', 'descriptionnew', $plugin['description'], 'textarea');
showsetting('plugins_edit_langexists', 'langexists', $plugin['modules']['extra']['langexists'], 'radio');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'modules', $anchor == 'modules');
showformheader("plugins&operation=edit&type=modules&pluginid=$pluginid", '', 'modulesform');
showtableheader('plugins_edit_modules');
showsubtitle(array('', 'plugins_edit_modules_type', 'plugins_edit_modules_name', 'plugins_edit_modules_menu', 'plugins_edit_modules_menu_url', 'plugins_edit_modules_adminid', 'display_order'));
$moduleids = array();
if(is_array($plugin['modules'])) {
foreach($plugin['modules'] as $moduleid => $module) {
if($moduleid === 'extra') {
continue;
}
$adminidselect = array($module['adminid'] => 'selected');
$includecheck = empty($val['include']) ? $lang['no'] : $lang['yes'];
$typeselect = '<optgroup label="'.lang('plugins_edit_modules_type_g1').'">'.
'<option h="1111" e="inc" value="1"'.($module['type'] == 1 || $module['type'] == 2 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_1').'</option>'.
'<option h="1111" e="inc" value="5"'.($module['type'] == 5 || $module['type'] == 6 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_5').'</option>'.
'<option h="1111" e="inc" value="7"'.($module['type'] == 7 || $module['type'] == 8 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_7').'</option>'.
'<option h="1111" e="inc" value="9"'.($module['type'] == 9 || $module['type'] == 10 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_9').'</option>'.
'<option h="1001" e="inc" value="14"'.($module['type'] == 14 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_14').'</option>'.
'<option h="1001" e="inc" value="15"'.($module['type'] == 15 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_15').'</option>'.
'<option h="1001" e="inc" value="16"'.($module['type'] == 16 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_16').'</option>'.
'<option h="1001" e="inc" value="3"'.($module['type'] == 3 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_3').'</option>'.
'</optgroup>'.
'<optgroup label="'.lang('plugins_edit_modules_type_g2').'">'.
'<option h="0000" e="inc" value="13"'.($module['type'] == 13 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_13').'</option>'.
'<option h="0011" e="inc" value="4"'.($module['type'] == 4 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_4').'</option>'.
'<option h="0011" e="class" value="11"'.($module['type'] == 11 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_11').'</option>'.
'<option h="0001" e="class" value="12"'.($module['type'] == 12 ? ' selected="selected"' : '').'>'.lang('plugins_edit_modules_type_12').'</option>'.
'</optgroup>';
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$moduleid]\">",
"<select id=\"s_$moduleid\" onchange=\"shide(this, '$moduleid')\" name=\"typenew[$moduleid]\">$typeselect</select>",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$moduleid]\" value=\"$module[name]\"><span id=\"e_$moduleid\"></span>",
"<span id=\"m_$moduleid\"><input type=\"text\" class=\"txt\" size=\"15\" name=\"menunew[$moduleid]\" value=\"$module[menu]\"></span>",
"<span id=\"u_$moduleid\"><input type=\"text\" class=\"txt\" size=\"15\" id=\"url_$moduleid\" onchange=\"shide($('s_$moduleid'), '$moduleid')\" name=\"urlnew[$moduleid]\" value=\"".dhtmlspecialchars($module['url'])."\"></span>",
"<span id=\"a_$moduleid\"><select name=\"adminidnew[$moduleid]\">\n".
"<option value=\"0\" $adminidselect[0]>$lang[usergroups_system_0]</option>\n".
"<option value=\"1\" $adminidselect[1]>$lang[usergroups_system_1]</option>\n".
"<option value=\"2\" $adminidselect[2]>$lang[usergroups_system_2]</option>\n".
"<option value=\"3\" $adminidselect[3]>$lang[usergroups_system_3]</option>\n".
"</select></span>",
"<span id=\"o_$moduleid\"><input type=\"text\" class=\"txt\" style=\"width:50px\" name=\"ordernew[$moduleid]\" value=\"$module[displayorder]\"></span>"
));
$moduleids[] = $moduleid;
}
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
lang('add_new'),
'<select id="s_n" onchange="shide(this, \'n\')" name="newtype">
<optgroup label="'.lang('plugins_edit_modules_type_g1').'">
<option h="1111" e="inc" value="1">'.lang('plugins_edit_modules_type_1').'</option>
<option h="1111" e="inc" value="5">'.lang('plugins_edit_modules_type_5').'</option>
<option h="1111" e="inc" value="7">'.lang('plugins_edit_modules_type_7').'</option>
<option h="1111" e="inc" value="9">'.lang('plugins_edit_modules_type_9').'</option>
<option h="1001" e="inc" value="14">'.lang('plugins_edit_modules_type_14').'</option>
<option h="1001" e="inc" value="15">'.lang('plugins_edit_modules_type_15').'</option>
<option h="1001" e="inc" value="16">'.lang('plugins_edit_modules_type_16').'</option>
<option h="1001" e="inc" value="3">'.lang('plugins_edit_modules_type_3').'</option>
</optgroup>
<optgroup label="'.lang('plugins_edit_modules_type_g2').'">
<option h="0000" e="inc" value="13">'.lang('plugins_edit_modules_type_13').'</option>
<option h="0011" e="inc" value="4">'.lang('plugins_edit_modules_type_4').'</option>
<option h="0011" e="class" value="11">'.lang('plugins_edit_modules_type_11').'</option>
<option h="0001" e="class" value="12">'.lang('plugins_edit_modules_type_12').'</option>
</optgroup>
</select>',
'<input type="text" class="txt" size="15" name="newname"><span id="e_n"></span>',
'<span id="m_n"><input type="text" class="txt" size="15" name="newmenu"></span>',
'<span id="u_n"><input type="text" class="txt" size="15" id="url_n" onchange="shide($(\'s_n\'), \'n\')" name="newurl"></span>',
'<span id="a_n"><select name="newadminid">'.
'<option value="0">'.lang('usergroups_system_0').'</option>'.
'<option value="1" selected>'.lang('usergroups_system_1').'</option>'.
'<option value="2">'.lang('usergroups_system_2').'</option>'.
'<option value="3">'.lang('usergroups_system_3').'</option>'.
'</select></span>',
'<span id="o_n"><input type="text" class="txt" style="width:50px" name="neworder"></span>',
));
showsubmit('editsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'hooks', $anchor == 'hooks');
showformheader("plugins&operation=edit&type=hooks&pluginid=$pluginid", '', 'hooksform');
showtableheader('plugins_edit_hooks');
showsubtitle(array('', 'available', 'plugins_hooks_title', 'plugins_hooks_callback', 'plugins_hooks_description', ''));
$query = $db->query("SELECT pluginhookid, title, description, available FROM {$tablepre}pluginhooks WHERE pluginid='$plugin[pluginid]'");
while($hook = $db->fetch_array($query)) {
$hook['description'] = nl2br(cutstr($hook['description'], 50));
$hook['evalcode'] = 'eval($hooks[\''.$plugin['identifier'].'_'.$hook['title'].'\']);';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$hook[pluginhookid]]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$hook[pluginhookid]]\" value=\"1\" ".($hook['available'] ? 'checked' : '')." onclick=\"if(this.checked) {\$('hookevalcode{$hook[pluginhookid]}').value='".addslashes($hook[evalcode])."';}else{\$('hookevalcode{$hook[pluginhookid]}').value='N/A';}\">",
"<input type=\"text\" class=\"txt\" name=\"titlenew[$hook[pluginhookid]]\" size=\"15\" value=\"$hook[title]\"></td>\n".
"<td><input type=\"text\" class=\"txt\" name=\"hookevalcode{$hook[pluginhookid]}\" id=\"hookevalcode{$hook[pluginhookid]}\"size=\"30\" value=\"".($hook['available'] ? $hook[evalcode] : 'N/A')."\" readonly>",
$hook['description'],
"<a href=\"$BASESCRIPT?action=plugins&operation=hooks&pluginid=$plugin[pluginid]&pluginhookid=$hook[pluginhookid]\" class=\"act\">$lang[edit]</a>"
));
}
showtablerow('', array('', '', '', 'colspan="3"'), array(
lang('add_new'),
'',
'<input type="text" class="txt" name="newtitle" size="15">',
''
));
showsubmit('editsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
$shideinit = '';
foreach($moduleids as $moduleid) {
$shideinit .= 'shide($("s_'.$moduleid.'"), \''.$moduleid.'\');';
}
echo '<script type="text/JavaScript">
function shide(obj, id) {
v = obj.options[obj.selectedIndex].getAttribute("h");
$("m_" + id).style.display = v.substr(0,1) == "1" ? "" : "none";
$("u_" + id).style.display = v.substr(1,1) == "1" ? "" : "none";
$("a_" + id).style.display = v.substr(2,1) == "1" ? "" : "none";
$("o_" + id).style.display = v.substr(3,1) == "1" ? "" : "none";
e = obj.options[obj.selectedIndex].getAttribute("e");
$("e_" + id).innerHTML = e && ($("url_" + id).value == \'\' || $("u_" + id).style.display == "none") ? "." + e + ".php" : "";
}
shide($("s_n"), "n");'.$shideinit.'
</script>';
showtagheader('div', 'vars', $anchor == 'vars');
showformheader("plugins&operation=edit&type=vars&pluginid=$pluginid", '', 'varsform');
showtableheader('plugins_edit_vars');
showsubtitle(array('', 'display_order', 'plugins_vars_title', 'plugins_vars_variable', 'plugins_vars_type', ''));
$query = $db->query("SELECT * FROM {$tablepre}pluginvars WHERE pluginid='$plugin[pluginid]' ORDER BY displayorder");
while($var = $db->fetch_array($query)) {
$var['type'] = $lang['plugins_edit_vars_type_'. $var['type']];
$var['title'] .= isset($lang[$var['title']]) ? '<br />'.$lang[$var['title']] : '';
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$var[pluginvarid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$var[pluginvarid]]\" value=\"$var[displayorder]\">",
$var['title'],
$var['variable'],
$var['type'],
"<a href=\"$BASESCRIPT?action=plugins&operation=vars&pluginid=$plugin[pluginid]&pluginvarid=$var[pluginvarid]\" class=\"act\">$lang[detail]</a>"
));
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
lang('add_new'),
'<input type="text" class="txt" size="2" name="newdisplayorder" value="0">',
'<input type="text" class="txt" size="15" name="newtitle">',
'<input type="text" class="txt" size="15" name="newvariable">',
'<select name="newtype">
<option value="number">'.lang('plugins_edit_vars_type_number').'</option>
<option value="text" selected>'.lang('plugins_edit_vars_type_text').'</option>
<option value="textarea">'.lang('plugins_edit_vars_type_textarea').'</option>
<option value="radio">'.lang('plugins_edit_vars_type_radio').'</option>
<option value="select">'.lang('plugins_edit_vars_type_select').'</option>
<option value="color">'.lang('plugins_edit_vars_type_color').'</option>
<option value="date">'.lang('plugins_edit_vars_type_date').'</option>
<option value="datetime">'.lang('plugins_edit_vars_type_datetime').'</option>
<option value="forum">'.lang('plugins_edit_vars_type_forum').'</option>
<option value="forums">'.lang('plugins_edit_vars_type_forums').'</option>
<option value="group">'.lang('plugins_edit_vars_type_group').'</option>
<option value="groups">'.lang('plugins_edit_vars_type_groups').'</option>
<option value="extcredit">'.lang('plugins_edit_vars_type_extcredit').'</option>
</seletc>',
''
));
showsubmit('editsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($type == 'common') {
$namenew = dhtmlspecialchars(trim($namenew));
$directorynew = dhtmlspecialchars($directorynew);
$identifiernew = trim($identifiernew);
$datatablesnew = dhtmlspecialchars(trim($datatablesnew));
$descriptionnew = dhtmlspecialchars($descriptionnew);
$copyrightnew = $plugin['copyright'] ? addslashes($plugin['copyright']) : dhtmlspecialchars($copyrightnew);
$adminidnew = ($adminidnew > 0 && $adminidnew <= 3) ? $adminidnew : 1;
if(!$namenew) {
cpmsg('plugins_edit_name_invalid', '', 'error');
} elseif(!isplugindir($directorynew)) {
cpmsg('plugins_edit_directory_invalid', '', 'error');
} elseif($identifiernew != $plugin['identifier']) {
$query = $db->query("SELECT pluginid FROM {$tablepre}plugins WHERE identifier='$identifiernew' LIMIT 1");
if($db->num_rows($query) || !ispluginkey($identifiernew)) {
cpmsg('plugins_edit_identifier_invalid', '', 'error');
}
}
if($langexists && !file_exists($langfile = DISCUZ_ROOT.'./forumdata/plugins/'.$identifiernew.'.lang.php')) {
cpmsg('plugins_edit_language_invalid', '', 'error');
}
$plugin['modules']['extra']['langexists'] = $langexists;
$db->query("UPDATE {$tablepre}plugins SET adminid='$adminidnew', name='$namenew', modules='".addslashes(serialize($plugin['modules']))."', identifier='$identifiernew', description='$descriptionnew', datatables='$datatablesnew', directory='$directorynew', copyright='$copyrightnew' WHERE pluginid='$pluginid'");
} elseif($type == 'modules') {
$modulesnew = array();
$newname = trim($newname);
if(is_array($plugin['modules'])) {
foreach($plugin['modules'] as $moduleid => $module) {
if(!isset($delete[$moduleid])) {
if($moduleid === 'extra') {
continue;
}
$modulesnew[] = array(
'name' => $namenew[$moduleid],
'menu' => $menunew[$moduleid],
'url' => $urlnew[$moduleid],
'type' => $typenew[$moduleid],
'adminid' => ($adminidnew[$moduleid] >= 0 && $adminidnew[$moduleid] <= 3) ? $adminidnew[$moduleid] : $module['adminid'],
'displayorder' => intval($ordernew[$moduleid]),
);
}
}
}
$newmodule = array();
if(!empty($newname)) {
$modulesnew[] = array(
'name' => $newname,
'menu' => $newmenu,
'url' => $newurl,
'type' => $newtype,
'adminid' => $newadminid,
'displayorder' => intval($neworder),
);
}
usort($modulesnew, 'modulecmp');
$namesarray = array();
foreach($modulesnew as $key => $module) {
$namekey = in_array($module['type'], array(11, 12)) ? 1 : 0;
if(!ispluginkey($module['name'])) {
cpmsg('plugins_edit_modules_name_invalid', '', 'error');
} elseif(@in_array($module['name'], $namesarray[$namekey])) {
cpmsg('plugins_edit_modules_duplicated', '', 'error');
}
$namesarray[$namekey][] = $module['name'];
$module['menu'] = trim($module['menu']);
$module['url'] = trim($module['url']);
$module['adminid'] = $module['adminid'] >= 0 && $module['adminid'] <= 3 ? $module['adminid'] : 1 ;
$unseturl = TRUE;
switch($module['type']) {
case 1:
case 5:
case 7:
case 9:
if(empty($module['url'])) {
$module['type']++;
} else {
$unseturl = FALSE;
}
case 3:
case 14:
case 15:
case 16:
case 17:
if(empty($module['menu'])) {
cpmsg('plugins_edit_modules_menu_invalid', '', 'error');
}
if($unseturl) {
unset($module['url']);
}
break;
case 4:
case 11:
case 12:
case 13:
unset($module['menu'], $module['url']);
break;
default:
cpmsg('undefined_action', '', 'error');
}
$modulesnew[$key] = $module;
}
if(!empty($plugin['modules']['extra'])) {
$modulesnew['extra'] = $plugin['modules']['extra'];
}
$db->query("UPDATE {$tablepre}plugins SET modules='".addslashes(serialize($modulesnew))."' WHERE pluginid='$pluginid'");
} elseif($type == 'hooks') {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id => $val) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}pluginhooks WHERE pluginid='$pluginid' AND pluginhookid IN ($ids)");
}
if(is_array($titlenew)) {
$titlearray = array();
foreach($titlenew as $id => $val) {
if(!ispluginkey($val) || in_array($val, $titlearray)) {
cpmsg('plugins_edit_hooks_title_invalid', '', 'error');
}
$titlearray[] = $val;
$db->query("UPDATE {$tablepre}pluginhooks SET title='".dhtmlspecialchars($titlenew[$id])."', available='".intval($availablenew[$id])."' WHERE pluginid='$pluginid' AND pluginhookid='$id'");
}
}
if($newtitle) {
if(!ispluginkey($newtitle) || (is_array($titlenew) && in_array($newtitle, $titlenew))) {
cpmsg('plugins_edit_hooks_title_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}pluginhooks (pluginid, title, description, code, available)
VALUES ('$pluginid', '".dhtmlspecialchars($newtitle)."', '', '', 0)");
}
} elseif($type == 'vars') {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}pluginvars WHERE pluginid='$pluginid' AND pluginvarid IN ($ids)");
}
if(is_array($displayordernew)) {
foreach($displayordernew as $id => $displayorder) {
$db->query("UPDATE {$tablepre}pluginvars SET displayorder='$displayorder' WHERE pluginid='$pluginid' AND pluginvarid='$id'");
}
}
$newtitle = dhtmlspecialchars(trim($newtitle));
$newvariable = trim($newvariable);
if($newtitle && $newvariable) {
$query = $db->query("SELECT pluginvarid FROM {$tablepre}pluginvars WHERE pluginid='$pluginid' AND variable='$newvariable' LIMIT 1");
if($db->num_rows($query) || strlen($newvariable) > 40 || !ispluginkey($newvariable)) {
cpmsg('plugins_edit_var_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}pluginvars (pluginid, displayorder, title, variable, type)
VALUES ('$pluginid', '$newdisplayorder', '$newtitle', '$newvariable', '$newtype')");
}
}
updatecache('plugins');
updatecache('settings');
updatemenu();
cpmsg('plugins_edit_succeed', "$BASESCRIPT?action=plugins&operation=edit&pluginid=$pluginid&anchor=$anchor", 'succeed');
}
} elseif($operation == 'delete') {
$plugin = $db->fetch_first("SELECT name, identifier, directory, modules, version FROM {$tablepre}plugins WHERE pluginid='$pluginid'");
$dir = $plugin['directory'];
$modules = unserialize($plugin['modules']);
if(!$confirmed) {
$entrydir = DISCUZ_ROOT.'./plugins/'.$dir;
$newver = $upgradestr = '';
if(file_exists($entrydir)) {
$d = dir($entrydir);
while($f = $d->read()) {
if(preg_match('/^discuz\_plugin\_'.$plugin['identifier'].'(\_\w+)?\.xml$/', $f, $a)) {
$extratxt = $extra = substr($a[1], 1);
if(preg_match('/^SC\_GBK$/i', $extra)) {
$extratxt = '简体中文版';
} elseif(preg_match('/^SC\_UTF8$/i', $extra)) {
$extratxt = '简体中文UTF8版';
} elseif(preg_match('/^TC\_BIG5$/i', $extra)) {
$extratxt = '繁體中文版';
} elseif(preg_match('/^TC\_UTF8$/i', $extra)) {
$extratxt = '繁體中文UTF8版';
}
$importtxt = @implode('', file($entrydir.'/'.$f));
$pluginarray = getimportdata('Discuz! Plugin');
$newver = !empty($pluginarray['plugin']['version']) ? $pluginarray['plugin']['version'] : 0;
$upgradestr .= $newver > $plugin['version'] ? ' <input class="btn" onclick="location.href=\''.$BASESCRIPT.'?action=plugins&operation=upgrade&pluginid='.$pluginid.'&xmlfile='.rawurlencode($a[0]).'\'" type="button" value="'.lang('plugins_update_to').($extra ? $extratxt : $lang['plugins_import_default']).' '.$newver.'" /> ' : '';
}
}
}
showsubmenu($lang['plugins_config_uninstall'].' - '.$plugin['name']);
echo '<div class="infobox">'.($upgradestr ? '<h4 class="infotitle2">'.$lang['plugins_config_upgrade'].'</h4>'.$upgradestr.'<br /><br />' : '').'
<h4 class="infotitle2">'.$lang['plugins_config_delete'].'</h4>
<input class="btn" onclick="location.href=\''.$BASESCRIPT.'?action=plugins&operation=delete&pluginid='.$pluginid.'&confirmed=yes\'" type="button" value="'.$lang['plugins_config_uninstallplugin'].'" /><br /><br />
<input class="btn" onclick="location.href=\''.$BASESCRIPT.'?action=plugins\'" type="button" value="'.$lang['cancel'].'"/>
</div>';
} else {
$identifier = $plugin['identifier'];
$db->query("DELETE FROM {$tablepre}plugins WHERE pluginid=$pluginid");
$db->query("DELETE FROM {$tablepre}pluginvars WHERE pluginid=$pluginid");
updatecache('plugins');
updatecache('settings');
updatemenu();
if($dir) {
$dir = substr($dir, 0, -1);
$pdir = DISCUZ_ROOT.'./plugins/'.$dir;
if(file_exists($pdir)) {
$d = dir($pdir);
while($f = $d->read()) {
if(preg_match('/^discuz\_plugin_'.$dir.'(\_\w+)?\.xml$/', $f, $a)) {
$installtype = substr($a[1], 1);
$file = $pdir.'/'.$f;
$importtxt = @implode('', file($file));
$pluginarray = getimportdata('Discuz! Plugin');
if(!empty($pluginarray['uninstallfile']) && preg_match('/^[\w\.]+$/', $pluginarray['uninstallfile'])) {
dheader('location: '.$BASESCRIPT.'?action=plugins&operation=pluginuninstall&dir='.$dir.'&installtype='.$installtype);
}
break;
}
}
}
}
if(!empty($modules['extra']['langexists'])) {
@unlink(DISCUZ_ROOT.'./forumdata/plugins/'.$identifier.'.lang.php');
}
pluginstat('uninstall', $pluginarray['plugin']);
cpmsg('plugins_delete_succeed', "$BASESCRIPT?action=plugins", 'succeed');
}
} elseif($operation == 'hooks') {
$pluginhook = $db->fetch_first("SELECT * FROM {$tablepre}plugins p, {$tablepre}pluginhooks ph WHERE p.pluginid='$pluginid' AND ph.pluginid=p.pluginid AND ph.pluginhookid='$pluginhookid'");
if(!$pluginhook) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('hooksubmit')) {
shownav('plugin', 'nav_plugins');
showsubmenu($lang['plugins_edit'].' - '.$pluginhook['name'], array(
array('plugins_list', 'plugins', 0),
array('config', 'plugins&operation=edit&pluginid='.$pluginid.'&anchor=config', 0),
array('plugins_config_module', 'plugins&operation=edit&pluginid='.$pluginid.'&anchor=modules', 0),
array('plugins_config_hooks', 'plugins&operation=edit&pluginid='.$pluginid.'&anchor=hooks', 1),
array('plugins_config_vars', 'plugins&operation=edit&pluginid='.$pluginid.'&anchor=vars', 0),
array('export', 'plugins&operation=export&pluginid='.$pluginid, 0),
));
showtips('plugins_edit_hooks_tips');
showformheader("plugins&operation=hooks&pluginid=$pluginid&pluginhookid=$pluginhookid");
showtableheader();
showtitle($lang['plugins_edit_hooks'].' - '.$pluginhook['title']);
showsetting('plugins_edit_hooks_description', 'descriptionnew', $pluginhook['description'], 'textarea');
showsetting('plugins_edit_hooks_code', 'codenew', $pluginhook['code'], 'textarea');
showsubmit('hooksubmit');
showtablefooter();
showformfooter();
} else {
$descriptionnew = dhtmlspecialchars(trim($descriptionnew));
$codenew = trim($codenew);
$db->query("UPDATE {$tablepre}pluginhooks SET description='$descriptionnew', code='$codenew' WHERE pluginid='$pluginid' AND pluginhookid='$pluginhookid'");
updatecache('settings');
cpmsg('plugins_edit_hooks_succeed', "$BASESCRIPT?action=plugins&operation=edit&pluginid=$pluginid&anchor=hooks", 'succeed');
}
} elseif($operation == 'vars') {
$pluginvar = $db->fetch_first("SELECT * FROM {$tablepre}plugins p, {$tablepre}pluginvars pv WHERE p.pluginid='$pluginid' AND pv.pluginid=p.pluginid AND pv.pluginvarid='$pluginvarid'");
if(!$pluginvar) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('varsubmit')) {
shownav('plugin', 'nav_plugins');
showsubmenu($lang['plugins_edit'].' - '.$pluginvar['name'], array(
array('plugins_list', 'plugins', 0),
array('config', 'plugins&operation=edit&pluginid='.$pluginid.'&anchor=config', 0),
array('plugins_config_module', 'plugins&operation=edit&pluginid='.$pluginid.'&anchor=modules', 0),
array('plugins_config_hooks', 'plugins&operation=edit&pluginid='.$pluginid.'&anchor=hooks', 0),
array('plugins_config_vars', 'plugins&operation=edit&pluginid='.$pluginid.'&anchor=vars', 1),
array('export', 'plugins&operation=export&pluginid='.$pluginid, 0),
));
$typeselect = '<select name="typenew" onchange="if(this.value == \'select\') $(\'extra\').style.display=\'\'; else $(\'extra\').style.display=\'none\';">';
foreach(array('number', 'text', 'radio', 'textarea', 'select', 'color', 'date', 'datetime', 'forum', 'forums', 'group', 'groups', 'extcredit') as $type) {
$typeselect .= '<option value="'.$type.'" '.($pluginvar['type'] == $type ? 'selected' : '').'>'.$lang['plugins_edit_vars_type_'.$type].'</option>';
}
$typeselect .= '</select>';
showformheader("plugins&operation=vars&pluginid=$pluginid&pluginvarid=$pluginvarid");
showtableheader();
showtitle($lang['plugins_edit_vars'].' - '.$pluginvar['title']);
showsetting('plugins_edit_vars_title', 'titlenew', $pluginvar['title'], 'text');
showsetting('plugins_edit_vars_description', 'descriptionnew', $pluginvar['description'], 'textarea');
showsetting('plugins_edit_vars_type', '', '', $typeselect);
showsetting('plugins_edit_vars_variable', 'variablenew', $pluginvar['variable'], 'text');
showtagheader('tbody', 'extra', $pluginvar['type'] == 'select');
showsetting('plugins_edit_vars_extra', 'extranew', $pluginvar['extra'], 'textarea');
showtagfooter('tbody');
showsubmit('varsubmit');
showtablefooter();
showformfooter();
} else {
$titlenew = cutstr(dhtmlspecialchars(trim($titlenew)), 25);
$descriptionnew = cutstr(dhtmlspecialchars(trim($descriptionnew)), 255);
$variablenew = trim($variablenew);
$extranew = dhtmlspecialchars(trim($extranew));
if(!$titlenew) {
cpmsg('plugins_edit_var_title_invalid', '', 'error');
} elseif($variablenew != $pluginvar['variable']) {
$query = $db->query("SELECT pluginvarid FROM {$tablepre}pluginvars WHERE variable='$variablenew'");
if($db->num_rows($query) || !$variablenew || strlen($variablenew) > 40 || !ispluginkey($variablenew)) {
cpmsg('plugins_edit_vars_invalid', '', 'error');
}
}
$db->query("UPDATE {$tablepre}pluginvars SET title='$titlenew', description='$descriptionnew', type='$typenew', variable='$variablenew', extra='$extranew' WHERE pluginid='$pluginid' AND pluginvarid='$pluginvarid'");
updatecache('plugins');
cpmsg('plugins_edit_vars_succeed', "$BASESCRIPT?action=plugins&operation=edit&pluginid=$pluginid&anchor=vars", 'succeed');
}
}
function modulecmp($a, $b) {
return $a['displayorder'] > $b['displayorder'] ? 1 : -1;
}
function updatemenu() {
global $BASESCRIPT;
$pluginmenus = array(array('addons', 'addons'), array('plugins_menu', 'plugins'));
@include DISCUZ_ROOT.'./forumdata/cache/adminmenu.php';
if(is_array($adminmenu)) {
foreach($adminmenu as $row) {
$pluginmenus[] = array($row['name'], $row['url']);
}
}
$s = '';
foreach($pluginmenus as $menu) {
if($menu[0] && $menu[1]) {
$s .= '<li><a href="'.(substr($menu[1], 0, 4) == 'http' ? $menu[1] : $BASESCRIPT.'?action='.$menu[1]).'" hidefocus="true" target="'.($menu[2] ? $menu[2] : 'main').'"'.($menu[3] ? $menu[3] : '').'>'.lang($menu[0]).'</a></li>';
}
}
echo '<script type="text/JavaScript">parent.$(\'menu_plugin\').innerHTML = \''.str_replace("'", "\'", $s).'\';parent.initCpMenus(\'leftmenu\');parent.$(\'cmain\').innerHTML = parent.initCpMap();</script>';
}
function runquery($sql) {
global $dbcharset, $tablepre, $db;
$sql = str_replace("\r", "\n", str_replace(array(' cdb_', ' {tablepre}', ' `cdb_'), array(' '.$tablepre, ' '.$tablepre, ' `'.$tablepre), $sql));
$ret = array();
$num = 0;
foreach(explode(";\n", trim($sql)) as $query) {
$queries = explode("\n", trim($query));
foreach($queries as $query) {
$ret[$num] .= $query[0] == '#' || $query[0].$query[1] == '--' ? '' : $query;
}
$num++;
}
unset($sql);
foreach($ret as $query) {
$query = trim($query);
if($query) {
if(substr($query, 0, 12) == 'CREATE TABLE') {
$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
$db->query(createtable($query, $dbcharset));
} else {
$db->query($query);
}
}
}
}
function createtable($sql, $dbcharset) {
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
(mysql_get_server_info() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
}
function langeval($array) {
$return = '';
foreach($array as $k => $v) {
$k = str_replace("'", '', $k);
$return .= "\t'$k' => '".str_replace(array("\\'", "'"), array("\\\'", "\'"), stripslashes($v))."',\n";
}
return "array(\n$return);\n\n";
}
function pluginstat($type, $data) {
$url = 'http://stat.discuz.com/plugins.php?action='.$type.'&id='.rawurlencode($data['identifier']).'&version='.rawurlencode($data['version']).'&url='.rawurlencode($GLOBALS['boardurl']).'&ip='.$GLOBALS['onlineip'];
echo '<script src="'.$url.'" type="text/JavaScript"></script>';
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/plugins.inc.php | PHP | asf20 | 67,510 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: cpanel.share.php 20964 2009-11-04 03:18:22Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class AdminSession {
var $uid = 0;
var $panel = 0;
var $inadmincp = false;
var $isfounder = false;
var $cpaccess = 0;
var $checkip = 1;
var $logfile = 'cplog';
var $timelimit;
var $errorcount = 0;
var $storage = array();
var $db = null;
var $tablepre = '';
function adminsession($uid, $groupid, $adminid, $ip) {
global $adminipaccess, $db, $tablepre;
$this->panel = defined('IN_ADMINCP') ? 1 : (defined('IN_MODCP') ? 2 : -1);
$this->inadmincp = defined('IN_ADMINCP');
$this->uid = $uid;
$this->timelimit = time() - 1800;
$this->db = &$db;
$this->tablepre = &$tablepre;
if($uid < 1 || $adminid < 1 || ($this->inadmincp && $adminid != 1)) {
$cpaccess = 0;
}elseif($this->inadmincp && $adminipaccess && !ipaccess($ip, $adminipaccess)) {
$cpaccess = 2;
} else {
$session = $this->_loadsession($uid, $ip, $GLOBALS['admincp']['checkip']);
$this->errorcount = $session['errorcount'];
$this->storage = $session['storage'];
if(empty($session)) {
$this->creatsession($uid, $adminid, $ip);
$cpaccess = 1;
} elseif($session['errorcount'] == -1) {
$this->update();
$cpaccess = 3;
} elseif($session['errorcount'] <= 3) {
$cpaccess = 1;
} else {
$cpaccess = -1;
}
}
if($cpaccess == 0) {
//clearcookies();
showmessage('admin_cpanel_noaccess', 'logging.php?action=login', 'HALTED');
} elseif($cpaccess == 2) {
showmessage('admin_cpanel_noaccess_ip', NULL, 'HALTED');
} elseif($cpaccess == -1) {
showmessage('admin_cpanel_locked', NULL, 'HALTED');
}
$this->cpaccess = $cpaccess;
}
function _loadsession($uid, $ip, $checkip = 1) {
$session = array();
$query = $this->db->query("SELECT uid, adminid, panel, ip, dateline, errorcount, storage FROM {$this->tablepre}adminsessions
WHERE uid='$uid' ".($checkip ? "AND ip='$ip'" : '')." AND panel='{$this->panel}' AND dateline>'{$this->timelimit}'", 'SILENT');
if(!$this->db->error()) {
$session = $this->db->fetch_array($query);
if(isset($session['storage'])) {
$session['storage'] = $session['storage'] ? unserialize(base64_decode($session['storage'])) : array();
}
} else {
$this->db->query("DROP TABLE IF EXISTS {$this->tablepre}adminsessions");
$this->db->query("CREATE TABLE {$this->tablepre}adminsessions (
uid mediumint(8) UNSIGNED NOT NULL default '0',
adminid smallint(6) unsigned NOT NULL DEFAULT '0',
panel tinyint(1) NOT NULL DEFAULT '0',
ip varchar(15) NOT NULL default '',
dateline int(10) unsigned NOT NULL default '0',
errorcount tinyint(1) NOT NULL default '0',
`storage` mediumtext NOT NULL,
PRIMARY KEY (`uid`, `panel`))".(mysql_get_server_info() > '4.1' ? " ENGINE=MYISAM DEFAULT CHARSET=$GLOBALS[dbcharset]" : " TYPE=MYISAM")
);
}
return $session;
}
function creatsession($uid, $adminid, $ip) {
$url_forward = !empty($_SERVER['QUERY_STRING']) ? addslashes($_SERVER['QUERY_STRING']) : '';
$this->destroy($uid);
$this->db->query("INSERT INTO {$this->tablepre}adminsessions (uid, adminid, panel, ip, dateline, errorcount)
VALUES ('$uid', '$adminid', '$this->panel', '$ip', '".time()."', '0')");
$this->set('url_forward', $url_forward, true);
}
function destroy($uid = 0) {
empty($uid) && $uid = $this->uid;
$this->db->query("DELETE FROM {$this->tablepre}adminsessions WHERE (uid='$uid' AND panel='$this->panel') OR dateline<'$this->timelimit'");
}
function _loadstorage() {
$storage = $this->db->result_first("SELECT storage FROM {$this->tablepre}adminsessions WHERE uid='{$this->uid}' AND panel='$this->panel'");
if(!empty($storage)) {
$this->storage = unserialize(base64_decode($storage));
} else {
$this->storage = array();
}
}
function isfounder($user = '') {
$user = empty($user) ? array('uid' => $GLOBALS['discuz_uid'], 'adminid' => $GLOBALS['adminid'], 'username' => $GLOBALS['discuz_userss']) : $user;
$founders = str_replace(' ', '', $GLOBALS['forumfounders']);
if($user['adminid'] <> 1) {
return FALSE;
} elseif(empty($founders)) {
return TRUE;
} elseif(strexists(",$founders,", ",$user[uid],")) {
return TRUE;
} elseif(!is_numeric($user['username']) && strexists(",$founders,", ",$user[username],")) {
return TRUE;
} else {
return FALSE;
}
}
function set($varname, $value, $updatedb = false) {
$this->storage[$varname] = $value;
$updatedb && $this->update();
}
function get($varname, $fromdb = false) {
$return = null;
$fromdb && $this->_loadstorage();
if(isset($this->storage[$varname])) {
$return = $this->storage[$varname];
}
return $return;
}
function clear($updatedb = false) {
$this->storage = array();
$updatedb && $this->update();
}
function update() {
if($this->uid) {
$timestamp = time();
$storage = !empty($this->storage) ? base64_encode((serialize($this->storage))) : '';
$this->db->query("UPDATE {$this->tablepre}adminsessions SET dateline='$timestamp', errorcount='{$this->errorcount}', storage='{$storage}'
WHERE uid='{$this->uid}' AND panel='$this->panel'", 'UNBUFFERED');
}
}
}
function acpmsg($message, $url = '', $type = '', $extra = '') {
if(defined('IN_ADMINCP')) {
!defined('CPHEADER_SHOWN') && cpheader();
cpmsg($message, $url, $type, $extra);
} else {
showmessage($message, $url, $extra);
}
}
function savebanlog($username, $origgroupid, $newgroupid, $expiration, $reason) {
global $discuz_userss, $groupid, $onlineip, $timestamp, $forum, $reason;
writelog('banlog', dhtmlspecialchars("$timestamp\t$discuz_userss\t$groupid\t$onlineip\t$username\t$origgroupid\t$newgroupid\t$expiration\t$reason"));
}
function clearlogstring($str) {
if(!empty($str)) {
if(!is_array($str)) {
$str = dhtmlspecialchars(trim($str));
$str = str_replace(array("\t", "\r\n", "\n", " ", " "), ' ', $str);
} else {
foreach ($str as $key => $val) {
$str[$key] = clearlogstring($val);
}
}
}
return $str;
}
function implodearray($array, $skip = array()) {
$return = '';
if(is_array($array) && !empty($array)) {
foreach ($array as $key => $value) {
if(empty($skip) || !in_array($key, $skip)) {
if(is_array($value)) {
$return .= "$key={".implodearray($value, $skip)."}; ";
} else {
$return .= "$key=$value; ";
}
}
}
}
return $return;
}
function deletethreads($tids = array()) {
global $db, $tablepre, $losslessdel, $creditspolicy;
static $cleartable = array(
'threadsmod', 'relatedthreads', 'posts', 'polls',
'polloptions', 'trades', 'activities', 'activityapplies', 'debates',
'debateposts', 'attachments', 'favorites', 'typeoptionvars', 'forumrecommend', 'postposition'
);
$threadsdel = 0;
if($tids = implodeids($tids)) {
$auidarray = array();
$query = $db->query("SELECT uid, attachment, dateline, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
if($attach['dateline'] > $losslessdel) {
$auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
}
}
if($auidarray) {
updateattachcredits('-', $auidarray, $creditspolicy['postattach']);
}
foreach($cleartable as $tb) {
$db->query("DELETE FROM {$tablepre}$tb WHERE tid IN ($tids)", 'UNBUFFERED');
}
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($tids)");
$threadsdel = $db->affected_rows();
}
return $threadsdel;
}
function undeletethreads($tids) {
global $db, $tablepre, $creditspolicy;
$threadsundel = 0;
if($tids && is_array($tids)) {
$tids = '\''.implode('\',\'', $tids).'\'';
$tuidarray = $ruidarray = $fidarray = array();
$query = $db->query("SELECT fid, first, authorid FROM {$tablepre}posts WHERE tid IN ($tids)");
while($post = $db->fetch_array($query)) {
if($post['first']) {
$tuidarray[] = $post['authorid'];
} else {
$ruidarray[] = $post['authorid'];
}
if(!in_array($post['fid'], $fidarray)) {
$fidarray[] = $post['fid'];
}
}
if($tuidarray) {
updatepostcredits('+', $tuidarray, $creditspolicy['post']);
}
if($ruidarray) {
updatepostcredits('+', $ruidarray, $creditspolicy['reply']);
}
$db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE tid IN ($tids)", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SET displayorder='0', moderated='1' WHERE tid IN ($tids)");
$threadsundel = $db->affected_rows();
updatemodlog($tids, 'UDL');
updatemodworks('UDL', $threadsundel);
foreach($fidarray as $fid) {
updateforumcount($fid);
}
}
return $threadsundel;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/cpanel.share.php | PHP | asf20 | 9,098 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: threadtypes.inc.php 21237 2009-11-23 03:02:28Z liulanbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if($special) {
$special = 1;
$navlang = 'threadtype_infotypes';
$operation = 'type';
$changetype = 'threadsorts';
} else {
$special = 0;
$navlang = 'forums_edit_threadtypes';
$changetype = 'threadtypes';
}
if(!submitcheck('typesubmit')) {
$forumsarray = $fidsarray = array();
$query = $db->query("SELECT f.fid, f.name, ff.$changetype FROM {$tablepre}forums f , {$tablepre}forumfields ff WHERE ff.$changetype<>'' AND f.fid=ff.fid");
while($forum = $db->fetch_array($query)) {
$forum[$changetype] = unserialize($forum[$changetype]);
if(is_array($forum[$changetype]['types'])) {
foreach($forum[$changetype]['types'] as $typeid => $name) {
$forumsarray[$typeid][] = '<a href="'.$BASESCRIPT.'?action=forums&operation=edit&fid='.$forum['fid'].'&anchor=threadtypes">'.$forum['name'].'</a>';
$fidsarray[$typeid][] = $forum['fid'];
}
}
}
if($special) {
$typemodelopt = '';
$query = $db->query("SELECT id, name FROM {$tablepre}typemodels ORDER BY displayorder");
while($typemodel = $db->fetch_array($query)) {
$typemodelopt .= "<option value=\"$typemodel[id]\" ".($typemodel['id'] == $threadtype['special'] ? 'selected="selected"' : '').">$typemodel[name]</option>";
}
}
$threadtypes = '';
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE ".($special ? "special!='0'" : "special='0'")." ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
$threadtypes .= showtablerow('', array('class="td25"', 'class="td28"', '', 'class="td29"', 'title="'.lang('forums_threadtypes_forums_comment').'"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[typeid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$type[typeid]]\" value=\"$type[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$type[typeid]]\" value=\"".dhtmlspecialchars($type['name'])."\">",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"descriptionnew[$type[typeid]]\" value=\"$type[description]\">",
is_array($forumsarray[$type['typeid']]) ? '<ul class="nowrap lineheight"><li>'.implode(',</li><li> ', $forumsarray[$type['typeid']])."</li></ul><input type=\"hidden\" name=\"fids[$type[typeid]]\" value=\"".implode(', ', $fidsarray[$type['typeid']])."\">" : '',
$special ? "<a href=\"$BASESCRIPT?action=threadtypes&operation=sortdetail&sortid=$type[typeid]\" class=\"act nowrap\">$lang[detail]</a>" : ''
), TRUE);
}
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1, '', 'td25'],
[1, '<input type="text" class="txt" name="newdisplayorder[]" size="2" value="">', 'td28'],
[1, '<input type="text" class="txt" name="newname[]" size="15">'],
[1, '<input type="text" class="txt" name="newdescription[]" size="30" value="">', 'td29'],
[2, '']
],
];
</script>
<?
shownav('forum', $navlang);
showsubmenu($navlang);
!$special ? showtips('forums_edit_threadtypes_tips') : '';
showformheader("threadtypes&");
showhiddenfields(array('special' => $special));
showtableheader('');
showsubtitle(array('', 'display_order', 'name', 'description', 'forums_relation', ''));
echo $threadtypes;
?>
<tr>
<td class="td25"></td>
<td colspan="4"><div><a href="###" onclick="addrow(this, 0)" class="addtr"><?=$lang['threadtype_infotypes_add']?></a></div></td>
<?
echo $special ? '<td> </td>' : '<td></td>';
?>
</tr>
<?
showsubmit('typesubmit', 'submit', 'del');
showformfooter();
} else {
$updatefids = $modifiedtypes = array();
if(is_array($delete)) {
if($deleteids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE sortid IN ($deleteids)");
$db->query("DELETE FROM {$tablepre}tradeoptionvars WHERE sortid IN ($deleteids)");
$db->query("DELETE FROM {$tablepre}typevars WHERE sortid IN ($deleteids)");
$db->query("DELETE FROM {$tablepre}threadtypes WHERE typeid IN ($deleteids) AND special='$special'");
}
if($special == 1) {
foreach($delete as $sortid) {
$db->query("DROP TABLE IF EXISTS {$tablepre}optionvalue$sortid");
}
}
if($deleteids && $db->affected_rows()) {
$db->query("UPDATE {$tablepre}threads SET typeid='0' WHERE typeid IN ($deleteids)");
foreach($delete as $id) {
if(is_array($namenew) && isset($namenew[$id])) {
unset($namenew[$id]);
}
if(!empty($fids[$id])) {
foreach(explode(',', $fids[$id]) as $fid) {
if($fid = intval($fid)) {
$updatefids[$fid]['deletedids'][] = intval($id);
}
}
}
}
}
}
if(is_array($namenew) && $namenew) {
foreach($namenew as $typeid => $val) {
$db->query("UPDATE {$tablepre}threadtypes SET name='".trim($namenew[$typeid])."', description='".dhtmlspecialchars(trim($descriptionnew[$typeid]))."', displayorder='$displayordernew[$typeid]', special='$special' WHERE typeid='$typeid'");
if($db->affected_rows()) {
$modifiedtypes[] = $typeid;
}
}
if($modifiedtypes = array_unique($modifiedtypes)) {
foreach($modifiedtypes as $id) {
if(!empty($fids[$id])) {
foreach(explode(',', $fids[$id]) as $fid) {
if($fid = intval($fid)) {
$updatefids[$fid]['modifiedids'][] = $id;
}
}
}
}
}
}
if($updatefids) {
$query = $db->query("SELECT fid, $changetype FROM {$tablepre}forumfields WHERE fid IN (".implodeids(array_keys($updatefids)).") AND $changetype<>''");
while($forum = $db->fetch_array($query)) {
$fid = $forum['fid'];
$forum[$changetype] = unserialize($forum[$changetype]);
if($updatefids[$fid]['deletedids']) {
foreach($updatefids[$fid]['deletedids'] as $id) {
unset($forum[$changetype]['types'][$id], $forum[$changetype]['flat'][$id], $forum[$changetype]['selectbox'][$id]);
}
}
if($updatefids[$fid]['modifiedids']) {
foreach($updatefids[$fid]['modifiedids'] as $id) {
if(isset($forum[$changetype]['types'][$id])) {
$namenew[$id] = trim($namenew[$id]);
$forum[$changetype]['types'][$id] = $namenew[$id];
if(isset($forum[$changetype]['selectbox'][$id])) {
$forum[$changetype]['selectbox'][$id] = $namenew[$id];
} else {
$forum[$changetype]['flat'][$id] = $namenew[$id];
}
}
}
}
$db->query("UPDATE {$tablepre}forumfields SET $changetype='".addslashes(serialize($forum[$changetype]))."' WHERE fid='$fid'");
}
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
if($newname1 = trim($value)) {
$query = $db->query("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$newname1'");
if($db->num_rows($query)) {
cpmsg('forums_threadtypes_duplicate', '', 'error');
}
$db->query("INSERT INTO {$tablepre}threadtypes (name, description, displayorder, special) VALUES
('$newname1', '".dhtmlspecialchars(trim($newdescription[$key]))."', '$newdisplayorder[$key]', '$special')");
}
}
}
cpmsg('forums_threadtypes_succeed', $BASESCRIPT.'?action=threadtypes&special='.$special, 'succeed');
}
} elseif($operation == 'typeoption') {
if(!submitcheck('typeoptionsubmit')) {
$classid = $classid ? intval($classid) : $db->result_first("SELECT * FROM {$tablepre}typeoptions WHERE classid='0' ORDER BY displayorder LIMIT 1");
$classoptions = array();
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid='0' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$classoptions[] = array($option[title], "threadtypes&operation=typeoption&classid=$option[optionid]", $classid == $option[optionid]);
}
if($classid) {
if(!$typetitle = $db->result_first("SELECT title FROM {$tablepre}typeoptions WHERE optionid='$classid'")) {
cpmsg('threadtype_infotypes_noexist', $BASESCRIPT.'?action=threadtypes', 'error');
}
$typeoptions = '';
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid='$classid' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$option['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$typeoptions .= showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$option[optionid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$option[optionid]]\" value=\"$option[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"title[$option[optionid]]\" value=\"".dhtmlspecialchars($option['title'])."\">",
"$option[identifier]<input type=\"hidden\" name=\"identifier[$option[optionid]]\" value=\"$option[identifier]\">",
$option['type'],
"<a href=\"$BASESCRIPT?action=threadtypes&operation=optiondetail&optionid=$option[optionid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1, '', 'td25'],
[1, '<input type="text" class="txt" size="2" name="newdisplayorder[]" value="0">', 'td28'],
[1, '<input type="text" class="txt" size="15" name="newtitle[]">'],
[1, '<input type="text" class="txt" size="15" name="newidentifier[]">'],
[1, '<select name="newtype[]"><option value="number">$lang[threadtype_edit_vars_type_number]</option><option value="text" selected>$lang[threadtype_edit_vars_type_text]</option><option value="textarea">$lang[threadtype_edit_vars_type_textarea]</option><option value="radio">$lang[threadtype_edit_vars_type_radio]</option><option value="checkbox">$lang[threadtype_edit_vars_type_checkbox]</option><option value="select">$lang[threadtype_edit_vars_type_select]</option><option value="calendar">$lang[threadtype_edit_vars_type_calendar]</option><option value="email">$lang[threadtype_edit_vars_type_email]</option><option value="image">$lang[threadtype_edit_vars_type_image]</option><option value="url">$lang[threadtype_edit_vars_type_url]</option></select>'],
[1, '']
],
];
</script>
EOT;
shownav('forum', 'threadtype_infotypes_option');
showsubmenu('threadtype_cat_manage', $classoptions);
showformheader("threadtypes&operation=typeoption&typeid=$typeid");
showhiddenfields(array('classid' => $classid));
showtableheader();
showsubtitle(array('', 'display_order', 'name', 'threadtype_variable', 'threadtype_type', ''));
echo $typeoptions;
echo '<tr><td></td><td colspan="5"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['threadtype_infotypes_add_option'].'</a></div></td></tr>';
showsubmit('typeoptionsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}typeoptions WHERE optionid IN ($ids)");
$db->query("DELETE FROM {$tablepre}typevars WHERE optionid IN ($ids)");
}
if(is_array($title)) {
foreach($title as $id => $val) {
$db->query("UPDATE {$tablepre}typeoptions SET displayorder='$displayorder[$id]', title='$title[$id]', identifier='$identifier[$id]' WHERE optionid='$id'");
}
}
if(is_array($newtitle)) {
foreach($newtitle as $key => $value) {
$newtitle1 = dhtmlspecialchars(trim($value));
$newidentifier1 = trim($newidentifier[$key]);
if($newtitle1 && $newidentifier1) {
$query = $db->query("SELECT optionid FROM {$tablepre}typeoptions WHERE identifier='$newidentifier1' LIMIT 1");
if($db->num_rows($query) || strlen($newidentifier1) > 40 || !ispluginkey($newidentifier1)) {
cpmsg('threadtype_infotypes_optionvariable_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}typeoptions (classid, displayorder, title, identifier, type)
VALUES ('$classid', '$newdisplayorder[$key]', '$newtitle1', '$newidentifier1', '$newtype[$key]')");
} elseif($newtitle1 && !$newidentifier1) {
cpmsg('threadtype_infotypes_option_invalid', $BASESCRIPT.'?action=threadtypes&operation=typeoption&classid='.$classid, 'error');
}
}
}
updatecache('threadsorts');
cpmsg('threadtype_infotypes_succeed', $BASESCRIPT.'?action=threadtypes&operation=typeoption&classid='.$classid, 'succeed');
}
} elseif($operation == 'optiondetail') {
$option = $db->fetch_first("SELECT * FROM {$tablepre}typeoptions WHERE optionid='$optionid'");
if(!$option) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
shownav('forum', 'threadtype_infotypes_option');
showsubmenu('threadtype_infotypes_option');
$typeselect = '<select name="typenew" onchange="var styles, key;styles=new Array(\'number\',\'text\',\'radio\', \'checkbox\', \'textarea\', \'select\', \'image\'); for(key in styles) {var obj=$(\'style_\'+styles[key]); obj.style.display=styles[key]==this.options[this.selectedIndex].value?\'\':\'none\';}">';
foreach(array('number', 'text', 'radio', 'checkbox', 'textarea', 'select', 'calendar', 'email', 'url', 'image') as $type) {
$typeselect .= '<option value="'.$type.'" '.($option['type'] == $type ? 'selected' : '').'>'.$lang['threadtype_edit_vars_type_'.$type].'</option>';
}
$typeselect .= '</select>';
$option['rules'] = unserialize($option['rules']);
showformheader("threadtypes&operation=optiondetail&optionid=$optionid");
showtableheader();
showtitle('threadtype_infotypes_option_config');
showsetting('name', 'titlenew', $option['title'], 'text');
showsetting('threadtype_variable', 'identifiernew', $option['identifier'], 'text');
showsetting('type', '', '', $typeselect);
showsetting('threadtype_edit_desc', 'descriptionnew', $option['description'], 'textarea');
showsetting('threadtype_unit', 'unitnew', $option['unit'], 'text');
showtagheader('tbody', "style_number", $option['type'] == 'number');
showtitle('threadtype_edit_vars_type_number');
showsetting('threadtype_edit_maxnum', 'rules[number][maxnum]', $option['rules']['maxnum'], 'text');
showsetting('threadtype_edit_minnum', 'rules[number][minnum]', $option['rules']['minnum'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_text", $option['type'] == 'text');
showtitle('threadtype_edit_vars_type_text');
showsetting('threadtype_edit_textmax', 'rules[text][maxlength]', $option['rules']['maxlength'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_textarea", $option['type'] == 'textarea');
showtitle('threadtype_edit_vars_type_textarea');
showsetting('threadtype_edit_textmax', 'rules[textarea][maxlength]', $option['rules']['maxlength'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_select", $option['type'] == 'select');
showtitle('threadtype_edit_vars_type_select');
showsetting('threadtype_edit_choices', 'rules[select][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_radio", $option['type'] == 'radio');
showtitle('threadtype_edit_vars_type_radio');
showsetting('threadtype_edit_choices', 'rules[radio][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_checkbox", $option['type'] == 'checkbox');
showtitle('threadtype_edit_vars_type_checkbox');
showsetting('threadtype_edit_choices', 'rules[checkbox][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_image", $option['type'] == 'image');
showtitle('threadtype_edit_vars_type_image');
showsetting('threadtype_edit_images_weight', 'rules[image][maxwidth]', $option['rules']['maxwidth'], 'text');
showsetting('threadtype_edit_images_height', 'rules[image][maxheight]', $option['rules']['maxheight'], 'text');
showtagfooter('tbody');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$titlenew = trim($titlenew);
if(!$titlenew || !$identifiernew) {
cpmsg('threadtype_infotypes_option_invalid', '', 'error');
}
$query = $db->query("SELECT optionid FROM {$tablepre}typeoptions WHERE identifier='$identifiernew' AND optionid!='$optionid' LIMIT 1");
if($db->num_rows($query) || strlen($identifiernew) > 40 || !ispluginkey($identifiernew)) {
cpmsg('threadtype_infotypes_optionvariable_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}typeoptions SET title='$titlenew', description='$descriptionnew', identifier='$identifiernew', type='$typenew', unit='$unitnew', rules='".addslashes(serialize($rules[$typenew]))."' WHERE optionid='$optionid'");
updatecache('threadsorts');
cpmsg('threadtype_infotypes_option_succeed', $BASESCRIPT.'?action=threadtypes&operation=typeoption', 'succeed');
}
} elseif($operation == 'sortdetail') {
if(!submitcheck('sortdetailsubmit') && !submitcheck('sortpreviewsubmit')) {
$threadtype = $db->fetch_first("SELECT name, template, stemplate, modelid, expiration FROM {$tablepre}threadtypes WHERE typeid='$sortid'");
$threadtype['modelid'] = isset($modelid) ? intval($modelid) : $threadtype['modelid'];
$typemodelopt = '';
$existoption = $showoption = array();
$query = $db->query("SELECT id, name, options, customoptions FROM {$tablepre}typemodels ORDER BY displayorder");
while($typemodel = $db->fetch_array($query)) {
if($typemodel['id'] == $threadtype['modelid']) {
foreach(explode("\t", $typemodel['customoptions']) as $id) {
$existoption[$id] = 0;
}
foreach(explode("\t", $typemodel['options']) as $id) {
$existoption[$id] = 1;
}
}
$typemodelopt .= "<option value=\"$typemodel[id]\" ".($typemodel['id'] == $threadtype['modelid'] ? 'selected="selected"' : '').">$typemodel[name]</option>";
}
$sortoptions = $jsoptionids = '';
$query = $db->query("SELECT t.optionid, t.displayorder, t.available, t.required, t.unchangeable, t.search, t.subjectshow, tt.title, tt.type, tt.identifier
FROM {$tablepre}typevars t, {$tablepre}typeoptions tt
WHERE t.sortid='$sortid' AND t.optionid=tt.optionid ORDER BY t.displayorder");
while($option = $db->fetch_array($query)) {
$jsoptionids .= "optionids.push($option[optionid]);\r\n";
$optiontitle[$option['identifier']] = $option['title'];
$showoption[$option['optionid']]['optionid'] = $option['optionid'];
$showoption[$option['optionid']]['title'] = $option['title'];
$showoption[$option['optionid']]['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$showoption[$option['optionid']]['identifier'] = $option['identifier'];
$showoption[$option['optionid']]['displayorder'] = $option['displayorder'];
$showoption[$option['optionid']]['available'] = $option['available'];
$showoption[$option['optionid']]['required'] = $option['required'];
$showoption[$option['optionid']]['unchangeable'] = $option['unchangeable'];
$showoption[$option['optionid']]['search'] = $option['search'];
$showoption[$option['optionid']]['subjectshow'] = $option['subjectshow'];
}
if($existoption && is_array($existoption)) {
$optionids = $comma = '';
foreach($existoption as $optionid => $val) {
$optionids .= $comma.$optionid;
$comma = '\',\'';
}
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN ('$optionids')");
while($option = $db->fetch_array($query)) {
$showoption[$option['optionid']]['optionid'] = $option['optionid'];
$showoption[$option['optionid']]['title'] = $option['title'];
$showoption[$option['optionid']]['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$showoption[$option['optionid']]['identifier'] = $option['identifier'];
$showoption[$option['optionid']]['required'] = $existoption[$option['optionid']];
$showoption[$option['optionid']]['available'] = 1;
$showoption[$option['optionid']]['unchangeable'] = 0;
$showoption[$option['optionid']]['model'] = 1;
}
}
$searchtitle = $searchvalue = $searchunit = array();
foreach($showoption as $optionid => $option) {
$sortoptions .= showtablerow('id="optionid'.$optionid.'"', array('class="td25"', 'class="td28 td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$option[optionid]\" ".($option['model'] ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$option[optionid]]\" value=\"$option[displayorder]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$option[optionid]]\" value=\"1\" ".($option['available'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
dhtmlspecialchars($option['title']),
$option['type'],
"<input class=\"checkbox\" type=\"checkbox\" name=\"required[$option[optionid]]\" value=\"1\" ".($option['required'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"unchangeable[$option[optionid]]\" value=\"1\" ".($option['unchangeable'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"search[$option[optionid]]\" value=\"1\" ".($option['search'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"subjectshow[$option[optionid]]\" value=\"1\" ".($option['subjectshow'] ? 'checked' : '').">",
"<a href=\"###\" onclick=\"insertvar('$option[identifier]', 'typetemplate', 'message');doane(event);return false;\" class=\"act\">".$lang['threadtype_infotypes_add_template']."</a>",
"<a href=\"###\" onclick=\"insertvar('$option[identifier]', 'stypetemplate', 'subject');doane(event);return false;\" class=\"act\">".$lang['threadtype_infotypes_add_stemplate']."</a>",
"<a href=\"$BASESCRIPT?action=threadtypes&operation=optiondetail&optionid=$option[optionid]\" class=\"act\">".$lang['edit']."</a>"
), TRUE);
$searchtitle[] = '/{('.$option['identifier'].')}/e';
$searchvalue[] = '/\[('.$option['identifier'].')value\]/e';
$searchunit[] = '/\[('.$option['identifier'].')unit\]/e';
}
if($threadtype['template']) {
$previewtemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $threadtype['template']);
$previewtemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $previewtemplate);
$previewtemplate = preg_replace($searchunit, "showoption('\\1', 'unit')", $previewtemplate);
}
if($threadtype['stemplate']) {
$previewstemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $threadtype['stemplate']);
$previewstemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $previewstemplate);
$previewstemplate = preg_replace($searchunit, "showoption('\\1', 'unit')", $previewstemplate);
}
shownav('forum', 'forums_edit_threadsorts');
showsubmenu('forums_edit_threadsorts');
showtips('forums_edit_threadsorts_tips');
showformheader("threadtypes&operation=sortdetail&sortid=$sortid");
showtableheader('threadtype_models', 'nobottom');
showsetting('threadtype_models_select', '', '', '<select name="modelid" onchange="window.location=\''.$BASESCRIPT.'?action=threadtypes&operation=sortdetail&sortid='.$sortid.'&modelid=\'+this.options[this.selectedIndex].value"><option value="0">'.$lang['none'].'</option>'.$typemodelopt.'</select>');
showsetting('threadtype_infotypes_validity', 'typeexpiration', $threadtype['expiration'], 'radio');
showtablefooter();
showtableheader("$threadtype[name] - $lang[threadtype_infotypes_add_option]", 'noborder fixpadding');
showtablerow('', 'id="classlist"', '');
showtablerow('', 'id="optionlist"', '');
showtablefooter();
showtableheader("$threadtype[name] - $lang[threadtype_infotypes_exist_option]", 'noborder fixpadding', 'id="sortlist"');
showsubtitle(array('<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form,\'delete\')" /><label for="chkall">'.lang('del').'</label>', 'display_order', 'available', 'name', 'type', 'required', 'unchangeable', 'threadtype_infotypes_search', 'threadtype_infotypes_show', '', '', ''));
echo $sortoptions;
showtablefooter();
?>
<a name="template"></a>
<div class="colorbox">
<h4 style="margin-bottom:15px;"><?=$threadtype['name']?> - <?=$lang['threadtype_infotypes_template']?></h4>
<textarea cols="100" rows="5" id="typetemplate" name="typetemplate" style="width: 95%;" onkeyup="textareasize(this)"><?=$threadtype['template']?></textarea>
<br /><br />
<h4 style="margin-bottom:15px;"><?=$threadtype['name']?> - <?=$lang['threadtype_infotypes_stemplate']?></h4>
<textarea cols="100" rows="5" id="stypetemplate" name="stypetemplate" style="width: 95%;" onkeyup="textareasize(this)"><?=$threadtype['stemplate']?></textarea>
<br /><br />
<b><?=$lang['threadtype_infotypes_template']?>:</b>
<ul class="tpllist"><?=$lang['threadtype_infotypes_template_tips']?></ul>
<?php
if($previewtemplate) {
echo '<fieldset style="margin:1em 0; padding:1em 1.5em;"><legend><b>'.$lang['threadtype_infotypes_template_preview'].':</b></legend>';
echo $previewtemplate;
echo '</fieldset>';
}
if($previewstemplate) {
echo '<fieldset style="margin:1em 0; padding:1em 1.5em;"><legend><b>'.$lang['threadtype_infotypes_stemplate_preview'].':</b></legend>';
echo $previewstemplate;
echo '</fieldset>';
}
?>
<input type="submit" class="btn" name="sortdetailsubmit" value="<?=$lang['submit']?>"> <input type="submit" class="btn" name="sortpreviewsubmit" value="<?=$lang['threadtype_infotypes_template_preview']?>">
</div>
</form>
<script type="text/JavaScript">
var optionids = new Array();
<?=$jsoptionids?>
function insertvar(text, focusarea, location) {
$(focusarea).focus();
selection = document.selection;
if(selection && selection.createRange) {
var sel = selection.createRange();
sel.text = location == 'message' ? '<li><b>{' + text + '}</b>: [' + text + 'value] [' + text + "unit]</li>\r\n" : '{' + text + '}: [' + text + 'value] [' + text + 'unit]';
sel.moveStart('character', -strlen(text));
} else {
$(focusarea).value += location == 'message' ? '<li><b>{' + text + '}</b>: [' + text + 'value] [' + text + "unit]</li>\r\n" : '{' + text + '}: [' + text + 'value] [' + text + 'unit]';
}
}
function checkedbox() {
var tags = $('optionlist').getElementsByTagName('input');
for(var i=0; i<tags.length; i++) {
if(in_array(tags[i].value, optionids)) {
tags[i].checked = true;
}
}
}
function insertoption(optionid) {
var x = new Ajax();
x.optionid = optionid;
x.get('<?=$BASESCRIPT?>?action=threadtypes&operation=sortlist&inajax=1&optionid=' + optionid, function(s, x) {
if(!in_array(x.optionid, optionids)) {
var div = document.createElement('div');
div.style.display = 'none';
$('append_parent').appendChild(div);
div.innerHTML = '<table>' + s + '</table>';
var tr = div.getElementsByTagName('tr');
var trs = $('sortlist').getElementsByTagName('tr');
tr[0].id = 'optionid' + optionid;
trs[trs.length - 1].parentNode.appendChild(tr[0]);
$('append_parent').removeChild(div);
optionids.push(x.optionid);
} else {
$('optionid' + x.optionid).parentNode.removeChild($('optionid' + x.optionid));
for(var i=0; i<optionids.length; i++) {
if(optionids[i] == x.optionid) {
optionids[i] = 0;
}
}
}
});
}
</script>
<script type="text/JavaScript">ajaxget('<?=$BASESCRIPT?>?action=threadtypes&operation=classlist', 'classlist');</script>
<script type="text/JavaScript">ajaxget('<?=$BASESCRIPT?>?action=threadtypes&operation=optionlist&sortid=<?=$sortid?>', 'optionlist', '', '', '', checkedbox);</script>
<?
} else {
$db->query("UPDATE {$tablepre}threadtypes SET special='1', modelid='".intval($modelid)."', template='$typetemplate', stemplate='$stypetemplate', expiration='$typeexpiration' WHERE typeid='$sortid'");
if(submitcheck('sortdetailsubmit')) {
$orgoption = $orgoptions = $addoption = array();
$query = $db->query("SELECT optionid FROM {$tablepre}typevars WHERE sortid='$sortid'");
while($orgoption = $db->fetch_array($query)) {
$orgoptions[] = $orgoption['optionid'];
}
if(intval($modelid)) {
$modelopt = $db->fetch_first("SELECT options, customoptions FROM {$tablepre}typemodels WHERE id='$modelid'");
if($modelopt['customoptions']) {
foreach(explode("\t", $modelopt['customoptions']) as $id) {
$addoption[$id] = $required[$id] = 0;
$available[$id] = 1;
}
}
if($modelopt['options']) {
foreach(explode("\t", $modelopt['options']) as $id) {
$addoption[$id] = $available[$id] = $required[$id] = 1;
}
}
}
$addoption = $addoption ? (array)$addoption + (array)$displayorder : (array)$displayorder;
@$newoptions = array_keys($addoption);
if(empty($addoption)) {
cpmsg('threadtype_infotypes_invalid', '', 'error');
}
@$delete = array_merge((array)$delete, array_diff($orgoptions, $newoptions));
if($delete) {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}typevars WHERE sortid='$sortid' AND optionid IN ($ids)");
}
foreach($delete as $id) {
unset($addoption[$id]);
}
}
$insertoptionid = $indexoption = array();
$create_table_sql = $separator = $create_tableoption_sql = '';
if(is_array($addoption)) {
$query = $db->query("SELECT optionid, type, identifier FROM {$tablepre}typeoptions WHERE optionid IN (".implodeids(array_keys($addoption)).")");
while($option = $db->fetch_array($query)) {
$insertoptionid[$option['optionid']]['type'] = $option['type'];
$insertoptionid[$option['optionid']]['identifier'] = $option['identifier'];
}
$query = $db->query("SHOW TABLES LIKE '{$tablepre}optionvalue$sortid'");
if($db->num_rows($query) != 1) {
$create_table_sql = "CREATE TABLE {$tablepre}optionvalue$sortid (";
foreach($addoption as $optionid => $option) {
$identifier = $insertoptionid[$optionid]['identifier'];
if(in_array($insertoptionid[$optionid]['type'], array('radio', 'select', 'number')) || $search[$optionid]) {
if(in_array($insertoptionid[$optionid]['type'], array('radio', 'select'))) {
$create_tableoption_sql .= "$separator$identifier smallint(6) UNSIGNED NOT NULL DEFAULT '0'\r\n";
} elseif($insertoptionid[$optionid]['type'] == 'number') {
$create_tableoption_sql .= "$separator$identifier int(10) UNSIGNED NOT NULL DEFAULT '0'\r\n";
} else {
$create_tableoption_sql .= "$separator$identifier mediumtext NOT NULL\r\n";
}
$separator = ' ,';
if(in_array($insertoptionid[$optionid]['type'], array('radio', 'select', 'number'))) {
$indexoption[] = $identifier;
}
}
}
$create_table_sql .= ($create_tableoption_sql ? $create_tableoption_sql.',' : '')."tid mediumint(8) UNSIGNED NOT NULL DEFAULT '0',fid smallint(6) UNSIGNED NOT NULL DEFAULT '0',";
$create_table_sql .= "KEY (fid)";
if($indexoption) {
foreach($indexoption as $index) {
$create_table_sql .= "$separator KEY $index ($index)\r\n";
$separator = ' ,';
}
}
$create_table_sql .= ") TYPE=MyISAM;";
$dbcharset = empty($dbcharset) ? str_replace('-','',$charset) : $dbcharset;
$create_table_sql = syntablestruct($create_table_sql, $db->version() > '4.1', $dbcharset);
$db->query($create_table_sql);
} else {
$tables = array();
if($db->version() > '4.1') {
$query = $db->query("SHOW FULL COLUMNS FROM {$tablepre}optionvalue$sortid", 'SILENT');
} else {
$query = $db->query("SHOW COLUMNS FROM {$tablepre}optionvalue$sortid", 'SILENT');
}
while($field = @$db->fetch_array($query)) {
$tables[$field['Field']] = 1;
}
foreach($addoption as $optionid => $option) {
$identifier = $insertoptionid[$optionid]['identifier'];
if(!$tables[$identifier] && (in_array($insertoptionid[$optionid]['type'], array('radio', 'select', 'number')) || $search[$optionid])) {
$fieldname = $identifier;
if(in_array($insertoptionid[$optionid]['type'], array('radio', 'select'))) {
$fieldtype = 'smallint(6) UNSIGNED NOT NULL DEFAULT \'0\'';
} elseif($insertoptionid[$optionid]['type'] == 'number') {
$fieldtype = 'int(10) UNSIGNED NOT NULL DEFAULT \'0\'';
} else {
$fieldtype = 'mediumtext NOT NULL';
}
$db->query("ALTER TABLE {$tablepre}optionvalue$sortid ADD $fieldname $fieldtype");
if(in_array($insertoptionid[$optionid]['type'], array('radio', 'select', 'number'))) {
$db->query("ALTER TABLE {$tablepre}optionvalue$sortid ADD INDEX ($fieldname)");
}
}
}
}
foreach($addoption as $id => $val) {
$optionid = $db->fetch_first("SELECT optionid FROM {$tablepre}typeoptions WHERE optionid='$id'");
if($optionid) {
$db->query("INSERT INTO {$tablepre}typevars (sortid, optionid, available, required) VALUES ('$sortid', '$id', '1', '".intval($val)."')", 'SILENT');
$db->query("UPDATE {$tablepre}typevars SET displayorder='$displayorder[$id]', available='$available[$id]', required='$required[$id]', unchangeable='$unchangeable[$id]', search='$search[$id]', subjectshow='$subjectshow[$id]' WHERE sortid='$sortid' AND optionid='$id'");
} else {
$db->query("DELETE FROM {$tablepre}typevars WHERE sortid='$sortid' AND optionid IN ($id)");
}
}
}
updatecache('threadsorts');
cpmsg('threadtype_infotypes_succeed', $BASESCRIPT.'?action=threadtypes&special=1', 'succeed');
} elseif(submitcheck('sortpreviewsubmit')) {
header("Location: $boardurl$BASESCRIPT?action=threadtypes&operation=sortdetail&sortid=$sortid#template");
}
}
} elseif($operation == 'typemodel') {
if(!submitcheck('modelsubmit')) {
$typemodels = '';
$query = $db->query("SELECT * FROM {$tablepre}typemodels ORDER BY displayorder");
while($model = $db->fetch_array($query)) {
$typemodels .= showtablerow('', array('class="td25"', 'class="td28 td23"', 'class="td24"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$model[id]\" ".($model['type'] ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"displayorder[$model[id]]\" value=\"$model[displayorder]\">",
"<input type=\"text\" class=\"txt\" name=\"name[$model[id]]\" value=\"$model[name]\">",
"<a href=\"$BASESCRIPT?action=threadtypes&operation=modeldetail&modelid=$model[id]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1, '', 'td25'],
[1, '<input type="text" class="txt" size="10" name="newdisplayorder[]">', 'td28 td23'],
[1, '<input type="text" class="txt" name="newtitle[]">', 'td24'],
[1, '']
],
];
</script>
EOT;
shownav('forum', 'threadtype_models');
showsubmenu('threadtype_models', '');
showformheader('threadtypes&operation=typemodel');
showtableheader();
showsubtitle(array('', 'display_order', 'name', ''));
echo $typemodels;
echo '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['threadtype_infotypes_add_model'].'</a></div></td></tr>';
showsubmit('modelsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}typemodels WHERE id IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}typemodels SET displayorder='$displayorder[$id]', name='$name[$id]' WHERE id='$id'");
}
}
if(is_array($newtitle)) {
foreach($newtitle as $key => $value) {
if($value) {
$db->query("INSERT INTO {$tablepre}typemodels (name, displayorder, type)
VALUES ('$value', '$newdisplayorder[$key]', '0')");
}
}
}
cpmsg('threadtype_infotypes_model_succeed', $BASESCRIPT.'?action=threadtypes&operation=typemodel', 'succeed');
}
} elseif($operation == 'modeldetail') {
if(!submitcheck('modeldetailsubmit')) {
$classoptions = $modeloption = $sysoption = $sysoptselect = '';
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid!='0' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$classoptions .= "<option value=\"$option[optionid]\">$option[title]</option>";
}
$model = $db->fetch_first("SELECT * FROM {$tablepre}typemodels WHERE id='".intval($modelid)."'");
if(!$model) {
cpmsg('undefined_action', '', 'error');
}
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN (".implodeids(explode("\t", $model['customoptions'])).")");
while($modelopt = $db->fetch_array($query)){
$modeloption .= "<option value=\"$modelopt[optionid]\">$modelopt[title]</option>";
}
if($model['type']) {
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN (".implodeids(explode("\t", $model['options'])).")");
while($modelopt = $db->fetch_array($query)){
$sysoption .= "<option value=\"$modelopt[optionid]\">$modelopt[title]</option>";
}
$sysoptselect = '<select name="" size="10" multiple="multiple">'.$sysoption.'</select>';
}
$optselect = '<select name="" size="10" multiple="multiple" id="coptselect">'.$classoptions.'</select>';
$hoptselect = '<select name="customoptions[]" size="10" multiple="multiple" id="moptselect">'.$modeloption.'</select>';
echo <<<EOT
<script type="text/JavaScript">
function copyoption(s1, s2) {
var s1 = $(s1);
var s2 = $(s2);
var len = s1.options.length;
for(var i=0; i<len; i++) {
op = s1.options[i];
if(op.selected == true && !optionexists(s2, op.value)) {
o = op.cloneNode(true);
s2.appendChild(o);
}
}
}
function optionexists(s1, value) {
var len = s1.options.length;
for(var i=0; i<len; i++) {
if(s1.options[i].value == value) {
return true;
}
}
return false;
}
function removeoption(s1) {
var s1 = $(s1);
var len = s1.options.length;
for(var i=s1.options.length - 1; i>-1; i--) {
op = s1.options[i];
if(op.selected && op.selected == true) {
s1.removeChild(op);
}
}
return false;
}
function selectalloption(s1) {
var s1 = $(s1);
var len = s1.options.length;
for(var i=s1.options.length - 1; i>-1; i--) {
op = s1.options[i];
op.selected = true;
}
}
</script>
EOT;
showsubmenu('threadtype_models_option_setting');
showformheader("threadtypes&operation=modeldetail&modelid=$modelid", 'onsubmit="selectalloption(\'moptselect\');"');
showtableheader();
showsetting('name', 'namenew', $model['name'], 'text');
if($model['type']) {
showsetting('threadtype_models_option_model', '', '', $sysoptselect);
}
showsetting('threadtype_models_option_user', '', '', $hoptselect.'<br /><a href="###" onclick="removeoption(\'moptselect\')">['.$lang['del'].']</a>');
showsetting('threadtype_models_option_system', '', '', $optselect.'<br /><a href="###" onclick="copyoption(\'coptselect\', \'moptselect\')">['.$lang['threadtype_models_option_copy'].']</a>');
showsubmit('modeldetailsubmit');
showtablefooter();
showformfooter();
} else {
$customoptionsnew = $customoptions && is_array($customoptions) ? implode("\t", $customoptions) : '';
$db->query("UPDATE {$tablepre}typemodels SET name='$namenew', customoptions='$customoptionsnew' WHERE id='$modelid'");
cpmsg('threadtype_infotypes_model_succeed', $BASESCRIPT.'?action=threadtypes&operation=typemodel', 'succeed');
}
} elseif($operation == 'classlist') {
$classoptions = '';
$classidarray = array();
!$classid && $classid = 0;
$query = $db->query("SELECT optionid, title FROM {$tablepre}typeoptions WHERE classid='$classid' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$classidarray[] = $option['optionid'];
$classoptions .= "<a href=\"#ol\" onclick=\"ajaxget('$BASESCRIPT?action=threadtypes&operation=optionlist&typeid=$typeid&classid=$option[optionid]', 'optionlist', 'optionlist', 'Loading...', '', checkedbox)\">$option[title]</a> ";
}
include template('header');
echo $classoptions;
include template('footer');
exit;
} elseif($operation == 'optionlist') {
if(!$classid) {
$classid = $db->result_first("SELECT optionid FROM {$tablepre}typeoptions WHERE classid='0' ORDER BY displayorder LIMIT 1");
}
$query = $db->query("SELECT optionid FROM {$tablepre}typevars WHERE sortid='$typeid'");
$option = $options = array();
while($option = $db->fetch_array($query)) {
$options[] = $option['optionid'];
}
$optionlist = '';
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid='$classid' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$optionlist .= "<input ".(in_array($option['optionid'], $options) ? ' checked="checked" ' : '')."class=\"checkbox\" type=\"checkbox\" name=\"typeselect[]\" id=\"typeselect_$option[optionid]\" value=\"$option[optionid]\" onclick=\"insertoption(this.value);\" /><label for=\"typeselect_$option[optionid]\">".dhtmlspecialchars($option['title'])."</label> ";
}
include template('header');
echo $optionlist;
include template('footer');
exit;
} elseif($operation == 'sortlist') {
$option = $db->fetch_first("SELECT * FROM {$tablepre}typeoptions WHERE optionid='$optionid' LIMIT 1");
include template('header');
$option['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$option['available'] = 1;
showtablerow('', array('class="td25"', 'class="td28 td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$option[optionid]\" ".($option['model'] ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$option[optionid]]\" value=\"$option[displayorder]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$option[optionid]]\" value=\"1\" ".($option['available'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
dhtmlspecialchars($option['title']),
$option[type],
"<input class=\"checkbox\" type=\"checkbox\" name=\"required[$option[optionid]]\" value=\"1\" ".($option['required'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"unchangeable[$option[optionid]]\" value=\"1\" ".($option['unchangeable'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"search[$option[optionid]]\" value=\"1\" ".($option['search'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"subjectshow[$option[optionid]]\" value=\"1\" ".($option['subjectshow'] ? 'checked' : '').">",
"<a href=\"###\" onclick=\"insertvar('$option[identifier]', 'typetemplate', 'message');doane(event);return false;\" class=\"act\">".$lang['threadtype_infotypes_add_template']."</a>",
"<a href=\"###\" onclick=\"insertvar('$option[identifier]', 'stypetemplate', 'subject');doane(event);return false;\" class=\"act\">".$lang['threadtype_infotypes_add_stemplate']."</a>",
"<a href=\"$BASESCRIPT?action=threadtypes&operation=optiondetail&optionid=$option[optionid]\" class=\"act\">".$lang['edit']."</a>"
));
include template('footer');
exit;
}
function showoption($var, $type) {
global $optiontitle, $lang;
if($optiontitle[$var]) {
$optiontitle[$var] = $type == 'title' ? $optiontitle[$var] : $optiontitle[$var].($type == 'value' ? $lang['value'] : $lang['unit']);
return $optiontitle[$var];
} else {
return "!$var!";
}
}
function syntablestruct($sql, $version, $dbcharset) {
if(strpos(trim(substr($sql, 0, 18)), 'CREATE TABLE') === FALSE) {
return $sql;
}
$sqlversion = strpos($sql, 'ENGINE=') === FALSE ? FALSE : TRUE;
if($sqlversion === $version) {
return $sqlversion && $dbcharset ? preg_replace(array('/ character set \w+/i', '/ collate \w+/i', "/DEFAULT CHARSET=\w+/is"), array('', '', "DEFAULT CHARSET=$dbcharset"), $sql) : $sql;
}
if($version) {
return preg_replace(array('/TYPE=HEAP/i', '/TYPE=(\w+)/is'), array("ENGINE=MEMORY DEFAULT CHARSET=$dbcharset", "ENGINE=\\1 DEFAULT CHARSET=$dbcharset"), $sql);
} else {
return preg_replace(array('/character set \w+/i', '/collate \w+/i', '/ENGINE=MEMORY/i', '/\s*DEFAULT CHARSET=\w+/is', '/\s*COLLATE=\w+/is', '/ENGINE=(\w+)(.*)/is'), array('', '', 'ENGINE=HEAP', '', '', 'TYPE=\\1\\2'), $sql);
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/threadtypes.inc.php | PHP | asf20 | 45,290 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: search.inc.php 19537 2009-09-04 04:26:24Z wangjinbo $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$actionarray = array(
'settings' => array(
'basic',
'access' => array('register', 'access'),
'styles' => array('global', 'index', 'forumdisplay', 'viewthread', 'member', 'refresh'),
'seo',
'cachethread',
'serveropti',
'editor',
'functions' => array('editor', 'stat', 'mod', 'tags', 'other'),
'permissions',
'credits',
'mail' => array('settings', 'check'),
'sec' => array('seclevel', 'seccode', 'secqaa'),
'datetime',
'attach' => array('basic', 'image', 'remote', 'antileech'),
'wap',
'ec',
'uc',
'uchome',
'msn'
),
'forums' => array(
'admin',
'edit' => array('basic', 'extend', 'posts', 'credits', 'threadtypes', 'threadsorts', 'perm'),
'moderators',
'delete',
'merge',
'copy'
),
'threadtypes' => array(),
'members' => array(
'clean',
'newsletter',
'reward',
'confermedal',
'add',
'group',
'access',
'credit',
'medal',
'edit',
'ipban',
'ban'
),
'profilefields' => array(
'admin',
'edit'
),
'admingroups' => array(
'admin',
'edit'
),
'usergroups' => array(
'admin',
'edit' => array('basic', 'system', 'special', 'post', 'attach', 'magic', 'invite', 'credit'),
'viewsgroup'
),
'ranks' => array(),
'styles' => array(
'admin',
'edit',
'config',
'import'
),
'templates' => array(
'admin',
'add',
'edit'
),
'moderate' => array(
'members',
'threads',
'replies'
),
'threads' => array(),
'prune' => array(),
'recyclebin' => array('clean'),
'announce' => array(
'admin',
'add',
'edit'
),
'smilies' => array(),
'misc' => array(
'link',
'onlinelist',
'censor',
'bbcode',
'tag',
'icon',
'attachtype',
'cron',
'custommenu',
'customnav',
'focus'
),
'faq' => array(),
'adv' => array(
'admin',
'add',
'edit'
),
'db' => array(
'runquery',
'optimize',
'export',
'import'
),
'extended' => array(
'tag'
),
'tasks' => array(
'add',
'edit',
'type'
),
'tools' => array(
'updatecache',
'fileperms'
),
'attach' => array(),
'counter' => array(),
'jswizard' => array('admin', 'config', 'import'),
'creditwizard' => array(),
'google' => array(),
'qihoo' => array(
'config',
'topics'
),
'ec' => array(
'alipay',
'credit',
'orders'
),
'tradelog' => array(),
'medals' => array(),
'magics' => array('config', 'admin', 'market'),
'plugins' => array(
'config',
'edit',
'hooks',
'vars'
),
'logs' => array(
'illegal',
'rate',
'credit',
'mod',
'ban',
'cp',
'error',
'invite',
'magic',
'medal'
)
);
$keywords = trim($keywords);
$results = array();
$kws = explode(' ', $keywords);
$kws = array_map('trim', $kws);
$keywords = implode(' ', $kws);
if($searchsubmit && $keywords) {
foreach($lang as $key => $value) {
$matched = TRUE;
foreach($kws as $kw) {
if(strpos(strtolower($value), strtolower($kw)) === FALSE) {
$matched = FALSE;
break;
}
}
if($matched) {
$tmp = explode('_', $key);
if(isset($actionarray[$tmp[0]])) {
$url = $BASESCRIPT.'?action='.$tmp[0];
$vname = $tmp[0];
$subject = '<a href="'.$url.'&highlight='.urlencode($keywords).'" target="_blank"><u>'.lang($vname).'</u></a>';
if(is_array($actionarray[$tmp[0]][$tmp[1]])) {
$url .= '&operation='.$tmp[1];
$vname .= '_'.$tmp[1];
$subject .= ' » <a href="'.$url.'&highlight='.urlencode($keywords).'" target="_blank"><u>'.lang($vname).'</u></a>';
if(in_array($tmp[2], $actionarray[$tmp[0]][$tmp[1]])) {
$url .= '&anchor='.$tmp[2];
$vname .= '_'.$tmp[2];
$subject .= ' » <a href="'.$url.'&highlight='.urlencode($keywords).'" target="_blank"><u>'.lang($vname).'</u></a>';
}
} else {
if(in_array($tmp[1], $actionarray[$tmp[0]])) {
$url .= '&operation='.$tmp[1];
$vname .= '_'.$tmp[1];
$subject .= ' » <a href="'.$url.'&highlight='.urlencode($keywords).'" target="_blank"><u>'.lang($vname).'</u></a>';
}
}
if(isset($results[$url])) {
$results[$url]['message'] .= '<br />'.$value;
} else {
$results[$url] = array('subject' => $subject, 'message' => $value);
}
}
}
}
if($results) {
showsubmenu('search_result');
foreach($results as $result) {
echo '<div class="news"><h3>'.$result[subject].'</h3><p class="lineheight">'.strip_tags($result[message], '<br>').'</p></div>';
}
echo <<<EOT
<script type="text/JavaScript">
function parsetag(tag) {
var str = $('cpcontainer').innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) {
if(tag && $3.indexOf(tag) != -1) {
$3 = $3.replace(tag, '<h_>');
}
return $2 + $3;
});
$('cpcontainer').innerHTML = str.replace(/<h_>/ig, function($1, $2) {
return '<font color="#c60a00">' + tag + '</font>';
});
}
EOT;
foreach($kws as $kw) {
echo 'parsetag(\''.$kw.'\');';
}
echo '</script>';
} else {
cpmsg('search_result_noexists');
}
} else {
cpmsg('search_keyword_noexists', '', 'error');
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/search.inc.php | PHP | asf20 | 5,471 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: medals.inc.php 21268 2009-11-24 06:15:58Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(!submitcheck('medalsubmit')) {
shownav('extended', 'nav_medals', 'admin');
showsubmenu('nav_medals', array(
array('admin', 'medals', 1),
array('nav_medals_confer', 'members&operation=confermedal', 0),
array('nav_medals_mod', 'medals&operation=mod', 0)
));
showtips('medals_tips');
showformheader('medals');
showtableheader();
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
'',
lang('display_order'),
'',
lang('available'),
lang('name'),
lang('description'),
lang('medals_image'),
lang('medals_type'),
'',
));
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
[1,'', 'td25'],
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newname[]" size="10">'],
[1,'<input type="text" class="txt" name="newdescription[]" size="30">'],
[1,'<input type="text" class="txt" name="newimage[]" size="20">'],
[1,'', 'td23'],
[1,'', 'td25']
]
];
</script>
<?
$query = $db->query("SELECT * FROM {$tablepre}medals ORDER BY displayorder");
while($medal = $db->fetch_array($query)) {
$checkavailable = $medal['available'] ? 'checked' : '';
$medal['type'] = $medal['type'] == 1 ? lang('medals_register') : lang('medals_adminadd');
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$medal[medalid]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$medal[medalid]]\" value=\"$medal[displayorder]\">",
"<img src=\"images/common/$medal[image]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$medal[medalid]]\" value=\"1\" $checkavailable>",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"name[$medal[medalid]]\" value=\"$medal[name]\">",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"description[$medal[medalid]]\" value=\"$medal[description]\">",
"<input type=\"text\" class=\"txt\" size=\"20\" name=\"image[$medal[medalid]]\" value=\"$medal[image]\">",
$medal[type],
"<a href=\"$BASESCRIPT?action=medals&operation=edit&medalid=$medal[medalid]\" class=\"act\">$lang[detail]</a>"
));
}
echo '<tr><td></td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['medals_addnew'].'</a></div></td></tr>';
showsubmit('medalsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}medals WHERE medalid IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}medals SET name=".($name[$id] ? '\''.dhtmlspecialchars($name[$id]).'\'' : 'name').", available='$available[$id]', description=".($description[$id] ? '\''.dhtmlspecialchars($description[$id]).'\'' : 'name').", displayorder='".intval($displayorder[$id])."', image=".($image[$id] ? '\''.$image[$id].'\'' : 'image')." WHERE medalid='$id'");
}
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
if($value != '' && $newimage[$key] != '') {
$db->query("INSERT INTO {$tablepre}medals (name, available, image, displayorder, description) VALUES ('".dhtmlspecialchars($value)."', '$newavailable[$key]', '$newimage[$key]', '".intval($newdisplayorder[$key])."', '".dhtmlspecialchars($newdescription[$key])."')");
}
}
}
updatecache('settings');
updatecache('medals');
cpmsg('medals_succeed', $BASESCRIPT.'?action=medals', 'succeed');
}
} elseif($operation == 'mod') {
if(submitcheck('delmedalsubmit')) {
if (is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$query = $db->query("UPDATE {$tablepre}medallog SET type='3' WHERE id IN ($ids)");
cpmsg('medals_invalidate_succeed', $BASESCRIPT.'?action=medals&operation=mod', 'succeed');
} else {
cpmsg('medals_please_input', $BASESCRIPT.'?action=medals&operation=mod', 'error');
}
} elseif(submitcheck('modmedalsubmit')) {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$query = $db->query("SELECT me.id, me.uid, me.medalid, me.dateline, me.expiration, mf.medals
FROM {$tablepre}medallog me
LEFT JOIN {$tablepre}memberfields mf USING (uid)
WHERE id IN ($ids)");
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
while($modmedal = $db->fetch_array($query)) {
$modmedal['medals'] = empty($medalsnew[$modmedal['uid']]) ? $modmedal['medals'] : $medalsnew[$modmedal['uid']];
foreach($modmedal['medals'] = explode("\t", $modmedal['medals']) as $key => $modmedalid) {
list($medalid, $medalexpiration) = explode("|", $modmedalid);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$medalsnew[$modmedal['uid']][$key] = $modmedalid;
}
}
$medalstatus = empty($modmedal['expiration']) ? 0 : 1;
$modmedal['expiration'] = $modmedal['expiration'] ? ($timestamp + $modmedal['expiration'] - $modmedal['dateline']) : '';
$medalsnew[$modmedal['uid']][] = $modmedal['medalid'].(empty($modmedal['expiration']) ? '' : '|'.$modmedal['expiration']);
$db->query("UPDATE {$tablepre}medallog SET type=1, status='$medalstatus', expiration='$modmedal[expiration]' WHERE id='$modmedal[id]'");
}
foreach ($medalsnew as $key => $medalnew) {
$medalnew = implode("\t", $medalnew);
$db->query("UPDATE {$tablepre}memberfields SET medals='$medalnew' WHERE uid='$key'");
}
cpmsg('medals_validate_succeed', $BASESCRIPT.'?action=medals&operation=mod', 'succeed');
} else {
cpmsg('medals_please_input', $BASESCRIPT.'?action=medals&operation=mod', 'error');
}
} else {
$medals = '';
$query = $db->query("SELECT mel.*, m.username, me.name FROM {$tablepre}medallog mel
LEFT JOIN {$tablepre}medals me ON me.medalid = mel.medalid
LEFT JOIN {$tablepre}members m ON m.uid = mel.uid
WHERE mel.type=2 ORDER BY dateline");
while($medal = $db->fetch_array($query)) {
$medal['dateline'] = gmdate('Y-m-d H:i', $medal['dateline'] + $timeoffset * 3600);
$medal['expiration'] = empty($medal['expiration']) ? $lang['medals_forever'] : gmdate('Y-m-d H:i', $medal['expiration'] + $timeoffset * 3600);
$medals .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$medal[id]\">",
"<a href=\"space.php?username=".rawurlencode($medal['username'])."\" target=\"_blank\">$medal[username]</a>",
$medal['name'],
$medal['dateline'],
$medal['expiration']
), TRUE);
}
shownav('extended', 'nav_medals', 'nav_medals_mod');
showsubmenu('nav_medals', array(
array('admin', 'medals', 0),
array('nav_medals_confer', 'members&operation=confermedal', 0),
array('nav_medals_mod', 'medals&operation=mod', 1)
));
showformheader('medals&operation=mod');
showtableheader('medals_mod');
showtablerow('', '', array(
'',
lang('medals_user'),
lang('medals_name'),
lang('medals_date'),
lang('medals_expr'),
));
echo $medals;
showsubmit('modmedalsubmit', 'medals_modpass', 'select_all', '<input type="submit" class="btn" value="'.lang('medals_modnopass').'" name="delmedalsubmit"> ');
showtablefooter();
showformfooter();
}
} elseif($operation == 'edit') {
$medalid = intval($medalid);
if(!submitcheck('medaleditsubmit')) {
$medal = $db->fetch_first("SELECT * FROM {$tablepre}medals WHERE medalid='$medalid'");
$medal['permission'] = unserialize($medal['permission']);$medal['permission'] = $medal['permission'][0];
$checkmedaltype = array($medal['type'] => 'checked');
shownav('extended', 'nav_medals', 'admin');
showsubmenu('nav_medals', array(
array('admin', 'medals', 1),
array('nav_medals_confer', 'members&operation=confermedal', 0),
array('nav_medals_mod', 'medals&operation=mod', 0)
));
showformheader("medals&operation=edit&medalid=$medalid");
showtableheader(lang('medals_edit').' - '.$medal['name'], 'nobottom');
showsetting('medals_name1', 'namenew', $medal['name'], 'text');
showsetting('medals_img', '', '', '<input type="text" class="txt" size="30" name="imagenew" value="'.$medal['image'].'" ><img src="images/common/'.$medal['image'].'">');
showsetting('medals_type1', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($checkmedaltype[0] ? ' class="checked"' : '').'><input name="typenew" type="radio" class="radio" value="0" '.$checkmedaltype[0].'> '.$lang['medals_adminadd'].'</li>
<li'.($checkmedaltype[1] ? ' class="checked"' : '').'><input name="typenew" type="radio" class="radio" value="1" '.$checkmedaltype[1].'> '.$lang['medals_register'].'</li></ul>'
);
showsetting('medals_expr1', 'expirationnew', $medal['expiration'], 'text');
showsetting('medals_memo', 'descriptionnew', $medal['description'], 'text');
showtablefooter();
showtableheader('medals_perm', 'notop');
$formulareplace .= '\'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\',\'<u>'.$lang['settings_credits_formula_posts'].'</u>\',\'<u>'.$lang['settings_credits_formula_oltime'].'</u>\',\'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\'';
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, textend) {
$('formulapermnew').focus();
textend = isUndefined(textend) ? '' : textend;
if(!isUndefined($('formulapermnew').selectionStart)) {
var opn = $('formulapermnew').selectionStart + 0;
if(textend != '') {
text = text + $('formulapermnew').value.substring($('formulapermnew').selectionStart, $('formulapermnew').selectionEnd) + textend;
}
$('formulapermnew').value = $('formulapermnew').value.substr(0, $('formulapermnew').selectionStart) + text + $('formulapermnew').value.substr($('formulapermnew').selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
if(textend != '') {
text = text + sel.text + textend;
}
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$('formulapermnew').value += text;
}
formulaexp();
}
var formulafind = new Array('digestposts', 'posts', 'threads', 'oltime', 'pageviews');
var formulareplace = new Array(<?=$formulareplace?>);
function formulaexp() {
var result = $('formulapermnew').value;
<?
$extcreditsbtn = '';
for($i = 1; $i <= 8; $i++) {
$extcredittitle = $extcredits[$i]['title'] ? $extcredits[$i]['title'] : $lang['settings_credits_formula_extcredits'].$i;
echo 'result = result.replace(/extcredits'.$i.'/g, \'<u>'.$extcredittitle.'</u>\');';
$extcreditsbtn .= '<a href="###" onclick="insertunit(\'extcredits'.$i.'\')">'.$extcredittitle.'</a> ';
}
$profilefields = '';
$query = $db->query("SELECT * FROM {$tablepre}profilefields WHERE available='1' AND unchangeable='1'");
while($profilefield = $db->fetch_array($query)) {
echo 'result = result.replace(/field_'.$profilefield['fieldid'].'/g, \'<u>'.str_replace("'", "\'", $profilefield['title']).'</u>\');';
$profilefields .= '<a href="###" onclick="insertunit(\' field_'.$profilefield['fieldid'].' \')"> '.$profilefield['title'].' </a> ';
}
echo 'result = result.replace(/regdate/g, \'<u>'.$lang['forums_edit_perm_formula_regdate'].'</u>\');';
echo 'result = result.replace(/regday/g, \'<u>'.$lang['forums_edit_perm_formula_regday'].'</u>\');';
echo 'result = result.replace(/regip/g, \'<u>'.$lang['forums_edit_perm_formula_regip'].'</u>\');';
echo 'result = result.replace(/lastip/g, \'<u>'.$lang['forums_edit_perm_formula_lastip'].'</u>\');';
echo 'result = result.replace(/buyercredit/g, \'<u>'.$lang['forums_edit_perm_formula_buyercredit'].'</u>\');';
echo 'result = result.replace(/sellercredit/g, \'<u>'.$lang['forums_edit_perm_formula_sellercredit'].'</u>\');';
echo 'result = result.replace(/digestposts/g, \'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\');';
echo 'result = result.replace(/posts/g, \'<u>'.$lang['settings_credits_formula_posts'].'</u>\');';
echo 'result = result.replace(/threads/g, \'<u>'.$lang['settings_credits_formula_threads'].'</u>\');';
echo 'result = result.replace(/oltime/g, \'<u>'.$lang['settings_credits_formula_oltime'].'</u>\');';
echo 'result = result.replace(/pageviews/g, \'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\');';
echo 'result = result.replace(/and/g, \' <b>'.$lang['forums_edit_perm_formula_and'].'</b> \');';
echo 'result = result.replace(/or/g, \' <b>'.$lang['forums_edit_perm_formula_or'].'</b> \');';
echo 'result = result.replace(/>=/g, \'≥\');';
echo 'result = result.replace(/<=/g, \'≤\');';
echo 'result = result.replace(/==/g, \'=\');';
?>
$('formulapermexp').innerHTML = result;
}
</script>
<tr><td colspan="2"><div class="extcredits">
<?php echo $extcreditsbtn?>
<a href="###" onclick="insertunit(' regdate ')"> <?php echo lang('forums_edit_perm_formula_regdate')?> </a>
<a href="###" onclick="insertunit(' regday ')"> <?php echo lang('forums_edit_perm_formula_regday')?> </a>
<a href="###" onclick="insertunit(' regip ')"> <?php echo lang('forums_edit_perm_formula_regip')?> </a>
<a href="###" onclick="insertunit(' lastip ')"> <?php echo lang('forums_edit_perm_formula_lastip')?> </a>
<a href="###" onclick="insertunit(' buyercredit ')"> <?php echo lang('forums_edit_perm_formula_buyercredit')?> </a>
<a href="###" onclick="insertunit(' sellercredit ')"> <?php echo lang('forums_edit_perm_formula_sellercredit')?> </a>
<a href="###" onclick="insertunit(' digestposts ')"><?php echo lang('forums_edit_perm_formula_digestposts')?></a>
<a href="###" onclick="insertunit(' posts ')"><?php echo lang('forums_edit_perm_formula_posts')?></a>
<a href="###" onclick="insertunit(' threads ')"><?php echo lang('forums_edit_perm_formula_threads')?></a>
<a href="###" onclick="insertunit(' oltime ')"><?php echo lang('forums_edit_perm_formula_oltime')?></a>
<a href="###" onclick="insertunit(' pageviews ')"><?php echo lang('forums_edit_perm_formula_pageviews')?></a><?php echo $profilefields;?><br />
<a href="###" onclick="insertunit(' + ')"> + </a>
<a href="###" onclick="insertunit(' - ')"> - </a>
<a href="###" onclick="insertunit(' * ')"> * </a>
<a href="###" onclick="insertunit(' / ')"> / </a>
<a href="###" onclick="insertunit(' > ')"> > </a>
<a href="###" onclick="insertunit(' >= ')"> >= </a>
<a href="###" onclick="insertunit(' < ')"> < </a>
<a href="###" onclick="insertunit(' <= ')"> <= </a>
<a href="###" onclick="insertunit(' == ')"> = </a>
<a href="###" onclick="insertunit(' != ')"> != </a>
<a href="###" onclick="insertunit(' (', ') ')"> ( ) </a>
<a href="###" onclick="insertunit(' and ')"> <?php echo lang('forums_edit_perm_formula_and')?> </a>
<a href="###" onclick="insertunit(' or ')"> <?php echo lang('forums_edit_perm_formula_or')?> </a> <br />
</div><div id="formulapermexp" class="marginbot diffcolor2"><?=$formulapermexp?></div>
<textarea name="formulapermnew" id="formulapermnew" style="width: 80%" rows="3" onkeyup="formulaexp()"><?=dhtmlspecialchars($medal['permission'])?></textarea>
<br /><span class="smalltxt"><?=$lang['medals_permformula']?></span>
<br /><?=$lang['creditwizard_current_formula_notice']?>
<script type="text/JavaScript">formulaexp()</script>
</td></tr>
<?
showsubmit('medaleditsubmit');
showtablefooter();
showformfooter();
} else {
if($formulapermnew && !preg_match("/^(\{|\}|\+|\-|\*|\/|\.|>|<|=|!|\d|\s|\(|\)|extcredits[1-8]|regdate|regday|regip|lastip|buyercredit|sellercredit|field\_\d+|digestposts|posts|threads|pageviews|oltime|and|or)+$/", $formulapermnew) ||
!is_null(@eval(preg_replace(
array("/(regdate|regday|regip|lastip|buyercredit|sellercredit|field\_\d+|digestposts|posts|threads|pageviews|oltime|extcredits[1-8])/", "/\{([\d\.\-]+?)\}/"),
array("\$\\1", "'\\1'"), $formulapermnew).';'))) {
cpmsg('forums_formulaperm_error', '', 'error');
}
$formulapermary[0] = $formulapermnew;
$formulapermary[1] = preg_replace(
array("/(digestposts|posts|threads|pageviews|oltime|extcredits[1-8])/", "/(regdate|regday|regip|lastip|buyercredit|sellercredit|field\_\d+)/"),
array("\$_DSESSION['\\1']", "\$memberformula['\\1']"),
$formulapermnew);
$formulapermnew = addslashes(serialize($formulapermary));
$db->query("UPDATE {$tablepre}medals SET name=".($namenew ? '\''.dhtmlspecialchars($namenew).'\'' : 'name').", type='$typenew', description='".dhtmlspecialchars($descriptionnew)."', expiration='".intval($expirationnew)."', permission='$formulapermnew', image='$imagenew' WHERE medalid='$medalid'");
updatecache('medals');
cpmsg('medals_succeed', $BASESCRIPT.'?action=medals&do=editmedals', 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/medals.inc.php | PHP | asf20 | 18,233 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: project.inc.php 21337 2010-01-06 08:09:58Z tiger $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(!isfounder()) {
cpheader();
cpmsg('noaccess', '', 'error');
}
$query = $db->query("SELECT disabledactions FROM {$tablepre}adminactions WHERE admingid='$groupid'");
$dactionarray = ($dactionarray = unserialize($db->result($query, 0))) ? $dactionarray : array();
$allowforumsedit = !in_array('forums', $dactionarray) ? 1 : 0;
$allowusergroups = !in_array('groups_user', $dactionarray) ? 1 : 0;
$allowcreditwizard = !in_array('creditwizard', $dactionarray) ? 1 : 0;
if(empty($allowforumsedit) && empty($allowusergroups) && empty($allowcreditwizard)) {
cpheader();
cpmsg('action_noaccess', '', 'error');
}
if($operation == 'export' && $id) {
$projectarray = $db->fetch_first("SELECT * FROM {$tablepre}projects WHERE id='$id'");
if(!$projectarray) {
cpheader();
cpmsg('undefined_action', '', 'error');
}
if(($projectarray['type'] == 'forum' && empty($allowforumsedit)) || ($projectarray['type'] == 'group' && empty($allowusergroups)) || ($projectarray['type'] == 'extcredit' && empty($allowcreditwizard))) {
cpheader();
cpmsg('action_noaccess', '', 'error');
}
$projectarray['version'] = strip_tags($version);
exportdata('Discuz! Project', $projectarray['type'].'_'.$projectarray['name'], $projectarray);
}
cpheader();
if(!$operation) {
if(!submitcheck('projectsubmit')) {
$listarray = array();
$projectlist = $typeadd = $selecttype = '';
$page = max(1, intval($page));
$start_limit = ($page - 1) * 10;
$allowaction = array(
'forum' => $allowforumsedit,
'group' => $allowusergroups,
'extcredit' => $allowcreditwizard,
);
if(!empty($type) && in_array($type, array('forum', 'group', 'extcredit'))) {
foreach($allowaction as $key => $val) {
if($type == $key && empty($val)) {
cpmsg('action_noaccess', '', 'error');
}
}
$typeadd = "WHERE type='$type'";
$selecttype = '&type='.$type;
} else {
$typeadd = $comma = '';
foreach($allowaction as $key => $val) {
if(!empty($val)) {
$typeadd .= $comma."'$key'";
$comma = ', ';
}
}
$typeadd = 'WHERE type IN ('.$typeadd.')';
}
$projectnum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}projects $typeadd");
$query = $db->query("SELECT id, name, type, description FROM {$tablepre}projects $typeadd LIMIT $start_limit, 10");
while($list = $db->fetch_array($query)) {
$list['name'] = dhtmlspecialchars($list['name']);
$list['description'] = dhtmlspecialchars($list['description']);
$projecttype = 'project_'.$list['type'].'_scheme';
$projectlist .= showtablerow('', array('class="td25"', 'class="td24"', 'class="td26"', 'class="td24"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$list[id]\">",
"<input type=\"text\" class=\"txtnobd\" onblur=\"this.className='txtnobd'\" onfocus=\"this.className='txt'\" size=\"15\" name=\"name[$list[id]]\" value=\"$list[name]\">",
"<input type=\"text\" class=\"txtnobd\" onblur=\"this.className='txtnobd'\" onfocus=\"this.className='txt'\" size=\"40\" name=\"description[$list[id]]\" value=\"$list[description]\">",
$lang[$projecttype],
"<a href=\"$BASESCRIPT?action=project&operation=export&id=$list[id]\" class=\"act\">".$lang['export']."</a> <a href=\"$BASESCRIPT?action=project&operation=apply&projectid=$list[id]&type=$list[type]\" class=\"act\">".$lang['apply']."</a>"
), TRUE);
}
$multipage = multi($projectnum, 10, $page, "$BASESCRIPT?action=project$selecttype");
shownav('tools', 'project_scheme');
showsubmenu('project_scheme', array(
$allowforumsedit ? array('project_forum_scheme', 'project&type=forum', $type == 'forum') : array(),
$allowusergroups ? array('project_group_scheme', 'project&type=group', $type == 'group') : array(),
$allowcreditwizard ? array('project_extcredit_scheme', 'project&type=extcredit', $type == 'extcredit') : array(),
array('project_import_stick', 'project&operation=import', $operation == 'import')
));
showformheader('project');
showtableheader();
showsubtitle(array('', 'name', 'description', 'type', ''));
echo $projectlist;
showsubmit('projectsubmit', 'submit', 'del', '', $multipage);
showtablefooter();
showformfooter();
} else {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}projects WHERE id IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}projects SET name='$name[$id]', description='$description[$id]' WHERE id='$id'");
}
}
cpmsg('project_update_forum', $BASESCRIPT.'?action=project', 'succeed');
}
} elseif($operation == 'import') {
if(!submitcheck('importsubmit')) {
shownav('tools', 'project_scheme');
showsubmenu('project_scheme', array(
$allowforumsedit ? array('project_forum_scheme', 'project&type=forum', $type == 'forum') : array(),
$allowusergroups ? array('project_group_scheme', 'project&type=group', $type == 'group') : array(),
$allowcreditwizard ? array('project_extcredit_scheme', 'project&type=extcredit', $type == 'extcredit') : array(),
array('project_import_stick', 'project&operation=import', $operation == 'import')
));
showformheader('project&operation=import', 'enctype');
showtableheader('project_import_stick');
showimportdata();
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
require_once DISCUZ_ROOT.'./admin/importdata.func.php';
import_project();
cpmsg('project_import_succeed', $BASESCRIPT.'?action=project', 'succeed');
}
} elseif($operation == 'add') {
$delfields = array(
'forum' => array('fid', 'fup', 'type', 'name', 'status', 'displayorder', 'threads', 'posts', 'todayposts', 'lastpost', 'description', 'modworks', 'password', 'icon', 'redirect', 'moderators', 'rules', 'threadtypes', 'threadsorts', 'typemodels', 'tradetypes', 'threadplugin'),
'group' => array('groupid', 'radminid', 'type', 'system', 'grouptitle', 'creditshigher', 'creditslower', 'stars', 'color', 'groupavatar')
);
if(!submitcheck('addsubmit')) {
shownav('tools', 'project_scheme_add');
showsubmenu('project_scheme_add');
if(!empty($projectid)) {
$query = $db->query("SELECT name, description, value FROM {$tablepre}projects WHERE id='$projectid'");
$project = $db->fetch_array($query);
}
if(($type == 'forum' && empty($allowforumsedit)) || ($type == 'group' && empty($allowusergroups)) || ($type == 'extcredit' && empty($allowcreditwizard))) {
cpmsg('action_noaccess', '', 'error');
}
$allselected = 'selected';
if($type == 'forum' || $type == 'group') {
$listoption = '';
$fieldarray = $type == 'forum' ? array_merge(fetch_table_struct('forums'), fetch_table_struct('forumfields')) : fetch_table_struct('usergroups');
$listfields = array_diff($fieldarray, $delfields[$type]);
foreach($listfields as $field) {
$listoption .= '<option value="'.$field.'">'.($lang['project_option_'.$type.'_'.$field] ? $lang['project_option_'.$type.'_'.$field] : $field).'</option>';
}
} elseif($type == 'extcredit') {
$value = unserialize($project['value']);
$savemethod = $value['savemethod'];
$allselected = '';
$listoption = '<option value="1"'.(@in_array(1, $savemethod) ? ' selected': '').'>'.$lang['project_credits_item_config'].'</option>';
$listoption .= '<option value="2"'.(@in_array(2, $savemethod) ? ' selected': '').'>'.$lang['project_credits_rule_config'].'</option>';
$listoption .= '<option value="3"'.(@in_array(3, $savemethod) ? ' selected': '').'>'.$lang['project_credits_use_config'].'</option>';
}
showformheader("project&operation=add&id=$id");
showhiddenfields(array('projectid' => $projectid, 'type' => $type, 'detailsubmit' => 'submit'));
showtableheader();
showtitle('project_scheme_save');
if(!empty($projectid)) {
showsetting('project_scheme_cover', 'coverwith', '', 'radio');
}
showsetting('project_scheme_option', '', '', '<select name="fieldoption[]" size="10" multiple="multiple"><option value="all" '.$allselected.'>'.$lang['all'].'</option>'.$listoption.'</select>');
showsetting('project_scheme_title', 'name', $project['name'], 'text');
showsetting('project_scheme_description', 'description', $project['description'], 'textarea');
showsubmit('addsubmit');
showtablefooter();
} else {
$type = !empty($type) && in_array($type, array('forum', 'group', 'extcredit')) ? $type : '';
if(empty($name)) {
cpmsg('project_no_title', '', 'error');
}
if($type == 'forum') {
$value = $db->fetch_first("SELECT f.*, ff.* FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING (fid)
WHERE f.fid='$id'");
if(!$value) {
cpmsg('forums_nonexistence', '', 'error');
}
} elseif($type == 'group') {
$value = $db->fetch_first("SELECT * FROM {$tablepre}usergroups WHERE groupid='$id'");
if(!$value) {
cpmsg('project_no_usergroup', '', 'error');
}
} elseif($type == 'extcredit') {
if(empty($fieldoption)) {
cpmsg('project_no_item', '', 'error');
}
$delfields = array();
$fieldoption = in_array('all', $fieldoption) ? array(1, 2, 3) : $fieldoption;
$variables = in_array(1, $fieldoption) ? ", 'extcredits', 'creditspolicy'" : '';
$variables .= in_array(2, $fieldoption) ? ", 'creditsformula'" : '';
$variables .= in_array(3, $fieldoption) ? ", 'creditstrans', 'creditstax', 'transfermincredits', 'exchangemincredits', 'maxincperthread', 'maxchargespan'" : '';
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable IN (''$variables)");
$value['savemethod'] = $fieldoption;
while($data = $db->fetch_array($query)) {
$value[$data['variable']] = $data['value'];
}
}
if($type == 'forum' || $type == 'group') {
if(in_array('all', $fieldoption)) {
foreach($delfields[$type] as $field) {
unset($value[$field]);
}
} else {
$selectlist = '';
foreach($value as $key => $val) {
if(in_array($key, $fieldoption)) {
$selectlist[$key] .= $val;
}
}
$value = $selectlist;
}
}
$value = !empty($value) ? addslashes(serialize($value)) : '';
if(!empty($projectid) && !empty($coverwith)) {
$db->query("UPDATE {$tablepre}projects SET name='$name', description='$description', value='$value' WHERE id='$projectid'");
} else {
$db->query("INSERT INTO {$tablepre}projects (name, type, description, value) VALUES ('$name', '$type', '$description', '$value')");
}
if($type == 'forum') {
cpmsg('project_sava_succeed', $BASESCRIPT.'?action=forums&operation=edit&fid='.$id, 'succeed');
} elseif($type == 'group') {
cpmsg('project_sava_succeed', $BASESCRIPT.'?action=usergroups&operation=edit&id='.$id, 'succeed');
} elseif($type == 'extcredit') {
cpmsg('project_sava_succeed', $BASESCRIPT.'?action=settings&operation=credits', 'succeed');
}
}
} elseif($operation == 'apply') {
$type = !empty($type) && in_array($type, array('forum', 'group', 'extcredit')) ? $type : 'forum';
if(($type == 'forum' && empty($allowforumsedit)) || ($type == 'group' && empty($allowusergroups)) || ($type == 'extcredit' && empty($allowcreditwizard))) {
cpmsg('action_noaccess', '', 'error');
}
$projectselect = "<select name=\"projectid\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
$query = $db->query("SELECT id, name, type FROM {$tablepre}projects WHERE type='$type'");
while($project = $db->fetch_array($query)) {
$projectselect .= "<option value=\"$project[id]\" ".($project['id'] == $projectid ? 'selected="selected"' : NULL).">$project[name]</option>\n";
}
$projectselect .= '</select>';
if(!submitcheck('applysubmit')) {
if($type == 'forum') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="target[]" size="10" multiple="multiple">'.forumselect(FALSE, 0, 0, TRUE).'</select>';
} elseif($type == 'group') {
$groupselect = '<select name="target[]" size="10" multiple="multiple">';
$query = $db->query("SELECT groupid, type, grouptitle, creditshigher, creditslower, stars, color, groupavatar FROM {$tablepre}usergroups ORDER BY creditshigher");
while($group = $db->fetch_array($query)) {
$groupselect .= '<option value="'.$group['groupid'].'">'.$group['grouptitle'].'</option>';
}
$groupselect .= '</select>';
} elseif($type == 'extcredit') {
dheader("location: $BASESCRIPT?action=settings&operation=credits&projectid=$projectid");
}
shownav('tools', 'project_scheme');
showsubmenu('project_global_forum');
showformheader("project&operation=apply&projectid=$projectid");
showtableheader();
showtitle($type == 'forum' ? 'project_scheme_forum' : 'project_group_scheme');
showsetting('project_scheme_name', '', '', $projectselect);
if($type == 'forum') {
showsetting('forums_copy_target', '', '', $forumselect);
} elseif($type == 'group') {
showsetting('project_target_usergroup', '', '', $groupselect);
}
showsubmit('applysubmit');
showtablefooter();
showformfooter();
} else {
if(empty($target)) {
cpmsg('project_target_item_invalid', '', 'error');
}
$applyids = implodeids($target);
$project = $db->fetch_first("SELECT type, value FROM {$tablepre}projects WHERE id='$projectid'");
if(!$project) {
cpmsg('project_no_scheme', '', 'error');
}
if(!$value = unserialize($project['value'])) {
cpmsg('project_invalid', '', 'error');
}
if($project['type'] == 'forum') {
$table_forum_columns = array('styleid', 'allowsmilies', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowmediacodenew', 'allowanonymous', 'allowshare', 'allowpostspecial', 'alloweditrules', 'alloweditpost', 'allowspecialonly', 'modnewposts', 'recyclebin', 'jammer', 'forumcolumns', 'threadcaches', 'disablewatermark', 'autoclose', 'simple');
$table_forumfield_columns = array('attachextensions', 'postcredits', 'replycredits', 'digestcredits', 'postattachcredits', 'getattachcredits', 'viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm', 'modrecommend', 'formulaperm');
$updatesql = $comma = '';
foreach($table_forum_columns as $field) {
if(isset($value[$field])) {
$updatesql .= "$comma$field='".addslashes($value[$field])."'";
$comma = ', ';
}
}
if($updatesql && $applyids) {
$db->query("UPDATE {$tablepre}forums SET $updatesql WHERE fid IN ($applyids)");
}
$updatesql = $comma = '';
foreach($table_forumfield_columns as $field) {
if(isset($value[$field])) {
$updatesql .= "$comma$field='".addslashes($value[$field])."'";
$comma = ', ';
}
}
if($updatesql && $applyids) {
$db->query("UPDATE {$tablepre}forumfields SET $updatesql WHERE fid IN ($applyids)");
}
} elseif($project['type'] == 'group') {
$usergroup_columns = array('readaccess', 'allowvisit', 'allowpost', 'allowreply', 'allowpostpoll', 'allowpostreward', 'allowposttrade', 'allowpostactivity', 'allowdirectpost', 'allowgetattach', 'allowpostattach', 'allowvote', 'allowmultigroups', 'allowsearch', 'allowcstatus', 'allowinvisible', 'allowtransfer', 'allowsetreadperm', 'allowsetattachperm', 'allowhidecode', 'allowhtml', 'allowcusbbcode', 'allowanonymous', 'allownickname', 'allowsigbbcode', 'allowsigimgcode', 'allowviewpro', 'allowviewstats', 'disableperiodctrl', 'reasonpm', 'maxprice', 'maxsigsize', 'maxattachsize', 'maxsizeperday', 'maxpostsperhour', 'attachextensions', 'raterange', 'mintradeprice', 'maxtradeprice', 'minrewardprice', 'maxrewardprice', 'magicsdiscount', 'allowmagics', 'maxmagicsweight', 'allowbiobbcode', 'allowbioimgcode', 'maxbiosize', 'allowinvite', 'allowmailinvite', 'inviteprice', 'maxinvitenum', 'maxinviteday', 'allowpostdebate', 'tradestick', 'exempt');
$updatesql = $comma = '';
foreach($usergroup_columns as $field) {
if(isset($value[$field])) {
$updatesql .= "$comma$field='".addslashes($value[$field])."'";
$comma = ', ';
}
}
if($updatesql && $applyids) {
$db->query("UPDATE {$tablepre}usergroups SET $updatesql WHERE groupid IN ($applyids)");
}
}
cpmsg('project_scheme_succeed', '', 'succeed');
}
}
function fetch_table_struct($tablename, $result = 'FIELD') {
global $db, $tablepre;
$datas = array();
$query = $db->query("DESCRIBE $tablepre$tablename");
while($data = $db->fetch_array($query)) {
$datas[$data['Field']] = $result == 'FIELD' ? $data['Field'] : $data;
}
return $datas;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/project.inc.php | PHP | asf20 | 17,117 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tasks.inc.php 21301 2009-11-25 15:02:22Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$id = intval($id);
$membervars = array('act', 'num', 'time');
$postvars = array('act', 'forumid', 'num', 'time', 'threadid', 'authorid');
$modvars = array();
$sys_scripts = array('member', 'post', 'mod');
$sys_types = array('member' => array('name' => lang('nav_task_member'), 'version' => '1.0'), 'post' => array('name' => lang('nav_task_post'), 'version' => '1.0'));
$custom_types = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='tasktypes'");
$custom_types = $custom_types ? unserialize($custom_types) : array();
$custom_scripts = array_keys($custom_types);
$submenus = array();
foreach(array_merge($sys_types, $custom_types) as $k => $v) {
$submenus[] = array($v['name'], "tasks&operation=add&script=$k");
}
if(!($operation)) {
if(!submitcheck('tasksubmit')) {
shownav('extended', 'nav_tasks');
showsubmenu('nav_tasks', array(
array('admin', 'tasks', 1),
array(array('menu' => 'add', 'submenu' => $submenus), '', 0),
array('nav_task_type', 'tasks&operation=type', 0)
));
showtips('tasks_tips');
showformheader('tasks');
showtableheader('config', 'fixpadding');
showsetting('tasks_on', 'taskonnew', $taskon, 'radio');
showtablefooter();
showtableheader('admin', 'fixpadding');
showsubtitle(array('name', 'available', 'display_order', 'type', 'tasks_reward', 'time', ''));
$starttasks = array();
$query = $db->query("SELECT * FROM {$tablepre}tasks ORDER BY displayorder, taskid DESC");
while($task = $db->fetch_array($query)) {
if($task['reward'] == 'credit') {
$reward = lang('credits').' '.$extcredits[$task['prize']]['title'].' '.$task['bonus'].' '.$extcredits[$task['prize']]['unit'];
} elseif($task['reward'] == 'magic') {
$magicname = $db->result_first("SELECT name FROM {$tablepre}magics WHERE magicid='$task[prize]'");
$reward = lang('tasks_reward_magic').' '.$magicname.' '.$task['bonus'];
} elseif($task['reward'] == 'medal') {
$medalname = $db->result_first("SELECT name FROM {$tablepre}medals WHERE medalid='$task[prize]'");
$reward = lang('medals').' '.$medalname.($task['bonus'] ? ' '.lang('validity').$task['bonus'].' '.lang('days') : '');
} elseif($task['reward'] == 'invite') {
$reward = lang('tasks_reward_invite').' '.$task['prize'].($task['bonus'] ? ' '.lang('validity').$task['bonus'].' '.lang('days') : '');
} elseif($task['reward'] == 'group') {
$grouptitle = $db->result_first("SELECT grouptitle FROM {$tablepre}usergroups WHERE groupid='$task[prize]'");
$reward = lang('usergroup').' '.$grouptitle.($task['bonus'] ? ' '.lang('validity').' '.$task['bonus'].' '.lang('days') : '');
} else {
$reward = lang('none');
}
if($task['available'] == '1' && (!$task['starttime'] || $task['starttime'] <= $timestamp) && (!$task['endtime'] || $task['endtime'] > $timestamp)) {
$starttasks[] = $task['taskid'];
}
$checked = $task['available'] ? ' checked="checked"' : '';
if($task['starttime'] && $task['endtime']) {
$task['time'] = gmdate('y-m-d', $task['starttime'] + $timeoffset * 3600).' ~ '.gmdate('y-m-d', $task['endtime'] + $timeoffset * 3600);
} elseif($task['starttime'] && !$task['endtime']) {
$task['time'] = gmdate('y-m-d', $task['starttime'] + $timeoffset * 3600).' '.lang('tasks_online');
} elseif(!$task['starttime'] && $task['endtime']) {
$task['time'] = gmdate('y-m-d', $task['endtime'] + $timeoffset * 3600).' '.lang('tasks_offline');
} else {
$task['time'] = lang('nolimit');
}
showtablerow('', array('', 'class="td25"'), array(
"<input type=\"text\" class=\"txt\" name=\"namenew[$task[taskid]]\" size=\"20\" value=\"$task[name]\"><input type=\"hidden\" name=\"nameold[$task[taskid]]\" value=\"$task[name]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$task[taskid]]\" value=\"1\"$checked><input type=\"hidden\" name=\"availableold[$task[taskid]]\" value=\"$task[available]\">",
'<input type="text" class="txt" name="displayordernew['.$task['taskid'].']" value="'.$task['displayorder'].'" size="3" />',
$task['newbietask'] == '1' ? lang('tasks_newbie_task') : (in_array($task['scriptname'], $custom_scripts) ? $custom_types[$task['scriptname']]['name'] : lang('nav_task_'.$task['scriptname'])),
$reward,
$task['time'].'<input type="hidden" name="newbietasknew['.$task['taskid'].']" value="'.$task['newbietask'].'"><input type="hidden" name="scriptnamenew['.$task['taskid'].']" value="'.$task['scriptname'].'">',
"<a href=\"$BASESCRIPT?action=tasks&operation=edit&id=$task[taskid]\" class=\"act\">$lang[edit]</a>",
$task['newbietask'] == '1' ? '' : "<a href=\"$BASESCRIPT?action=tasks&operation=delete&id=$task[taskid]\" class=\"act\">$lang[delete]</a>"
));
}
if($starttasks) {
$db->query("UPDATE {$tablepre}tasks SET available='2' WHERE taskid IN (".implodeids($starttasks).")", 'UNBUFFERED');
}
showsubmit('tasksubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$checksettingsok = TRUE;
if(is_array($namenew)) {
foreach($namenew as $id => $name) {
$availablenew[$id] = $availablenew[$id] && (!$starttimenew[$id] || $starttimenew[$id] <= $timestamp) && (!$endtimenew[$id] || $endtimenew[$id] > $timestamp) ? 2 : $availablenew[$id];
if($newbietasknew[$id] && $availablenew[$id]) {
switch(substr($scriptnamenew[$id], 7)) {
case 'post_reply':
$checkid = 'threadid';
break;
case 'post_newthread':
$checkid = 'forumid';
break;
case 'sendpm':
case 'addbuddy':
$checkid = 'authorid';
break;
default:
$checkid = '';
break;
}
if($checkid) {
$checkresult = $db->result_first("SELECT value FROM {$tablepre}taskvars WHERE taskid='$id' AND variable='$checkid'");
if(empty($checkresult)) {
$availablenew[$id] = 0;
$checksettingsok = FALSE;
}
}
}
$displayorderadd = isset($displayordernew[$id]) ? ", displayorder='$displayordernew[$id]'" : '';
$db->query("UPDATE {$tablepre}tasks SET name='".dhtmlspecialchars($namenew[$id])."', available='$availablenew[$id]'$displayorderadd WHERE taskid='$id'");
}
}
$updatesettings = $updatenewbietask = FALSE;
if($taskonnew != $taskon) {
$updatesettings = TRUE;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('taskon', '$taskonnew')");
}
if(is_array($newbietasknew)) {
foreach($newbietasknew as $id => $v) {
if($availablenew[$id] != $availableold[$id] || $namenew[$id] != $nameold[$id]) {
$updatesettings = TRUE;
}
if($v == '2' && $availablenew[$id] && !$availableold[$id]) {
$updatenewbietask = TRUE;
}
}
}
if($updatenewbietask) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('newbietaskupdate', '$timestamp')");
}
$updatesettings && updatecache('settings');
cpmsg($checksettingsok ? 'tasks_succeed' : 'tasks_settings_invalid', $BASESCRIPT.'?action=tasks', $checksettingsok ? 'succeed' : 'error');
}
} elseif($operation == 'add' && $script) {
if(!in_array($script, $sys_scripts)) {
if(in_array($script, $custom_scripts)) {
include language('tasks');
if((!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.cfg.php') || (!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.inc.php')) {
cpmsg('tasks_noscript_or_nocfg', '', 'error');
}
} else {
cpmsg('undefined_action', '', 'error');
}
}
if(!submitcheck('addsubmit')) {
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
shownav('extended', 'nav_tasks');
showsubmenu('nav_tasks', array(
array('admin', 'tasks', 0),
array(array('menu' => 'add', 'submenu' => $submenus), '', 1),
array('nav_task_type', 'tasks&operation=type', 0)
));
if(in_array($script, $sys_scripts)) {
showtips('tasks_tips_add_'.$script);
$task_name = $task_description = $task_icon = $task_period = '';
}
showformheader('tasks&operation=add&script='.$script);
showtableheader('tasks_add_basic', 'fixpadding');
showsetting('tasks_add_name', 'name', $task_name, 'text');
showsetting('tasks_add_desc', 'description', $task_description, 'textarea');
showsetting('tasks_add_icon', 'icon', $task_icon, 'text');
showsetting('tasks_add_starttime', 'starttime', '', 'calendar');
showsetting('tasks_add_endtime', 'endtime', '', 'calendar');
showsetting('tasks_add_period', 'period', $task_period, 'text');
showsetting('tasks_add_reward', array('reward', array(
array('', lang('none'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')),
array('credit', lang('credits'), array('reward_credit' => '', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')),
$magicstatus ? array('magic', lang('tasks_reward_magic'), array('reward_credit' => 'none', 'reward_magic' => '', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')) : '',
$medalstatus ? array('medal', lang('medals'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => '', 'reward_invite' => 'none', 'reward_group' => 'none')) : '',
$regstatus > 1 ? array('invite', lang('tasks_reward_invite'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => '', 'reward_group' => 'none')) : '',
array('group', lang('tasks_add_group'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => ''))
)), '', 'mradio');
$extcreditarray = array(array(0, lang('select')));
foreach($extcredits as $creditid => $extcredit) {
$extcreditarray[] = array($creditid, $extcredit['title']);
}
showtagheader('tbody', 'reward_credit');
showsetting('tasks_add_extcredit', array('prize_credit', $extcreditarray), 0, 'select');
showsetting('tasks_add_credits', 'bonus_credit', '0', 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_magic');
showsetting('tasks_add_magicname', array('prize_magic', fetcharray('magicid', 'name', 'magics', "available='1' ORDER BY displayorder")), 0, 'select');
showsetting('tasks_add_magicnum', 'bonus_magic', '0', 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_medal');
showsetting('tasks_add_medalname', array('prize_medal', fetcharray('medalid', 'name', 'medals', "available='1' ORDER BY displayorder")), 0, 'select');
showsetting('tasks_add_medalexp', 'bonus_medal', '', 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_invite');
showsetting('tasks_add_invitenum', 'prize_invite', '1', 'text');
showsetting('tasks_add_inviteexp', 'bonus_invite', '10', 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_group');
showsetting('tasks_add_group', array('prize_group', fetcharray('groupid', 'grouptitle', 'usergroups', "type='special' AND radminid='0'")), 0, 'select');
showsetting('tasks_add_groupexp', 'bonus_group', '', 'text');
showtagfooter('tbody');
showtitle('tasks_add_appyperm');
showsetting('tasks_add_groupperm', array('grouplimit', array(
array('all', lang('tasks_add_group_all'), array('specialgroup' => 'none')),
array('member', lang('tasks_add_group_member'), array('specialgroup' => 'none')),
array('admin', lang('tasks_add_group_admin'), array('specialgroup' => 'none')),
array('special', lang('tasks_add_group_special'), array('specialgroup' => ''))
)), 'all', 'mradio');
showtagheader('tbody', 'specialgroup');
showsetting('tasks_add_usergroup', array('applyperm[]', fetcharray('groupid', 'grouptitle', 'usergroups', '')), 0, 'mselect');
showtagfooter('tbody');
showsetting('tasks_add_relatedtask', array('relatedtaskid', fetcharray('taskid', 'name', 'tasks', "available='2' ORDER BY displayorder, taskid DESC")), 0, 'select');
showsetting('tasks_add_maxnum', 'tasklimits', '', 'text');
if(in_array($script, $custom_scripts)) {
if(is_array($task_conditions)) {
foreach($task_conditions as $taskvar) {
if($taskvar['sort'] == 'apply' && $taskvar['name']) {
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['type'], '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
}
}
showtitle('tasks_add_conditions');
if($script == 'member') {
showsetting('tasks_add_limit_act', array('act', array(
array('buddy', lang('tasks_add_act_buddy'), array('timelimit' => 'none')),
array('favorite', lang('tasks_add_act_favorite'), array('timelimit' => 'none')),
array('magic', lang('tasks_add_act_magic'), array('timelimit' => ''))
)), 'buddy', 'mradio');
showsetting('tasks_add_limit_num', 'num', '', 'text');
showtagheader('tbody', 'timelimit');
showsetting('tasks_add_limit_time', 'time', '', 'text');
showtagfooter('tbody');
} elseif($script == 'post') {
showsetting('tasks_add_limit_act', array('act', array(
array('newthread', lang('tasks_add_act_newthread'), array('forumlimit' => '', 'speciallimit' => 'none')),
array('newreply', lang('tasks_add_act_newreply'), array('forumlimit' => 'none', 'speciallimit' => '')),
array('newpost', lang('tasks_add_act_newpost'), array('forumlimit' => '', 'speciallimit' => 'none'))
)), 'newpost', 'mradio');
require_once DISCUZ_ROOT.'./include/forum.func.php';
showtagheader('tbody', 'forumlimit', TRUE);
showsetting('tasks_add_limit_forumid', '', '', '<SELECT name="forumid"><option value="">'.lang('none').'</option>'.forumselect(FALSE, 0, 0, TRUE).'</select>');
showtagfooter('tbody');
showtagheader('tbody', 'speciallimit');
showsetting('tasks_add_limit_threadid', 'threadid', '', 'text');
showsetting('tasks_add_limit_authorid', 'author', '', 'text');
showtagfooter('tbody');
showsetting('tasks_add_limit_num', 'num', '', 'text');
showsetting('tasks_add_limit_time', 'time', '', 'text');
} elseif($script == 'mod') {
} elseif(in_array($script, $custom_scripts)) {
$haveconditions = FALSE;
if(is_array($task_conditions) && $task_conditions) {
foreach($task_conditions as $taskvar) {
if($taskvar['sort'] == 'complete' && $taskvar['name']) {
$haveconditions = TRUE;
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['type'], '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
}
if(!$haveconditions) {
showtablerow('', 'class="td27" colspan="2"', lang('nolimit'));
}
if(is_array($task_settings) && $task_settings) {
$havesettings = FALSE;
foreach($task_settings as $taskvar) {
if($taskvar['name']) {
if(!$havesettings) {
showtitle('tasks_add_settings');
$havesettings = TRUE;
}
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['type'], '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
}
}
showsubmit('addsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$applyperm = $grouplimit == 'special' && is_array($applyperm) ? implode("\t", $applyperm) : $grouplimit;
$starttime = dmktime($starttime);
$endtime = dmktime($endtime);
$prize = ${'prize_'.$reward};
$bonus = ${'bonus_'.$reward};
if(!$name || !$description) {
cpmsg('tasks_basic_invalid', '', 'error');
} elseif(($endtime && $endtime <= $timestamp) || ($starttime && $endtime && $endtime <= $starttime)) {
cpmsg('tasks_time_invalid', '', 'error');
} elseif($reward && (!$prize || ($reward == 'credit' && !$bonus))) {
cpmsg('tasks_reward_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}tasks (relatedtaskid, available, name, description, icon, tasklimits, applyperm, scriptname, starttime, endtime, period, reward, prize, bonus)
VALUES ('$relatedtaskid', '0', '$name', '$description', '$icon', '$tasklimits', '$applyperm', '$script', '$starttime', '$endtime', '$period', '$reward', '$prize', '$bonus')");
$taskid = $db->insert_id();
if(in_array($script, $sys_scripts)) {
if(!$threadid && $author) {
$authorid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$author'");
}
foreach(${$script.'vars'} as $item) {
if(in_array($item, array('num', 'time', 'threadid'))) {
$$item = intval($$item);
}
$db->query("INSERT INTO {$tablepre}taskvars (taskid, name, description, variable, value)
VALUES ('$taskid', '".lang('tasks_add_limit_'.$item)."', '".lang('tasks_add_limit_'.$item.'_comment')."', '$item', '".$$item."')");
}
} else {
if(is_array($task_conditions) && $task_conditions) {
foreach($task_conditions as $taskvars) {
if($taskvars['name']) {
$variable = is_array($taskvars['variable']) ? $taskvars['variable'][0] : $taskvars['variable'];
$db->query("INSERT INTO {$tablepre}taskvars (taskid, sort, name, description, variable, value, type, extra)
VALUES ('$taskid', '$taskvars[sort]', '$taskvars[name]', '$taskvars[description]', '{$variable}', '${$variable}', '$taskvars[type]', '$taskvars[extra]')");
}
}
}
if(is_array($task_settings) && $task_settings) {
foreach($task_settings as $taskvars) {
if($taskvars['name']) {
$db->query("INSERT INTO {$tablepre}taskvars (taskid, sort, name, description, variable, value, type, extra)
VALUES ('$taskid', 'setting', '$taskvars[name]', '$taskvars[description]', '$taskvars[variable]', '${$taskvars[variable]}', '$taskvars[type]', '$taskvars[extra]')");
}
}
}
}
cpmsg('tasks_succeed', "$BASESCRIPT?action=tasks", 'succeed');
}
} elseif($operation == 'edit' && $id) {
$task = $db->fetch_first("SELECT * FROM {$tablepre}tasks WHERE taskid='$id'");
include language('tasks');
@include DISCUZ_ROOT.'./include/tasks/'.$task['scriptname'].'.cfg.php';
$task_condition_variable = array();
if(is_array($task_conditions) && $task_conditions) {
foreach($task_conditions as $task_condition) {
if($task_condition['variable']) {
$task_condition_variable[$task_condition['variable'][0]] = $task_condition['variable'];
}
}
}
if(!submitcheck('editsubmit')) {
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
shownav('extended', 'nav_tasks');
showsubmenu('nav_tasks', array(
array('admin', 'tasks', 0),
array(array('menu' => 'add', 'submenu' => $submenus), '', 0),
array('nav_task_type', 'tasks&operation=type', 0)
));
showformheader('tasks&operation=edit&id='.$id);
showtableheader('tasks_edit_basic', 'fixpadding');
showsetting('tasks_add_name', 'name', $task['name'], 'text');
showsetting('tasks_add_desc', 'description', $task['description'], 'textarea');
showsetting('tasks_add_icon', 'icon', $task['icon'], 'text');
if($task['newbietask'] == '0') {
showsetting('tasks_add_starttime', 'starttime', $task['starttime'] ? gmdate('y-m-d', $task['starttime'] + $timeoffset * 3600) : '', 'calendar');
showsetting('tasks_add_endtime', 'endtime', $task['endtime'] ? gmdate('y-m-d', $task['endtime'] + $timeoffset * 3600) : '', 'calendar');
showsetting('tasks_add_period', 'period', $task['period'], 'text');
}
showsetting('tasks_add_reward', array('reward', array(
array('', lang('none'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')),
array('credit', lang('credits'), array('reward_credit' => '', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite'=> 'none', 'reward_group' => 'none')),
$magicstatus ? array('magic', lang('tasks_reward_magic'), array('reward_credit' => 'none', 'reward_magic' => '', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')) : '',
$medalstatus ? array('medal', lang('medals'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => '', 'reward_invite' => 'none', 'reward_group' => 'none')) : '',
$regstatus > 1 ? array('invite', lang('tasks_reward_invite'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => '', 'reward_group' => 'none')) : '',
array('group', lang('tasks_add_group'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => ''))
)), $task['reward'], 'mradio');
$extcreditarray = array(array(0, lang('select')));
foreach($extcredits as $creditid => $extcredit) {
$extcreditarray[] = array($creditid, $extcredit['title']);
}
showtagheader('tbody', 'reward_credit', $task['reward'] == 'credit');
showsetting('tasks_add_extcredit', array('prize_credit', $extcreditarray), $task['prize'], 'select');
showsetting('tasks_add_credits', 'bonus_credit', $task['bonus'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_magic', $task['reward'] == 'magic');
showsetting('tasks_add_magicname', array('prize_magic', fetcharray('magicid', 'name', 'magics', "available='1' ORDER BY displayorder")), $task['prize'], 'select');
showsetting('tasks_add_magicnum', 'bonus_magic', $task['bonus'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_medal', $task['reward'] == 'medal');
showsetting('tasks_add_medalname', array('prize_medal', fetcharray('medalid', 'name', 'medals', "available='1' ORDER BY displayorder")), $task['prize'], 'select');
showsetting('tasks_add_medalexp', 'bonus_medal', $task['bonus'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_invite', $task['reward'] == 'invite');
showsetting('tasks_add_invitenum', 'prize_invite', $task['prize'], 'text');
showsetting('tasks_add_inviteexp', 'bonus_invite', $task['bonus'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_group', $task['reward'] == 'group');
showsetting('tasks_add_group', array('prize_group', fetcharray('groupid', 'grouptitle', 'usergroups', "type='special' AND radminid='0'")), $task['prize'], 'select');
showsetting('tasks_add_groupexp', 'bonus_group', $task['bonus'], 'text');
showtagfooter('tbody');
showtitle('tasks_add_appyperm');
if($task['newbietask'] == '1') {
showsetting('tasks_newbie_task_item1', '', '', '');
} elseif($task['newbietask'] == '2') {
showsetting('tasks_newbie_task_item2', '', '', '');
} else {
if(!$task['applyperm']) {
$task['applyperm'] = 'all';
}
$task['grouplimit'] = in_array($task['applyperm'], array('all', 'member', 'admin')) ? $task['applyperm'] : 'special';
showsetting('tasks_add_groupperm', array('grouplimit', array(
array('all', lang('tasks_add_group_all'), array('specialgroup' => 'none')),
array('member', lang('tasks_add_group_member'), array('specialgroup' => 'none')),
array('admin', lang('tasks_add_group_admin'), array('specialgroup' => 'none')),
array('special', lang('tasks_add_group_special'), array('specialgroup' => ''))
)), $task['grouplimit'], 'mradio');
showtagheader('tbody', 'specialgroup', $task['grouplimit'] == 'special');
showsetting('tasks_add_usergroup', array('applyperm[]', fetcharray('groupid', 'grouptitle', 'usergroups', '')), explode("\t", $task['applyperm']), 'mselect');
showtagfooter('tbody');
showsetting('tasks_add_relatedtask', array('relatedtaskid', fetcharray('taskid', 'name', 'tasks', "available='2' AND taskid!='$task[taskid]'")), $task['relatedtaskid'], 'select');
showsetting('tasks_add_maxnum', 'tasklimits', $task['tasklimits'], 'text');
}
$taskvars = array();
$query = $db->query("SELECT * FROM {$tablepre}taskvars WHERE taskid='$id'");
while($taskvar = $db->fetch_array($query)) {
if($taskvar['sort'] == 'apply') {
$taskvars['apply'][] = $taskvar;
} elseif($taskvar['sort'] == 'complete') {
$taskvars['complete'][$taskvar['variable']] = $taskvar;
} elseif($taskvar['sort'] == 'setting' && $taskvar['name']) {
$taskvars['setting'][$taskvar['variable']] = $taskvar;
}
}
if($taskvars['apply']) {
foreach($taskvars['apply'] as $taskvar) {
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['type'], '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
showtitle('tasks_add_conditions');
if($task['scriptname'] == 'member') {
showsetting('tasks_add_limit_act', array('act', array(
array('buddy', lang('tasks_add_act_buddy'), array('timelimit' => 'none')),
array('favorite', lang('tasks_add_act_favorite'), array('timelimit' => 'none')),
array('magic', lang('tasks_add_act_magic'), array('timelimit' => ''))
)), $taskvars['complete']['act']['value'], 'mradio');
showsetting('tasks_add_limit_num', 'num', $taskvars['complete']['num']['value'], 'text');
showtagheader('tbody', 'timelimit', $taskvars['complete']['act']['value'] == 'magic');
showsetting('tasks_add_limit_time', 'time', $taskvars['complete']['time']['value'], 'text');
showtagfooter('tbody');
} elseif($task['scriptname'] == 'post') {
showsetting('tasks_add_limit_act', array('act', array(
array('newthread', lang('tasks_add_act_newthread'), array('forumlimit' => '', 'speciallimit' => 'none')),
array('newreply', lang('tasks_add_act_newreply'), array('forumlimit' => 'none', 'speciallimit' => '')),
array('newpost', lang('tasks_add_act_newpost'), array('forumlimit' => '', 'speciallimit' => 'none'))
)), $taskvars['complete']['act']['value'], 'mradio');
require_once DISCUZ_ROOT.'./include/forum.func.php';
showtagheader('tbody', 'forumlimit', $taskvars['complete']['act']['value'] != 'newreply');
showsetting('tasks_add_limit_forumid', '', '', '<SELECT name="forumid"><option value="">'.lang('nolimit').'</option>'.forumselect(FALSE, 0, $taskvars['complete']['forumid']['value']).'</select>');
showtagfooter('tbody');
showtagheader('tbody', 'speciallimit', $taskvars['complete']['act']['value'] == 'newreply');
showsetting('tasks_add_limit_threadid', 'threadid', $taskvars['complete']['threadid']['value'] ? $taskvars['complete']['threadid']['value'] : '', 'text');
$author = $taskvars['complete']['authorid']['value'] && ($author = $db->result_first("SELECT username FROM {$tablepre}members WHERE uid='{$taskvars[complete][authorid][value]}'")) ? $author : '';
showsetting('tasks_add_limit_authorid', 'author', $author, 'text');
showtagfooter('tbody');
showsetting('tasks_add_limit_num', 'num', $taskvars['complete']['num']['value'], 'text');
showsetting('tasks_add_limit_time', 'time', $taskvars['complete']['time']['value'], 'text');
} else {
if($taskvars['complete']) {
foreach($taskvars['complete'] as $taskvar) {
if($taskvar['variable']) {
if($taskvar['variable'] == 'forumid') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
showsetting($taskvar['name'], '', '', '<SELECT name="forumid"><option value="">'.lang('nolimit').'</option>'.forumselect(FALSE, 0, $taskvars['complete']['forumid']['value']).'</select>');
} elseif($taskvar['variable'] == 'authorid') {
$author = $taskvars['complete']['authorid']['value'] && ($author = $db->result_first("SELECT username FROM {$tablepre}members WHERE uid='{$taskvars[complete][authorid][value]}'")) ? $author : '';
showsetting($taskvar['name'], 'author', $author, 'text', '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], !empty($task_condition_variable[$taskvar['variable']]) ? $task_condition_variable[$taskvar['variable']] : $taskvar['variable'], $taskvar['value'], $taskvar['type'], '', 0, $taskvar['description']);
}
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
} else {
showtablerow('', 'class="td27" colspan="2"', lang('nolimit'));
}
if($taskvars['setting']) {
showtitle('tasks_add_settings');
foreach($taskvars['setting'] as $taskvar) {
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['type'], '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
}
showsubmit('editsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$applyperm = $grouplimit == 'special' && is_array($applyperm) ? implode("\t", $applyperm) : $grouplimit;
$starttime = dmktime($starttime);
$endtime = dmktime($endtime);
$prize = ${'prize_'.$reward};
$bonus = ${'bonus_'.$reward};
if(!$name || !$description) {
cpmsg('tasks_basic_invalid', '', 'error');
} elseif(($starttime != $task['starttime'] || $endtime != $task['endtime']) && (($endtime && $endtime <= $timestamp) || ($starttime && $endtime && $endtime <= $starttime))) {
cpmsg('tasks_time_invalid', '', 'error');
} elseif($reward && (!$prize || ($reward == 'credit' && !$bonus))) {
cpmsg('tasks_reward_invalid', '', 'error');
} elseif($task['newbietask'] == '1') {
switch(substr($task['scriptname'], 7)) {
case 'post_reply':
$checkid = 'tid';
$newbiesettingok = checksettings('tid', $threadid);
break;
case 'post_newthread':
$checkid = 'fid';
$newbiesettingok = checksettings('fid', $forumid);
break;
case 'sendpm':
case 'addbuddy':
$checkid = 'uid';
$newbiesettingok = checksettings('uid', $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$author'"));
break;
default:
$newbiesettingok = TRUE;
break;
}
if(!$newbiesettingok) {
cpmsg('tasks_newbie_setting_invalid_'.$checkid);
}
}
if($task['available'] == '2' && ($starttime > $timestamp || ($endtime && $endtime <= $timestamp))) {
$db->query("UPDATE {$tablepre}tasks SET available='1' WHERE taskid='$id'", 'UNBUFFERED');
}
if($task['available'] == '1' && (!$starttime || $starttime <= $timestamp) && (!$endtime || $endtime > $timestamp)) {
$db->query("UPDATE {$tablepre}tasks SET available='2' WHERE taskid='$id'", 'UNBUFFERED');
}
if(in_array($task['scriptname'], $sys_scripts)) {
if(!$threadid && $author) {
$authorid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$author'");
}
$itemarray = ${$task['scriptname'].'vars'};
} else {
if($author) {
$authorid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$author'");
}
$itemarray = array();
$query = $db->query("SELECT variable FROM {$tablepre}taskvars WHERE taskid='$id' AND variable IS NOT NULL");
while($taskvar = $db->fetch_array($query)) {
$itemarray[] = $taskvar['variable'];
}
}
$db->query("UPDATE {$tablepre}tasks SET relatedtaskid='$relatedtaskid', name='$name', description='$description', icon='$icon', tasklimits='$tasklimits', applyperm='$applyperm', starttime='$starttime', endtime='$endtime', period='$period', reward='$reward', prize='$prize', bonus='$bonus' WHERE taskid='$id'");
foreach($itemarray as $item) {
if(in_array($item, array('num', 'time', 'threadid'))) {
$$item = intval($$item);
}
if(isset($$item)) {
$db->query("UPDATE {$tablepre}taskvars SET value='".$$item."' WHERE taskid='$id' AND variable='$item'");
}
}
if($task['newbietask'] == '1') {
updatecache('settings');
}
cpmsg('tasks_succeed', "$BASESCRIPT?action=tasks", 'succeed');
}
} elseif($operation == 'delete' && $id) {
if(!$confirmed) {
cpmsg('tasks_del_confirm', "$BASESCRIPT?action=tasks&operation=delete&id=$id", 'form');
}
$task = $db->fetch_first("SELECT newbietask FROM {$tablepre}tasks WHERE taskid='$id'");
if(!$task || $task['newbietask'] == '1') {
cpmsg('undefined_action', '', 'error');
}
$db->query("DELETE FROM {$tablepre}tasks WHERE taskid='$id'");
$db->query("DELETE FROM {$tablepre}taskvars WHERE taskid='$id'");
$db->query("DELETE FROM {$tablepre}mytasks WHERE taskid='$id'");
cpmsg('tasks_del', $BASESCRIPT.'?action=tasks', 'succeed');
} elseif($operation == 'type') {
include language('tasks');
shownav('extended', 'nav_tasks');
showsubmenu('nav_tasks', array(
array('admin', 'tasks', 0),
array(array('menu' => 'add', 'submenu' => $submenus), '', 0),
array('nav_task_type', 'tasks&operation=type', 1)
));
showtips('tasks_tips_add_type');
$taskdir = DISCUZ_ROOT.'./include/tasks';
$tasksdir = dir($taskdir);
$scripts = array();
while($entry = $tasksdir->read()) {
$script = substr($entry, 0, -8);
if(!in_array($entry, array('.', '..')) && !in_array($script, $sys_scripts) && preg_match("/^[\w\.]+$/", $entry) && substr($entry, -8)== '.inc.php' && strlen($entry) < 30 && is_file($taskdir.'/'.$entry) && is_file($taskdir.'/'.$script.'.cfg.php')) {
$scripts[] = array('filename' => $script, 'filemtime' => @filemtime($taskdir.'/'.$entry));
}
}
uasort($scripts, 'filemtimesort');
showtableheader('', 'fixpadding');
showsubtitle(array('name', 'tasks_script', 'tasks_version', 'copyright', ''));
foreach($scripts as $script) {
require_once $taskdir.'/'.$script['filename'].'.cfg.php';
showtablerow('', array('id="custom_task_'.$script['filename'].'" onmouseover="showMenu({\'ctrlid\':this.id})"'), array(
$task_name.($script['filemtime'] > $timestamp - 86400 ? ' <font color="red">New!</font>' : '').'<div class="dropmenu1" id="custom_task_'.$script['filename'].'_menu" style="display: none; white-space: normal; width: 30%; padding: 10px;">'.$task_description.'</div>',
$script['filename'].'.inc.php',
$task_version,
$task_copyright,
in_array($script['filename'], $custom_scripts) ? "<a href=\"$BASESCRIPT?action=tasks&operation=upgrade&script=$script[filename]\" class=\"act\">$lang[tasks_upgrade]</a> <a href=\"$BASESCRIPT?action=tasks&operation=uninstall&script=$script[filename]\" class=\"act\">$lang[tasks_uninstall]</a><br />" : "<a href=\"$BASESCRIPT?action=tasks&operation=install&script=$script[filename]\" class=\"act\">$lang[tasks_install]</a>"
));
}
foreach($sys_types as $script => $task) {
showtablerow('', '', array(
$task['name'],
$script.'.inc.php',
$task['version'],
'<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>',
''
));
}
showtablefooter();
} elseif($operation == 'install' && $script) {
include language('tasks');
if((!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.cfg.php') || (!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.inc.php')) {
cpmsg('tasks_noscript_or_nocfg', '', 'error');
} elseif(!(function_exists('task_install') && function_exists('task_uninstall') && function_exists('task_upgrade') && function_exists('task_condition') && function_exists('task_preprocess') && function_exists('task_csc') && function_exists('task_sufprocess'))) {
cpmsg('tasks_code_invalid', '', 'error');
} elseif($db->result_first("SELECT COUNT(*) FROM {$tablepre}tasks WHERE scriptname='$script'")) {
cpmsg('tasks_install_duplicate', '', 'error');
}
task_install();
$custom_types[$script] = array('name' => $task_name, 'version' => $task_version);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('tasktypes', '".addslashes(serialize($custom_types))."')");
cpmsg('tasks_installed', $BASESCRIPT.'?action=tasks', 'succeed');
} elseif($operation == 'uninstall' && $script) {
if(!$confirmed) {
cpmsg('tasks_uninstall_confirm', "$BASESCRIPT?action=tasks&operation=uninstall&script=$script", 'form');
}
if(in_array($script, $sys_scripts)) {
cpmsg('undefined_action', '', 'error');
} elseif(!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.inc.php') {
cpmsg('tasks_noscript', '', 'error');
}
$ids = $comma = '';
$query = $db->query("SELECT taskid FROM {$tablepre}tasks WHERE scriptname='$script'");
while($task = $db->fetch_array($query)) {
$ids = $comma.$task['taskid'];
$comma = ',';
}
if($ids) {
$db->query("DELETE FROM {$tablepre}tasks WHERE taskid IN ($ids)");
$db->query("DELETE FROM {$tablepre}taskvars WHERE taskid IN ($ids)");
$db->query("DELETE FROM {$tablepre}mytasks WHERE taskid IN ($ids)");
}
task_uninstall();
unset($custom_types[$script]);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('tasktypes', '".addslashes(serialize($custom_types))."')");
cpmsg('tasks_uninstalled', $BASESCRIPT.'?action=tasks', 'succeed');
} elseif($operation == 'upgrade' && $script) {
include language('tasks');
if(in_array($script, $sys_scripts)) {
cpmsg('undefined_action', '', 'error');
} elseif((!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.cfg.php') || (!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.inc.php')) {
cpmsg('tasks_noscript_or_nocfg', '', 'error');
} elseif($custom_types[$script]['version'] >= $task_version) {
cpmsg('tasks_newest', '', 'error');
}
task_upgrade();
$db->query("UPDATE {$tablepre}tasks SET name='$task_name', description='$task_description', icon='$task_icon', tasklimits='$task_tasklimits', starttime='$task_starttime', endtime='$task_endtime', period='$task_period', reward='$task_reward', prize='$task_prize', bonus='$task_bonus', version='$task_version' WHERE scriptname='$script'");
$custom_types[$script] = array('name' => $task_name, 'version' => $task_version);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('tasktypes', '".addslashes(serialize($custom_types))."')");
cpmsg('tasks_updated', $BASESCRIPT.'?action=tasks', 'succeed');
}
function fetcharray($id, $name, $table, $conditions = '1') {
global $db, $tablepre;
$array = array(array(0, lang('nolimit')));
$query = $db->query("SELECT $id, $name FROM $tablepre$table".($conditions ? " WHERE $conditions" : ''));
while($result = $db->fetch_array($query)) {
$array[] = array($result[$id], $result[$name]);
}
return $array;
}
function runquery($sql) {
global $dbcharset, $tablepre, $db;
$sql = str_replace("\r", "\n", str_replace(' cdb_', ' '.$tablepre, $sql));
$ret = array();
$num = 0;
foreach(explode(";\n", trim($sql)) as $query) {
$queries = explode("\n", trim($query));
foreach($queries as $query) {
$ret[$num] .= $query[0] == '#' || $query[0].$query[1] == '--' ? '' : $query;
}
$num++;
}
unset($sql);
foreach($ret as $query) {
$query = trim($query);
if($query) {
if(substr($query, 0, 12) == 'CREATE TABLE') {
$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
$db->query(createtable($query, $dbcharset));
} else {
$db->query($query);
}
}
}
}
function createtable($sql, $dbcharset) {
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
(mysql_get_server_info() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
}
function dmktime($date) {
if(strpos($date, '-')) {
$time = explode('-', $date);
return mktime(0, 0, 0, $time[1], $time[2], $time[0]);
}
return 0;
}
function checksettings($id, $v) {
global $db, $tablepre;
$v = intval($v);
if(!$v) {
return FALSE;
}
switch($id) {
case 'tid':
$result = $db->query("SELECT COUNT(*) FROM {$tablepre}threads WHERE tid='$v' AND displayorder>='0'");
break;
case 'fid':
$result = $db->query("SELECT COUNT(*) FROM {$tablepre}forums WHERE fid='$v'");
break;
case 'uid':
$result = $db->query("SELECT COUNT(*) FROM {$tablepre}members WHERE uid='$v'");
break;
default:
$result = 0;
break;
}
return $result ? TRUE : FALSE;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/tasks.inc.php | PHP | asf20 | 41,188 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forums.inc.php 21337 2010-01-06 08:09:58Z tiger $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = empty($operation) ? 'admin' : $operation;
if($operation == 'admin') {
if(!submitcheck('editsubmit')) {
shownav('forum', 'forums_admin');
showsubmenu('forums_admin');
showtips('forums_admin_tips');
$projectselect = '<option value="0" selected="selected">'.$lang['none'].'</option>';
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='forum'");
while($project = $db->fetch_array($query)) {
$projectselect .= '<option value="'.$project['id'].'">'.$project['name'].'</option>';
}
?>
<script type="text/JavaScript">
var rowtypedata = [
[[1,'<input type="text" class="txt" name="newcatorder[]" value="0" />', 'td25'], [3, '<input name="newcat[]" value="<?=$lang['forums_admin_add_category_name']?>" size="20" type="text" class="txt" />']],
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="board"><input name="newforum[{1}][]" value="<?=$lang['forums_admin_add_forum_name']?>" size="20" type="text" class="txt" /><select name="projectid[{1}][]"><?=$projectselect?></select></div>']],
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="childboard"><input name="newforum[{1}][]" value="<?=$lang['forums_admin_add_forum_name']?>" size="20" type="text" class="txt" /><select name="projectid[{1}][]" id="projectid[{1}]"><?=$projectselect?></select> <input name="inherited[{1}][]" type="checkbox" class="checkbox" value="1" onclick="if($(\'projectid[{1}]\').disabled) {$(\'projectid[{1}]\').disabled = false;} else {$(\'projectid[{1}]\').disabled = true;}"> <?=$lang['forums_edit_inherited']?></div>']],
];
</script>
<?
showformheader('forums');
showtableheader('');
showsubtitle(array('display_order', 'forums_admin_name', 'forums_moderators', ''));
$forums = $showedforums = array();
$query = $db->query("SELECT f.fid, f.type, f.status, f.name, f.fup, f.displayorder, f.inheritedmod, ff.moderators, ff.password, ff.redirect
FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING(fid)
ORDER BY f.type<>'group', f.displayorder");
while($forum = $db->fetch_array($query)) {
$forums[] = $forum;
}
for($i = 0; $i < count($forums); $i++) {
if($forums[$i]['type'] == 'group') {
echo showforum($i, 'group');
for($j = 0; $j < count($forums); $j++) {
if($forums[$j]['fup'] == $forums[$i]['fid'] && $forums[$j]['type'] == 'forum') {
echo showforum($j);
$lastfid = 0;
for($k = 0; $k < count($forums); $k++) {
if($forums[$k]['fup'] == $forums[$j]['fid'] && $forums[$k]['type'] == 'sub') {
echo showforum($k, 'sub');
$lastfid = $forums[$k]['fid'];
}
}
echo showforum($j, $lastfid, 'lastchildboard');
}
}
echo showforum($i, '', 'lastboard');
} elseif(!$forums[$i]['fup'] && $forums[$i]['type'] == 'forum') {
echo showforum($i);
for($j = 0; $j < count($forums); $j++) {
if($forums[$j]['fup'] == $forums[$i]['fid'] && $forums[$j]['type'] == 'sub') {
echo showforum($j, 'sub');
}
}
echo showforum($i, '', 'lastchildboard');
}
}
foreach($forums as $key => $forum) {
if(!in_array($key, $showedforums)) {
$db->query("UPDATE {$tablepre}forums SET fup='0', type='forum' WHERE fid='$forum[fid]'");
echo showforum($key);
}
}
echo showforum($i, '', 'last');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
// read from groups
$usergroups = array();
$query = $db->query("SELECT groupid, type, creditshigher, creditslower FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$usergroups[$group['groupid']] = $group;
}
if(is_array($order)) {
foreach($order as $fid => $value) {
$db->query("UPDATE {$tablepre}forums SET name='$name[$fid]', displayorder='$order[$fid]' WHERE fid='$fid'");
}
}
if(is_array($newcat)) {
foreach($newcat as $key => $forumname) {
if(empty($forumname)) {
continue;
}
$db->query("INSERT INTO {$tablepre}forums (type, name, status, displayorder)
VALUES ('group', '$forumname', '1', '$newcatorder[$key]')");
$fid = $db->insert_id();
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
}
}
$table_forum_columns = array('fup', 'type', 'name', 'status', 'displayorder', 'styleid', 'allowsmilies', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowmediacodenew', 'allowanonymous', 'allowshare', 'allowpostspecial', 'alloweditrules', 'alloweditpost', 'modnewposts', 'recyclebin', 'jammer', 'forumcolumns', 'threadcaches', 'disablewatermark', 'autoclose', 'simple');
$table_forumfield_columns = array('fid', 'attachextensions', 'threadtypes', 'postcredits', 'replycredits', 'digestcredits', 'postattachcredits', 'getattachcredits', 'viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm');
$projectdata = array();
if(is_array($newforum)) {
foreach($newforum as $fup => $forums) {
$forum = $db->fetch_first("SELECT * FROM {$tablepre}forums WHERE fid='$fup'");
foreach($forums as $key => $forumname) {
if(empty($forumname)) {
continue;
}
$forumfields = array();
$id = $projectid[$fup][$key];
$inheritedid = $inherited[$fup] ? $fup : '';
if(!empty($id)) {
$projectdata[$id] = empty($projectdata[$id]) ? unserialize($db->result_first("SELECT value FROM {$tablepre}projects WHERE id='$id'")) : $projectdata[$id];
foreach($table_forum_columns as $field) {
$forumfields[$field] = $projectdata[$id][$field];
}
foreach($table_forumfield_columns as $field) {
$forumfields[$field] = $projectdata[$id][$field];
}
} elseif(!empty($inheritedid)) {
$query = $db->query("SELECT * FROM {$tablepre}forums WHERE fid='$inheritedid'");
$forum = $db->fetch_array($query);
$query = $db->query("SELECT * FROM {$tablepre}forumfields WHERE fid='$inheritedid'");
$forumfield = $db->fetch_array($query);
foreach($table_forum_columns as $field) {
$forumfields[$field] = $forum[$field];
}
foreach($table_forumfield_columns as $field) {
$forumfields[$field] = $forumfield[$field];
}
} else {
$forumfields['allowsmilies'] = $forumfields['allowbbcode'] = $forumfields['allowimgcode'] = $forumfields['allowshare'] = 1;
$forumfields['allowpostspecial'] = 127;
}
$forumfields['fup'] = $forum ? $fup : 0;
$forumfields['type'] = $forum['type'] == 'forum' ? 'sub' : 'forum';
$forumfields['name'] = $forumname;
$forumfields['status'] = 1;
$forumfields['displayorder'] = $neworder[$fup][$key];
$sql1 = $sql2 = $comma = '';
foreach($table_forum_columns as $field) {
if(isset($forumfields[$field])) {
$sql1 .= "$comma$field";
$sql2 .= "$comma'{$forumfields[$field]}'";
$comma = ', ';
}
}
$db->query("INSERT INTO {$tablepre}forums ($sql1) VALUES ($sql2)");
$forumfields['fid'] = $fid = $db->insert_id();
$sql1 = $sql2 = $comma = '';
foreach($table_forumfield_columns as $field) {
if(isset($forumfields[$field])) {
$sql1 .= "$comma$field";
$sql2 .= "$comma'{$forumfields[$field]}'";
$comma = ', ';
}
}
$db->query("INSERT INTO {$tablepre}forumfields ($sql1) VALUES ($sql2)");
$query = $db->query("SELECT uid, inherited FROM {$tablepre}moderators WHERE fid='$fup'");
while($mod = $db->fetch_array($query)) {
if($mod['inherited'] || $forum['inheritedmod']) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, inherited)
VALUES ('$mod[uid]', '$fid', '1')");
}
}
}
}
}
updatecache('forums');
cpmsg('forums_update_succeed', $BASESCRIPT.'?action=forums', 'succeed');
}
} elseif($operation == 'moderators' && $fid) {
if(!submitcheck('modsubmit')) {
shownav('forum', 'forums_moderators_edit');
showsubmenu(lang('forums_moderators_edit').' - '.$forum['name']);
showtips('forums_moderators_tips');
showformheader("forums&operation=moderators&fid=$fid&");
showtableheader('', 'fixpadding');
showsubtitle(array('', 'display_order', 'username', 'usergroups', 'forums_moderators_inherited'));
$query = $db->query("SELECT a.admingid, u.radminid, u.grouptitle FROM {$tablepre}admingroups a
INNER JOIN {$tablepre}usergroups u ON u.groupid=a.admingid
WHERE u.radminid>'0'
ORDER BY u.type, a.admingid");
$modgroups = array();
$groupselect = '<select name="newgroup">';
while($modgroup = $db->fetch_array($query)) {
if($modgroup['radminid'] == 3) {
$groupselect .= '<option value="'.$modgroup['admingid'].'">'.$modgroup['grouptitle'].'</option>';
}
$modgroups[$modgroup['admingid']] = $modgroup['grouptitle'];
}
$groupselect .= '</select>';
$query = $db->query("SELECT m.username, m.groupid, mo.* FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND m.uid=mo.uid ORDER BY mo.inherited, mo.displayorder");
while($mod = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td28"'), array(
'<input type="checkbox" class="checkbox" name="delete[]" value="'.$mod[uid].'"'.($mod['inherited'] ? ' disabled' : '').' />',
'<input type="text" class="txt" name="displayordernew['.$mod[uid].']" value="'.$mod[displayorder].'" size="2" />',
"<a href=\"$BASESCRIPT?action=members&operation=group&uid=$mod[uid]\" target=\"_blank\">$mod[username]</a>",
$modgroups[$mod['groupid']],
lang($mod['inherited'] ? 'yes' : 'no'),
));
}
if($forum['type'] == 'group' || $forum['type'] == 'sub') {
$checked = $forum['type'] == 'group' ? 'checked' : '';
$disabled = 'disabled';
} else {
$checked = $forum['inheritedmod'] ? 'checked' : '';
$disabled = '';
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
lang('add_new'),
'<input type="text" class="txt" name="newdisplayorder" value="0" size="2" />',
'<input type="text" class="txt" name="newmoderator" value="" size="20" />',
$groupselect,
''
));
showsubmit('modsubmit', 'submit', 'del', '<input class="checkbox" type="checkbox" name="inheritedmodnew" value="1" '.$checked.' '.$disabled.' id="inheritedmodnew" /><label for="inheritedmodnew">'.lang('forums_moderators_inherit').'</label>');
showtablefooter();
showformfooter();
} else {
if($forum['type'] == 'group') {
$inheritedmodnew = 1;
} elseif($forum['type'] == 'sub') {
$inheritedmodnew = 0;
}
if(!empty($delete) || $newmoderator || (bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) {
$fidarray = $newmodarray = $origmodarray = array();
if($forum['type'] == 'group') {
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='forum' AND fup='$fid'");
while($sub = $db->fetch_array($query)) {
$fidarray[] = $sub['fid'];
}
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='sub' AND fup IN ('".implode('\',\'', $fidarray)."')");
while($sub = $db->fetch_array($query)) {
$fidarray[] = $sub['fid'];
}
} elseif($forum['type'] == 'forum') {
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='sub' AND fup='$fid'");
while($sub = $db->fetch_array($query)) {
$fidarray[] = $sub['fid'];
}
}
if(is_array($delete)) {
foreach($delete as $uid) {
$db->query("DELETE FROM {$tablepre}moderators WHERE uid='$uid' AND ((fid='$fid' AND inherited='0') OR (fid IN ('".implode('\',\'', $fidarray)."') AND inherited='1'))");
}
$excludeuids = 0;
$deleteuids = '\''.implode('\',\'', $delete).'\'';
$query = $db->query("SELECT uid FROM {$tablepre}moderators WHERE uid IN ($deleteuids)");
while($mod = $db->fetch_array($query)) {
$excludeuids .= ','.$mod['uid'];
}
$usergroups = array();
$query = $db->query("SELECT groupid, type, radminid, creditshigher, creditslower FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$usergroups[$group['groupid']] = $group;
}
$query = $db->query("SELECT uid, groupid, credits FROM {$tablepre}members WHERE uid IN ($deleteuids) AND uid NOT IN ($excludeuids) AND adminid NOT IN (1,2)");
while($member = $db->fetch_array($query)) {
if($usergroups[$member['groupid']]['type'] == 'special' && $usergroups[$member['groupid']]['radminid'] != 3) {
$adminidnew = -1;
$groupidnew = $member['groupid'];
} else {
$adminidnew = 0;
foreach($usergroups as $group) {
if($group['type'] == 'member' && $member['credits'] >= $group['creditshigher'] && $member['credits'] < $group['creditslower']) {
$groupidnew = $group['groupid'];
break;
}
}
}
$db->query("UPDATE {$tablepre}members SET adminid='$adminidnew', groupid='$groupidnew' WHERE uid='$member[uid]'");
}
}
if((bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) {
$query = $db->query("SELECT uid FROM {$tablepre}moderators WHERE fid='$fid' AND inherited='0'");
while($mod = $db->fetch_array($query)) {
$origmodarray[] = $mod['uid'];
if(!$forum['inheritedmod'] && $inheritedmodnew) {
$newmodarray[] = $mod['uid'];
}
}
if($forum['inheritedmod'] && !$inheritedmodnew) {
$db->query("DELETE FROM {$tablepre}moderators WHERE uid IN ('".implode('\',\'', $origmodarray)."') AND fid IN ('".implode('\',\'', $fidarray)."') AND inherited='1'");
}
}
if($newmoderator) {
$member = $db->fetch_first("SELECT uid FROM {$tablepre}members WHERE username='$newmoderator'");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} else {
$newmodarray[] = $member['uid'];
$db->query("UPDATE {$tablepre}members SET groupid='$newgroup' WHERE uid='$member[uid]' AND adminid NOT IN (1,2,3,4,5,6,7,8,-1)");
$db->query("UPDATE {$tablepre}members SET adminid='3' WHERE uid='$member[uid]' AND adminid NOT IN (1,2)");
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited)
VALUES ('$member[uid]', '$fid', '$newdisplayorder', '0')");
}
}
foreach($newmodarray as $uid) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited)
VALUES ('$uid', '$fid', '$newdisplayorder', '0')");
if($inheritedmodnew) {
foreach($fidarray as $ifid) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, inherited)
VALUES ('$uid', '$ifid', '1')");
}
}
}
if($forum['type'] == 'group') {
$inheritedmodnew = 1;
} elseif($forum['type'] == 'sub') {
$inheritedmodnew = 0;
}
$db->query("UPDATE {$tablepre}forums SET inheritedmod='$inheritedmodnew' WHERE fid='$fid'");
}
if(is_array($displayordernew)) {
foreach($displayordernew as $uid => $order) {
$db->query("UPDATE {$tablepre}moderators SET displayorder='$order' WHERE fid='$fid' AND uid='$uid'");
}
}
$moderators = $tab = '';
$query = $db->query("SELECT m.username FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND mo.inherited='0' AND m.uid=mo.uid ORDER BY mo.displayorder");
while($mod = $db->fetch_array($query)) {
$moderators .= $tab.addslashes($mod['username']);
$tab = "\t";
}
$db->query("UPDATE {$tablepre}forumfields SET moderators='$moderators' WHERE fid='$fid'");
cpmsg('forums_moderators_update_succeed', "$BASESCRIPT?action=forums&operation=moderators&fid=$fid", 'succeed');
}
} elseif($operation == 'merge') {
if(!submitcheck('mergesubmit') || $source == $target) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$forumselect = "<select name=\"%s\">\n<option value=\"\"> > $lang[select]</option><option value=\"\"> </option>".str_replace('%', '%%', forumselect(FALSE, 0, 0, TRUE)).'</select>';
shownav('forum', 'forums_merge');
showsubmenu('forums_merge');
showformheader('forums&operation=merge');
showtableheader();
showsetting('forums_merge_source', '', '', sprintf($forumselect, 'source'));
showsetting('forums_merge_target', '', '', sprintf($forumselect, 'target'));
showsubmit('mergesubmit');
showtablefooter();
showformfooter();
} else {
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}forums WHERE fid IN ('$source', '$target') AND type<>'group'") != 2) {
cpmsg('forums_nonexistence', '', 'error');
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}forums WHERE fup='$source'")) {
cpmsg('forums_merge_source_sub_notnull', '', 'error');
}
$db->query("UPDATE {$tablepre}threads SET fid='$target' WHERE fid='$source'");
$db->query("UPDATE {$tablepre}posts SET fid='$target' WHERE fid='$source'");
$sourceforum = $db->fetch_first("SELECT threads, posts FROM {$tablepre}forums WHERE fid='$source'");
$db->query("UPDATE {$tablepre}forums SET threads=threads+$sourceforum[threads], posts=posts+$sourceforum[posts] WHERE fid='$target'");
$db->query("DELETE FROM {$tablepre}forums WHERE fid='$source'");
$db->query("DELETE FROM {$tablepre}forumfields WHERE fid='$source'");
$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$source'");
$query = $db->query("SELECT * FROM {$tablepre}access WHERE fid='$source'");
while($access = $db->fetch_array($query)) {
$db->query("INSERT INTO {$tablepre}access (uid, fid, allowview, allowpost, allowreply, allowgetattach)
VALUES ('$access[uid]', '$target', '$access[allowview]', '$access[allowpost]', '$access[allowreply]', '$access[allowgetattach]')", 'SILENT');
}
$db->query("DELETE FROM {$tablepre}access WHERE fid='$source'");
updatecache('forums');
cpmsg('forums_merge_succeed', $BASESCRIPT.'?action=forums', 'succeed');
}
} elseif($operation == 'edit') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
if(empty($fid)) {
cpmsg('forums_edit_nonexistence', $BASESCRIPT.'?action=forums&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : '').(!empty($anchor) ? "&anchor=$anchor" : ''), 'form', '<select name="fid">'.forumselect(FALSE, 0, 0, TRUE).'</select>');
}
$perms = array('viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm');
$forum = $db->fetch_first("SELECT *, f.fid AS fid FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING (fid)
WHERE f.fid='$fid'");
if(!$forum) {
cpmsg('forums_nonexistence', '', 'error');
}
$query = $db->query("SELECT disabledactions FROM {$tablepre}adminactions WHERE admingid='$groupid'");
$dactionarray = ($dactionarray = unserialize($db->result($query, 0))) ? $dactionarray : array();
$allowthreadtypes = !in_array('threadtypes', $dactionarray);
if(!empty($projectid)) {
$query = $db->query("SELECT value FROM {$tablepre}projects WHERE id='$projectid'");
$forum = @array_merge($forum, unserialize($db->result($query, 0)));
}
$forumdomains = array();
$query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='forumdomains'");
$forumdomains = @unserialize($db->result($query, 0));
if(!submitcheck('detailsubmit') && !submitcheck('saveconfigsubmit')) {
$anchor = in_array($anchor, array('basic', 'extend', 'posts', 'credits', 'threadtypes', 'threadsorts', 'perm')) ? $anchor : 'basic';
shownav('forum', 'forums_edit');
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$forumselect = '';
foreach($_DCACHE['forums'] as $forums) {
if($forums['type'] == 'group') {
$forumselect .= '<em class="hover" onclick="location.href=\''.$BASESCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].'\'">'.$forums['name'].'</em>';
} elseif($forums['type'] == 'forum') {
$forumselect .= '<a class="f'.($fid == $forums['fid'] ? ' current"' : '').'" href="###" onclick="location.href=\''.$BASESCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].($forum['type'] != 'group' ? '&anchor=\'+currentAnchor' : '\'').'+\'&scrolltop=\'+document.documentElement.scrollTop">'.$forums['name'].'</a>';
} elseif($forums['type'] == 'sub') {
$forumselect .= '<a class="s'.($fid == $forums['fid'] ? ' current"' : '').'" href="###" onclick="location.href=\''.$BASESCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].($forum['type'] != 'group' ? '&anchor=\'+currentAnchor' : '\'').'+\'&scrolltop=\'+document.documentElement.scrollTop">'.$forums['name'].'</a>';
}
}
$forumselect = '<span id="fselect" class="right popupmenu_dropmenu" onmouseover="showMenu({\'ctrlid\':this.id,\'pos\':\'34\'});$(\'fselect_menu\').style.top=(parseInt($(\'fselect_menu\').style.top)-document.documentElement.scrollTop)+\'px\'">'.$lang['forums_edit_switch'].'<em> </em></span>'.
'<div id="fselect_menu" class="popupmenu_popup" style="width:200px;display:none">'.$forumselect.'</div>';
if($forum['type'] == 'group') {
showsubmenu("$lang[forums_cat_detail] - $forum[name]", array(), $forumselect);
if(!empty($switch)) {
echo '<script type="text/javascript">showMenu({\'ctrlid\':\'fselect\',\'pos\':\'34\'});</script>';
}
} else {
showsubmenuanchors(lang('forums_edit').' - '.$forum['name'], array(
array('forums_edit_basic', 'basic', $anchor == 'basic'),
array('forums_edit_extend', 'extend', $anchor == 'extend'),
array('forums_edit_posts', 'posts', $anchor == 'posts'),
array('forums_edit_credits', 'credits', $anchor == 'credits'),
array('forums_edit_threadtypes', 'threadtypes', $anchor == 'threadtypes'),
array('forums_edit_threadsorts', 'threadsorts', $anchor == 'threadsorts'),
array('forums_edit_perm', 'perm', $anchor == 'perm')
), $forumselect);
if(!empty($switch)) {
echo '<script type="text/javascript">showMenu({\'ctrlid\':\'fselect\',\'pos\':\'34\'});</script>';
}
}
showtips('forums_edit_tips');
showformheader("forums&operation=edit&fid=$fid&");
showhiddenfields(array('type' => $forum['type']));
$sideselect = array();
$infosidestatus[0] && $sideselect[0] = '<select name="foruminfosidestatus[0]">
<option value="">'.$lang['forums_edit_extend_sideselect_global'].'</option>
<option value="-1"'.($infosidestatus['f'.$fid][0] == -1 ? ' selected="selected"' : '').'>'.$lang['forums_edit_extend_sideselect_off'].'</option>';
if($sideselect) {
$query = $db->query("SELECT variable FROM {$tablepre}request WHERE type=-2");
while($side = $db->fetch_array($query)) {
$infosidestatus[0] && $sideselect[0] .= "<option value=\"$side[variable]\" ".($infosidestatus['f'.$fid][0] == $side['variable'] ? 'selected="selected"' : NULL).">$side[variable]</option>\n";
}
$infosidestatus[0] && $sideselect[0] .= '</select>';
}
if($forum['type'] == 'group') {
$forum['extra'] = unserialize($forum['extra']);
showtableheader();
showsetting('forums_edit_basic_cat_name', 'namenew', $forum['name'], 'text');
showsetting('forums_edit_basic_cat_name_color', 'extra[namecolor]', $forum['extra']['namecolor'], 'color');
showsetting('forums_edit_extend_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text');
showsetting('forums_cat_display', 'statusnew', $forum['status'], 'radio');
if($sideselect) {
showsetting('forums_cat_extend_sideselect', '', '', $sideselect[0]);
}
showsubmit('detailsubmit');
showtablefooter();
} else {
require_once DISCUZ_ROOT.'./include/editor.func.php';
$projectselect = "<select name=\"projectid\" onchange=\"window.location='$BASESCRIPT?action=forums&operation=edit&fid=$fid&projectid='+this.options[this.options.selectedIndex].value\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='forum'");
while($project = $db->fetch_array($query)) {
$projectselect .= "<option value=\"$project[id]\" ".($project['id'] == $projectid ? 'selected="selected"' : NULL).">$project[name]</option>\n";
}
$projectselect .= '</select>';
$fupselect = "<select name=\"fupnew\">\n";
$query = $db->query("SELECT fid, type, name, fup FROM {$tablepre}forums WHERE fid<>'$fid' AND type<>'sub' ORDER BY displayorder");
while($fup = $db->fetch_array($query)) {
$fups[] = $fup;
}
if(is_array($fups)) {
foreach($fups as $forum1) {
if($forum1['type'] == 'group') {
$selected = $forum1['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
$fupselect .= "<option value=\"$forum1[fid]\" $selected>$forum1[name]</option>\n";
foreach($fups as $forum2) {
if($forum2['type'] == 'forum' && $forum2['fup'] == $forum1['fid']) {
$selected = $forum2['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
$fupselect .= "<option value=\"$forum2[fid]\" $selected> > $forum2[name]</option>\n";
}
}
}
}
foreach($fups as $forum0) {
if($forum0['type'] == 'forum' && $forum0['fup'] == 0) {
$selected = $forum0['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
$fupselect .= "<option value=\"$forum0[fid]\" $selected>$forum0[name]</option>\n";
}
}
}
$fupselect .= '</select>';
$groups = array();
$query = $db->query("SELECT type, groupid, grouptitle, radminid FROM {$tablepre}usergroups ORDER BY (creditshigher<>'0' || creditslower<>'0'), creditslower, groupid");
while($group = $db->fetch_array($query)) {
$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
$groups[$group['type']][] = $group;
}
$styleselect = "<select name=\"styleidnew\"><option value=\"0\">$lang[use_default]</option>";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$styleselect .= "<option value=\"$style[styleid]\" ".
($style['styleid'] == $forum['styleid'] ? 'selected="selected"' : NULL).
">$style[name]</option>\n";
}
$styleselect .= '</select>';
if($forum['autoclose']) {
$forum['autoclosetime'] = abs($forum['autoclose']);
$forum['autoclose'] = $forum['autoclose'] / abs($forum['autoclose']);
}
$viewaccess = $postaccess = $replyaccess = $getattachaccess = $postattachaccess = '';
$query = $db->query("SELECT m.username, a.* FROM {$tablepre}access a LEFT JOIN {$tablepre}members m USING (uid) WHERE a.fid='$fid'");
while($access = $db->fetch_array($query)) {
$member = ", <a href=\"$BASESCRIPT?action=members&operation=access&uid=$access[uid]\" target=\"_blank\">$access[username]</a>";
$viewaccess .= $access['allowview'] > 0 ? $member : NULL;
$postaccess .= $access['allowpost'] > 0 ? $member : NULL;
$replyaccess .= $access['allowreply'] > 0 ? $member : NULL;
$getattachaccess .= $access['allowgetattach'] > 0 ? $member : NULL;
$postattachaccess .= $access['allowpostattach'] > 0 ? $member : NULL;
}
unset($member);
$forum['typemodels'] = unserialize($forum['typemodels']);
if($forum['threadtypes']) {
$forum['threadtypes'] = unserialize($forum['threadtypes']);
$forum['threadtypes']['status'] = 1;
} else {
$forum['threadtypes'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array());
}
if($forum['threadsorts']) {
$forum['threadsorts'] = unserialize($forum['threadsorts']);
$forum['threadsorts']['status'] = 1;
} else {
$forum['threadsorts'] = array('status' => 0, 'required' => 0, 'prefix' => 0, 'options' => array());
}
if($forum['threadplugin']) {
$forum['threadplugin'] = unserialize($forum['threadplugin']);
}
$typeselect = $sortselect = '';
$typemodelid = array();
$query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
$typemodelid[] = $type['modelid'];
$typeselected = array();
$enablechecked = '';
$keysort = $type['special'] ? 'threadsorts' : 'threadtypes';
if(isset($forum[$keysort]['flat'][$type['typeid']])) {
$enablechecked = ' checked="checked"';
$typeselected[1] = ' selected="selected"';
} elseif(isset($forum[$keysort]['selectbox'][$type['typeid']])) {
$enablechecked = ' checked="checked"';
$typeselected[2] = ' selected="selected"';
} else {
$typeselected[1] = ' selected="selected"';
}
$showtype = TRUE;
if($type['special'] && !@include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$type['typeid'].'.php') {
$showtype = FALSE;
}
if(!$type['special']) {
$typeselect .= showtablerow('', array('class="td25"'), array(
'<input type="checkbox" name="threadtypesnew[options][enable]['.$type['typeid'].']" value="1" class="checkbox"'.$enablechecked.' />',
$type['name'],
$type['description'],
"<select name=\"threadtypesnew[options][{$type[typeid]}]\"><option value=\"1\" $typeselected[1]>$lang[forums_edit_threadtypes_use_cols]</option><option value=\"2\" $typeselected[2]>$lang[forums_edit_threadtypes_use_choice]</option></select>",
), TRUE);
} else {
$typeselected[3] = $forum['threadsorts']['show'][$type['typeid']] ? ' checked="checked"' : '';
$sortselect .= $showtype ? showtablerow('', array('class="td25"'), array(
'<input type="checkbox" name="threadsortsnew[options][enable]['.$type['typeid'].']" value="1" class="checkbox"'.$enablechecked.' />',
$type['name'],
$type['description'],
"<select name=\"threadsortsnew[options][{$type[typeid]}]\"><option value=\"1\" $typeselected[1]>$lang[forums_edit_threadtypes_use_cols]</option><option value=\"2\" $typeselected[2]>$lang[forums_edit_threadtypes_use_choice]</option></select>",
"<input class=\"checkbox\" type=\"checkbox\" name=\"threadsortsnew[options][show][{$type[typeid]}]\" value=\"3\" $typeselected[3] />",
"<input class=\"radio\" type=\"radio\" name=\"threadsortsnew[defaultshow]\" value=\"$type[typeid]\" ".($forum['threadsorts']['defaultshow'] == $type['typeid'] ? 'checked' : '')." />"
), TRUE) : '';
}
}
$typeselect = $typeselect ? $typeselect : showtablerow('', array('class="td25"'), $lang['forums_edit_threadtypes_nonexistence'], TRUE);
$sortselect = $sortselect ? $sortselect : showtablerow('', array('class="td25"'), $lang['forums_edit_threadsorts_nonexistence'], TRUE);
$num = 0;
$typemodelshow = FALSE;
$typemodelselect = '<ul class="nofloat" onmouseover="altStyle(this);">';
$query = $db->query("SELECT * FROM {$tablepre}typemodels ORDER BY displayorder");
while($model = $db->fetch_array($query)) {
$num++;
$modelchecked = $forum['typemodels'][$model['id']] ? 'checked' : '';
if(in_array($model['id'], $typemodelid)) {
$typemodelshow = TRUE;
$typemodelselect .= "<li".($modelchecked ? ' class="checked"' : '')."><input class=\"checkbox\" type=\"checkbox\" name=\"typemodel[]\" value=\"$model[id]\" $modelchecked>$model[name]</li>";
}
}
$typemodelselect .= '</ul>';
$forum['postcredits'] = $forum['postcredits'] ? unserialize($forum['postcredits']) : array();
$forum['replycredits'] = $forum['replycredits'] ? unserialize($forum['replycredits']) : array();
$forum['digestcredits'] = $forum['digestcredits'] ? unserialize($forum['digestcredits']) : array();
$forum['postattachcredits'] = $forum['postattachcredits'] ? unserialize($forum['postattachcredits']) : array();
$forum['getattachcredits'] = $forum['getattachcredits'] ? unserialize($forum['getattachcredits']) : array();
$simplebin = sprintf('%08b', $forum['simple']);
$forum['defaultorderfield'] = bindec(substr($simplebin, 0, 2));
$forum['defaultorder'] = ($forum['simple'] & 32) ? 1 : 0;
$forum['subforumsindex'] = bindec(substr($simplebin, 3, 2));
$forum['subforumsindex'] = $forum['subforumsindex'] == 0 ? -1 : ($forum['subforumsindex'] == 2 ? 0 : 1);
$forum['simple'] = $forum['simple'] & 1;
$forum['modrecommend'] = $forum['modrecommend'] ? unserialize($forum['modrecommend']) : '';
$forum['formulaperm'] = unserialize($forum['formulaperm']);
$forum['medal'] = $forum['formulaperm']['medal'];
$forum['formulapermmessage'] = $forum['formulaperm']['message'];
$forum['formulapermusers'] = $forum['formulaperm']['users'];
$forum['formulaperm'] = $forum['formulaperm'][0];
$forum['extra'] = unserialize($forum['extra']);
$forum['threadsorts']['default'] = $forum['threadsorts']['defaultshow'] ? 1 : 0;
showtagheader('div', 'basic', $anchor == 'basic');
showtableheader('forums_edit_basic', 'nobottom');
showsetting('forums_edit_basic_name', 'namenew', $forum['name'], 'text');
showsetting('forums_edit_base_name_color', 'extra[namecolor]', $forum['extra']['namecolor'], 'color');
showsetting('forums_edit_basic_scheme', '', '', $projectselect);
showsetting('forums_edit_basic_display', array('statusnew', array(
array(1, $lang['forums_edit_basic_display_yes']),
array(0, $lang['forums_edit_basic_display_no']),
array(2, $lang['forums_edit_basic_display_select'])
)), $forum['status'], 'mradio');
showsetting('forums_edit_basic_up', '', '', $fupselect);
showsetting('forums_edit_basic_redirect', 'redirectnew', $forum['redirect'], 'text');
showsetting('forums_edit_basic_icon', 'iconnew', $forum['icon'], 'text');
showsetting('forums_edit_basic_description', 'descriptionnew', html2bbcode($forum['description']), 'textarea');
showsetting('forums_edit_basic_rules', 'rulesnew', html2bbcode($forum['rules']), 'textarea');
showsetting('forums_edit_basic_keyword', 'keywordsnew', $forum['keywords'], 'text');
showsetting('forums_edit_basic_binddomain', 'binddomainnew', $forumdomains[$fid], 'text');
showtablefooter();
showtagfooter('div');
showtagheader('div', 'extend', $anchor == 'extend');
showtableheader('forums_edit_extend', 'nobottom');
showsetting('forums_edit_extend_style', '', '', $styleselect);
showsetting('forums_edit_extend_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text');
showsetting('forums_edit_extend_subforumsindex', array('subforumsindexnew', array(
array(-1, $lang['default']),
array(1, $lang['yes']),
array(0, $lang['no'])
), 1), $forum['subforumsindex'], 'mradio');
showsetting('forums_edit_extend_simple', 'simplenew', $forum['simple'], 'radio');
showsetting('forums_edit_extend_recommend_top', 'allowglobalsticknew', $forum['allowglobalstick'], 'radio');
showsetting('forums_edit_extend_defaultorderfield', array('defaultorderfieldnew', array(
array(0, $lang['forums_edit_extend_order_lastpost']),
array(1, $lang['forums_edit_extend_order_starttime']),
array(2, $lang['forums_edit_extend_order_replies']),
array(3, $lang['forums_edit_extend_order_views'])
)), $forum['defaultorderfield'], 'mradio');
showsetting('forums_edit_extend_defaultorder', array('defaultordernew', array(
array(0, $lang['forums_edit_extend_order_desc']),
array(1, $lang['forums_edit_extend_order_asc'])
)), $forum['defaultorder'], 'mradio');
showsetting('forums_edit_extend_threadcache', 'threadcachesnew', $forum['threadcaches'], 'text');
showsetting('forums_edit_extend_edit_rules', 'alloweditrulesnew', $forum['alloweditrules'], 'radio');
if($sideselect) {
showsetting('forums_edit_extend_sideselect', '', '', $sideselect[0]);
}
showsetting('forums_edit_extend_recommend', 'modrecommendnew[open]', $forum['modrecommend']['open'], 'radio', '', 1);
showsetting('forums_edit_extend_recommend_sort', array('modrecommendnew[sort]', array(
array(1, $lang['forums_edit_extend_recommend_sort_auto']),
array(0, $lang['forums_edit_extend_recommend_sort_manual']),
array(2, $lang['forums_edit_extend_recommend_sort_mix']))), $forum['modrecommend']['sort'], 'mradio');
showsetting('forums_edit_extend_recommend_orderby', array('modrecommendnew[orderby]', array(
array(0, $lang['forums_edit_extend_recommend_orderby_dateline']),
array(1, $lang['forums_edit_extend_recommend_orderby_lastpost']),
array(2, $lang['forums_edit_extend_recommend_orderby_views']),
array(3, $lang['forums_edit_extend_recommend_orderby_replies']),
array(4, $lang['forums_edit_extend_recommend_orderby_digest']),
array(5, $lang['forums_edit_extend_recommend_orderby_recommend']),
array(6, $lang['forums_edit_extend_recommend_orderby_heats']),
)), $forum['modrecommend']['orderby'], 'mradio');
showsetting('forums_edit_extend_recommend_num', 'modrecommendnew[num]', $forum['modrecommend']['num'], 'text');
showsetting('forums_edit_extend_recommend_imagenum', 'modrecommendnew[imagenum]', $forum['modrecommend']['imagenum'], 'text');
showsetting('forums_edit_extend_recommend_imagesize', array('modrecommendnew[imagewidth]', 'modrecommendnew[imageheight]'), array(intval($forum['modrecommend']['imagewidth']), intval($forum['modrecommend']['imageheight'])), 'multiply');
showsetting('forums_edit_extend_recommend_maxlength', 'modrecommendnew[maxlength]', $forum['modrecommend']['maxlength'], 'text');
showsetting('forums_edit_extend_recommend_cachelife', 'modrecommendnew[cachelife]', $forum['modrecommend']['cachelife'], 'text');
showsetting('forums_edit_extend_recommend_dateline', 'modrecommendnew[dateline]', $forum['modrecommend']['dateline'], 'text');
showtablefooter();
showtagfooter('div');
showtagheader('div', 'posts', $anchor == 'posts');
showtableheader('forums_edit_posts', 'nobottom');
showsetting('forums_edit_posts_modposts', array('modnewpostsnew', array(
array(0, $lang['none']),
array(1, $lang['forums_edit_posts_modposts_threads']),
array(2, $lang['forums_edit_posts_modposts_posts'])
)), $forum['modnewposts'], 'mradio');
showsetting('forums_edit_posts_alloweditpost', 'alloweditpostnew', $forum['alloweditpost'], 'radio');
showsetting('forums_edit_posts_recyclebin', 'recyclebinnew', $forum['recyclebin'], 'radio');
showsetting('forums_edit_posts_html', 'allowhtmlnew', $forum['allowhtml'], 'radio');
showsetting('forums_edit_posts_bbcode', 'allowbbcodenew', $forum['allowbbcode'], 'radio');
showsetting('forums_edit_posts_imgcode', 'allowimgcodenew', $forum['allowimgcode'], 'radio');
showsetting('forums_edit_posts_mediacode', 'allowmediacodenew', $forum['allowmediacode'], 'radio');
showsetting('forums_edit_posts_smilies', 'allowsmiliesnew', $forum['allowsmilies'], 'radio');
showsetting('forums_edit_posts_jammer', 'jammernew', $forum['jammer'], 'radio');
showsetting('forums_edit_posts_anonymous', 'allowanonymousnew', $forum['allowanonymous'], 'radio');
showsetting('forums_edit_posts_disablewatermark', 'disablewatermarknew', $forum['disablewatermark'], 'radio');
if($tagstatus) {
showsetting('forums_edit_posts_tagstatus', array('allowtagnew', array(
array(0, $lang['forums_edit_posts_tagstatus_none']),
array(1, $lang['forums_edit_posts_tagstatus_use']),
array(2, $lang['forums_edit_posts_tagstatus_quired'])
)), $forum['allowtag'], 'mradio');
}
showsetting('forums_edit_posts_allowpostspecial', array('allowpostspecialnew', array(
$lang['thread_poll'],
$lang['thread_trade'],
$lang['thread_reward'],
$lang['thread_activity'],
$lang['thread_debate']
)), $forum['allowpostspecial'], 'binmcheckbox');
$threadpluginarray = '';
foreach($threadplugins as $tpid => $data) {
$threadpluginarray[] = array($tpid, $data['name']);
}
if($threadpluginarray) {
showsetting('forums_edit_posts_threadplugin', array('threadpluginnew', $threadpluginarray), $forum['threadplugin'], 'mcheckbox');
}
showsetting('forums_edit_posts_allowspecialonly', 'allowspecialonlynew', $forum['allowspecialonly'], 'radio');
if(!empty($tradetypes) && is_array($tradetypes)) {
$forum['tradetypes'] = unserialize($forum['tradetypes']);
$alldefault = !$forum['tradetypes'];
$tradetypearray = '';
foreach($tradetypes as $typeid => $typename) {
$tradetypearray[] = array($typeid, $typename);
if($alldefault) {
$forum['tradetypes'][] = $typeid;
}
}
showsetting('forums_edit_posts_trade_type', array('tradetypesnew', $tradetypearray), $forum['tradetypes'], 'mcheckbox');
}
showsetting('forums_edit_posts_autoclose', array('autoclosenew', array(
array(0, $lang['forums_edit_posts_autoclose_none'], array('autoclose_time' => 'none')),
array(1, $lang['forums_edit_posts_autoclose_dateline'], array('autoclose_time' => '')),
array(-1, $lang['forums_edit_posts_autoclose_lastpost'], array('autoclose_time' => ''))
)), $forum['autoclose'], 'mradio');
showtagheader('tbody', 'autoclose_time', $forum['autoclose'], 'sub');
showsetting('forums_edit_posts_autoclose_time', 'autoclosetimenew', $forum['autoclosetime'], 'text');
showtagfooter('tbody');
showsetting('forums_edit_posts_attach_ext', 'attachextensionsnew', $forum['attachextensions'], 'text');
showtablefooter();
showtagfooter('div');
showtagheader('div', 'credits', $anchor == 'credits');
showtableheader('forums_edit_credits_policy', 'fixpadding');
$customcreditspolicy = '';
echo '<tr><th>'.$lang['credits_id'].'</th>';
foreach($extcredits as $i => $extcredit) {
echo '<th valign="top">extcredits'.$i.'<br />('.$extcredit['title'].')</th>';
}
echo '</tr>';
if(is_array($extcredits)) {
foreach(array('post', 'reply', 'digest', 'postattach', 'getattach') as $policy) {
$row = array($lang['settings_credits_policy_'.$policy]);
$rowclass = array('class="td22"');
foreach($extcredits as $i => $extcredit) {
$row[] = '<input type="text" class="txt" size="2" name="'.$policy.'creditsnew['.$i.']" value="'.$forum[$policy.'credits'][$i].'" />';
$rowclass[] = 'class="td28"';
}
$customcreditspolicy .= showtablerow('title="'.$lang['settings_credits_policy_'.$policy.'_comment'].'"', $rowclass, $row, TRUE);
}
}
echo $customcreditspolicy;
showtablerow('', 'class="lineheight" colspan="9"', $lang['forums_edit_credits_comment']);
showtablefooter();
showtagfooter('div');
if($allowthreadtypes) {
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'<input type="checkbox" class="checkbox" name="newenable[]" checked="checked" />', 'td25'],
[1,'<input type="text" class="txt" name="newname[]" size="15" />'],
[1,'<input type="text" class="txt" name="newdescription[]" size="15" />'],
[1,'<select name="newoptions[]"><option value="1" selected="selected">$lang[forums_edit_threadtypes_use_cols]</option><option value="2">$lang[forums_edit_threadtypes_use_choice]</option></select>'],
[1,'']
],
];
</script>
EOT;
showtagheader('div', 'threadtypes', $anchor == 'threadtypes');
showtableheader('forums_edit_threadtypes', 'nobottom');
showsetting('forums_edit_threadtypes_status', array('threadtypesnew[status]', array(
array(1, $lang['yes'], array('threadtypes_config' => '', 'threadtypes_manage' => '')),
array(0, $lang['no'], array('threadtypes_config' => 'none', 'threadtypes_manage' => 'none'))
), TRUE), $forum['threadtypes']['status'], 'mradio');
showtagheader('tbody', 'threadtypes_config', $forum['threadtypes']['status']);
showsetting('forums_edit_threadtypes_required', 'threadtypesnew[required]', $forum['threadtypes']['required'], 'radio');
showsetting('forums_edit_threadtypes_listable', 'threadtypesnew[listable]', $forum['threadtypes']['listable'], 'radio');
showsetting('forums_edit_threadtypes_prefix', 'threadtypesnew[prefix]', $forum['threadtypes']['prefix'], 'radio');
showtagfooter('tbody');
showtablefooter();
showtagheader('div', 'threadtypes_manage', $forum['threadtypes']['status']);
showtableheader('', 'noborder fixpadding');
showsubtitle(array('enable', 'forums_edit_threadtypes_name', 'forums_edit_threadtypes_note', 'forums_edit_threadtypes_showtype', 'forums_edit_threadtypes_show'));
echo $typeselect;
echo '<tr><td colspan="6"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.lang('threadtype_infotypes_add').'</a></div></td></tr>';
echo '<tr><td class="lineheight" colspan="6">'.$lang['forums_edit_threadtypes_comment'].'</td></tr>';
showtablefooter();
showtagfooter('div');
showtagfooter('div');
showtagheader('div', 'threadsorts', $anchor == 'threadsorts');
showtableheader('forums_edit_threadsorts', 'nobottom');
showsetting('forums_edit_threadsorts_status', array('threadsortsnew[status]', array(
array(1, $lang['yes'], array('threadsorts_config' => '', 'threadsorts_manage' => '')),
array(0, $lang['no'], array('threadsorts_config' => 'none', 'threadsorts_manage' => 'none'))
), TRUE), $forum['threadsorts']['status'], 'mradio');
showtagheader('tbody', 'threadsorts_config', $forum['threadsorts']['status']);
showsetting('forums_edit_threadtypes_required', 'threadsortsnew[required]', $forum['threadsorts']['required'], 'radio');
showsetting('forums_edit_threadtypes_prefix', 'threadsortsnew[prefix]', $forum['threadsorts']['prefix'], 'radio');
showsetting('forums_edit_threadsorts_default', 'threadsortsnew[default]', $forum['threadsorts']['default'], 'radio');
if($typemodelshow) {
showsetting('forums_edit_threadsorts_typemodel', '', '', $typemodelselect);
}
showtagfooter('tbody');
showtablefooter();
showtagheader('div', 'threadsorts_manage', $forum['threadsorts']['status']);
showtableheader('', 'noborder fixpadding');
showsubtitle(array('enable', 'forums_edit_threadtypes_name', 'forums_edit_threadtypes_note', 'forums_edit_threadtypes_showtype', 'forums_edit_threadtypes_show', 'forums_edit_threadtypes_defaultshow'));
echo $sortselect;
showtablefooter();
showtagfooter('div');
showtagfooter('div');
}
showtagheader('div', 'perm', $anchor == 'perm');
showtableheader('forums_edit_perm_forum', 'nobottom');
showsetting('forums_edit_perm_passwd', 'passwordnew', $forum['password'], 'text');
showsetting('forums_edit_perm_users', 'formulapermusersnew', stripslashes($forum['formulapermusers']), 'textarea');
$colums = array();
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
foreach($_DCACHE['medals'] as $medalid => $medal) {
$colums[] = array($medalid, $medal['name']);
}
showtagheader('tbody', '', $medalstatus);
showsetting('forums_edit_perm_medal', array('medalnew', $colums), $forum['medal'], 'mcheckbox');
showtagfooter('tbody');
showtablefooter();
showtableheader('forums_edit_perm_forum', 'noborder fixpadding');
showsubtitle(array(
'',
'<input class="checkbox" type="checkbox" name="chkall1" onclick="checkAll(\'prefix\', this.form, \'viewperm\', \'chkall1\')" id="chkall1" /><label for="chkall1"> '.$lang['forums_edit_perm_view'].'</label>',
'<input class="checkbox" type="checkbox" name="chkall2" onclick="checkAll(\'prefix\', this.form, \'postperm\', \'chkall2\')" id="chkall2" /><label for="chkall2"> '.$lang['forums_edit_perm_post'].'</label>',
'<input class="checkbox" type="checkbox" name="chkall3" onclick="checkAll(\'prefix\', this.form, \'replyperm\', \'chkall3\')" id="chkall3" /><label for="chkall3"> '.$lang['forums_edit_perm_reply'].'</label>',
'<input class="checkbox" type="checkbox" name="chkall4" onclick="checkAll(\'prefix\', this.form, \'getattachperm\', \'chkall4\')" id="chkall4" /><label for="chkall4"> '.$lang['forums_edit_perm_getattach'].'</label>',
'<input class="checkbox" type="checkbox" name="chkall5" onclick="checkAll(\'prefix\', this.form, \'postattachperm\', \'chkall5\')" id="chkall5" /><label for="chkall5"> '.$lang['forums_edit_perm_postattach'].'</label>'
));
foreach(array('member', 'special', 'specialadmin', 'system') as $type) {
$tgroups = is_array($groups[$type]) ? $groups[$type] : array();
showtablerow('', '', array('<b>'.$lang['usergroups_'.$type].'</b>'));
foreach($tgroups as $group) {
$colums = array('<input class="checkbox" title="'.$lang['select_all'].'" type="checkbox" name="chkallv'.$group['groupid'].'" onclick="checkAll(\'value\', this.form, '.$group['groupid'].', \'chkallv'.$group['groupid'].'\')" id="chkallv_'.$group['groupid'].'" /><label for="chkallv_'.$group['groupid'].'"> '.$group['grouptitle'].'</label>');
foreach($perms as $perm) {
$checked = strstr($forum[$perm], "\t$group[groupid]\t") ? 'checked="checked"' : NULL;
$colums[] = '<input class="checkbox" type="checkbox" name="'.$perm.'[]" value="'.$group['groupid'].'" chkvalue="'.$group['groupid'].'" '.$checked.'>';
}
showtablerow('', '', $colums);
}
}
showtablerow('', 'class="lineheight" colspan="6"', $lang['forums_edit_perm_forum_comment']);
showtablefooter();
showtableheader('forums_edit_perm_formula', 'fixpadding');
$formulareplace .= '\'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\',\'<u>'.$lang['settings_credits_formula_posts'].'</u>\',\'<u>'.$lang['settings_credits_formula_oltime'].'</u>\',\'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\'';
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, textend) {
$('formulapermnew').focus();
textend = isUndefined(textend) ? '' : textend;
if(!isUndefined($('formulapermnew').selectionStart)) {
var opn = $('formulapermnew').selectionStart + 0;
if(textend != '') {
text = text + $('formulapermnew').value.substring($('formulapermnew').selectionStart, $('formulapermnew').selectionEnd) + textend;
}
$('formulapermnew').value = $('formulapermnew').value.substr(0, $('formulapermnew').selectionStart) + text + $('formulapermnew').value.substr($('formulapermnew').selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
if(textend != '') {
text = text + sel.text + textend;
}
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$('formulapermnew').value += text;
}
formulaexp();
}
var formulafind = new Array('digestposts', 'posts', 'oltime', 'pageviews');
var formulareplace = new Array(<?php echo $formulareplace?>);
function formulaexp() {
var result = $('formulapermnew').value;
<?php
$extcreditsbtn = '';
for($i = 1; $i <= 8; $i++) {
$extcredittitle = $extcredits[$i]['title'] ? $extcredits[$i]['title'] : $lang['settings_credits_formula_extcredits'].$i;
echo 'result = result.replace(/extcredits'.$i.'/g, \'<u>'.str_replace("'", "\'", $extcredittitle).'</u>\');';
$extcreditsbtn .= '<a href="###" onclick="insertunit(\'extcredits'.$i.'\')">'.$extcredittitle.'</a> ';
}
$profilefields = '';
$query = $db->query("SELECT * FROM {$tablepre}profilefields WHERE available='1' AND unchangeable='1'");
while($profilefield = $db->fetch_array($query)) {
echo 'result = result.replace(/field_'.$profilefield['fieldid'].'/g, \'<u>'.str_replace("'", "\'", $profilefield['title']).'</u>\');';
$profilefields .= '<a href="###" onclick="insertunit(\' field_'.$profilefield['fieldid'].' \')"> '.$profilefield['title'].' </a> ';
}
echo 'result = result.replace(/regdate/g, \'<u>'.$lang['forums_edit_perm_formula_regdate'].'</u>\');';
echo 'result = result.replace(/regday/g, \'<u>'.$lang['forums_edit_perm_formula_regday'].'</u>\');';
echo 'result = result.replace(/regip/g, \'<u>'.$lang['forums_edit_perm_formula_regip'].'</u>\');';
echo 'result = result.replace(/lastip/g, \'<u>'.$lang['forums_edit_perm_formula_lastip'].'</u>\');';
echo 'result = result.replace(/buyercredit/g, \'<u>'.$lang['forums_edit_perm_formula_buyercredit'].'</u>\');';
echo 'result = result.replace(/sellercredit/g, \'<u>'.$lang['forums_edit_perm_formula_sellercredit'].'</u>\');';
echo 'result = result.replace(/digestposts/g, \'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\');';
echo 'result = result.replace(/posts/g, \'<u>'.$lang['settings_credits_formula_posts'].'</u>\');';
echo 'result = result.replace(/threads/g, \'<u>'.$lang['settings_credits_formula_threads'].'</u>\');';
echo 'result = result.replace(/oltime/g, \'<u>'.$lang['settings_credits_formula_oltime'].'</u>\');';
echo 'result = result.replace(/pageviews/g, \'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\');';
echo 'result = result.replace(/and/g, \' <b>'.$lang['forums_edit_perm_formula_and'].'</b> \');';
echo 'result = result.replace(/or/g, \' <b>'.$lang['forums_edit_perm_formula_or'].'</b> \');';
echo 'result = result.replace(/>=/g, \'≥\');';
echo 'result = result.replace(/<=/g, \'≤\');';
echo 'result = result.replace(/==/g, \'=\');';
?>
$('formulapermexp').innerHTML = result;
}
</script>
<tr><td colspan="2"><div class="extcredits">
<?php echo $extcreditsbtn?>
<a href="###" onclick="insertunit(' regdate ')"> <?php echo lang('forums_edit_perm_formula_regdate')?> </a>
<a href="###" onclick="insertunit(' regday ')"> <?php echo lang('forums_edit_perm_formula_regday')?> </a>
<a href="###" onclick="insertunit(' regip ')"> <?php echo lang('forums_edit_perm_formula_regip')?> </a>
<a href="###" onclick="insertunit(' lastip ')"> <?php echo lang('forums_edit_perm_formula_lastip')?> </a>
<a href="###" onclick="insertunit(' buyercredit ')"> <?php echo lang('forums_edit_perm_formula_buyercredit')?> </a>
<a href="###" onclick="insertunit(' sellercredit ')"> <?php echo lang('forums_edit_perm_formula_sellercredit')?> </a>
<a href="###" onclick="insertunit(' digestposts ')"><?php echo lang('forums_edit_perm_formula_digestposts')?></a>
<a href="###" onclick="insertunit(' posts ')"><?php echo lang('forums_edit_perm_formula_posts')?></a>
<a href="###" onclick="insertunit(' threads ')"><?php echo lang('forums_edit_perm_formula_threads')?></a>
<a href="###" onclick="insertunit(' oltime ')"><?php echo lang('forums_edit_perm_formula_oltime')?></a>
<a href="###" onclick="insertunit(' pageviews ')"><?php echo lang('forums_edit_perm_formula_pageviews')?></a><?php echo $profilefields;?><br />
<a href="###" onclick="insertunit(' + ')"> + </a>
<a href="###" onclick="insertunit(' - ')"> - </a>
<a href="###" onclick="insertunit(' * ')"> * </a>
<a href="###" onclick="insertunit(' / ')"> / </a>
<a href="###" onclick="insertunit(' > ')"> > </a>
<a href="###" onclick="insertunit(' >= ')"> >= </a>
<a href="###" onclick="insertunit(' < ')"> < </a>
<a href="###" onclick="insertunit(' <= ')"> <= </a>
<a href="###" onclick="insertunit(' == ')"> = </a>
<a href="###" onclick="insertunit(' != ')"> != </a>
<a href="###" onclick="insertunit(' (', ') ')"> ( ) </a>
<a href="###" onclick="insertunit(' and ')"> <?php echo lang('forums_edit_perm_formula_and')?> </a>
<a href="###" onclick="insertunit(' or ')"> <?php echo lang('forums_edit_perm_formula_or')?> </a> <br />
<div id="formulapermexp" class="margintop marginbot diffcolor2"><?php echo $formulapermexp?></div>
</div>
<textarea name="formulapermnew" id="formulapermnew" class="marginbot" style="width:80%" rows="3" onkeyup="formulaexp()"><?php echo dhtmlspecialchars($forum['formulaperm'])?></textarea>
<script type="text/JavaScript">formulaexp()</script>
<br /><span class="smalltxt"><?=$lang['forums_edit_perm_formula_comment']?></span>
<br /><?php echo lang('creditwizard_current_formula_notice')?>
</td></tr>
<?php
showtablefooter();
showtableheader('', 'noborder fixpadding');
showsetting('forums_edit_perm_formulapermmessage', 'formulapermmessagenew', $forum['formulapermmessage'], 'textarea');
showtablefooter();
showtagfooter('div');
showtableheader('', 'notop');
showsubmit('detailsubmit', 'submit', '', $forum['type'] != 'group' ? '<input type="submit" class="btn" name="saveconfigsubmit" value="'.$lang['saveconf'].'">' : '');
showtablefooter();
}
showformfooter();
} else {
if(strlen($namenew) > 50) {
cpmsg('forums_name_toolong', '', 'error');
}
if($formulapermnew && !preg_match("/^(\{|\}|\+|\-|\*|\/|\.|>|<|=|!|\d|\s|\(|\)|extcredits[1-8]|regdate|regday|regip|lastip|buyercredit|sellercredit|field\_\d+|digestposts|posts|threads|pageviews|oltime|and|or)+$/", $formulapermnew) ||
!is_null(@eval(preg_replace(
array("/(regdate|regday|regip|lastip|buyercredit|sellercredit|field\_\d+|digestposts|posts|threads|pageviews|oltime|extcredits[1-8])/", "/\{([\d\.\-]+?)\}/"),
array("\$\\1", "'\\1'"), $formulapermnew).';'))) {
cpmsg('forums_formulaperm_error', '', 'error');
}
$formulapermary[0] = $formulapermnew;
$formulapermary[1] = preg_replace(
array("/(digestposts|posts|threads|pageviews|oltime|extcredits[1-8])/", "/(regdate|regday|regip|lastip|buyercredit|sellercredit|field\_\d+)/"),
array("\$_DSESSION['\\1']", "\$memberformula['\\1']"),
$formulapermnew);
$formulapermary['medal'] = $medalnew;
$formulapermary['message'] = $formulapermmessagenew;
$formulapermary['users'] = $formulapermusersnew;
$formulapermnew = addslashes(serialize($formulapermary));
if($type == 'group') {
if($namenew) {
if($foruminfosidestatus) {
$infosidestatusnew = $infosidestatus;
unset($infosidestatusnew['f'.$fid]);
$foruminfosidestatus[0] != $infosidestatus[2] && $foruminfosidestatus[0] != '' && $infosidestatusnew['f'.$fid][0] = $foruminfosidestatus[0];
$foruminfosidestatus['posts'] != $infosidestatus['posts'] && $foruminfosidestatus['posts'] != '' && $infosidestatusnew['f'.$fid]['posts'] = $foruminfosidestatus['posts'];
if($infosidestatus != $infosidestatusnew) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".(addslashes(serialize($infosidestatusnew)))."')");
updatecache('settings');
}
}
$forumcolumnsnew = $forumcolumnsnew > 1 ? intval($forumcolumnsnew) : 0;
$db->query("UPDATE {$tablepre}forums SET name='$namenew',forumcolumns='".$forumcolumnsnew."',status='".intval($statusnew)."' WHERE fid='$fid'");
$extranew = is_array($_POST['extra']) ? $_POST['extra'] : array();
$extranew = serialize($extranew);
$db->query("UPDATE {$tablepre}forumfields SET extra='$extranew' WHERE fid='$fid'");
updatecache('forums');
cpmsg('forums_edit_succeed', $BASESCRIPT.'?action=forums', 'succeed');
} else {
cpmsg('forums_edit_name_invalid', '', 'error');
}
} else {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$extensionarray = array();
foreach(explode(',', $attachextensionsnew) as $extension) {
if($extension = trim($extension)) {
$extensionarray[] = $extension;
}
}
$attachextensionsnew = implode(', ', $extensionarray);
foreach($perms as $perm) {
${$perm.'new'} = is_array($$perm) && !empty($$perm) ? "\t".implode("\t", $$perm)."\t" : '';
}
$fupadd = '';
if($fupnew != $forum['fup']) {
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE fup='$fid'");
if($db->num_rows($query)) {
cpmsg('forums_edit_sub_notnull', '', 'error');
}
$fup = $db->fetch_first("SELECT fid, type, inheritedmod FROM {$tablepre}forums WHERE fid='$fupnew'");
$fupadd = ", type='".($fup['type'] == 'forum' ? 'sub' : 'forum')."', fup='$fup[fid]'";
$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid' AND inherited='1'");
$query = $db->query("SELECT * FROM {$tablepre}moderators WHERE fid='$fupnew' ".($fup['inheritedmod'] ? '' : "AND inherited='1'"));
while($mod = $db->fetch_array($query)) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited)
VALUES ('$mod[uid]', '$fid', '0', '1')");
}
$moderators = $tab = '';
$query = $db->query("SELECT m.username FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND mo.inherited='0' AND m.uid=mo.uid ORDER BY mo.displayorder");
while($mod = $db->fetch_array($query)) {
$moderators .= $tab.addslashes($mod['username']);
$tab = "\t";
}
$db->query("UPDATE {$tablepre}forumfields SET moderators='$moderators' WHERE fid='$fid'");
}
$allowpostspecialtrade = intval($allowpostspecialnew[2]);
$allowpostspecialnew = bindec(intval($allowpostspecialnew[6]).intval($allowpostspecialnew[5]).intval($allowpostspecialnew[4]).intval($allowpostspecialnew[3]).intval($allowpostspecialnew[2]).intval($allowpostspecialnew[1]));
$allowspecialonlynew = $allowpostspecialnew || $threadplugins && $threadpluginnew ? $allowspecialonlynew : 0;
$forumcolumnsnew = $forumcolumnsnew > 1 ? intval($forumcolumnsnew) : 0;
$threadcachesnew = max(0, min(100, intval($threadcachesnew)));
$subforumsindexnew = $subforumsindexnew == -1 ? 0 : ($subforumsindexnew == 0 ? 2 : 1);
$simplenew = bindec(sprintf('%02d', decbin($defaultorderfieldnew)).$defaultordernew.sprintf('%02d', decbin($subforumsindexnew)).'00'.$simplenew);
$allowglobalsticknew = $allowglobalsticknew ? 1 : 0;
$db->query("UPDATE {$tablepre}forums SET status='$statusnew', name='$namenew', styleid='$styleidnew', alloweditpost='$alloweditpostnew',
allowpostspecial='$allowpostspecialnew', allowspecialonly='$allowspecialonlynew', allowhtml='$allowhtmlnew', allowbbcode='$allowbbcodenew', allowimgcode='$allowimgcodenew', allowmediacode='$allowmediacodenew',
allowsmilies='$allowsmiliesnew', alloweditrules='$alloweditrulesnew', modnewposts='$modnewpostsnew',
recyclebin='$recyclebinnew', jammer='$jammernew', allowanonymous='$allowanonymousnew', forumcolumns='$forumcolumnsnew', threadcaches='$threadcachesnew',
simple='$simplenew', allowglobalstick='$allowglobalsticknew', disablewatermark='$disablewatermarknew', allowtag='$allowtagnew', autoclose='".intval($autoclosenew * $autoclosetimenew)."' $fupadd
WHERE fid='$fid'");
$query = $db->query("SELECT fid FROM {$tablepre}forumfields WHERE fid='$fid'");
if(!($db->num_rows($query))) {
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
}
foreach(array('post', 'reply', 'digest', 'postattach', 'getattach') as $item) {
if(${$item.'creditsnew'}) {
foreach(${$item.'creditsnew'} as $i => $v) {
if($v == '') {
unset(${$item.'creditsnew'}[$i]);
} else {
$v = intval($v);
${$item.'creditsnew'}[$i] = $v < -99 ? -99 : $v;
${$item.'creditsnew'}[$i] = $v > 99 ? 99 : $v;
}
}
}
${$item.'creditsnew'} = ${$item.'creditsnew'} ? addslashes(serialize(${$item.'creditsnew'})) : '';
}
$threadtypesnew['types'] = $threadtypesnew['flat'] = $threadtypes['selectbox'] = $threadtypes['special'] = $threadtypes['show'] = array();
$threadsortsnew['types'] = $threadsortsnew['flat'] = $threadsorts['selectbox'] = $threadsorts['special'] = $threadsorts['show'] = array();
if($allowthreadtypes) {
if(is_array($newname) && $newname) {
$newname = array_unique($newname);
if($newname) {
foreach($newname as $key => $val) {
$val = trim($val);
if($newenable[$key] && $val) {
$newtypeid = $db->result_first("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$val'");
if(!$newtypeid) {
$db->query("INSERT INTO {$tablepre}threadtypes (name, description) VALUES
('$val', '".dhtmlspecialchars(trim($newdescription[$key]))."')");
$newtypeid = $db->insert_id();
}
if($newoptions[$key] == 1) {
$threadtypesnew['types'][$newtypeid] = $threadtypesnew['flat'][$newtypeid] = $val;
} elseif($newoptions[$key] == 2) {
$threadtypesnew['types'][$newtypeid] = $threadtypesnew['selectbox'][$newtypeid] = $val;
}
}
}
}
$threadtypesnew['status'] = 1;
} else {
$newname = array();
}
if($threadtypesnew['status']) {
if(is_array($threadtypesnew['options']) && $threadtypesnew['options']) {
$typeids = '0';
foreach($threadtypesnew['options'] as $key => $val) {
$typeids .= $val ? ', '.intval($key) : '';
}
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ($typeids) AND special='' ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
if($threadtypesnew['options']['enable'][$type['typeid']]) {
if($threadtypesnew['options'][$type['typeid']] == 1) {
$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['flat'][$type['typeid']] = $type['name'];
} elseif($threadtypesnew['options'][$type['typeid']] == 2) {
$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['selectbox'][$type['typeid']] = $type['name'];
}
}
}
}
$threadtypesnew = $threadtypesnew['types'] ? addslashes(serialize(array
(
'required' => (bool)$threadtypesnew['required'],
'listable' => (bool)$threadtypesnew['listable'],
'prefix' => (bool)$threadtypesnew['prefix'],
'types' => $threadtypesnew['types'],
'selectbox' => $threadtypesnew['selectbox'],
'flat' => $threadtypesnew['flat'],
))) : '';
} else {
$threadtypesnew = '';
}
$threadtypesadd = "threadtypes='$threadtypesnew',";
if($threadsortsnew['status']) {
if(is_array($threadsortsnew['options']) && $threadsortsnew['options']) {
$sortids = '0';
foreach($threadsortsnew['options'] as $key => $val) {
$sortids .= $val ? ', '.intval($key) : '';
}
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ($sortids) AND special='1' ORDER BY displayorder");
while($sort = $db->fetch_array($query)) {
if($threadsortsnew['options']['enable'][$sort['typeid']]) {
if($threadsortsnew['options'][$sort['typeid']] == 1) {
$threadsortsnew['types'][$sort['typeid']] = $threadsortsnew['flat'][$sort['typeid']] = $sort['name'];
} elseif($threadsortsnew['options'][$sort['typeid']] == 2) {
$threadsortsnew['types'][$sort['typeid']] = $threadsortsnew['selectbox'][$sort['typeid']] = $sort['name'];
}
}
$threadsortsnew['expiration'][$sort['typeid']] = $sort['expiration'];
$threadsortsnew['show'][$sort['typeid']] = $threadsortsnew['options']['show'][$sort['typeid']] ? 1 : 0;
$threadsortsnew['typemodelid'][$sort['typeid']] = $sort['modelid'];
}
}
if($threadsortsnew['default'] && !$threadsortsnew['defaultshow']) {
cpmsg('forums_edit_threadsort_nonexistence', '', 'error');
}
$threadsortsnew = $threadsortsnew['types'] ? addslashes(serialize(array
(
'required' => (bool)$threadsortsnew['required'],
'prefix' => (bool)$threadsortsnew['prefix'],
'types' => $threadsortsnew['types'],
'selectbox' => $threadsortsnew['selectbox'],
'flat' => $threadsortsnew['flat'],
'show' => $threadsortsnew['show'],
'expiration' => $threadsortsnew['expiration'],
'modelid' => $threadsortsnew['typemodelid'],
'defaultshow' => $threadsortsnew['default'] ? $threadsortsnew['defaultshow'] : '',
))) : '';
} else {
$threadsortsnew = '';
}
$threadsortsadd = "threadsorts='$threadsortsnew',";
if($typemodel) {
$query = $db->query("SELECT id, name FROM {$tablepre}typemodels WHERE id IN (".implodeids($typemodel).") ORDER BY displayorder");
while($model = $db->fetch_array($query)) {
$threadtypemodel[$model['id']]['name'] = $model['name'];
}
$threadtypemodeladd = addslashes(serialize($threadtypemodel));
}
} else {
$threadtypesadd = $threadsortsadd = $threadtypemodeladd = '';
}
if(!empty($tradetypes) && is_array($tradetypes) && $allowpostspecialtrade) {
if(count($tradetypes) == count($tradetypesnew)) {
$tradetypesnew = '';
} else {
$tradetypesnew = addslashes(serialize($tradetypesnew));
}
} else {
$tradetypesnew = '';
}
$threadpluginnew = addslashes(serialize($threadpluginnew));
$modrecommendnew['num'] = $modrecommendnew['num'] ? intval($modrecommendnew['num']) : 10;
$modrecommendnew['cachelife'] = $modrecommendnew['cachelife'] ? intval($modrecommendnew['cachelife']) : 900;
$modrecommendnew['maxlength'] = $modrecommendnew['maxlength'] ? intval($modrecommendnew['maxlength']) : 0;
$modrecommendnew['dateline'] = $modrecommendnew['dateline'] ? intval($modrecommendnew['dateline']) : 0;
$modrecommendnew['imagenum'] = $modrecommendnew['imagenum'] ? intval($modrecommendnew['imagenum']) : 5;
$modrecommendnew['imagewidth'] = $modrecommendnew['imagewidth'] ? intval($modrecommendnew['imagewidth']) : 200;
$modrecommendnew['imageheight'] = $modrecommendnew['imageheight'] ? intval($modrecommendnew['imageheight']): 150;
$modrecommendnew = $modrecommendnew && is_array($modrecommendnew) ? addslashes(serialize($modrecommendnew)) : '';
$descriptionnew = addslashes(preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode(stripslashes($descriptionnew), 1, 0, 0, 0, 1, 1, 0, 0, 1)));
$rulesnew = addslashes(preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode(stripslashes($rulesnew), 1, 0, 0, 0, 1, 1, 0, 0, 1)));
$extranew = is_array($_POST['extra']) ? $_POST['extra'] : array();
$extranew = serialize($extranew);
$db->query("UPDATE {$tablepre}forumfields SET description='$descriptionnew', icon='$iconnew', password='$passwordnew', redirect='$redirectnew', rules='$rulesnew',
attachextensions='$attachextensionsnew', $threadtypesadd $threadsortsadd postcredits='$postcreditsnew', replycredits='$replycreditsnew', digestcredits='$digestcreditsnew',
postattachcredits='$postattachcreditsnew', getattachcredits='$getattachcreditsnew', viewperm='$viewpermnew', postperm='$postpermnew', replyperm='$replypermnew', tradetypes='$tradetypesnew', typemodels='$threadtypemodeladd',
getattachperm='$getattachpermnew', postattachperm='$postattachpermnew', formulaperm='$formulapermnew', modrecommend='$modrecommendnew', keywords='$keywordsnew', threadplugin='$threadpluginnew', extra='$extranew' WHERE fid='$fid'");
if($modrecommendnew && !$modrecommendnew['sort']) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
recommendupdate($fid, $modrecommendnew, '1');
}
updatecache('forums');
$update_setting_cache = false;
if($binddomainnew) {
$binddomainnew = preg_replace('/^https?:\/\//is', '', trim($binddomainnew));
} else {
$binddomainnew = '';
}
if(!isset($forumdomains[$fid]) || $forumdomains[$fid] != $binddomainnew) {
if(empty($binddomainnew)) {
unset($forumdomains[$fid]);
} else {
$forumdomains[$fid] = $binddomainnew;
}
if($forumdomains) {
$binddomains = array_flip($forumdomains);
} else {
$binddomains = array();
}
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('forumdomains', '".(addslashes(serialize($forumdomains)))."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('binddomains', '".(addslashes(serialize($binddomains)))."')");
$update_setting_cache = true;
}
if($foruminfosidestatus) {
$infosidestatusnew = $infosidestatus;
unset($infosidestatusnew['f'.$fid]);
$foruminfosidestatus[0] != $infosidestatus[0] && $foruminfosidestatus[0] != '' && $infosidestatusnew['f'.$fid][0] = $foruminfosidestatus[0];
$foruminfosidestatus['posts'] != $infosidestatus['posts'] && $foruminfosidestatus['posts'] != '' && $infosidestatusnew['f'.$fid]['posts'] = $foruminfosidestatus['posts'];
if($infosidestatus != $infosidestatusnew) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".(addslashes(serialize($infosidestatusnew)))."')");
$update_setting_cache = true;
}
}
if($update_setting_cache) {
updatecache('settings');
}
if(submitcheck('saveconfigsubmit') && $type != 'group') {
$projectid = intval($projectid);
dheader("Location: $boardurl$BASESCRIPT?action=project&operation=add&id=$fid&type=forum&projectid=$projectid");
} else {
cpmsg('forums_edit_succeed', "$BASESCRIPT?action=forums&operation=edit&fid=$fid".($anchor ? "&anchor=$anchor" : ''), 'succeed');
}
}
}
} elseif($operation == 'delete') {
if($ajax) {
ob_end_clean();
require_once DISCUZ_ROOT.'./include/post.func.php';
$tids = array();
$total = intval($total);
$pp = intval($pp);
$currow = intval($currow);
$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' LIMIT $pp");
while($thread = $db->fetch_array($query)) {
$tids[] = $thread['tid'];
}
$tids = implode(',', $tids);
if($tids) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
foreach(array('threads', 'threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'debateposts', 'attachments', 'favorites', 'typeoptionvars', 'forumrecommend') as $value) {
$db->query("DELETE FROM {$tablepre}$value WHERE tid IN ($tids)", 'UNBUFFERED');
if($value == 'attachments') {
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE tid IN ($tids)", 'UNBUFFERED');
}
}
}
if($currow + $pp > $total) {
$db->query("DELETE FROM {$tablepre}forums WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}forumfields WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}access WHERE fid='$fid'");
echo 'TRUE';
exit;
}
echo 'GO';
exit;
} else {
if($finished) {
updatecache('forums');
cpmsg('forums_delete_succeed', $BASESCRIPT.'?action=forums', 'succeed');
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}forums WHERE fup='$fid'")) {
cpmsg('forums_delete_sub_notnull', '', 'error');
}
if(!$confirmed) {
cpmsg('forums_delete_confirm', "$BASESCRIPT?action=forums&operation=delete&fid=$fid", 'form');
} else {
$threads = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid='$fid'");
cpmsg('forums_delete_alarm', "$BASESCRIPT?action=forums&operation=delete&fid=$fid&confirmed=1", 'loadingform', '<div id="percent">0%</div>', FALSE);
echo "
<div id=\"statusid\" style=\"display:none\"></div>
<script type=\"text/JavaScript\">
var xml_http_building_link = '".$lang['xml_http_building_link']."';
var xml_http_sending = '".$lang['xml_http_sending']."';
var xml_http_loading = '".$lang['xml_http_loading']."';
var xml_http_load_failed = '".$lang['xml_http_load_failed']."';
var xml_http_data_in_processed = '".$lang['xml_http_data_in_processed']."';
var adminfilename = '$BASESCRIPT';
function forumsdelete(url, total, pp, currow) {
var x = new Ajax('HTML', 'statusid');
x.get(url+'&ajax=1&pp='+pp+'&total='+total+'&currow='+currow, function(s) {
if(s != 'GO') {
location.href = adminfilename + '?action=forums&operation=delete&finished=1';
}
currow += pp;
var percent = ((currow / total) * 100).toFixed(0);
percent = percent > 100 ? 100 : percent;
document.getElementById('percent').innerHTML = percent+'%';
document.getElementById('percent').style.backgroundPosition = '-'+percent+'%';
if(currow < total) {
forumsdelete(url, total, pp, currow);
}
});
}
forumsdelete(adminfilename + '?action=forums&operation=delete&fid=$fid&confirmed=1', $threads, 2000, 0);
</script>
";
}
}
} elseif($operation == 'copy') {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$source = intval($source);
$sourceforum = $_DCACHE['forums'][$source];
if(empty($sourceforum) || $sourceforum['type'] == 'group') {
cpmsg('forums_copy_source_invalid', '', 'error');
}
$delfields = array(
'forums' => array('fid', 'fup', 'type', 'name', 'status', 'displayorder', 'threads', 'posts', 'todayposts', 'lastpost', 'modworks', 'icon'),
'forumfields' => array('description', 'password', 'redirect', 'moderators', 'rules', 'threadsorts', 'typemodels', 'tradetypes', 'threadplugin'),
);
$fields = array(
'forums' => fetch_table_struct('forums'),
'forumfields' => fetch_table_struct('forumfields'),
);
if(!submitcheck('copysubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="target[]" size="10" multiple="multiple">'.forumselect(FALSE, 0, 0, TRUE).'</select>';
$optselect = '<select name="options[]" size="10" multiple="multiple">';
$fieldarray = array_merge($fields['forums'], $fields['forumfields']);
$listfields = array_diff($fieldarray, array_merge($delfields['forums'], $delfields['forumfields']));
foreach($listfields as $field) {
$optselect .= '<option value="'.$field.'">'.($lang['project_option_forum_'.$field] ? $lang['project_option_forum_'.$field] : $field).'</option>';
}
$optselect .= '</select>';
shownav('forum', 'forums_copy');
showsubmenu('forums_copy');
showtips('forums_copy_tips');
showformheader('forums&operation=copy');
showhiddenfields(array('source' => $source));
showtableheader();
showtitle($lang['forums_copy']);
showsetting(lang('forums_copy_source').':','','', $sourceforum['name']);
showsetting('forums_copy_target', '', '', $forumselect);
showsetting('forums_copy_options', '', '', $optselect);
showsubmit('copysubmit');
showtablefooter();
showformfooter();
} else {
$fids = $comma = '';
if(is_array($target) && count($target)) {
foreach($target as $fid) {
if(($fid = intval($fid)) && $fid != $source ) {
$fids .= $comma.$fid;
$comma = ',';
}
}
}
if(empty($fids)) {
cpmsg('forums_copy_target_invalid', '', 'error');
}
$forumoptions = array();
if(is_array($options) && !empty($options)) {
foreach($options as $option) {
if($option = trim($option)) {
if(in_array($option, $fields['forums'])) {
$forumoptions['forums'][] = $option;
} elseif(in_array($option, $fields['forumfields'])) {
$forumoptions['forumfields'][] = $option;
}
}
}
}
if(empty($forumoptions)) {
cpmsg('forums_copy_options_invalid', '', 'error');
}
foreach(array('forums', 'forumfields') as $table) {
if(is_array($forumoptions[$table]) && !empty($forumoptions[$table])) {
$sourceforum = $db->fetch_first("SELECT ".implode($forumoptions[$table],',')." FROM {$tablepre}$table WHERE fid='$source'");
if(!$sourceforum) {
cpmsg('forums_copy_source_invalid', '', 'error');
}
$updatequery = 'fid=fid';
foreach($sourceforum as $key => $val) {
$updatequery .= ", $key='".addslashes($val)."'";
}
$db->query("UPDATE {$tablepre}$table SET $updatequery WHERE fid IN ($fids)");
}
}
updatecache('forums');
cpmsg('forums_copy_succeed', $BASESCRIPT.'?action=forums', 'succeed');
}
}
function showforum($key, $type = '', $last = '') {
global $forums, $showedforums, $lang, $indexname;
$forum = $forums[$key];
$showedforums[] = $key;
if($last == '') {
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$forum['fid'].']" value="'.$forum['displayorder'].'" /></td><td>';
if($type == 'group') {
$return .= '<div class="parentboard">';
} elseif($type == '') {
$return .= '<div class="board">';
} elseif($type == 'sub') {
$return .= '<div id="cb_'.$forum['fid'].'" class="childboard">';
}
$boardattr = '';
if(!$forum['status'] || $forum['password'] || $forum['redirect']) {
$boardattr = '<div class="boardattr">';
$boardattr .= $forum['status'] ? '' : $lang['forums_admin_hidden'];
$boardattr .= !$forum['password'] ? '' : ' '.$lang['forums_admin_password'];
$boardattr .= !$forum['redirect'] ? '' : ' '.$lang['forums_admin_url'];
$boardattr .= '</div>';
}
$return .= '<input type="text" name="name['.$forum['fid'].']" value="'.htmlspecialchars($forum['name']).'" class="txt" />'.
($type == '' ? '<a href="###" onclick="addrowdirect = 1;addrow(this, 2, '.$forum['fid'].')" class="addchildboard">'.$lang['forums_admin_add_sub'].'</a>' : '').
'</div>'.$boardattr.
'</td><td>'.showforum_moderators($forum).'</td>
<td><a href="'.$BASESCRIPT.'?action=forums&operation=edit&fid='.$forum['fid'].'" title="'.$lang['forums_edit_comment'].'" class="act">'.$lang['edit'].'</a>'.
($type != 'group' ? '<a href="'.$BASESCRIPT.'?action=forums&operation=copy&source='.$forum['fid'].'" title="'.$lang['forums_copy_comment'].'" class="act">'.$lang['forums_copy'].'</a>' : '').
'<a href="'.$BASESCRIPT.'?action=forums&operation=delete&fid='.$forum['fid'].'" title="'.$lang['forums_delete_comment'].'" class="act">'.$lang['delete'].'</a></td></tr>';
} else {
if($last == 'lastboard') {
$return = '<tr><td></td><td colspan="3"><div class="lastboard"><a href="###" onclick="addrow(this, 1, '.$forum['fid'].')" class="addtr">'.$lang['forums_admin_add_forum'].'</a></div></td></tr>';
} elseif($last == 'lastchildboard' && $type) {
$return = '<script type="text/JavaScript">$(\'cb_'.$type.'\').className = \'lastchildboard\';</script>';
} elseif($last == 'last') {
$return = '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['forums_admin_add_category'].'</a></div></td></tr>';
}
}
return $return;
}
function showforum_moderators($forum) {
if($forum['moderators']) {
$moderators = explode("\t", $forum['moderators']);
$count = count($moderators);
$max = $count > 2 ? 2 : $count;
$mods = array();
for($i = 0;$i < $max;$i++) {
$mods[] = $forum['inheritedmod'] ? '<b>'.$moderators[$i].'</b>' : $moderators[$i];
}
$r = implode(', ', $mods);
if($count > 2) {
$r = '<span onmouseover="showMenu({\'ctrlid\':this.id})" id="mods_'.$forum['fid'].'">'.$r.'</span>';
$mods = array();
foreach($moderators as $moderator) {
$mods[] = $forum['inheritedmod'] ? '<b>'.$moderator.'</b>' : $moderator;
}
$r = '<a href="'.$BASESCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.lang('forums_moderators_comment').'">'.$r.'</a> ...';
$r .= '<div class="dropmenu1" id="mods_'.$forum['fid'].'_menu" style="display: none">'.implode('<br />', $mods).'</div>';
} else {
$r = '<a href="'.$BASESCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.lang('forums_moderators_comment').'">'.$r.'</a>';
}
} else {
$r = '<a href="'.$BASESCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.lang('forums_moderators_comment').'">'.lang('forums_admin_no_moderator').'</a>';
}
return $r;
}
function fetch_table_struct($tablename, $result = 'FIELD') {
global $db, $tablepre;
$datas = array();
$query = $db->query("DESCRIBE $tablepre$tablename");
while($data = $db->fetch_array($query)) {
$datas[$data['Field']] = $result == 'FIELD' ? $data['Field'] : $data;
}
return $datas;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/forums.inc.php | PHP | asf20 | 85,253 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: misc.inc.php 21184 2009-11-19 07:00:04Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = $operation ? $operation : 'custommenu';
if($operation == 'onlinelist') {
if(!submitcheck('onlinesubmit')) {
shownav('style', 'misc_onlinelist');
showsubmenu('nav_misc_onlinelist');
showtips('misc_onlinelist_tips');
showformheader('misc&operation=onlinelist&');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'display_order', 'usergroup', 'usergroups_title', 'misc_onlinelist_image'));
$listarray = array();
$query = $db->query("SELECT * FROM {$tablepre}onlinelist");
while($list = $db->fetch_array($query)) {
$list['title'] = dhtmlspecialchars($list['title']);
$listarray[$list['groupid']] = $list;
}
$onlinelist = '';
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type<>'member'");
$group = array('groupid' => 0, 'grouptitle' => 'Member');
do {
$id = $group['groupid'];
showtablerow('', array('class="td25"', 'class="td23 td28"', 'class="td24"', 'class="td24"', 'class="td21 td26"'), array(
$listarray[$id]['url'] ? " <img src=\"images/common/{$listarray[$id]['url']}\">" : '',
'<input type="text" class="txt" name="displayordernew['.$id.']" value="'.$listarray[$id]['displayorder'].'" size="3" />',
$group['groupid'] <= 8 ? lang('usergroups_system_'.$id) : $group['grouptitle'],
'<input type="text" class="txt" name="titlenew['.$id.']" value="'.($listarray[$id]['title'] ? $listarray[$id]['title'] : $group['grouptitle']).'" size="15" />',
'<input type="text" class="txt" name="urlnew['.$id.']" value="'.$listarray[$id]['url'].'" size="20" />'
));
} while($group = $db->fetch_array($query));
showsubmit('onlinesubmit', 'submit', 'td');
showtablefooter();
showformfooter();
} else {
if(is_array($urlnew)) {
$db->query("DELETE FROM {$tablepre}onlinelist");
foreach($urlnew as $id => $url) {
$url = trim($url);
if($id == 0 || $url) {
$db->query("INSERT INTO {$tablepre}onlinelist (groupid, displayorder, title, url)
VALUES ('$id', '$displayordernew[$id]', '$titlenew[$id]', '$url')");
}
}
}
updatecache(array('onlinelist', 'groupicon'));
cpmsg('onlinelist_succeed', $BASESCRIPT.'?action=misc&operation=onlinelist', 'succeed');
}
} elseif($operation == 'link') {
if(!submitcheck('linksubmit')) {
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
[1,'<input type="text" class="txt" name="newname[]" size="15">'],
[1,'<input type="text" class="txt" name="newurl[]" size="20">'],
[1,'<input type="text" class="txt" name="newdescription[]" size="30">', 'td26'],
[1,'<input type="text" class="txt" name="newlogo[]" size="20">']
]
]
</script>
<?
shownav('adv', 'misc_link');
showsubmenu('nav_misc_links');
showtips('misc_link_tips');
showformheader('misc&operation=link');
showtableheader();
showsubtitle(array('', 'display_order', 'misc_link_edit_name', 'misc_link_edit_url', 'misc_link_edit_description', 'misc_link_edit_logo'));
$query = $db->query("SELECT * FROM {$tablepre}forumlinks ORDER BY displayorder");
while($forumlink = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td28"', '', '', 'class="td26"'), array(
'<input type="checkbox" class="checkbox" name="delete[]" value="'.$forumlink['id'].'" />',
'<input type="text" class="txt" name="displayorder['.$forumlink[id].']" value="'.$forumlink['displayorder'].'" size="3" />',
'<input type="text" class="txt" name="name['.$forumlink[id].']" value="'.$forumlink['name'].'" size="15" />',
'<input type="text" class="txt" name="url['.$forumlink[id].']" value="'.$forumlink['url'].'" size="20" />',
'<input type="text" class="txt" name="description['.$forumlink[id].']" value="'.$forumlink['description'].'" size="30" />',
'<input type="text" class="txt" name="logo['.$forumlink[id].']" value="'.$forumlink['logo'].'" size="20" />'
));
}
echo '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['misc_link_add'].'</a></div></td></tr>';
showsubmit('linksubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}forumlinks WHERE id IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}forumlinks SET displayorder='$displayorder[$id]', name='$name[$id]', url='$url[$id]',description='$description[$id]',logo='$logo[$id]' WHERE id='$id'");
}
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
if($value) {
$db->query("INSERT INTO {$tablepre}forumlinks (displayorder, name, url, description, logo) VALUES ('$newdisplayorder[$key]', '$value', '$newurl[$key]', '$newdescription[$key]', '$newlogo[$key]')");
}
}
}
updatecache('forumlinks');
cpmsg('forumlinks_succeed', $BASESCRIPT.'?action=misc&operation=link', 'succeed');
}
} elseif($operation == 'bbcode') {
if(!submitcheck('bbcodessubmit') && !$edit) {
echo '<script type="text/JavaScript">loadcss("editor");</script>';
shownav('style', 'settings_editor');
showsubmenu('settings_editor', array(
array('settings_editor_global', 'settings&operation=editor', 0),
array('settings_editor_code', 'misc&operation=bbcode', 1),
));
showtips('misc_bbcode_edit_tips');
showformheader('misc&operation=bbcode');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'misc_bbcode_tag', 'available', 'display', 'display_order', 'misc_bbcode_icon', 'misc_bbcode_icon_file', ''));
$query = $db->query("SELECT * FROM {$tablepre}bbcodes ORDER BY displayorder");
while($bbcode = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td21"', 'class="td25"', 'class="td25"', 'class="td28 td24"', 'class="td25"', 'class="td21"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$bbcode[id]\">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"tagnew[$bbcode[id]]\" value=\"$bbcode[tag]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$bbcode[id]]\" value=\"1\" ".($bbcode['available'] ? 'checked="checked"' : NULL).">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"displaynew[$bbcode[id]]\" value=\"1\" ".($bbcode['available'] == '2' ? 'checked="checked"' : NULL).">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$bbcode[id]]\" value=\"$bbcode[displayorder]\">",
$bbcode['icon'] ? "<em class=\"editor\"><a class=\"customedit\"><img src=\"images/common/$bbcode[icon]\" border=\"0\"></a></em>" : ' ',
"<input type=\"text\" class=\"txt\" size=\"25\" name=\"iconnew[$bbcode[id]]\" value=\"$bbcode[icon]\">",
"<a href=\"$BASESCRIPT?action=misc&operation=bbcode&edit=$bbcode[id]\" class=\"act\">$lang[detail]</a>"
));
}
showtablerow('', array('class="td25"', 'class="td25"', 'class="td25"', 'class="td25"', 'class="td28 td24"', 'class="td25"', 'class="td21"'), array(
lang('add_new'),
'<input type="text" class="txt" size="15" name="newtag">',
'',
'',
'<input type="text" class="txt" size="2" name="newdisplayorder">',
'',
'<input type="text" class="txt" size="25" name="newicon">',
''
));
showsubmit('bbcodessubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} elseif(submitcheck('bbcodessubmit')) {
if(is_array($delete)) {
$ids = '\''.implode('\',\'', $delete).'\'';
$db->query("DELETE FROM {$tablepre}bbcodes WHERE id IN ($ids)");
}
if(is_array($tagnew)) {
$custom_ids = array();
$query = $db->query("SELECT id FROM {$tablepre}bbcodes");
while($bbcode = $db->fetch_array($query)) {
$custom_ids[] = $bbcode['id'];
}
foreach($tagnew as $id => $val) {
if(in_array($id, $custom_ids) && !preg_match("/^[0-9a-z]+$/i", $tagnew[$id]) && strlen($tagnew[$id]) < 20) {
cpmsg('dzcode_edit_tag_invalid', '', 'error');
}
$availablenew[$id] = in_array($id, $custom_ids) ? $availablenew[$id] : 1;
$availablenew[$id] = $availablenew[$id] && $displaynew[$id] ? 2 : $availablenew[$id];
$sqladd = in_array($id, $custom_ids) ? ", tag='$tagnew[$id]', icon='$iconnew[$id]'" : '';
$db->query("UPDATE {$tablepre}bbcodes SET available='$availablenew[$id]', displayorder='$displayordernew[$id]' $sqladd WHERE id='$id'");
}
}
if($newtag != '') {
if(!preg_match("/^[0-9a-z]+$/i", $newtag && strlen($newtag) < 20)) {
cpmsg('dzcode_edit_tag_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}bbcodes (tag, icon, available, displayorder, params, nest)
VALUES ('$newtag', '$newicon', '0', '$newdisplayorder', '1', '1')");
}
updatecache(array('bbcodes', 'bbcodes_display'));
cpmsg('dzcode_edit_succeed', $BASESCRIPT.'?action=misc&operation=bbcode', 'succeed');
} elseif($edit) {
$bbcode = $db->fetch_first("SELECT * FROM {$tablepre}bbcodes WHERE id='$edit'");
if(!$bbcode) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
$bbcode['prompt'] = str_replace("\t", "\n", $bbcode['prompt']);
shownav('style', 'nav_posting_bbcode');
showsubmenu($lang['misc_bbcode_edit'].' - '.$bbcode['tag']);
showformheader("misc&operation=bbcode&edit=$edit");
showtableheader();
showsetting('misc_bbcode_edit_tag', 'tagnew', $bbcode['tag'], 'text');
showsetting('misc_bbcode_edit_replacement', 'replacementnew', $bbcode['replacement'], 'textarea');
showsetting('misc_bbcode_edit_example', 'examplenew', $bbcode['example'], 'text');
showsetting('misc_bbcode_edit_explanation', 'explanationnew', $bbcode['explanation'], 'text');
showsetting('misc_bbcode_edit_params', 'paramsnew', $bbcode['params'], 'text');
showsetting('misc_bbcode_edit_prompt', 'promptnew', $bbcode['prompt'], 'textarea');
showsetting('misc_bbcode_edit_nest', 'nestnew', $bbcode['nest'], 'text');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$tagnew = trim($tagnew);
if(!preg_match("/^[0-9a-z]+$/i", $tagnew)) {
cpmsg('dzcode_edit_tag_invalid', '', 'error');
} elseif($paramsnew < 1 || $paramsnew > 3 || $nestnew < 1 || $nestnew > 3) {
cpmsg('dzcode_edit_range_invalid', '', 'error');
}
$promptnew = trim(str_replace(array("\t", "\r", "\n"), array('', '', "\t"), $promptnew));
$db->query("UPDATE {$tablepre}bbcodes SET tag='$tagnew', replacement='$replacementnew', example='$examplenew', explanation='$explanationnew', params='$paramsnew', prompt='$promptnew', nest='$nestnew' WHERE id='$edit'");
updatecache(array('bbcodes', 'bbcodes_display'));
cpmsg('dzcode_edit_succeed', $BASESCRIPT.'?action=misc&operation=bbcode', 'succeed');
}
}
} elseif($operation == 'censor') {
$page = max(1, intval($page));
$ppp = 30;
$addcensors = isset($addcensors) ? trim($addcensors) : '';
if($do == 'export') {
ob_end_clean();
dheader('Cache-control: max-age=0');
dheader('Expires: '.gmdate('D, d M Y H:i:s', $timestamp - 31536000).' GMT');
dheader('Content-Encoding: none');
dheader('Content-Disposition: attachment; filename=CensorWords.txt');
dheader('Content-Type: text/plain');
$query = $db->query("SELECT find, replacement FROM {$tablepre}words ORDER BY find ASC");
while($censor = $db->fetch_array($query)) {
$censor['replacement'] = str_replace('*', '', $censor['replacement']) <> '' ? $censor['replacement'] : '';
echo $censor['find'].($censor['replacement'] != '' ? '='.stripslashes($censor['replacement']) : '')."\n";
}
exit();
} elseif(submitcheck('addcensorsubmit') && $addcensors != '') {
$oldwords = array();
if($adminid == 1 && $overwrite == 2) {
$db->query("TRUNCATE {$tablepre}words");
} else {
$query = $db->query("SELECT find, admin FROM {$tablepre}words");
while($censor = $db->fetch_array($query)) {
$oldwords[md5($censor['find'])] = $censor['admin'];
}
$db->free_result($query);
}
$censorarray = explode("\n", $addcensors);
$updatecount = $newcount = $ignorecount = 0;
foreach($censorarray as $censor) {
list($newfind, $newreplace) = array_map('trim', explode('=', $censor));
$newreplace = $newreplace <> '' ? daddslashes(str_replace("\\\'", '\'', $newreplace), 1) : '**';
if(strlen($newfind) < 3) {
$ignorecount ++;
continue;
} elseif(isset($oldwords[md5($newfind)])) {
if($overwrite && ($adminid == 1 || $oldwords[md5($newfind)] == $discuz_userss)) {
$updatecount ++;
$db->query("UPDATE {$tablepre}words SET replacement='$newreplace' WHERE `find`='$newfind'");
} else {
$ignorecount ++;
}
} else {
$newcount ++;
$db->query("INSERT INTO {$tablepre}words (admin, find, replacement) VALUES
('$discuz_user', '$newfind', '$newreplace')");
$oldwords[md5($newfind)] = $discuz_userss;
}
}
updatecache('censor');
cpmsg('censor_batch_add_succeed', "$BASESCRIPT?action=misc&operation=censor&anchor=import", 'succeed');
} elseif(!submitcheck('censorsubmit')) {
$ppp = 50;
$page = max(1, intval($page));
$startlimit = ($page - 1) * $ppp;
$totalcount = $db->result_first("SELECT count(*) FROM {$tablepre}words");
$multipage = multi($totalcount, $ppp, $page, "$BASESCRIPT?action=misc&operation=censor");
shownav('topic', 'nav_posting_censor');
$anchor = in_array($anchor, array('list', 'import')) ? $anchor : 'list';
showsubmenuanchors('nav_posting_censor', array(
array('admin', 'list', $anchor == 'list'),
array('misc_censor_batch_add', 'import', $anchor == 'import')
));
showtips('misc_censor_tips', 'list_tips', $anchor == 'list');
showtips('misc_censor_batch_add_tips', 'import_tips', $anchor == 'import');
showtagheader('div', 'list', $anchor == 'list');
showformheader("misc&operation=censor&page=$page", '', 'listform');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'misc_censor_word', 'misc_censor_replacement', 'operator'));
$query = $db->query("SELECT * FROM {$tablepre}words ORDER BY find ASC LIMIT $startlimit, $ppp");
while($censor = $db->fetch_array($query)) {
$censor['replacement'] = stripslashes($censor['replacement']);
$disabled = $adminid != 1 && $censor['admin'] != $discuz_userss ? 'disabled' : NULL;
showtablerow('', array('class="td25"', 'class="td26"', 'class="td26"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$censor[id]\" $disabled>",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"find[$censor[id]]\" value=\"$censor[find]\" $disabled>",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"replace[$censor[id]]\" value=\"$censor[replacement]\" $disabled>",
$censor['admin']
));
}
showtablerow('', array('class="td25"', 'class="td26"', 'class="td26"'), array(
lang('add_new'),
'<input type="text" class="txt" size="30" name="newfind">',
'<input type="text" class="txt" size="30" name="newreplace">',
''
));
showsubmit('censorsubmit', 'submit', 'del', '', $multipage);
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'import', $anchor == 'import');
showformheader("misc&operation=censor&page=$page", 'fixpadding');
showtableheader('', 'fixpadding', 'importform');
showtablerow('', 'class="vtop rowform"', '<br /><textarea name="addcensors" class="tarea" rows="10" cols="80"></textarea><br /><br />'.mradio('overwrite', array(
0 => lang('misc_censor_batch_add_no_overwrite'),
1 => lang('misc_censor_batch_add_overwrite'),
2 => lang('misc_censor_batch_add_clear')
), '', FALSE));
showsubmit('addcensorsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}words WHERE id IN ($ids) AND ('$adminid'='1' OR admin='$discuz_user')");
}
if(is_array($find)) {
foreach($find as $id => $val) {
$find[$id] = $val = trim(str_replace('=', '', $find[$id]));
if(strlen($val) < 3) {
cpmsg('censor_keywords_tooshort', '', 'error');
}
$replace[$id] = daddslashes(str_replace("\\\'", '\'', $replace[$id]), 1);
$db->query("UPDATE {$tablepre}words SET find='$find[$id]', replacement='$replace[$id]', extra='$extrav[$id]' WHERE id='$id' AND ('$adminid'='1' OR admin='$discuz_user')");
}
}
$newfind = trim(str_replace('=', '', $newfind));
$newreplace = trim($newreplace);
if($newfind != '') {
if(strlen($newfind) < 3) {
cpmsg('censor_keywords_tooshort', '', 'error');
}
$newreplace = daddslashes(str_replace("\\\'", '\'', $newreplace), 1);
if($oldcenser = $db->fetch_first("SELECT admin FROM {$tablepre}words WHERE find='$newfind'")) {
cpmsg('censor_keywords_existence', '', 'error');
} else {
$db->query("INSERT INTO {$tablepre}words (admin, find, replacement, extra) VALUES
('$discuz_user', '$newfind', '$newreplace', '$newextra')");
}
}
updatecache('censor');
cpmsg('censor_succeed', "$BASESCRIPT?action=misc&operation=censor&page=$page", 'succeed');
}
} elseif($operation == 'icon') {
if(!submitcheck('iconsubmit')) {
$anchor = in_array($anchor, array('list', 'add')) ? $anchor : 'list';
shownav('style', 'nav_thread_icon');
showsubmenuanchors('nav_thread_icon', array(
array('admin', 'list', $anchor == 'list'),
array('add', 'add', $anchor == 'add')
));
showtagheader('div', 'list', $anchor == 'list');
showformheader('misc&operation=icon');
showtableheader();
showsubtitle(array('', 'display_order', 'smilies_edit_image', 'smilies_edit_filename'));
$imgfilter = array();
$query = $db->query("SELECT * FROM {$tablepre}smilies WHERE type='icon' ORDER BY displayorder");
while($smiley = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$smiley[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$smiley[id]]\" value=\"$smiley[displayorder]\">",
"<img src=\"images/icons/$smiley[url]\">",
$smiley[url]
));
$imgfilter[] = $smiley[url];
}
showsubmit('iconsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'add', $anchor == 'add');
showformheader('misc&operation=icon');
showtableheader();
showsubtitle(array('', 'display_order', 'smilies_edit_image', 'smilies_edit_filename'));
$newid = 0;
$imgextarray = array('jpg', 'gif');
$iconsdir = dir(DISCUZ_ROOT.'./images/icons');
while($entry = $iconsdir->read()) {
if(in_array(strtolower(fileext($entry)), $imgextarray) && !in_array($entry, $imgfilter) && is_file(DISCUZ_ROOT.'./images/icons/'.$entry)) {
showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"'), array(
"<input type=\"checkbox\" name=\"addcheck[$newid]\" class=\"checkbox\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"adddisplayorder[$newid]\" value=\"0\">",
"<img src=\"images/icons/$entry\">",
"<input type=\"text\" class=\"txt\" size=\"35\" name=\"addurl[$newid]\" value=\"$entry\" readonly>"
));
$newid ++;
}
}
$iconsdir->close();
if(!$newid) {
showtablerow('', array('class="td25"', 'colspan="3"'), array('', lang('misc_icon_tips')));
} else {
showsubmit('iconsubmit', 'submit', '<input type="checkbox" class="checkbox" name="chkall2" onclick="checkAll(\'prefix\', this.form, \'addcheck\', \'chkall2\')">'.lang('select_all'));
}
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}smilies WHERE id IN ($ids)");
}
if(is_array($displayorder)) {
foreach($displayorder as $id => $val) {
$displayorder[$id] = intval($displayorder[$id]);
$db->query("UPDATE {$tablepre}smilies SET displayorder='$displayorder[$id]' WHERE id='$id'");
}
}
if(is_array($addurl)) {
foreach($addurl as $k => $v) {
if($addcheck[$k]) {
$query = $db->query("INSERT INTO {$tablepre}smilies (displayorder, type, url)
VALUES ('{$adddisplayorder[$k]}', 'icon', '$addurl[$k]')");
}
}
}
updatecache('icons');
cpmsg('thread_icon_succeed', "$BASESCRIPT?action=misc&operation=icon", 'succeed');
}
} elseif($operation == 'stamp') {
if(!submitcheck('stampsubmit')) {
$anchor = in_array($anchor, array('list', 'add')) ? $anchor : 'list';
shownav('style', 'nav_thread_stamp');
showsubmenuanchors('nav_thread_stamp', array(
array('admin', 'list', $anchor == 'list'),
array('add', 'add', $anchor == 'add')
));
showtagheader('div', 'list', $anchor == 'list');
showtips('misc_stamp_listtips');
showformheader('misc&operation=stamp');
showtableheader();
showsubtitle(array('', 'misc_stamp_id', 'misc_stamp_name', 'smilies_edit_image', 'smilies_edit_filename', 'misc_stamp_option'));
$imgfilter = array();
$tselect = '<select><option value="0">'.lang('none').'</option><option value="1">'.lang('misc_stamp_option_stick').'</option><option value="2">'.lang('misc_stamp_option_digest').'</option><option value="3">'.lang('misc_stamp_option_recommend').'</option></select>';
$query = $db->query("SELECT * FROM {$tablepre}smilies WHERE type='stamp' ORDER BY displayorder");
while($smiley = $db->fetch_array($query)) {
$s = $r = array();
$s[] = '<select>';
$r[] = '<select name="typeidnew['.$smiley['id'].']">';
if($smiley['typeid']) {
$s[] = '<option value="'.$smiley['typeid'].'">';
$r[] = '<option value="'.$smiley['typeid'].'" selected="selected">';
$s[] = '<option value="0">';
$r[] = '<option value="-1">';
}
$tselectrow = str_replace($s, $r, $tselect);
showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$smiley[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$smiley[id]]\" value=\"$smiley[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"code[$smiley[id]]\" value=\"$smiley[code]\">",
"<img src=\"images/stamps/$smiley[url]\">",
$smiley['url'],
$tselectrow,
));
$imgfilter[] = $smiley['url'];
}
showsubmit('stampsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'add', $anchor == 'add');
showformheader('misc&operation=stamp');
showtableheader();
showsubtitle(array('', 'misc_stamp_id', 'smilies_edit_image', 'smilies_edit_filename'));
$newid = 0;
$imgextarray = array('png', 'gif');
$stampsdir = dir(DISCUZ_ROOT.'./images/stamps');
while($entry = $stampsdir->read()) {
if(in_array(strtolower(fileext($entry)), $imgextarray) && !in_array($entry, $imgfilter) && is_file(DISCUZ_ROOT.'./images/stamps/'.$entry)) {
showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"'), array(
"<input type=\"checkbox\" name=\"addcheck[$newid]\" class=\"checkbox\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"adddisplayorder[$newid]\" value=\"0\">",
"<img src=\"images/stamps/$entry\">",
"<input type=\"text\" class=\"txt\" size=\"35\" name=\"addurl[$newid]\" value=\"$entry\" readonly>"
));
$newid ++;
}
}
$stampsdir->close();
if(!$newid) {
showtablerow('', array('class="td25"', 'colspan="3"'), array('', lang('misc_stamp_tips')));
} else {
showsubmit('stampsubmit', 'submit', '<input type="checkbox" class="checkbox" name="chkall2" onclick="checkAll(\'prefix\', this.form, \'addcheck\', \'chkall2\')">'.lang('select_all'));
}
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}smilies WHERE id IN ($ids)");
}
if(is_array($displayorder)) {
$typeidset = array();
foreach($displayorder as $id => $val) {
$displayorder[$id] = intval($displayorder[$id]);
if($displayorder[$id] >= 0 && $displayorder[$id] < 100) {
$typeidadd = '';
if($typeidnew[$id] && !isset($typeidset[$typeidnew[$id]])) {
$typeidnew[$id] = $typeidnew[$id] > 0 ? $typeidnew[$id] : 0;
$typeidadd = ",typeid='$typeidnew[$id]'";
$typeidset[$typeidnew[$id]] = TRUE;
}
$db->query("UPDATE {$tablepre}smilies SET displayorder='$displayorder[$id]',code='$code[$id]'$typeidadd WHERE id='$id'");
}
}
}
if(is_array($addurl)) {
$count = $db->result_first("SELECT COUNT(*) FROM {$tablepre}smilies WHERE type='stamp'");
if($count < 100) {
foreach($addurl as $k => $v) {
if($addcheck[$k]) {
$count++;
$query = $db->query("INSERT INTO {$tablepre}smilies (displayorder, type, url)
VALUES ('0', 'stamp', '$addurl[$k]')");
}
}
}
}
updatecache('stamps');
updatecache('stamptypeid');
cpmsg('thread_stamp_succeed', "$BASESCRIPT?action=misc&operation=stamp", 'succeed');
}
} elseif($operation == 'attachtype') {
if(!submitcheck('typesubmit')) {
$attachtypes = '';
$query = $db->query("SELECT * FROM {$tablepre}attachtypes");
while($type = $db->fetch_array($query)) {
$attachtypes .= showtablerow('', array('class="td25"', 'class="td24"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[id]\" />",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"extension[$type[id]]\" value=\"$type[extension]\" />",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"maxsize[$type[id]]\" value=\"$type[maxsize]\" />"
), TRUE);
}
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input name="newextension[]" type="text" class="txt" size="10">', 'td24'],
[1,'<input name="newmaxsize[]" type="text" class="txt" size="15">']
]
];
</script>
<?
shownav('topic', 'nav_posting_attachtype');
showsubmenu('nav_posting_attachtype');
showtips('misc_attachtype_tips');
showformheader('misc&operation=attachtype');
showtableheader();
showtablerow('class="partition"', array('class="td25"'), array('', lang('misc_attachtype_ext'), lang('misc_attachtype_maxsize')));
echo $attachtypes;
echo '<tr><td></td><td colspan="2"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['misc_attachtype_add'].'</a></div></tr>';
showsubmit('typesubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}attachtypes WHERE id IN ($ids)");
}
if(is_array($extension)) {
foreach($extension as $id => $val) {
$db->query("UPDATE {$tablepre}attachtypes SET extension='$extension[$id]', maxsize='$maxsize[$id]' WHERE id='$id'");
}
}
if(is_array($newextension)) {
foreach($newextension as $key => $value) {
if($newextension1 = trim($value)) {
if($db->result_first("SELECT id FROM {$tablepre}attachtypes WHERE extension='$newextension1'")) {
cpmsg('attachtypes_duplicate', '', 'error');
}
$db->query("INSERT INTO {$tablepre}attachtypes (extension, maxsize) VALUES
('$newextension1', '$newmaxsize[$key]')");
}
}
}
cpmsg('attachtypes_succeed', $BASESCRIPT.'?action=misc&operation=attachtype', 'succeed');
}
} elseif($operation == 'cron') {
if(empty($edit) && empty($run)) {
if(!submitcheck('cronssubmit')) {
shownav('tools', 'misc_cron');
showsubmenu('nav_misc_cron');
showtips('misc_cron_tips');
showformheader('misc&operation=cron');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'name', 'available', 'type', 'time', 'misc_cron_last_run', 'misc_cron_next_run', ''));
$query = $db->query("SELECT * FROM {$tablepre}crons ORDER BY type DESC");
while($cron = $db->fetch_array($query)) {
$disabled = $cron['weekday'] == -1 && $cron['day'] == -1 && $cron['hour'] == -1 && $cron['minute'] == '' ? 'disabled' : '';
if($cron['day'] > 0 && $cron['day'] < 32) {
$cron['time'] = lang('misc_cron_permonth').$cron['day'].lang('misc_cron_day');
} elseif($cron['weekday'] >= 0 && $cron['weekday'] < 7) {
$cron['time'] = lang('misc_cron_perweek').lang('misc_cron_week_day_'.$cron['weekday']);
} elseif($cron['hour'] >= 0 && $cron['hour'] < 24) {
$cron['time'] = lang('misc_cron_perday');
} else {
$cron['time'] = lang('misc_cron_perhour');
}
$cron['time'] .= $cron['hour'] >= 0 && $cron['hour'] < 24 ? sprintf('%02d', $cron[hour]).lang('misc_cron_hour') : '';
if(!in_array($cron['minute'], array(-1, ''))) {
foreach($cron['minute'] = explode("\t", $cron['minute']) as $k => $v) {
$cron['minute'][$k] = sprintf('%02d', $v);
}
$cron['minute'] = implode(',', $cron['minute']);
$cron['time'] .= $cron['minute'].lang('misc_cron_minute');
} else {
$cron['time'] .= '00'.lang('misc_cron_minute');
}
$cron['lastrun'] = $cron['lastrun'] ? gmdate("$dateformat<\b\\r />$timeformat", $cron['lastrun'] + $_DCACHE['settings']['timeoffset'] * 3600) : '<b>N/A</b>';
$cron['nextcolor'] = $cron['nextrun'] && $cron['nextrun'] + $_DCACHE['settings']['timeoffset'] * 3600 < $timestamp ? 'style="color: #ff0000"' : '';
$cron['nextrun'] = $cron['nextrun'] ? gmdate("$dateformat<\b\\r />$timeformat", $cron['nextrun'] + $_DCACHE['settings']['timeoffset'] * 3600) : '<b>N/A</b>';
showtablerow('', array('class="td25"', 'class="crons"', 'class="td25"', 'class="td25"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$cron[cronid]\" ".($cron['type'] == 'system' ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" name=\"namenew[$cron[cronid]]\" size=\"20\" value=\"$cron[name]\"><br /><b>$cron[filename]</b>",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$cron[cronid]]\" value=\"1\" ".($cron['available'] ? 'checked' : '')." $disabled>",
lang($cron['type'] == 'system' ? 'inbuilt' : 'costom'),
$cron[time],
$cron[lastrun],
$cron[nextrun],
"<a href=\"$BASESCRIPT?action=misc&operation=cron&edit=$cron[cronid]\" class=\"act\">$lang[edit]</a><br />".
($cron['available'] ? " <a href=\"$BASESCRIPT?action=misc&operation=cron&run=$cron[cronid]\" class=\"act\">$lang[misc_cron_run]</a>" : " <a href=\"###\" class=\"act\" disabled>$lang[misc_cron_run]</a>")
));
}
showtablerow('', array('','colspan="10"'), array(
lang('add_new'),
'<input type="text" class="txt" name="newname" value="" size="20" />'
));
showsubmit('cronssubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}crons WHERE cronid IN ($ids) AND type='user'");
}
if(is_array($namenew)) {
foreach($namenew as $id => $name) {
$db->query("UPDATE {$tablepre}crons SET name='".dhtmlspecialchars($namenew[$id])."', available='".$availablenew[$id]."' ".($availablenew[$id] ? '' : ', nextrun=\'0\'')." WHERE cronid='$id'");
}
}
if($newname = trim($newname)) {
$db->query("INSERT INTO {$tablepre}crons (name, type, available, weekday, day, hour, minute, nextrun)
VALUES ('".dhtmlspecialchars($newname)."', 'user', '0', '-1', '-1', '-1', '', '$timestamp')");
}
$query = $db->query("SELECT cronid, filename FROM {$tablepre}crons");
while($cron = $db->fetch_array($query)) {
if(!file_exists(DISCUZ_ROOT.'./include/crons/'.$cron['filename'])) {
$db->query("UPDATE {$tablepre}crons SET available='0', nextrun='0' WHERE cronid='$cron[cronid]'");
}
}
//updatecache('crons');
updatecache('settings');
cpmsg('crons_succeed', $BASESCRIPT.'?action=misc&operation=cron', 'succeed');
}
} else {
$cronid = empty($run) ? $edit : $run;
$cron = $db->fetch_first("SELECT * FROM {$tablepre}crons WHERE cronid='$cronid'");
if(!$cron) {
cpmsg('undefined_action', '', 'error');
}
$cron['filename'] = str_replace(array('..', '/', '\\'), array('', '', ''), $cron['filename']);
$cronminute = str_replace("\t", ',', $cron['minute']);
$cron['minute'] = explode("\t", $cron['minute']);
if(!empty($edit)) {
if(!submitcheck('editsubmit')) {
shownav('tools', 'misc_cron');
showsubmenu($lang['misc_cron_edit'].' - '.$cron['name']);
showtips('misc_cron_edit_tips');
$weekdayselect = $dayselect = $hourselect = '';
for($i = 0; $i <= 6; $i++) {
$weekdayselect .= "<option value=\"$i\" ".($cron['weekday'] == $i ? 'selected' : '').">".$lang['misc_cron_week_day_'.$i]."</option>";
}
for($i = 1; $i <= 31; $i++) {
$dayselect .= "<option value=\"$i\" ".($cron['day'] == $i ? 'selected' : '').">$i $lang[misc_cron_day]</option>";
}
for($i = 0; $i <= 23; $i++) {
$hourselect .= "<option value=\"$i\" ".($cron['hour'] == $i ? 'selected' : '').">$i $lang[misc_cron_hour]</option>";
}
shownav('tools', 'misc_cron');
showformheader("misc&operation=cron&edit=$cronid");
showtableheader();
showsetting('misc_cron_edit_weekday', '', '', "<select name=\"weekdaynew\"><option value=\"-1\">*</option>$weekdayselect</select>");
showsetting('misc_cron_edit_day', '', '', "<select name=\"daynew\"><option value=\"-1\">*</option>$dayselect</select>");
showsetting('misc_cron_edit_hour', '', '', "<select name=\"hournew\"><option value=\"-1\">*</option>$hourselect</select>");
showsetting('misc_cron_edit_minute', 'minutenew', $cronminute, 'text');
showsetting('misc_cron_edit_filename', 'filenamenew', $cron['filename'], 'text');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$daynew = $weekdaynew != -1 ? -1 : $daynew;
if(strpos($minutenew, ',') !== FALSE) {
$minutenew = explode(',', $minutenew);
foreach($minutenew as $key => $val) {
$minutenew[$key] = $val = intval($val);
if($val < 0 || $var > 59) {
unset($minutenew[$key]);
}
}
$minutenew = array_slice(array_unique($minutenew), 0, 12);
$minutenew = implode("\t", $minutenew);
} else {
$minutenew = intval($minutenew);
$minutenew = $minutenew >= 0 && $minutenew < 60 ? $minutenew : '';
}
if(preg_match("/[\\\\\/\:\*\?\"\<\>\|]+/", $filenamenew)) {
cpmsg('crons_filename_illegal', '', 'error');
} elseif(!is_readable(DISCUZ_ROOT.($cronfile = "./include/crons/$filenamenew"))) {
cpmsg('crons_filename_invalid', '', 'error');
} elseif($weekdaynew == -1 && $daynew == -1 && $hournew == -1 && $minutenew === '') {
cpmsg('crons_time_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}crons SET weekday='$weekdaynew', day='$daynew', hour='$hournew', minute='$minutenew', filename='".trim($filenamenew)."' WHERE cronid='$cronid'");
updatecache('crons');
require_once DISCUZ_ROOT.'./include/cron.func.php';
cronnextrun($cron);
cpmsg('crons_succeed', $BASESCRIPT.'?action=misc&operation=cron', 'succeed');
}
} else {
if(!@include_once DISCUZ_ROOT.($cronfile = "./include/crons/$cron[filename]")) {
cpmsg('crons_run_invalid', '', 'error');
} else {
require_once DISCUZ_ROOT.'./include/cron.func.php';
cronnextrun($cron);
cpmsg('crons_run_succeed', $BASESCRIPT.'?action=misc&operation=cron', 'succeed');
}
}
}
} elseif($operation == 'tag') {
if(!$tagstatus) {
cpmsg('tags_not_open', "$BASESCRIPT?action=settings&operation=functions#subtitle_tags");
}
if(submitcheck('tagsubmit') && !empty($tag)) {
$tagdelete = $tagclose = $tagopen = array();
foreach($tag as $key => $value) {
if($value == -1) {
$tagdelete[] = $key;
} elseif($value == 1) {
$tagclose[] = $key;
} elseif($value == 0) {
$tagopen[] = $key;
}
}
if($tagdelete) {
$db->query("DELETE FROM {$tablepre}tags WHERE tagname IN (".implodeids($tagdelete).")", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadtags WHERE tagname IN (".implodeids($tagdelete).")", 'UNBUFFERED');
}
if($tagclose) {
$db->query("UPDATE {$tablepre}tags SET closed=1 WHERE tagname IN (".implodeids($tagclose).")", 'UNBUFFERED');
}
if($tagopen) {
$db->query("UPDATE {$tablepre}tags SET closed=0 WHERE tagname IN (".implodeids($tagopen).")", 'UNBUFFERED');
}
if($tagdelete || $tagclose || $tagopen) {
updatecache(array('tags_index', 'tags_viewthread'));
}
cpmsg('tags_updated', $BASESCRIPT.'?action=misc&operation=tag&tagsearchsubmit=yes&tagname='.rawurlencode($tagname).'&threadnumlower='.intval($threadnumlower).'&threadnumhigher='.intval($threadnumhigher).'&status='.intval($status), 'succeed');
}
shownav('topic', 'nav_posting_tag');
showsubmenu('nav_posting_tag');
if(!submitcheck('tagsearchsubmit', 1)) {
$tagcount[0] = $db->result_first("SELECT count(*) FROM {$tablepre}tags");
$tagcount[1] = $db->result_first("SELECT count(*) FROM {$tablepre}tags WHERE closed=1");
$tagcount[2] = $tagcount[0] - $tagcount[1];
showformheader('misc&operation=tag');
showtableheader('misc_tag_search');
showsetting('misc_tag', 'tagname', '', 'text');
showsetting('misc_tag_threadnum_between', array('threadnumhigher', 'threadnumlower'), array(), 'range');
showsetting('misc_tag_status', array( 'status', array(
array(-1, lang('all')."($tagcount[0])"),
array(1, lang('misc_tag_status_1')."($tagcount[1])"),
array(0, lang('misc_tag_status_0')."($tagcount[2])")
), TRUE), -1, 'mradio');
showsubmit('tagsearchsubmit', 'misc_tag_search');
showtablefooter();
showformfooter();
} else {
$tagpp = 100;
$page = max(1, intval($page));
$threadnumlower = !empty($threadnumlower) ? intval($threadnumlower) : '';
$threadnumhigher = !empty($threadnumhigher) ? intval($threadnumhigher) : '';
$sqladd = $tagname ? "tagname LIKE '%".str_replace(array('%', '*', '_'), array('\%', '%', '\_'), $tagname)."%'" : '1';
$sqladd .= $threadnumlower ? " AND total<'".intval($threadnumlower)."'" : '';
$sqladd .= $threadnumhigher ? " AND total>'".intval($threadnumhigher)."'" : '';
$sqladd .= $status != -1 ? " AND closed='".intval($status)."'" : '';
$pagetmp = $page;
$num = $db->result_first("SELECT count(*) FROM {$tablepre}tags WHERE $sqladd");
$multipage = multi($num, $tagpp, $page, $BASESCRIPT.'?action=misc&operation=tag&tagsearchsubmit=yes&tagname='.rawurlencode($tagname).'&threadnumlower='.intval($threadnumlower).'&threadnumhigher='.intval($threadnumhigher).'&status='.intval($status));
do {
$query = $db->query("SELECT * FROM {$tablepre}tags WHERE $sqladd ORDER BY total DESC LIMIT ".(($pagetmp - 1) * $tagpp).", $tagpp");
$pagetmp--;
} while(!$db->num_rows($query) && $pagetmp);
showformheader('misc&operation=tag&page='.$page);
showhiddenfields(array(
'tagname' => $tagname,
'threadnumlower' => $threadnumlower,
'threadnumhigher' => $threadnumhigher,
'tagname' => $tagname,
'status' => $status,
));
showtableheader('nav_posting_tag', 'fixpadding');
showtablerow('', array('class="td21"', 'class="td25"'), array(
lang('misc_tag'),
lang('misc_tag_threadnum'),
''
));
while($tag = $db->fetch_array($query)) {
showtablerow('', array('class="td21"', 'class="td25"'), array(
'<a href="tag.php?name='.rawurlencode($tag['tagname']).'" target="_blank">'.$tag['tagname'].'</a>',
$tag['total'],
'<input name="tag['.$tag['tagname'].']" type="radio" class="radio" value="-1"> '.$lang['delete'].' <input name="tag['.$tag['tagname'].']" type="radio" class="radio" value="1"'.($tag['closed'] ? ' checked' : '').'> '.$lang['misc_tag_status_1'].' <input name="tag['.$tag['tagname'].']" type="radio" class="radio" value="0"'.(!$tag['closed'] ? ' checked' : '').'> '.$lang['misc_tag_status_0']
));
}
showsubmit('tagsubmit', 'submit', '', '<a href="#" onclick="checkAll(\'option\', $(\'cpform\'), \'-1\')">'.lang('misc_tag_all_delete').'</a> <a href="#" onclick="checkAll(\'option\', $(\'cpform\'), \'1\')">'.lang('misc_tag_all_close').'</a> <a href="#" onclick="checkAll(\'option\', $(\'cpform\'), \'0\')">'.lang('misc_tag_all_open').'</a>', $multipage);
showtablefooter();
showformfooter();
}
} elseif($operation == 'custommenu') {
if(!$do) {
if(!submitcheck('optionsubmit')) {
$page = max(1, intval($page));
$mpp = 10;
$startlimit = ($page - 1) * $mpp;
$num = $db->result_first("SELECT count(*) FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='1'");
$multipage = $inajax ? multi($num, $mpp, $page, $BASESCRIPT.'?action=misc&operation=custommenu', 0, 3, TRUE, TRUE) :
multi($num, $mpp, $page, $BASESCRIPT.'?action=misc&operation=custommenu');
$optionlist = $ajaxoptionlist = '';
$query = $db->query("SELECT id, title, displayorder, url FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='1' ORDER BY displayorder, dateline DESC, clicks DESC LIMIT $startlimit, $mpp");
while($custom = $db->fetch_array($query)) {
$optionlist .= showtablerow('', array('class="td25"', 'class="td28"', '', 'class="td26"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$custom[id]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayordernew[$custom[id]]\" value=\"$custom[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"25\" name=\"titlenew[$custom[id]]\" value=\"".lang($custom['title'])."\"><input type=\"hidden\" name=\"langnew[$custom[id]]\" value=\"$custom[title]\">",
"<input type=\"text\" class=\"txt\" size=\"40\" name=\"urlnew[$custom[id]]\" value=\"$custom[url]\">"
), TRUE);
$ajaxoptionlist .= '<li><a href="'.$custom['url'].'" target="'.(substr($custom['url'], 0, 19) == $BASESCRIPT.'?action=' ? 'main' : '_blank').'">'.lang($custom['title']).'</a></li>';
}
if($inajax) {
ajaxshowheader();
echo $ajaxoptionlist.'<li>'.$multipage.'</li><script reload="1">initCpMenus(\'custommenu\');parent.cmcache=true;</script>';
ajaxshowfooter();
exit;
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
[1,'<input type="text" class="txt" name="newtitle[]" size="25">'],
[1,'<input type="text" class="txt" name="newurl[]" size="40">', 'td26']
]
];
</script>
EOT;
shownav('tools', 'nav_custommenu');
showsubmenu('nav_custommenu');
showformheader('misc&operation=custommenu');
showtableheader();
showsubtitle(array('', 'display_order', 'name', 'URL'));
echo $optionlist;
echo '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['misc_custommenu_add'].'</a></div></td></tr>';
showsubmit('optionsubmit', 'submit', 'del', '', $multipage);
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}admincustom WHERE id IN ($ids) AND uid='$discuz_uid'");
}
if(is_array($titlenew)) {
foreach($titlenew as $id => $title) {
$title = dhtmlspecialchars($langnew[$id] && lang($langnew[$id], false) ? $langnew[$id] : $title);
$db->query("UPDATE {$tablepre}admincustom SET title='$title', displayorder='$displayordernew[$id]', url='".dhtmlspecialchars($urlnew[$id])."' WHERE id='$id'");
}
}
if(is_array($newtitle)) {
foreach($newtitle as $k => $v) {
$db->query("INSERT INTO {$tablepre}admincustom (title, displayorder, url, sort, uid) VALUES ('".dhtmlspecialchars($v)."', '".intval($newdisplayorder[$k])."', '".dhtmlspecialchars($newurl[$k])."', '1', '$discuz_uid')");
}
}
cpmsg('custommenu_edit_succeed', $BASESCRIPT.'?action=misc&operation=custommenu', 'succeed', '<script type="text/JavaScript">parent.cmcache=false;</script>');
}
} elseif($do == 'add') {
if($title && $url) {
admincustom($title, dhtmlspecialchars($url), 1);
cpmsg('custommenu_add_succeed', $BASESCRIPT.'?'.$url, 'succeed', '<script type="text/JavaScript">parent.cmcache=false;</script>');
} else {
cpmsg('undefined_action', '', 'error');
}
} elseif($do == 'clean') {
if(!$confirmed) {
cpmsg('custommenu_history_delete_confirm', "$BASESCRIPT?action=misc&operation=custommenu&do=clean", 'form');
} else {
$db->query("DELETE FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='0'");
cpmsg('custommenu_history_delete_succeed', '#', 'succeed', '<script type="text/JavaScript">setTimeout("parent.location.reload();", 2999);</script>');
}
} else {
cpmsg('undefined_action');
}
} elseif($operation == 'customnav') {
if(!$do) {
if(!submitcheck('submit')) {
shownav('style', 'settings_styles');
showsubmenu('settings_styles', array(
array('nav_settings_global', 'settings&operation=styles&anchor=global', 0),
array('nav_settings_index', 'settings&operation=styles&anchor=index', 0),
array('nav_settings_forumdisplay', 'settings&operation=styles&anchor=forumdisplay', 0),
array('nav_settings_viewthread', 'settings&operation=styles&anchor=viewthread', 0),
array('nav_settings_member', 'settings&operation=styles&anchor=member', 0),
array('nav_settings_customnav', 'misc&operation=customnav', 1),
array(array('menu' => 'jswizard_infoside', 'submenu' => array(
array('jswizard_infoside_global', 'jswizard&operation=infoside&from=style'),
array('jswizard_infoside_2', 'jswizard&operation=infoside&sideid=2&from=style'),
array('jswizard_infoside_0', 'jswizard&operation=infoside&sideid=0&from=style'),
))),
array('nav_settings_refresh', 'settings&operation=styles&anchor=refresh', 0),
array('nav_settings_sitemessage', 'settings&operation=styles&anchor=sitemessage', 0)
));
showformheader('misc&operation=customnav');
showtableheader();
showsubtitle(array('', 'display_order', 'name', 'url', 'type', 'available', ''));
$navlist = $subnavlist = array();
$query = $db->query("SELECT * FROM {$tablepre}navs ORDER BY displayorder");
while($nav = $db->fetch_array($query)) {
if($nav['parentid']) {
$subnavlist[$nav['parentid']][] = $nav;
} else {
$navlist[$nav['id']] = $nav;
}
}
foreach($navlist as $nav) {
showtablerow('', array('class="td25"', 'class="td25"', 'width="210"'), array(
$nav['type'] == '0' ? '' : "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$nav[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$nav[id]]\" value=\"$nav[displayorder]\">",
"<div><input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$nav[id]]\" value=\"".dhtmlspecialchars($nav['name'])."\">".($nav['type'] == '1' ? "<a href=\"###\" onclick=\"addrowdirect=1;addrow(this, 1, $nav[id])\" class=\"addchildboard\">$lang[misc_customnav_add_submenu]</a>" : '').'</div>',
$nav['type'] == '0' ? $nav['url'] : "<input type=\"text\" class=\"txt\" size=\"15\" name=\"urlnew[$nav[id]]\" value=\"".dhtmlspecialchars($nav['url'])."\">",
lang($nav['type'] == '0' ? 'inbuilt' : 'costom'),
$nav['id'] == 1 ? "<input type=\"hidden\" name=\"availablenew[$nav[id]]\" value=\"1\">" : "<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$nav[id]]\" value=\"1\" ".($nav['available'] ? 'checked' : '').">",
"<a href=\"$BASESCRIPT?action=misc&operation=customnav&do=edit&id=$nav[id]\" class=\"act\">$lang[detail]</a>"
));
if(!empty($subnavlist[$nav['id']])) {
$subnavnum = count($subnavlist[$nav['id']]);
foreach($subnavlist[$nav['id']] as $sub) {
$subnavnum--;
showtablerow('', array('class="td25"', 'class="td25"'), array(
$sub['type'] == '0' ? '' : "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$sub[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$sub[id]]\" value=\"$sub[displayorder]\">",
"<div class=\"".($subnavnum ? 'board' : 'lastboard')."\"><input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$sub[id]]\" value=\"".dhtmlspecialchars($sub['name'])."\"></div>",
$sub['type'] == '0' ? $sub['url'] : "<input type=\"text\" class=\"txt\" size=\"15\" name=\"urlnew[$sub[id]]\" value=\"".dhtmlspecialchars($sub['url'])."\">",
lang($sub['type'] == '0' ? 'inbuilt' : 'costom'),
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$sub[id]]\" value=\"1\" ".($sub['available'] ? 'checked' : '').">",
"<a href=\"$BASESCRIPT?action=misc&operation=customnav&do=edit&id=$sub[id]\" class=\"act\">$lang[detail]</a>"
));
}
}
}
echo '<tr><td colspan="2"></td><td colspan="5"><div><a href="###" onclick="addrow(this, 0, 0)" class="addtr">'.$lang['misc_customnav_add_menu'].'</a></div></td></tr>';
showsubmit('submit', 'submit', 'del');
showtablefooter();
showformfooter();
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucapparray = uc_app_ls();
$applist = '';
if(count($ucapparray) > 1) {
$applist = $lang['misc_customnav_add_ucenter'].'<select name="applist" onchange="app(this)"><option value=""></option>';
foreach($ucapparray as $app) {
if($app['appid'] != UC_APPID) {
$applist .= "<option value=\"$app[url]\">$app[name]</option>";
}
}
$applist .= '</select>';
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1, '', 'td25'], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td28'], [1, '<input name="newname[]" value="" size="30" type="text" class="txt">'], [1, '<input name="newurl[]" value="" size="30" type="text" class="txt">', 'td29'], [3, '$applist <input type="hidden" name="newparentid[]" value="0" />']],
[[1, '', 'td25'], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td28'], [1, '<div class=\"board\"><input name="newname[]" value="" size="30" type="text" class="txt"></div>'], [1, '<input name="newurl[]" value="" size="30" type="text" class="txt">', 'td29'], [3, '$applist <input type="hidden" name="newparentid[]" value="{1}" />']]
];
function app(obj) {
var inputs = obj.parentNode.parentNode.getElementsByTagName('input');
for(var i = 0; i < inputs.length; i++) {
if(inputs[i].name == 'newname[]') {
inputs[i].value = obj.options[obj.options.selectedIndex].innerHTML;
} else if(inputs[i].name == 'newurl[]') {
inputs[i].value = obj.value;
}
}
}
</script>
EOT;
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}navs WHERE id IN ($ids)");
$db->query("DELETE FROM {$tablepre}navs WHERE parentid IN ($ids)");
}
if(is_array($namenew)) {
foreach($namenew as $id => $name) {
$name = trim(dhtmlspecialchars($name));
$urladd = !empty($urlnew[$id]) ? ", url='".str_replace('&', '&', dhtmlspecialchars($urlnew[$id]))."'" : '';
$availablenew[$id] = $name && (!isset($urlnew[$id]) || $urlnew[$id]) && $availablenew[$id];
$displayordernew[$id] = intval($displayordernew[$id]);
$nameadd = !empty($name) ? ", name='$name'" : '';
$db->query("UPDATE {$tablepre}navs SET displayorder='$displayordernew[$id]', available='$availablenew[$id]' $urladd $nameadd WHERE id='$id'");
}
}
if(is_array($newname)) {
foreach($newname as $k => $v) {
$v = dhtmlspecialchars(trim($v));
if(!empty($v)) {
$newavailable = $v && $newurl[$k];
$newparentid[$k] = intval($newparentid[$k]);
$newdisplayorder[$k] = intval($newdisplayorder[$k]);
$newurl[$k] = str_replace('&', '&', dhtmlspecialchars($newurl[$k]));
$db->query("INSERT INTO {$tablepre}navs (parentid, name, displayorder, url, type, available) VALUES ('$newparentid[$k]', '$v', '$newdisplayorder[$k]', '$newurl[$k]', '1', '$newavailable')");
}
}
}
updatecache('settings');
cpmsg('nav_add_succeed', $BASESCRIPT.'?action=misc&operation=customnav', 'succeed');
}
} elseif($do == 'edit' && $id) {
$nav = $db->fetch_first("SELECT * FROM {$tablepre}navs WHERE id='$id'");
if(!$nav) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
$string = sprintf('%02d', $nav['highlight']);
shownav('global', 'misc_customnav');
showsubmenu('settings_styles', array(
array('nav_settings_global', 'settings&operation=styles&anchor=global', 0),
array('nav_settings_customnav', 'misc&operation=customnav', 1),
array('nav_settings_index', 'settings&operation=styles&anchor=index', 0),
array('nav_settings_forumdisplay', 'settings&operation=styles&anchor=forumdisplay', 0),
array('nav_settings_viewthread', 'settings&operation=styles&anchor=viewthread', 0),
array('nav_settings_member', 'settings&operation=styles&anchor=member', 0),
array('nav_settings_refresh', 'settings&operation=styles&anchor=refresh', 0)
));
showformheader("misc&operation=customnav&do=edit&id=$id");
showtableheader();
showtitle('misc_customnav_detail');
showsetting('misc_customnav_name', 'namenew', $nav['name'], 'text');
showsetting('misc_customnav_title', 'titlenew', $nav['title'], 'text');
showsetting('misc_customnav_url', 'urlnew', $nav['url'], 'text', $nav['type'] == '0');
showsetting('misc_customnav_style', array('stylenew', array(lang('misc_customnav_style_underline'), lang('misc_customnav_style_italic'), lang('misc_customnav_style_bold'))), $string[0], 'binmcheckbox');
showsetting('misc_customnav_style_color', array('colornew', array(
array(0, '<span style="color: '.LINK.';">Default</span>'),
array(1, '<span style="color: Red;">Red</span>'),
array(2, '<span style="color: Orange;">Orange</span>'),
array(3, '<span style="color: Yellow;">Yellow</span>'),
array(4, '<span style="color: Green;">Green</span>'),
array(5, '<span style="color: Cyan;">Cyan</span>'),
array(6, '<span style="color: Blue;">Blue</span>'),
array(7, '<span style="color: Purple;">Purple</span>'),
array(8, '<span style="color: Gray;">Gray</span>'),
)), $string[1], 'mradio');
showsetting('misc_customnav_url_open', array('targetnew', array(
array(0, lang('misc_customnav_url_open_default')),
array(1, lang('misc_customnav_url_open_blank'))
), TRUE), $nav['target'], 'mradio');
showsetting('plugins_edit_modules_adminid', array('levelnew', array(
array(0, lang('nolimit')),
array(1, lang('member')),
array(2, lang('usergroups_system_3')),
array(3, lang('usergroups_system_1')),
)), $nav['level'], 'select');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$namenew = dhtmlspecialchars(trim($namenew));
$titlenew = dhtmlspecialchars(trim($titlenew));
$urlnew = dhtmlspecialchars(trim($urlnew));
$stylebin = '';
for($i = 3; $i >= 1; $i--) {
$stylebin .= empty($stylenew[$i]) ? '0' : '1';
}
$stylenew = bindec($stylebin);
$targetnew = intval($targetnew) ? 1 : 0;
$levelnew = intval($levelnew) && $levelnew > 0 && $levelnew < 4 ? intval($levelnew) : 0 ;
$urladd = $nav['type'] == '1' && $urlnew ? ", url='".dhtmlspecialchars($urlnew)."'" : '';
$db->query("UPDATE {$tablepre}navs SET name='$namenew', title='$titlenew', highlight='$stylenew$colornew', target='$targetnew', level='$levelnew' $urladd WHERE id='$id'");
updatecache('settings');
cpmsg('nav_add_succeed', $BASESCRIPT.'?action=misc&operation=customnav', 'succeed');
}
}
} elseif($operation == 'custombar') {
$id = '';
if(!empty($title) && !empty($url)) {
$id = admincustom($title, dhtmlspecialchars($url), 2);
}
if(!empty($deleteid)) {
$deleteid = intval($deleteid);
$db->query("DELETE FROM {$tablepre}admincustom WHERE id='$deleteid' AND uid='$discuz_uid' AND sort='2'");
}
$historymenus = '';
$query = $db->query("SELECT id, title, url FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='2' ORDER BY dateline");
while($custom = $db->fetch_array($query)) {
$historymenus .= '<em id="custombar_'.$custom['id'].'"><a onclick="mainFrame('.$custom['id'].', this.href);doane(event)" href="'.$custom['url'].'" hidefocus="true">'.lang($custom['title']).'</a><span onclick="custombar_update('.$custom['id'].')" title="'.$lang['custombar_del'].'"> </span></em>';
}
include template('header_ajax');
echo $historymenus;
include template('footer_ajax');
} elseif($operation == 'focus') {
require_once DISCUZ_ROOT.'./include/post.func.php';
$focus = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='focus'");
$focus = unserialize($focus);
if(!$do) {
if(!submitcheck('focussubmit')) {
shownav('adv', 'misc_focus');
showsubmenu('misc_focus', array(
array('config', 'misc&operation=focus&do=config', 0),
array('admin', 'misc&operation=focus', 1),
array(array('menu' => 'add', 'submenu' => array(
array('misc_focus_handadd', 'misc&operation=focus&do=handadd'),
array('misc_focus_threadadd', 'misc&operation=focus&do=threadadd'),
array('misc_focus_autoadd', 'misc&operation=focus&do=recommend')
)), '', 0),
));
showtips('misc_focus_tips');
showformheader('misc&operation=focus');
showtableheader('admin', 'fixpadding');
showsubtitle(array('', 'available', 'subject', ''));
if(is_array($focus['data'])) {
foreach($focus['data'] as $k => $v) {
showtablerow('', array('class="td25"', 'class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$k\">",
"<input type=\"checkbox\" class=\"checkbox\" name=\"available[$k]\" value=\"1\" ".($v['available'] ? 'checked' : '').">",
'<a href="'.$v['url'].'" target="_blank">'.$v[subject].'</a>',
"<a href=\"$BASESCRIPT?action=misc&operation=focus&do=edit&id=$k\" class=\"act\">$lang[edit]</a>",
));
}
}
showsubmit('focussubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
$newfocus = array();
$newfocus['title'] = $focus['title'];
$newfocus['data'] = array();
if(isset($focus['data']) && is_array($focus['data'])) foreach($focus['data'] as $k => $v) {
if(is_array($delete) && in_array($k, $delete)) {
unset($focus['data'][$k]);
} else {
$v['available'] = $available[$k] ? 1 : 0;
$newfocus['data'][$k] = $v;
}
}
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('focus', '".addslashes(serialize($newfocus))."')");
updatecache('focus');
cpmsg('focus_update_succeed', $BASESCRIPT.'?action=misc&operation=focus', 'succeed');
}
} elseif($do == 'handadd') {
if(count($focus['data']) >= 10) {
cpmsg('focus_add_num_limit', $BASESCRIPT.'?action=misc&operation=focus', 'error');
}
if(!submitcheck('addsubmit')) {
shownav('adv', 'misc_focus');
showsubmenu('misc_focus', array(
array('config', 'misc&operation=focus&do=config', 0),
array('admin', 'misc&operation=focus', 0),
array(array('menu' => 'add', 'submenu' => array(
array('misc_focus_handadd', 'misc&operation=focus&do=handadd'),
array('misc_focus_threadadd', 'misc&operation=focus&do=threadadd'),
array('misc_focus_autoadd', 'misc&operation=focus&do=recommend')
)), '', 1),
));
showtips('misc_focus_add_tips');
showformheader('misc&operation=focus&do=handadd');
showtableheader('misc_focus_handadd', 'fixpadding');
showsetting('misc_focus_handurl', 'focus_url', '', 'text');
showsetting('misc_focus_handsubject' , 'focus_subject', '', 'text');
showsetting('misc_focus_handsummary', 'focus_summary', '', 'textarea');
showsetting('misc_focus_handimg', 'focus_image', '', 'text');
showsubmit('addsubmit', 'submit', '', '');
showtablefooter();
showformfooter();
} else {
if($focus_url && $focus_subject && $focus_summary) {
if(is_array($focus['data'])) {
foreach($focus['data'] as $item) {
if($item['url'] == $focus_url) {
cpmsg('focus_topic_exists', $BASESCRIPT.'?action=misc&operation=focus&do=threadadd', 'error');
}
}
}
$focus['data'][] = array(
'url' => $focus_url,
'type' => 'hand',
'available' => '1',
'subject' => cutstr($focus_subject, 80),
'summary' => messagecutstr($focus_summary, 150),
'image' => $focus_image,
'aid' => 0,
'filename' => basename($focus_image),
);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('focus', '".addslashes(serialize($focus))."')");
updatecache('focus');
}
cpmsg('focus_add_succeed', $BASESCRIPT.'?action=misc&operation=focus', 'succeed');
}
} elseif($do == 'threadadd') {
if(count($focus['data']) >= 10) {
cpmsg('focus_add_num_limit', $BASESCRIPT.'?action=misc&operation=focus', 'error');
}
if(!submitcheck('addsubmit')) {
shownav('adv', 'misc_focus');
showsubmenu('misc_focus', array(
array('config', 'misc&operation=focus&do=config', 0),
array('admin', 'misc&operation=focus', 0),
array(array('menu' => 'add', 'submenu' => array(
array('misc_focus_handadd', 'misc&operation=focus&do=handadd'),
array('misc_focus_threadadd', 'misc&operation=focus&do=threadadd'),
array('misc_focus_autoadd', 'misc&operation=focus&do=recommend')
)), '', 1),
));
showtips('misc_focus_add_tips');
showformheader('misc&operation=focus&do=threadadd');
showtableheader('misc_focus_threadadd', 'fixpadding');
showsetting('misc_focus_threadurl', 'focus_url', '', 'text');
echo '<input type="hidden" value="" name="focus_tid" id="focus_tid" />';
showtagheader('tbody', 'focus_detail');
showtagfooter('tbody');
showtagheader('tbody', 'fetchthread', TRUE);
echo '<tr><td colspan="15"><div class="fixsel"><input type="button" value="'.lang('misc_focus_get_threadcontent').'" name="fetchthread" class="btn" onclick="fetchThread();" /></div></td></tr>';
showtagfooter('tbody');
showtagheader('tbody', 'addsubmit');
showsubmit('addsubmit', 'submit', '', '<input type="button" class="btn" name="settingsubmit" value="'.lang('misc_focus_reget_threadcontent').'" onclick="fetchThread();" class="act lightlink normal" />');
showtagfooter('tbody');
showtablefooter();
showformfooter();
echo <<<EOT
<script type="text/JavaScript">
function fetchThread() {
var focustid = '';
var focusurl = $('cpform').focus_url.value;
var re = /tid=(\d+)/ig;
var matches = re.exec(focusurl);
if(matches != null) {
focustid = matches[1];
} else {
re = /thread-(\d+)-/ig;
matches = re.exec(focusurl);
if(matches != null) {
focustid = matches[1];
}
}
if(focustid) {
ajaxget('$BASESCRIPT?action=misc&operation=focus&do=fetchthread&id=' + focustid, 'focus_detail');
$('fetchthread').style.display = 'none';
$('focus_detail').style.display = '';
$('addsubmit').style.display = '';
$('focus_tid').value = focustid;
} else {
alert('$lang[misc_focus_invalidurl]');
}
}
</script>
EOT;
} else {
if($focus_tid && $focus_subject && $focus_summary) {
$focus_url = 'viewthread.php?tid='.$focus_tid;
foreach($focus['data'] as $item) {
if($item['url'] == $focus_url) {
cpmsg('focus_topic_exists', $BASESCRIPT.'?action=misc&operation=focus&do=threadadd', 'error');
}
}
$focus['data'][] = array(
'url' => $focus_url,
'tid' => $focus_tid,
'type' => 'thread',
'available' => '1',
'subject' => cutstr($focus_subject, 80),
'summary' => messagecutstr($focus_summary, 150),
'image' => ($focus_aid = intval($focus_aid)) ? "image.php?aid=$focus_aid&size=58x58&key=".rawurlencode(authcode($focus_aid."\t58\t58", 'ENCODE', $_DCACHE['settings']['authkey'])) : '',
'aid' => $focus_aid,
'filename' => $focus_filename,
);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('focus', '".addslashes(serialize($focus))."')");
updatecache('focus');
}
cpmsg('focus_add_succeed', $BASESCRIPT.'?action=misc&operation=focus', 'succeed');
}
} elseif($do == 'recommend') {
if(count($focus['data']) >= 10) {
cpmsg('focus_add_num_limit', $BASESCRIPT.'?action=misc&operation=focus', 'error');
}
$focustids = $comma = '';
if(is_array($focus['data'])) {
foreach($focus['data'] as $k => $v) {
$focustids .= $comma.$k;
$comma = ',';
}
}
$page = max(1, intval($page));
$start_limit = ($page - 1) * 10;
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}forumrecommend".($focustids ? " WHERE tid NOT IN ($focustids)" : ''));
$multipage = multi($num, 10, $page, $BASESCRIPT.'?action=misc&operation=focus&do=recommend');
$recommends = array();
$query = $db->query("SELECT f.fid, f.tid, f.moderatorid, f.aid, m.username as moderator, p.authorid, p.author, p.subject, p.message, a.filename FROM {$tablepre}forumrecommend f
LEFT JOIN {$tablepre}members m ON f.moderatorid=m.uid
LEFT JOIN {$tablepre}posts p ON p.tid=f.tid AND p.first='1'
LEFT JOIN {$tablepre}attachments a ON a.aid=f.aid
".($focustids ? " WHERE f.tid NOT IN ($focustids)" : '')."
LIMIT $start_limit, 10");
while($recommend = $db->fetch_array($query)) {
$recommends[$recommend['tid']] = $recommend;
}
if(!submitcheck('recommendsubmit')) {
shownav('adv', 'misc_focus');
showsubmenu('misc_focus', array(
array('config', 'misc&operation=focus&do=config', 0),
array('admin', 'misc&operation=focus', 0),
array(array('menu' => 'add', 'submenu' => array(
array('misc_focus_handadd', 'misc&operation=focus&do=handadd'),
array('misc_focus_threadadd', 'misc&operation=focus&do=threadadd'),
array('misc_focus_autoadd', 'misc&operation=focus&do=recommend')
)), '', 1),
));
showtips('misc_focus_recommend_tips');
showformheader('misc&operation=focus&do=recommend&page='.$page);
showtableheader('misc_focus_autoadd', 'fixpadding');
showsubtitle(array('', 'subject', 'forum', 'author', 'misc_focus_recommender'));
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
foreach($recommends as $recommend) {
showtablerow('', array('class="td25"', '', '', '', 'class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"recommendtids[]\" value=\"$recommend[tid]\" checked=\"checked\" />",
'<a href="viewthread.php?tid='.$recommend['tid'].'" target="_blank">'.$recommend['subject'].'</a>',
'<a href="forumdisplay.php?fid='.$recommend['fid'].'" target="_blank">'.$_DCACHE['forums'][$recommend['fid']]['name'].'</a>',
'<a href="space.php?uid='.$recommend['authorid'].'" target="_blank">'.$recommend['author'].'</a>',
$recommend['moderatorid'] ? '<a href="space.php?uid='.$recommend['moderatorid'].'" target="_blank">'.$recommend['moderator'].'</a>' : 'System'
));
}
showsubmit('recommendsubmit', 'submit', '<input name="chkall" id="chkall" type="checkbox" class="checkbox" checked="checked" onclick="checkAll(\'prefix\', this.form, \'recommendtids\', \'chkall\')" /><label for="chkall">'.lang('select_all').'</label>', '', $multipage);
showtablefooter();
showformfooter();
} else {
if(is_array($recommendtids) && !empty($recommendtids)) {
$num = count($focus['data']);
foreach($recommendtids as $recommendtid) {
if($num >= 10) {
break;
}
$focus_url = 'viewthread.php?tid='.$recommendtid;
foreach($focus['data'] as $item) {
if($item['url'] == $focus_url) {
continue 2;
}
}
$num++;
$focus['data'][] = array(
'url' => $focus_url,
'tid' => $recommendtid,
'type' => 'thread',
'available' => '1',
'subject' => cutstr($recommends[$recommendtid]['subject'], 80),
'summary' => messagecutstr($recommends[$recommendtid]['message'], 150),
'image' => $focus_image,
'aid' => $recommends[$recommendtid]['aid'],
'filename' => $recommends[$recommendtid]['filename'],
);
}
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('focus', '".addslashes(serialize($focus))."')");
updatecache('focus');
}
cpmsg('focus_add_succeed', $BASESCRIPT.'?action=misc&operation=focus', 'succeed');
}
} elseif($do == 'edit') {
if(!$item = $focus['data'][$id]) {
cpmsg('focus_topic_noexists', $BASESCRIPT.'?action=misc&operation=focus', 'error');
}
if(!submitcheck('editsubmit')) {
shownav('adv', 'misc_focus');
showsubmenu('misc_focus', array(
array('config', 'misc&operation=focus&do=config', 0),
array('admin', 'misc&operation=focus', 0),
array(array('menu' => 'add', 'submenu' => array(
array('misc_focus_handadd', 'misc&operation=focus&do=handadd'),
array('misc_focus_threadadd', 'misc&operation=focus&do=threadadd'),
array('misc_focus_autoadd', 'misc&operation=focus&do=recommend')
)), '', 0),
));
showformheader('misc&operation=focus&do=edit&id='.$id);
showtableheader('misc_focus_edit', 'fixpadding');
if($item['type'] == 'thread') {
showsetting('misc_focus_threadurl', '', '', '<a href="'.$item['url'].'" target="_blank">'.$item['url'].'</a>');
showsetting('misc_focus_topic_subject', 'focus_subject', $item['subject'], 'text');
showsetting('misc_focus_topic_msg', 'focus_summary', $item['summary'], 'textarea');
$attachlist = $attachkeys = array();
$attachlist[] = array('', lang('select'));
$attachlist[] = array(0, lang('misc_focus_noimage'));
$thread = $db->fetch_first("SELECT pid, attachment FROM {$tablepre}posts WHERE tid='$item[tid]' AND first='1'");
if($thread['attachment']) {
$query = $db->query("SELECT aid, filename FROM {$tablepre}attachments WHERE pid='$thread[pid]' AND isimage IN ('1', '-1')");
while($attach = $db->fetch_array($query)) {
$attachlist[] = array($attach['aid'], $attach['filename']);
$attachkeys[$attach['aid']] = rawurlencode(authcode("$attach[aid]\t58\t58", 'ENCODE', $_DCACHE['settings']['authkey']));
}
}
if(!$attachlist && $item['aid']) {
$attachlist[] = array($item['aid'], $item['filename']);
$attachkeys[$item['aid']] = rawurlencode(authcode($item['aid']."\t58\t58", 'ENCODE', $_DCACHE['settings']['authkey']));
}
if($attachkeys) {
showsetting('misc_focus_image', array('focus_aid', $attachlist), $item['aid'], 'select');
showsetting('', 'focus_img', '', '<div id="focus_img_preview">'.($item['aid'] ? '<img src="image.php?aid='.$item['aid'].'&size=58x58&key='.$attachkeys[$item['aid']].'" />' : '').'</div><input type="hidden" name="focus_filename" value="" />');
}
echo '<script type="text/JavaScript">var attachkeys = [];';
foreach($attachkeys as $aid => $key) {
echo 'attachkeys['.$aid.'] = \''.$key.'\';';
}
echo "$('cpform').focus_aid.onchange = function() {\n";
echo "$('focus_img_preview').innerHTML = this.value > 0 ? '<img src=\"image.php?aid=' + this.value + '&size=58x58&key=' + attachkeys[this.value] + '&nocache=yes\" />' : '';";
echo "this.form.focus_filename.value = this.options[this.options.selectedIndex].innerHTML;";
echo "};";
echo "</script>";
} else {
showsetting('misc_focus_handurl', 'focus_url', $item['url'], 'text');
showsetting('misc_focus_handsubject' , 'focus_subject', $item['subject'], 'text');
showsetting('misc_focus_handsummary', 'focus_summary', $item['summary'], 'textarea');
showsetting('misc_focus_handimg', 'focus_image', $item['image'], 'text');
}
showsubmit('editsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
if($focus_subject && $focus_summary) {
if($item['type'] == 'thread') {
$focus_url = $item['url'];
} else {
$focus_filename = basename($focus_image);
}
$item = array(
'url' => $focus_url,
'tid' => $item['tid'],
'type' => $item['type'],
'available' => '1',
'subject' => cutstr($focus_subject, 80),
'summary' => messagecutstr($focus_summary, 150),
'image' => ($focus_aid = intval($focus_aid)) ? "image.php?aid=$focus_aid&size=58x58&key=".rawurlencode(authcode($focus_aid."\t58\t58", 'ENCODE', $_DCACHE['settings']['authkey'])) : $focus_image,
'aid' => $focus_aid,
'filename' => $focus_filename,
);
$focus['data'][$id] = $item;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('focus', '".addslashes(serialize($focus))."')");
updatecache('focus');
}
cpmsg('focus_edit_succeed', $BASESCRIPT.'?action=misc&operation=focus', 'succeed');
}
} elseif($do == 'config') {
if(!submitcheck('confsubmit')) {
shownav('adv', 'misc_focus');
showsubmenu('misc_focus', array(
array('config', 'misc&operation=focus&do=config', 1),
array('admin', 'misc&operation=focus', 0),
array(array('menu' => 'add', 'submenu' => array(
array('misc_focus_handadd', 'misc&operation=focus&do=handadd'),
array('misc_focus_threadadd', 'misc&operation=focus&do=threadadd'),
array('misc_focus_autoadd', 'misc&operation=focus&do=recommend')
)), '', 0),
));
showformheader('misc&operation=focus&do=config');
showtableheader('config', 'fixpadding');
showsetting('misc_focus_area_title', 'focus_title', empty($focus['title']) ? lang('misc_focus') : $focus['title'], 'text');
showsubmit('confsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$focus['title'] = trim($focus_title);
$focus['title'] = empty($focus['title']) ? lang('misc_focus') : $focus['title'];
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('focus', '".addslashes(serialize($focus))."')");
updatecache('focus');
cpmsg('focus_conf_succeed', $BASESCRIPT.'?action=misc&operation=focus&do=config', 'succeed');
}
} elseif($do == 'fetchthread' && $id) {
$thread = $db->fetch_first("SELECT pid, subject, message, attachment FROM {$tablepre}posts WHERE tid='$id' AND first='1'");
ajaxshowheader();
if(!$thread) {
echo '<script type="text/JavaScript">alert(\''.lang('misc_focus_nothread').'\');</script>';
ajaxshowfooter();
exit;
}
showsetting('misc_focus_topic_subject', 'focus_subject', $thread['subject'], 'text');
showsetting('misc_focus_topic_msg', 'focus_summary', messagecutstr($thread['message'], 150), 'textarea');
if($thread['attachment']) {
$attachlist = $attachkeys = array();
$attachlist[] = array('', lang('select'));
$attachlist[] = array(0, lang('misc_focus_noimage'));
$query = $db->query("SELECT aid, filename FROM {$tablepre}attachments WHERE pid='$thread[pid]' AND isimage IN ('1', '-1')");
while($attach = $db->fetch_array($query)) {
$attachlist[] = array($attach['aid'], $attach['filename']);
$attachkeys[$attach['aid']] = rawurlencode(authcode("$attach[aid]\t58\t58", 'ENCODE', $_DCACHE['settings']['authkey']));
}
if($attachkeys) {
showsetting('misc_focus_image', array('focus_aid', $attachlist), '', 'select');
showsetting('', 'focus_img', '', '<div id="focus_img_preview"></div><input type="hidden" name="focus_filename" value="" />');
}
}
echo '<script type="text/JavaScript">var attachkeys = [];';
foreach($attachkeys as $aid => $key) {
echo 'attachkeys['.$aid.'] = \''.$key.'\';';
}
echo <<<EOT
$('cpform').focus_aid.onchange = function() {
$('focus_img_preview').innerHTML = this.value > 0 ? '<img src="image.php?aid=' + this.value + '&size=58x58&key=' + attachkeys[this.value] + '&nocache=yes" />' : '';
this.form.focus_filename.value = this.options[this.options.selectedIndex].innerHTML;
};
</script>
EOT;
ajaxshowfooter();
exit;
}
} elseif($operation == 'checkstat') {
if($statid && $statkey) {
$q = "statid=$statid&statkey=$statkey";
$q=rawurlencode(base64_encode($q));
$url = 'http://stat.discuz.com/stat_ins.php?action=checkstat&q='.$q;
$key = dfopen($url);
$newstatdisable = $key == $statkey ? 0 : 1;
if($newstatdisable != $statdisable) {
$db->query("REPLACE {$tablepre}settings SET variable='statdisable', value='$newstatdisable'");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('settings');
}
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/misc.inc.php | PHP | asf20 | 78,011 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: zip.func.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
// vim: expandtab sw=4 ts=4 sts=4:
class zipfile {
var $datasec = array();
var $ctrl_dir = array();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0;
function unix2DosTime($unixtime = 0) {
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
} // end if
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} // end of the 'unix2DosTime()' method
function addFile($data, $name, $time = 0) {
$name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix2DosTime($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3]
. '\x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";');
$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00"; // ver needed to extract
$fr .= "\x00\x00"; // gen purpose bit flag
$fr .= "\x08\x00"; // compression method
$fr .= $hexdtime; // last mod time and date
// "local file header" segment
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$c_len = strlen($zdata);
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
$fr .= pack('v', strlen($name)); // length of filename
$fr .= pack('v', 0); // extra field length
$fr .= $name;
// "file data" segment
$fr .= $zdata;
// "data descriptor" segment (optional but necessary if archive is not
// served as file)
// nijel(2004-10-19): this seems not to be needed at all and causes
// problems in some cases (bug #1037737)
//$fr .= pack('V', $crc); // crc32
//$fr .= pack('V', $c_len); // compressed filesize
//$fr .= pack('V', $unc_len); // uncompressed filesize
// add this entry to array
$this -> datasec[] = $fr;
// now add to central directory record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .= "\x00\x00"; // version made by
$cdrec .= "\x14\x00"; // version needed to extract
$cdrec .= "\x00\x00"; // gen purpose bit flag
$cdrec .= "\x08\x00"; // compression method
$cdrec .= $hexdtime; // last mod time & date
$cdrec .= pack('V', $crc); // crc32
$cdrec .= pack('V', $c_len); // compressed filesize
$cdrec .= pack('V', $unc_len); // uncompressed filesize
$cdrec .= pack('v', strlen($name) ); // length of filename
$cdrec .= pack('v', 0 ); // extra field length
$cdrec .= pack('v', 0 ); // file comment length
$cdrec .= pack('v', 0 ); // disk number start
$cdrec .= pack('v', 0 ); // internal file attributes
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
$this -> old_offset += strlen($fr);
$cdrec .= $name;
// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
} // end of the 'addFile()' method
function file() {
$data = implode('', $this -> datasec);
$ctrldir = implode('', $this -> ctrl_dir);
return
$data .
$ctrldir .
$this -> eof_ctrl_dir .
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
pack('V', strlen($ctrldir)) . // size of central dir
pack('V', strlen($data)) . // offset to start of central dir
"\x00\x00"; // .zip file comment length
} // end of the 'file()' method
} // end of the 'zipfile' class
class SimpleUnzip {
// 2003-12-02 - HB >
var $Comment = '';
// 2003-12-02 - HB <
var $Entries = array();
var $Name = '';
var $Size = 0;
var $Time = 0;
function SimpleUnzip($in_FileName = '') {
if($in_FileName !== '') {
SimpleUnzip::ReadFile($in_FileName);
}
} // end of the 'SimpleUnzip' constructor
function Count() {
return count($this->Entries);
} // end of the 'Count()' method
function GetData($in_Index) {
return $this->Entries[$in_Index]->Data;
} // end of the 'GetData()' method
function GetEntry($in_Index) {
return $this->Entries[$in_Index];
} // end of the 'GetEntry()' method
function GetError($in_Index) {
return $this->Entries[$in_Index]->Error;
} // end of the 'GetError()' method
function GetErrorMsg($in_Index) {
return $this->Entries[$in_Index]->ErrorMsg;
} // end of the 'GetErrorMsg()' method
function GetName($in_Index) {
return $this->Entries[$in_Index]->Name;
} // end of the 'GetName()' method
function GetPath($in_Index) {
return $this->Entries[$in_Index]->Path;
} // end of the 'GetPath()' method
function GetTime($in_Index) {
return $this->Entries[$in_Index]->Time;
} // end of the 'GetTime()' method
function ReadFile($in_FileName) {
$this->Entries = array();
// Get file parameters
$this->Name = $in_FileName;
$this->Time = filemtime($in_FileName);
$this->Size = filesize($in_FileName);
// Read file
$oF = fopen($in_FileName, 'rb');
$vZ = fread($oF, $this->Size);
fclose($oF);
// 2003-12-02 - HB >
// Cut end of central directory
$aE = explode("\x50\x4b\x05\x06", $vZ);
// Easiest way, but not sure if format changes
//$this->Comment = substr($aE[1], 18);
// Normal way
$aP = unpack('x16/v1CL', $aE[1]);
$this->Comment = substr($aE[1], 18, $aP['CL']);
// Translates end of line from other operating systems
$this->Comment = strtr($this->Comment, array("\r\n" => "\n",
"\r" => "\n"));
// 2003-12-02 - HB <
// Cut the entries from the central directory
$aE = explode("\x50\x4b\x01\x02", $vZ);
// Explode to each part
$aE = explode("\x50\x4b\x03\x04", $aE[0]);
// Shift out spanning signature or empty entry
array_shift($aE);
// Loop through the entries
foreach($aE as $vZ) {
$aI = array();
$aI['E'] = 0;
$aI['EM'] = '';
// Retrieving local file header information
$aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ);
// Check if data is encrypted
$bE = ($aP['GPF'] && 0x0001) ? TRUE : FALSE;
$nF = $aP['FNL'];
// Special case : value block after the compressed data
if($aP['GPF'] & 0x0008) {
$aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
$aP['CRC'] = $aP1['CRC'];
$aP['CS'] = $aP1['CS'];
$aP['UCS'] = $aP1['UCS'];
$vZ = substr($vZ, 0, -12);
}
// Getting stored filename
$aI['N'] = substr($vZ, 26, $nF);
if(substr($aI['N'], -1) == '/') {
// is a directory entry - will be skipped
continue;
}
// Truncate full filename in path and filename
$aI['P'] = dirname($aI['N']);
$aI['P'] = $aI['P'] == '.' ? '' : $aI['P'];
$aI['N'] = basename($aI['N']);
$vZ = substr($vZ, 26 + $nF);
if(strlen($vZ) != $aP['CS']) {
$aI['E'] = 1;
$aI['EM'] = 'Compressed size is not equal with the value in header information.';
} else {
if($bE) {
$aI['E'] = 5;
$aI['EM'] = 'File is encrypted, which is not supported from this class.';
} else {
switch($aP['CM']) {
case 0: // Stored
// Here is nothing to do, the file ist flat.
break;
case 8: // Deflated
$vZ = gzinflate($vZ);
break;
case 12: // BZIP2
// 2003-12-02 - HB >
if(! extension_loaded('bz2')) {
if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
@dl('php_bz2.dll');
} else {
@dl('bz2.so');
}
}
if(extension_loaded('bz2')) {
// 2003-12-02 - HB <
$vZ = bzdecompress($vZ);
// 2003-12-02 - HB >
} else {
$aI['E'] = 7;
$aI['EM'] = "PHP BZIP2 extension not available.";
}
// 2003-12-02 - HB <
break;
default:
$aI['E'] = 6;
$aI['EM'] = "De-/Compression method {$aP['CM']} is not supported.";
}
// 2003-12-02 - HB >
if(! $aI['E']) {
// 2003-12-02 - HB <
if($vZ === FALSE) {
$aI['E'] = 2;
$aI['EM'] = 'Decompression of data failed.';
} else {
if(strlen($vZ) != $aP['UCS']) {
$aI['E'] = 3;
$aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
} else {
if(crc32($vZ) != $aP['CRC']) {
$aI['E'] = 4;
$aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
}
}
}
// 2003-12-02 - HB >
}
// 2003-12-02 - HB <
}
}
$aI['D'] = $vZ;
// DOS to UNIX timestamp
$aI['T'] = mktime(($aP['FT'] & 0xf800) >> 11,
($aP['FT'] & 0x07e0) >> 5,
($aP['FT'] & 0x001f) << 1,
($aP['FD'] & 0x01e0) >> 5,
($aP['FD'] & 0x001f),
(($aP['FD'] & 0xfe00) >> 9) + 1980);
$this->Entries[] = &new SimpleUnzipEntry($aI);
} // end for each entries
return $this->Entries;
} // end of the 'ReadFile()' method
} // end of the 'SimpleUnzip' class
class SimpleUnzipEntry {
var $Data = '';
var $Error = 0;
var $ErrorMsg = '';
var $Name = '';
var $Path = '';
var $Time = 0;
function SimpleUnzipEntry($in_Entry) {
$this->Data = $in_Entry['D'];
$this->Error = $in_Entry['E'];
$this->ErrorMsg = $in_Entry['EM'];
$this->Name = $in_Entry['N'];
$this->Path = $in_Entry['P'];
$this->Time = $in_Entry['T'];
} // end of the 'SimpleUnzipEntry' constructor
} // end of the 'SimpleUnzipEntry' class
?>
| zyyhong | trunk/jiaju001/newbbs/bbs/admin/zip.func.php | PHP | asf20 | 13,678 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: templates.inc.php 17432 2008-12-20 13:28:29Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$operation = empty($operation) ? 'admin' : $operation;
if($operation == 'admin') {
if(!submitcheck('tplsubmit')) {
$templates = '';
$query = $db->query("SELECT * FROM {$tablepre}templates");
while($tpl = $db->fetch_array($query)) {
$templates .= showtablerow('', array('class="td25"', '', 'class="td29"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" ".($tpl[templateid] == 1 ? 'disabled ' : '')."value=\"$tpl[templateid]\">",
"<input type=\"text\" class=\"txt\" size=\"8\" name=\"namenew[$tpl[templateid]]\" value=\"$tpl[name]\">",
"<input type=\"text\" class=\"txt\" size=\"20\" name=\"directorynew[$tpl[templateid]]\" value=\"$tpl[directory]\">",
!empty($tpl['copyright']) ? $tpl['copyright'] : "<input type=\"text\" class=\"txt\" size=\"8\" name=\"copyrightnew[$tpl[templateid]]\" value=>",
"<a href=\"$BASESCRIPT?action=templates&operation=maint&id=$tpl[templateid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
shownav('style', 'templates_admin');
showsubmenu('templates_admin');
showformheader('templates');
showtableheader();
showsubtitle(array('', 'templates_admin_name', 'dir', 'copyright', ''));
echo $templates;
echo '<tr><td>'.$lang['add_new'].'</td><td><input type="text" class="txt" size="8" name="newname"></td><td class="td29"><input type="text" class="txt" size="20" name="newdirectory"></td><td><input type="text" class="txt" size="25" name="newcopyright"></td><td> </td></tr>';
showsubmit('tplsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($newname) {
if(!$newdirectory) {
cpmsg('tpl_new_directory_invalid', '', 'error');
} elseif(!istpldir($newdirectory)) {
$directory = $newdirectory;
cpmsg('tpl_directory_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}templates (name, directory, copyright)
VALUES ('$newname', '$newdirectory', '$newcopyright')", 'UNBUFFERED');
}
foreach($directorynew as $id => $directory) {
if(!$delete || ($delete && !in_array($id, $delete))) {
if(!istpldir($directory)) {
cpmsg('tpl_directory_invalid', '', 'error');
} elseif($id == 1 && $directory != './templates/default') {
cpmsg('tpl_default_directory_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}templates SET name='$namenew[$id]', directory='$directorynew[$id]' WHERE templateid='$id'", 'UNBUFFERED');
if(!empty($copyrightnew[$id])) {
$db->query("UPDATE {$tablepre}templates SET copyright='$copyrightnew[$id]' WHERE templateid='$id' AND copyright=''", 'UNBUFFERED');
}
}
}
if(is_array($delete)) {
if(in_array('1', $delete)) {
cpmsg('tpl_delete_invalid', '', 'error');
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}templates WHERE templateid IN ($ids) AND templateid<>'1'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}styles SET templateid='1' WHERE templateid IN ($ids)", 'UNBUFFERED');
}
}
updatecache('styles');
cpmsg('tpl_update_succeed', $BASESCRIPT.'?action=templates', 'succeed');
}
} elseif($operation == 'maint') {
if(empty($id)) {
$tplselect = "<select name=\"id\" style=\"width: 150px\">\n";
$query = $db->query("SELECT templateid, name FROM {$tablepre}templates");
while($tpl = $db->fetch_array($query)) {
$tplselect .= "<option value=\"$tpl[templateid]\">$tpl[name]</option>\n";
}
$tplselect .= '</select>';
cpmsg('templates_edit_select', $BASESCRIPT.'?action=templates&operation=maint'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $tplselect);
}
$template = $db->fetch_first("SELECT * FROM {$tablepre}templates WHERE templateid='$id'");
if(!$template) {
cpmsg('undefined_action', '', 'error');
} elseif(!istpldir($template['directory'])) {
$directory = $template['directory'];
cpmsg('tpl_directory_invalid', '', 'error');
}
$warning = $template['templateid'] == 1 ? 'templates_maint_default_comment' : 'templates_maint_nondefault_comment';
if($keyword) {
$keywordadd = " - $lang[templates_maint_keyword] <i>".dhtmlspecialchars(stripslashes($keyword))."</i> - <a href=\"$BASESCRIPT?action=templates&operation=maint&id=$id\">[$lang[templates_maint_view_all]]</a>";
$keywordenc = rawurlencode($keyword);
}
$tpldir = dir(DISCUZ_ROOT.'./'.$template['directory']);
$tplarray = $langarray = $differ = $new = array();
while($entry = $tpldir->read()) {
$extension = strtolower(fileext($entry));
if($extension == 'htm' || $extension == 'php') {
if($extension == 'htm') {
$tplname = substr($entry, 0, -4);
$pos = strpos($tplname, '_');
if($keyword) {
if(!stristr(implode("\n", file(DISCUZ_ROOT."./$template[directory]/$entry")), $keyword)) {
continue;
}
}
if(!$pos) {
$tplarray[$tplname][] = $tplname;
} else {
$tplarray[substr($tplname, 0, $pos)][] = $tplname;
}
} else {
$langarray[] = substr($entry, 0, -9);
}
if($template['templateid'] != 1) {
if(file_exists(DISCUZ_ROOT."./templates/default/$entry")) {
if(md5_file(DISCUZ_ROOT."./templates/default/$entry") != md5_file(DISCUZ_ROOT."./$template[directory]/$entry")) {
$differ[] = $entry;
}
} else {
$new[] = $entry;
}
}
}
}
$tpldir->close();
ksort($tplarray);
ksort($langarray);
$templates = $languages = '';
$allowedittpls = checkpermission('tpledit', 0);
foreach($tplarray as $tpl => $subtpls) {
$templates .= "<li><h5>$tpl</h5><ul class=\"tpllist3\">";
foreach($subtpls as $subtpl) {
$filename = "$subtpl.htm";
$resetlink = '';
if(in_array($filename, $differ)) {
$subtpl = '<font color=\'#FF0000\'>'.$subtpl.'</font>';
$resetlink = " <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$filename&reset=yes\" class=\"act\">$lang[templates_maint_reset]</a>";
}
if(in_array($filename, $new)) {
$subtpl = '<font color=\'#00FF00\'>'.$subtpl.'</font>';
}
$templates .= '<li>';
if($allowedittpls) {
$templates .= "$subtpl <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$filename&keyword=$keywordenc\" class=\"act\">$lang[edit]</a> ".
"<a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$filename&delete=yes\" class=\"act\">$lang[delete]</a>$resetlink";
} else {
$templates .= "$subtpl <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$filename&keyword=$keywordenc\" class=\"act\">$lang[view]</a> ";
}
$templates .= '</li>';
}
$templates .= "</ul></li>";
}
$languages .= '<ul class="tpllist3">';
foreach($langarray as $langpack) {
$resetlink = '';
$langpackname = $langpack;
if(is_array($differ) && in_array($langpack.'.lang.php', $differ)) {
$langpackname = '<font color=\'#FF0000\'>'.$langpackname.'</font>';
$resetlink = " <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$langpack.lang.php&reset=yes\" class=\"act\">$lang[templates_maint_reset]</a>";
}
$languages .= '<li>';
if($allowedittpls) {
$languages .= "$langpackname <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$langpack.lang.php\" class=\"act\">$lang[edit]</a>";
$languages .= $template['templateid'] != 1 ? " <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$langpack.lang.php&delete=yes\" class=\"act\">$lang[delete]</a>" : '';
$languages .= "$resetlink";
} else {
$languages .= "$langpackname <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$langpack.lang.php\" class=\"act\">$lang[view]</a>";
}
$languages .= '</li>';
}
$languages .= '</ul>';
shownav('style', 'templates_maint');
showsubmenu(lang('templates_maint').' - '.$template['name']);
showtips($warning);
showtableheader('', 'nobottom fixpadding');
showformheader("templates&operation=add&id=$id");
showtablerow('', array('class="td21"', 'class="td22"'), array(
lang('templates_maint_new'),
'<input type="text" class="txt" name="name" size="40" maxlength="40">',
'<input type="submit" class="btn" value="'.lang('submit').'">'
));
showformfooter();
showformheader("templates&operation=maint&id=$id");
showtablerow('', array('class="td21"', 'class="td22"'), array(
lang('templates_maint_search'),
'<input type="text" class="txt" name="keyword" size="40">',
'<input type="submit" class="btn" value="'.lang('submit').'">'
));
showformfooter();
showtablefooter();
showtableheader(lang('templates_maint_select').$keywordadd, 'notop fixpadding');
?>
<tr><td style="background:none;">
<ul class="tpllist">
<li>
<h4>Discuz! <?=$lang['templates_maint_language_pack']?></h4>
<ul class="tpllist2">
<?=$languages?>
</ul>
</li>
<li>
<h4>Discuz! <?=$lang['templates_maint_html']?></h4>
<ul class="tpllist2">
<?=$templates?>
</ul>
</li>
</ul>
</td></tr>
<?
showtablefooter();
} elseif($operation == 'copy') {
checkpermission('tpledit');
$srctemplate = $db->fetch_first("SELECT directory FROM {$tablepre}templates WHERE templateid='$templateid'");
if(!$srctemplate) {
cpmsg('tpl_edit_nonexistence', '', 'error');
}
$desctemplate = $db->fetch_first("SELECT directory FROM {$tablepre}templates WHERE templateid='$copyto'");
if(!$desctemplate) {
cpmsg('tpl_edit_nonexistence', '', 'error');
}
if(!file_exists(DISCUZ_ROOT.$desctemplate['directory'])) {
$directory = $desctemplate['directory'];
cpmsg('tpl_directory_invalid', '', 'error');
}
$newfilename = DISCUZ_ROOT.$desctemplate['directory']."/$fn";
if(file_exists($newfilename) && !$confirmed) {
cpmsg('tpl_desctpl_exists', "$BASESCRIPT?action=templates&operation=copy&templateid=$templateid&fn=$fn©to=$copyto", 'form');
}
if(!copy(DISCUZ_ROOT."./$srctemplate[directory]/$fn", $newfilename)) {
cpmsg('tpl_tplcopy_invalid', '', 'error');
}
cpmsg('tpl_tplcopy_succeed', "$BASESCRIPT?action=templates&operation=edit&templateid=$templateid&fn=$fn", 'succeed');
} elseif($operation == 'edit') {
$allowedittpls = checkpermission('tpledit', 0);
$template = $db->fetch_first("SELECT * FROM {$tablepre}templates WHERE templateid='$templateid'");
if(!$template) {
cpmsg('tpl_edit_nonexistence', '', 'error');
}
$directorys = '';
$query = $db->query("SELECT templateid, directory FROM {$tablepre}templates WHERE templateid!='$templateid' GROUP BY directory");
while($directory = $db->fetch_array($query)) {
$directorys .='<option value="'.$directory['templateid'].'">'.$directory['directory'].'</option>';
}
$fn = str_replace(array('..', '/', '\\'), array('', '', ''), $fn);
$filename = DISCUZ_ROOT."./$template[directory]/$fn";
if(!is_writeable($filename)) {
cpmsg('tpl_edit_invalid', '', 'error');
}
$keywordenc = rawurlencode($keyword);
if(!submitcheck('editsubmit') && $delete != 'yes' && $reset != 'yes') {
$islang = FALSE;
if(preg_match('/\.lang\.php$/i', $filename)) {
$currentlang = $lang;
$currentmsglang = $msglang;
unset($lang, $msglang);
include $filename;
$islang = TRUE;
$langinputs = '';
isset($actioncode) && $langinputs .= langedit('actioncode');
isset($language) && $langinputs .= langedit('language');
isset($lang) && $langinputs .= langedit('lang');
isset($msglang) && $langinputs .= langedit('msglang');
isset($spacelanguage) && $langinputs .= langedit('spacelanguage');
$lang = $currentlang;
$msglang = $currentmsglang;
} else {
$fp = @fopen($filename, 'rb');
$content = @fread($fp, filesize($filename));
fclose($fp);
}
$resetbutton = $onclickevent = $checkresult = '';
if($template['templateid'] != 1) {
$defaulttpl = DISCUZ_ROOT."./templates/default/$fn";
if(file_exists($defaulttpl) && md5_file($defaulttpl) != md5_file($filename)) {
$resetbutton = ' <input style="vertical-align: middle" type="button" class="btn" value="'.$lang['templates_edit_reset'].'" accesskey="r" onclick="location.href=\''.$BASESCRIPT.'?action=templates&operation=edit&templateid='.$template['templateid'].'&fn='.$fn.'&keyword='.$keywordenc.'&reset=yes\'"> '.
(strtolower(fileext($fn)) == 'htm' ? '<input style="vertical-align: middle" type="button" class="btn" value="'.$lang['templates_edit_diff'].'" onclick="location.href=\''.$BASESCRIPT.'?action=templates&operation=edit&templateid='.$template['templateid'].'&fn='.$fn.'&keyword='.$keywordenc.'&checktpl=yes\'"> ' : '');
}
$dellist = $addlist = array();
if($checktpl && strtolower(fileext($fn)) == 'htm') {
$fp = @fopen($defaulttpl, 'rb');
$defaultcontent = @fread($fp, filesize($defaulttpl));
fclose($fp);
require_once DISCUZ_ROOT.'./include/diff.class.php';
$a = new Diff($content, $defaultcontent);
$entries = $a->fetch_diff();
$result = '<br /><table class="tb tb2 nobdb" width="100%" border="0" cellpadding="0" cellspacing="0"><tr class="partition"><td>'.$lang['templates_edit_diff_current'].'</td><td> </td><td>'.$lang['templates_edit_diff_default'].'</td></tr>';
foreach ($entries as $diff_entry) {
$result .= '<tr><th width="49.5%" valign="top" class="diff-'.$diff_entry->left_class().'">'.
$diff_entry->diff_text($diff_entry->left).'</th><th width="1%"> </th>'.
'<th width="49.5%" valign="top" class="diff-'.$diff_entry->right_class().'">'.
$diff_entry->diff_text($diff_entry->right)."</th></tr>";
}
$result .= '</table><br /><table class="tb tb2 nobdb" width="100%" border="0" cellpadding="4" cellspacing="0">'.
'<tr><th class="diff-deleted" style="text-align: center">'.$lang['templates_edit_diff_deleted'].'</th><th class="diff-notext"> </th></tr>'.
'<tr><th class="diff-changed" style="text-align: center" colspan="2">'.$lang['templates_edit_diff_changed'].' </th></tr>'.
'<tr><th class="diff-notext"> </th><th class="diff-added" style="text-align: center">'.$lang['templates_edit_diff_added'].'</th></tr></table>';
$checkresult = $result;
}
} else {
$onclickevent = 'onclick="return confirm(\''.$lang['templates_edit_default_overwriteconfirm'].'\')"';
}
$content = dhtmlspecialchars($content);
$filemtime = date("$dateformat $timeformat", filemtime($filename));
?>
<script language="JavaScript">
var n = 0;
function displayHTML(obj) {
win = window.open(" ", 'popup', 'toolbar = no, status = no, scrollbars=yes');
win.document.write("" + obj.value + "");
}
function HighlightAll(obj) {
obj.focus();
obj.select();
if(document.all) {
obj.createTextRange().execCommand("Copy");
window.status = "<?=$lang['templates_edit_clickboard']?>";
setTimeout("window.status=''", 1800);
}
}
function findInPage(obj, str, noalert) {
var txt, i, found;
if(str == "") {
return false;
}
if(document.layers) {
if(!obj.find(str)) {
while(obj.find(str, false, true)) {
n++;
}
} else {
n++;
}
if(n == 0 && !noalert) {
alert("<?=$lang['templates_edit_keyword_not_found']?>");
}
}
if(document.all) {
txt = obj.createTextRange();
for(i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart('character', 1);
txt.moveEnd('textedit');
}
if(found) {
txt.moveStart('character', -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
return true;
} else {
if(n > 0) {
n = 0;
findInPage(obj, str, noalert);
} else if(!noalert) {
alert("<?=$lang['templates_edit_keyword_not_found']?>");
}
}
}
return false;
}
<?
if($islang) {
?>
var ni = 0;
var niprev = 0;
function MultifindInPage(obj, str) {
for(var i = ni; i < obj.elements.length; i++) {
if(obj.elements[i].type == 'textarea') {
if(findInPage(obj.elements[i], str, 1)) {
ni = i;
break;
}
}
if(i == obj.elements.length - 1) ni = 0;
}
}
<?
}
?>
</script>
<?
shownav('style', 'templates_edit');
showsubmenu("$lang[templates_edit] - $template[name] $fn - $lang[lastmodified]: $filemtime");
showformheader("templates&operation=edit&templateid=$templateid&fn=$fn");
showhiddenfields(array('keyword' => $keywordenc));
?>
<div class="colorbox">
<?
if($islang) {
?>
<div style="margin-bottom:10px;width:99%;height:390px;overflow-y:scroll;overflow-x:hidden;">
<table class="tb tb2" style="border:none">
<tr><td><b><?=$lang['templates_edit_variable']?></b></td><td><b><?=$lang['templates_edit_value']?></b></td></tr>
<?=$langinputs?>
</table>
</div>
<?
} else {
?>
<textarea cols="100" rows="25" name="templatenew" style="margin-bottom:10px;width:99%;height:390px;"><?=$content?></textarea>
<?
}
?>
<input name="search" type="text" class="txt" style="width:150px;" accesskey="t" size="20" onChange="n=0;">
<?
if($islang) {
?>
<input type="button" class="btn" value="<?=$lang['search']?>" accesskey="f" onClick="MultifindInPage(this.form, this.form.search.value)">
<?
} else {
?>
<input type="button" class="btn" value="<?=$lang['search']?>" accesskey="f" onClick="findInPage(this.form.templatenew, this.form.search.value)">
<?
}
?>
<input type="button" class="btn" value="<?=$lang['return']?>" accesskey="e" onClick="location.href='<?=$BASESCRIPT?>?action=templates&operation=maint&id=<?=$templateid?>&keyword=<?=$keywordenc?>'">
<input type="button" class="btn" value="<?=$lang['preview']?>" accesskey="p" onClick="displayHTML(this.form.templatenew)">
<input type="button" class="btn" value="<?=$lang['copy']?>" accesskey="c" onClick="HighlightAll(this.form.templatenew)">
<?
if($allowedittpls) {
echo "<input type=\"submit\" class=\"btn\" name=\"editsubmit\" value=\"$lang[submit]\" $onclickevent><br />";
if($directorys) {
echo $lang['templates_edit_copyto_otherdirs']."<select id=\"copyto\">".
"$directorys</select> <input style=\"vertical-align: middle\" type=\"button\" class=\"btn\" value=\"$lang[templates_edit_start_copy]\" ".
"accesskey=\"r\" onclick=\"if(\$('copyto').value == 1 && confirm('$lang[templates_edit_default_overwriteconfirm]') || \$('copyto').value != 1) location.href='$BASESCRIPT?action=templates&operation=copy&templateid={$template['templateid']}&fn={$fn}©to='+\$('copyto').value\">";
}
echo $resetbutton;
}
echo '</div></form>'.$checkresult;
} elseif($delete == 'yes') {
checkpermission('tpledit');
if(!$confirmed) {
cpmsg('tpl_delete_confirm', "$BASESCRIPT?action=templates&operation=edit&templateid=$templateid&fn=$fn&delete=yes", 'form');
} else {
if(@unlink($filename)) {
cpmsg('tpl_delete_succeed', "$BASESCRIPT?action=templates&operation=maint&id=$templateid", 'succeed');
} else {
cpmsg('tpl_delete_fail', '', 'error');
}
}
} elseif($reset == 'yes') {
checkpermission('tpledit');
if(!$confirmed) {
cpmsg('tpl_reset_confirm', "$BASESCRIPT?action=templates&operation=edit&templateid=$templateid&fn=$fn&keyword=$keywordenc&reset=yes", 'form');
} else {
$defaultfilename = DISCUZ_ROOT.'./templates/default/'.$fn;
$filename = DISCUZ_ROOT."./$template[directory]/$fn";
if(!copy($defaultfilename, $filename)) {
cpmsg('tpl_edit_invalid', '', 'error');
}
cpmsg('tpl_reset_succeed', "$BASESCRIPT?action=templates&operation=maint&id=$templateid&keyword=$keywordenc", 'succeed');
}
} else {
checkpermission('tpledit');
if(preg_match('/\.lang\.php$/i', $filename)) {
$templatenew = '';
foreach($langnew as $key => $value) {
$templatenew .= '$'.$key." = array\n(\n";
foreach($value as $key1 => $value1) {
if(substr($value1, strlen($value1) -1 , 1) == '\\') {
$value1 .= '\\\\';
}
$templatenew .= "\t'$key1' => '".str_replace('\\\\\'', '\\\'', addcslashes(stripslashes(str_replace("\x0d\x0a", "\x0a", $value1)), "'"))."',\n";
}
$templatenew .= ");\n";
}
$templatenew = "<?php\n\n// Language Pack for Discuz! Version 1.0.0\n\n$templatenew\n?>";
} else {
$templatenew = stripslashes(str_replace("\x0d\x0a", "\x0a", $templatenew));
}
$fp = fopen($filename, 'wb');
flock($fp, 2);
fwrite($fp, $templatenew);
fclose($fp);
if(substr(basename($filename), 0, 3) == 'css') {
updatecache('styles');
}
cpmsg('tpl_edit_succeed', "$BASESCRIPT?action=templates&operation=maint&id=$templateid&keyword=$keywordenc", 'succeed');
}
} elseif($operation == 'add') {
checkpermission('tpledit');
$template = $db->fetch_first("SELECT * FROM {$tablepre}templates WHERE templateid='$id'");
if(!$template) {
cpmsg('tpl_add_invalid', '', 'error');
} elseif(!istpldir($template['directory'])) {
$directory = $template['directory'];
cpmsg('tpl_directory_invalid', '', 'error');
} elseif(file_exists(DISCUZ_ROOT."./$template[directory]/$name.htm")) {
cpmsg('tpl_add_duplicate', '', 'error');
} elseif(!@$fp = fopen(DISCUZ_ROOT."./$template[directory]/$name.htm", 'wb')) {
cpmsg('tpl_add_file_invalid', '', 'error');
}
@fclose($fp);
cpmsg('tpl_add_succeed', "$BASESCRIPT?action=templates&operation=edit&templateid=1&fn=$name.htm", 'succeed');
}
function langedit($var) {
global $$var, $currentlang;
$return = '';
foreach($$var as $key => $value) {
$return .= '<tr><td width="100" style="border:0">'.$key.'</td><td style="border:0"><textarea cols="100" rows="3" name="langnew['.$var.']['.$key.']" style="width: 95%;">'.dhtmlspecialchars($value).'</textarea></td></tr>';
}
return $return;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/templates.inc.php | PHP | asf20 | 22,297 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: login.inc.php 20196 2009-09-21 13:29:23Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if($inajax) {
ajaxshowheader();
ajaxshowfooter();
exit;
}
include language('admincp.menu');
echo <<<EOT
<!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>
<title>$menulang[admincp_title]</title>
<meta http-equiv="Content-Type" content="text/html;charset=$charset" />
<link rel="stylesheet" href="images/admincp/admincp.css" type="text/css" media="all" />
<meta content="Comsenz Inc." name="Copyright" />
</head>
<body>
<script language="JavaScript">
if(self.parent.frames.length != 0) {
self.parent.location=document.location;
}
</script>
<table class="logintb">
<tr>
<td class="login">
<h1>Discuz! Administrator's Control Panel</h1>
<p>$lang[login_tips]</p>
</td>
<td>
EOT;
if($cpaccess == 0 || (!$discuz_secques && $admincp['forcesecques'])) {
echo '<p class="logintips">'.$lang[$cpaccess == 0 ? 'noaccess' : 'login_nosecques'].'</p>';
} elseif($cpaccess == 1) {
$extra = '?'.(isset($action) && empty($frames) ? 'frames=yes&' : '').$_SERVER['QUERY_STRING'];
echo <<<EOT
<form method="post" name="login" id="loginform" action="$BASESCRIPT$extra">
<input type="hidden" name="sid" value="$sid">
<input type="hidden" name="frames" value="yes">
<p class="logintitle">$lang[username]: </p>
<p class="loginform">$discuz_userss</p>
<p class="logintitle">$lang[password]:</p>
<p class="loginform"><input name="admin_password" tabindex="1" type="password" class="txt" autocomplete="off" /></p>
<p class="logintitle">$lang[security_question]:</p>
<p class="loginform">
<select id="questionid" name="admin_questionid" tabindex="2">
<option value="0">$lang[security_question_0]</option>
<option value="1">$lang[security_question_1]</option>
<option value="2">$lang[security_question_2]</option>
<option value="3">$lang[security_question_3]</option>
<option value="4">$lang[security_question_4]</option>
<option value="5">$lang[security_question_5]</option>
<option value="6">$lang[security_question_6]</option>
<option value="7">$lang[security_question_7]</option>
</select>
</p>
<p class="logintitle">$lang[security_answer]:</p>
<p class="loginform"><input name="admin_answer" tabindex="3" type="text" class="txt" autocomplete="off" /></p>
<p class="loginnofloat"><input name="submit" value="$lang[submit]" tabindex="3" type="submit" class="btn" /></p>
</form>
<script type="text/JavaScript">document.getElementById('loginform').admin_password.focus();</script>
EOT;
}
echo <<<EOT
</td>
</tr>
<tr>
<td colspan="2" class="footer">
<div class="copyright">
<p>Powered by <a href="http://www.discuz.net/" target="_blank">Discuz!</a> $version </p>
<p>© 2001-2009, <a href="http://www.comsenz.com/" target="_blank">Comsenz</a> Inc.</p>
</div>
</td>
</tr>
</table>
</body>
</html>
EOT;
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/login.inc.php | PHP | asf20 | 3,259 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: adv.inc.php 20881 2009-10-28 09:07:58Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
cpheader();
if(empty($operation)) {
if(!submitcheck('advsubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
shownav('adv', 'adv_admin');
showsubmenu('adv_admin', array(
array('config', 'adv&operation=config', 0),
array('admin', 'adv', 1),
array(array('menu' => 'add', 'submenu' => array(
array('adv_type_headerbanner', 'adv&operation=advadd&type=headerbanner'),
array('adv_type_footerbanner', 'adv&operation=advadd&type=footerbanner'),
array('adv_type_text', 'adv&operation=advadd&type=text'),
array('adv_type_thread', 'adv&operation=advadd&type=thread'),
array('adv_type_interthread', 'adv&operation=advadd&type=interthread'),
array('adv_type_float', 'adv&operation=advadd&type=float'),
array('adv_type_couplebanner', 'adv&operation=advadd&type=couplebanner'),
array('adv_type_intercat', 'adv&operation=advadd&type=intercat'),
)), '', 0)
));
showformheader('adv');
showtableheader();
showsubtitle(array('', 'display_order', 'available', 'subject', 'type', 'adv_style', 'start_time', 'end_time', 'adv_targets', ''));
$advppp = 25;
$conditions = '';
$order_by = 'displayorder, advid DESC, targets DESC';
$page = max(1, intval($page));
$start_limit = ($page - 1) * $advppp;
$conditions .= $title ? " AND title LIKE '%$title%'" : '';
$conditions .= $type ? " AND type='$type'" : '';
$conditions .= $starttime ? " AND starttime>='".($timestamp - $starttime)."'" : '';
$order_by = $orderby == 'starttime' ? 'starttime' : ($orderby == 'type' ? 'type' : ($orderby == 'displayorder' ? 'displayorder' : 'advid DESC'));
$advnum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}advertisements WHERE 1 $conditions");
$query = $db->query("SELECT * FROM {$tablepre}advertisements WHERE 1 $conditions ORDER BY available DESC, $order_by LIMIT $start_limit, $advppp");
while($adv = $db->fetch_array($query)) {
$adv['type'] = $lang['adv_type_'.$adv['type']];
$adv['targets'] = showtargets($adv);
$adv['parameters'] = unserialize($adv['parameters']);
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$adv[advid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$adv[advid]]\" value=\"$adv[displayorder]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$adv[advid]]\" value=\"1\" ".($adv['available'] ? 'checked' : '').">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"titlenew[$adv[advid]]\" value=\"".dhtmlspecialchars($adv['title'])."\">",
$adv[type],
$lang['adv_style_'.$adv['parameters']['style']],
$adv['starttime'] ? gmdate($dateformat, $adv['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : $lang['unlimited'],
$adv['endtime'] ? gmdate($dateformat, $adv['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : $lang['unlimited'],
$adv[targets],
"<a href=\"$BASESCRIPT?action=adv&operation=advedit&advid=$adv[advid]\" class=\"act\">$lang[detail]</a>"
));
}
$multipage = multi($advnum, $advppp, $page, $BASESCRIPT.'?action=adv'.($title ? "&title=$title" : '').($type ? "&type=$type" : '').($starttime ? "&starttime=$starttime" : '').($orderby ? "&orderby=$orderby" : ''), 0, 3, TRUE, TRUE);
$starttimecheck = array($starttime => 'selected="selected"');
$typecheck = array($type => 'selected="selected"');
$orderbycheck = array($orderby => 'selected="selected"');
$title = isset($title) ? $title : $lang['adv_inputtitle'];
showsubmit('advsubmit', 'submit', 'del', '', $multipage.'
<input type="text" class="txt" name="title" value="'.$title.'" size="15" onclick="this.value=\'\'">
<select name="starttime">
<option value=""> '.lang('start_time').'</option>
<option value="0" '.$starttimecheck['0'].'> '.lang('all').'</option>
<option value="86400" '.$starttimecheck['86400'].'> '.lang('1_day').'</option>
<option value="604800" '.$starttimecheck['604800'].'> '.lang('7_day').'</option>
<option value="2592000" '.$starttimecheck['2592000'].'> '.lang('30_day').'</option>
<option value="7776000" '.$starttimecheck['7776000'].'> '.lang('90_day').'</option>
<option value="15552000" '.$starttimecheck['15552000'].'> '.lang('180_day').'</option>
<option value="31536000" '.$starttimecheck['31536000'].'> '.lang('365_day').'</option>
</select>
<select name="type">
<option value=""> '.lang('adv_type').'</option>
<option value="0" '.$typecheck['0'].'> '.lang('all').'</option>
<option value="headerbanner" '.$typecheck['headerbanner'].'> '.lang('adv_type_headerbanner').'
</option><option value="footerbanner" '.$typecheck['footerbanner'].'> '.lang('adv_type_footerbanner').'</option>
<option value="text" '.$typecheck['text'].'> '.lang('adv_type_text').'</option>
<option value="thread" '.$typecheck['thread'].'> '.lang('adv_type_thread').'</option>
<option value="interthread" '.$typecheck['interthread'].'> '.lang('adv_type_interthread').'</option>
<option value="float" '.$typecheck['float'].'> '.lang('adv_type_float').'</option>
<option value="couplebanner" '.$typecheck['couplebanner'].'> '.lang('adv_type_couplebanner').'</option>
<option value="intercat" '.$typecheck['intercat'].'> '.lang('adv_type_intercat').'</option>
</select>
<select name="orderby">
<option value=""> '.lang('adv_orderby').'</option>
<option value="starttime" '.$orderbycheck['starttime'].'> '.lang('adv_addtime').'</option>
<option value="type" '.$orderbycheck['type'].'> '.lang('adv_type').'</option>
<option value="displayorder" '.$orderbycheck['displayorder'].'> '.lang('display_order').'</option>
</select>
<input type="submit" class="btn" name="searchsubmit" value="'.lang('search').'" onclick="if(this.form.title.value==\''.lang('adv_inputtitle').'\'){this.form.title.value=\'\'}window.loacation=\''.$BASESCRIPT.'?action=adv&title=\'+this.form.title.value+\'&starttime=\'+this.form.starttime.value+\'&type=\'+this.form.type.value+\'&orderby=\'+this.form.orderby.value;">
');
showtablefooter();
showformfooter();
} else {
if($advids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}advertisements WHERE advid IN ($advids)");
}
if(is_array($titlenew)) {
foreach($titlenew as $advid => $title) {
$db->query("UPDATE {$tablepre}advertisements SET available='$availablenew[$advid]', displayorder='$displayordernew[$advid]', title='".cutstr($titlenew[$advid], 50)."' WHERE advid='$advid'", 'UNBUFFERED');
}
}
updatecache(array('settings', 'advs_archiver', 'advs_register', 'advs_index', 'advs_forumdisplay', 'advs_viewthread'));
cpmsg('adv_update_succeed', $BASESCRIPT.'?action=adv', 'succeed');
}
} elseif($operation == 'advadd' && in_array($type, array('headerbanner', 'footerbanner', 'text', 'thread', 'interthread', 'float', 'couplebanner', 'intercat')) || ($operation == 'advedit' && $advid)) {
if(!submitcheck('advsubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
shownav('adv', 'adv_admin');
showsubmenu('adv_admin', array(
array('config', 'adv&operation=config', 0),
array('admin', 'adv', 0),
array(array('menu' => 'add', 'submenu' => array(
array('adv_type_headerbanner', 'adv&operation=advadd&type=headerbanner'),
array('adv_type_footerbanner', 'adv&operation=advadd&type=footerbanner'),
array('adv_type_text', 'adv&operation=advadd&type=text'),
array('adv_type_thread', 'adv&operation=advadd&type=thread'),
array('adv_type_interthread', 'adv&operation=advadd&type=interthread'),
array('adv_type_float', 'adv&operation=advadd&type=float'),
array('adv_type_couplebanner', 'adv&operation=advadd&type=couplebanner'),
array('adv_type_intercat', 'adv&operation=advadd&type=intercat'),
)), '', $operation == 'advadd' ? 1 : 0)
));
if($operation == 'advedit') {
$adv = $db->fetch_first("SELECT * FROM {$tablepre}advertisements WHERE advid='$advid'");
if(!$adv) {
cpmsg('undefined_action', '', 'error');
}
$adv['parameters'] = unserialize($adv['parameters']);
if(in_array($adv['type'], array('footerbanner', 'thread'))) {
if($adv['type'] == 'thread') {
$dispchecked = array();
foreach((isset($adv['parameters']['displayorder']) ? explode("\t", $adv['parameters']['displayorder']) : array('0')) as $postcount) {
$dispchecked[$postcount] = ' selected="selected"';
}
}
} elseif($adv['type'] == 'intercat') {
if(is_array($adv['parameters']['position'])) {
$positionchecked = array();
foreach($adv['parameters']['position'] as $position) {
$positionchecked[$position] = ' selected="selected"';
}
} else {
$positionchecked = array(0 => ' selected="selected"');
}
}
$type = $adv['type'];
} else {
$title = cutstr($title, 50);
$style = in_array($style, array('text', 'image', 'flash')) ? $style : 'code';
$adv = array('type' => $type, 'title' => $title, 'parameters' => array('style' => $style), 'starttime' => $timestamp);
$positionchecked = $type == 'intercat' ? array(0 => ' selected="selected"') : array(1 => 'checked');
$dispchecked = array(0 => ' selected="selected"');
}
$adv['targets'] = $adv['targets'] != '' && $adv['targets'] != 'forum' ? explode("\t", $adv['targets']) : array('all');
if($type == 'intercat') {
$targetsselect = '<select name="advnew[targets][]" disabled="disabled"><option value="0"> > '.$lang['home'].'</option></select>';
} else {
$targetsselect = '<select name="advnew[targets][]" size="10" multiple="multiple"><option value="all"> > '.$lang['all'].'</option>'.
'<option value=""> </option>'.
(in_array($type, array('thread', 'interthread')) ? '' : '<option value="0"> > '.$lang['home'].'</option>').
(in_array($type, array('headerbanner', 'footerbanner')) ? '</option><option value="register"> > '.$lang['adv_register'].'</option>'.
'</option><option value="redirect"> > '.$lang['adv_jump'].'</option>'.
'</option><option value="archiver"> > Archiver</option>' : '').
'</option>'.forumselect(in_array($type, array('headerbanner', 'footerbanner', 'text', 'float', 'couplebanner')) ? TRUE : FALSE, 0, 0, TRUE).'</select>';
foreach($adv['targets'] as $target) {
$target = substr($target, 0, 3) == 'gid' ? substr($target, 3) : $target;
$targetsselect = preg_replace("/(\<option value=\"$target\")([^\>]*)(\>)/", "\\1 \\2 selected=\"selected\" \\3", $targetsselect);
}
}
if($type == 'thread') {
$dispselect = '<select name="advnew[displayorder][]" size="10" multiple="multiple"><option value="0"'.$dispchecked[0].'> > '.$lang['all'].'</option><option value="0"> </option>';
for($i = 1; $i <= $ppp; $i ++) {
$dispselect .= '<option value="'.$i.'"'.$dispchecked[$i].'> > #'.$i.'</option>';
}
$dispselect .= '</select>';
} elseif($type == 'intercat') {
$positionselect = '<select name="advnew[position][]" size="10" multiple="multiple"><option value="0"'.$positionchecked[0].'> > '.$lang['all'].'</option><option value=""> </option>';
foreach($_DCACHE['forums'] as $fid => $forum) {
if($forum['type'] == 'group') {
$positionselect .= '<option value="'.$fid.'"'.$positionchecked[$fid].'>'.$forum['name'].'</option>';
}
}
$positionselect .= '</select>';
}
$adv['starttime'] = $adv['starttime'] ? gmdate('Y-n-j', $adv['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : '';
$adv['endtime'] = $adv['endtime'] ? gmdate('Y-n-j', $adv['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : '';
$styleselect = array($adv['parameters']['style'] => 'selected');
showtips('adv_type_'.$adv['type'].'_tips');
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
showformheader("adv&operation=$operation".($operation == 'advadd' ? '&type='.$type : '&advid='.$advid));
if($operation == 'advadd') {
$title = $lang['adv_add'].' - '.$lang['adv_type_'.$type];
} else {
$title = $lang['adv_edit'].' - '.$lang['adv_type_'.$adv['type']].' - '.$adv['title'];
}
showtableheader();
showtitle($title);
showsetting('adv_edit_title', 'advnew[title]', $adv['title'], 'text');
showsetting('adv_edit_targets', '', '', $targetsselect);
if($adv['type'] == 'thread') {
showsetting('adv_edit_position_thread', array('advnew[position]', array(
array(1, $lang['adv_thread_down']),
array(2, $lang['adv_thread_up']),
array(3, $lang['adv_thread_right'])
), TRUE), $adv['parameters']['position'], 'mradio');
showsetting('adv_edit_display_position', '', '', $dispselect);
} elseif($adv['type'] == 'footerbanner') {
showsetting('adv_edit_position_footerbanner', array('advnew[position]', array(
array(1, $lang['adv_up']),
array(2, $lang['adv_middle']),
array(3, $lang['adv_down'])
), TRUE), $adv['parameters']['position'], 'mradio');
} elseif($adv['type'] == 'intercat') {
showsetting('adv_edit_position_intercat', '', '', $positionselect);
}
showsetting('adv_edit_starttime', 'advnew[starttime]', $adv['starttime'], 'calendar');
showsetting('adv_edit_endtime', 'advnew[endtime]', $adv['endtime'], 'calendar');
showsetting('adv_edit_style', '', '', '<select name="advnew[style]" onchange="var styles, key;styles=new Array(\'code\',\'text\',\'image\',\'flash\'); for(key in styles) {var obj=$(\'style_\'+styles[key]); obj.style.display=styles[key]==this.options[this.selectedIndex].value?\'\':\'none\';}"><option value="code" '.$styleselect['code'].'> '.$lang['adv_style_code'].'</option><option value="text" '.$styleselect['text'].'> '.$lang['adv_style_text'].'</option><option value="image" '.$styleselect['image'].'> '.$lang['adv_style_image'].'</option><option value="flash" '.$styleselect['flash'].'> '.$lang['adv_style_flash'].'</option></select>');
showtagheader('tbody', 'style_code', $adv['parameters']['style'] == 'code');
showtitle('adv_edit_style_code');
showsetting('adv_edit_style_code_html', 'advnew[code][html]', $adv['parameters']['html'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', 'style_text', $adv['parameters']['style'] == 'text');
showtitle('adv_edit_style_text');
showsetting('adv_edit_style_text_title', 'advnew[text][title]', $adv['parameters']['title'], 'text');
showsetting('adv_edit_style_text_link', 'advnew[text][link]', $adv['parameters']['link'], 'text');
showsetting('adv_edit_style_text_size', 'advnew[text][size]', $adv['parameters']['size'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'style_image', $adv['parameters']['style'] == 'image');
showtitle('adv_edit_style_image');
showsetting('adv_edit_style_image_url', 'advnew[image][url]', $adv['parameters']['url'], 'text');
showsetting('adv_edit_style_image_link', 'advnew[image][link]', $adv['parameters']['link'], 'text');
showsetting('adv_edit_style_image_width', 'advnew[image][width]', $adv['parameters']['width'], 'text');
showsetting('adv_edit_style_image_height', 'advnew[image][height]', $adv['parameters']['height'], 'text');
showsetting('adv_edit_style_image_alt', 'advnew[image][alt]', $adv['parameters']['alt'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'style_flash', $adv['parameters']['style'] == 'flash');
showtitle('adv_edit_style_flash');
showsetting('adv_edit_style_flash_url', 'advnew[flash][url]', $adv['parameters']['url'], 'text');
showsetting('adv_edit_style_flash_width', 'advnew[flash][width]', $adv['parameters']['width'], 'text');
showsetting('adv_edit_style_flash_height', 'advnew[flash][height]', $adv['parameters']['height'], 'text');
showtagfooter('tbody');
showsubmit('advsubmit');
showtablefooter();
showformfooter();
} else {
$advnew['starttime'] = $advnew['starttime'] ? strtotime($advnew['starttime']) : 0;
$advnew['endtime'] = $advnew['endtime'] ? strtotime($advnew['endtime']) : 0;
if(!$advnew['title']) {
cpmsg('adv_title_invalid', '', 'error');
} elseif(strlen($advnew['title']) > 50) {
cpmsg('adv_title_more', '', 'error');
} elseif($advnew['endtime'] && ($advnew['endtime'] <= $timestamp || $advnew['endtime'] <= $advnew['starttime'])) {
cpmsg('adv_endtime_invalid', '', 'error');
} elseif(($advnew['style'] == 'code' && !$advnew['code']['html'])
|| ($advnew['style'] == 'text' && (!$advnew['text']['title'] || !$advnew['text']['link']))
|| ($advnew['style'] == 'image' && (!$advnew['image']['url'] || !$advnew['image']['link']))
|| ($advnew['style'] == 'flash' && (!$advnew['flash']['url'] || !$advnew['flash']['width'] || !$advnew['flash']['height']))) {
cpmsg('adv_parameter_invalid', '', 'error');
}
if($operation == 'advadd') {
$db->query("INSERT INTO {$tablepre}advertisements (available, type)
VALUES ('1', '$type')");
$advid = $db->insert_id();
} else {
$type = $db->result_first("SELECT type FROM {$tablepre}advertisements WHERE advid='$advid'");
}
foreach($advnew[$advnew['style']] as $key => $val) {
$advnew[$advnew['style']][$key] = stripslashes($val);
}
$targetsarray = array();
if(is_array($advnew['targets'])) {
$gids = array();
foreach($_DCACHE['forums'] as $fid => $forum) {
if($forum['type'] == 'group') {
$gids[] = $fid;
}
}
foreach($advnew['targets'] as $target) {
if(in_array($type, array('headerbanner', 'footerbanner', 'text', 'float', 'couplebanner')) && in_array($target, $gids)) {
$targetsarray[] = 'gid'.$target;
} elseif($target == 'all') {
$targetsarray = in_array($type, array('thread', 'interthread')) ? array('forum') : array();
break;
} elseif(in_array($target, array('register', 'redirect', 'archiver')) || preg_match("/^\d+$/", $target) && ($target == 0 || in_array($_DCACHE['forums'][$target]['type'], array('forum', 'sub')))) {
$targetsarray[] = $target;
}
}
}
$advnew['targets'] = implode("\t", $targetsarray);
$advnew['displayorder'] = isset($advnew['displayorder']) ? implode("\t", $advnew['displayorder']) : '';
switch($advnew['style']) {
case 'code':
$advnew['code'] = $advnew['code']['html'];
break;
case 'text':
$advnew['code'] = '<a href="'.$advnew['text']['link'].'" target="_blank" '.($advnew['text']['size'] ? 'style="font-size: '.$advnew['text']['size'].'"' : '').'>'.$advnew['text']['title'].'</a>';
break;
case 'image':
$advnew['code'] = '<a href="'.$advnew['image']['link'].'" target="_blank"><img src="'.$advnew['image']['url'].'"'.($advnew['image']['height'] ? ' height="'.$advnew['image']['height'].'"' : '').($advnew['image']['width'] ? ' width="'.$advnew['image']['width'].'"' : '').($advnew['image']['alt'] ? ' alt="'.$advnew['image']['alt'].'"' : '').' border="0"></a>';
break;
case 'flash':
$advnew['code'] = '<embed width="'.$advnew['flash']['width'].'" height="'.$advnew['flash']['height'].'" src="'.$advnew['flash']['url'].'" type="application/x-shockwave-flash" wmode="transparent"></embed>';
break;
}
if($type == 'intercat') {
$advnew['position'] = is_array($advnew['position']) && !in_array('0', $advnew['position']) ? $advnew['position'] : '';
}
$advnew['parameters'] = addslashes(serialize(array_merge(array('style' => $advnew['style']), $advnew['style'] == 'code' ? array() : $advnew[$advnew['style']], array('html' => $advnew['code']), array('position' => $advnew['position']), array('displayorder' => $advnew['displayorder']))));
$advnew['code'] = addslashes($advnew['code']);
$query = $db->query("UPDATE {$tablepre}advertisements SET title='$advnew[title]', targets='$advnew[targets]', parameters='$advnew[parameters]', code='$advnew[code]', starttime='$advnew[starttime]', endtime='$advnew[endtime]' WHERE advid='$advid'");
if($type == 'intercat') {
updatecache('advs_index');
} elseif(in_array($type, array('thread', 'interthread'))) {
updatecache('advs_viewthread');
} elseif($type == 'text') {
updatecache(array('advs_index', 'advs_forumdisplay', 'advs_viewthread'));
} else {
updatecache(array('settings', 'advs_archiver', 'advs_register', 'advs_index', 'advs_forumdisplay', 'advs_viewthread'));
}
cpmsg('adv_succeed', $BASESCRIPT.'?action=adv', 'succeed');
}
} elseif($operation == 'config') {
if(!submitcheck('configsubmit')) {
$query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='admode'");
$admode = $db->result($query, 0);
shownav('adv', 'adv_admin');
showsubmenu('adv_admin', array(
array('config', 'adv&operation=config', 1),
array('admin', 'adv', 0),
array(array('menu' => 'add', 'submenu' => array(
array('adv_type_headerbanner', 'adv&operation=advadd&type=headerbanner'),
array('adv_type_footerbanner', 'adv&operation=advadd&type=footerbanner'),
array('adv_type_text', 'adv&operation=advadd&type=text'),
array('adv_type_thread', 'adv&operation=advadd&type=thread'),
array('adv_type_interthread', 'adv&operation=advadd&type=interthread'),
array('adv_type_float', 'adv&operation=advadd&type=float'),
array('adv_type_couplebanner', 'adv&operation=advadd&type=couplebanner'),
array('adv_type_intercat', 'adv&operation=advadd&type=intercat'),
)), '', 0)
));
showformheader('adv&operation=config');
showtableheader();
showsetting('adv_config_mode', array('admodenew', array(array(0, lang('adv_config_mode_0')), array(1, lang('adv_config_mode_1')))), $admode, 'select');
showsubmit('configsubmit');
showtablefooter();
showformfooter();
} else {
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('admode', '$admodenew')");
updatecache('settings');
cpmsg('adv_config_succeed', $BASESCRIPT.'?action=adv&operation=config', 'succeed');
}
}
function showtargets($adv) {
if($adv['targets'] == '' || $adv['targets'] == 'forum') {
return lang('all');
} else {
$targets = explode("\t", $adv['targets']);
$count = count($targets);
$max = $count > 2 ? 2 : $count;
$t = array();
for($i = 0;$i < $max;$i++) {
$t[] = showtargetlink($targets[$i]);
}
$r = implode(', ', $t);
if($count > 2) {
$r .= ' ...';
}
return $r;
}
}
function showtargetlink($target) {
global $_DCACHE, $indexname, $regname;
return substr($target, 0, 3) == 'gid' ? '<a href="'.$indexname.'?gid='.substr($target, 3).'" target="_blank">'.$_DCACHE['forums'][substr($target, 3)]['name'].'</a>' :
($target == 'register' ? '<a href="'.$regname.'" target="_blank">'.lang('adv_register').'</a>' :
($target == 'redirect' ? lang('adv_jump') :
($target == 'archiver' ? '<a href="archiver/" target="_blank">Archiver</a>' :
($target ? '<a href="forumdisplay.php?fid='.$target.'" target="_blank">'.$_DCACHE['forums'][$target]['name'].'</a>' : '<a href="'.$indexname.'" target="_blank">'.lang('home').'</a>'))));
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/adv.inc.php | PHP | asf20 | 23,582 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: profilefields.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(!submitcheck('fieldsubmit')) {
$query = $db->query("SELECT * FROM {$tablepre}profilefields");
while($field = $db->fetch_array($query)) {
$profilefields .= showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[{$field[fieldid]}]\" value=\"$field[fieldid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[{$field[fieldid]}]\" value=\"$field[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"18\" name=\"titlenew[{$field[fieldid]}]\" value=\"$field[title]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[{$field[fieldid]}]\" value=\"1\" ".($field['available'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"invisiblenew[{$field[fieldid]}]\" value=\"1\" ".($field['invisible'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"unchangeablenew[{$field[fieldid]}]\" value=\"1\" ".($field['unchangeable'] ? 'checked' : '').">",
"<a href=\"$BASESCRIPT?action=profilefields&operation=edit&id=$field[fieldid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
shownav('user', 'profilefields');
showsubmenu('profilefields');
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'', 'td28'],
[6,'<input type="text" class="txt" name="newtitle[]" size="18">']
]
];
</script>
EOT;
showformheader('profilefields');
showtableheader();
showsubtitle(array('', 'display_order', 'profilefields_title', 'available', 'profilefields_invisible', 'profilefields_unchangeable', ''));
echo $profilefields;
echo '<tr><td></td><td colspan="7"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['profilefields_add'].'</a></div></td></tr>';
showsubmit('fieldsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($titlenew)) {
foreach($titlenew as $id => $val) {
$db->query("UPDATE {$tablepre}profilefields SET title='$titlenew[$id]', available='$availablenew[$id]', invisible='$invisiblenew[$id]', displayorder='$displayordernew[$id]', unchangeable='$unchangeablenew[$id]' WHERE fieldid='$id'");
}
}
if(is_array($delete)) {
$ids = implode('\',\'', $delete);
$dropfields = implode(',DROP field_', $delete);
$db->query("DELETE FROM {$tablepre}profilefields WHERE fieldid IN ('$ids')");
$db->query("ALTER TABLE {$tablepre}memberfields DROP field_$dropfields");
}
if(is_array($newtitle)) {
foreach($newtitle as $value) {
if($value = trim($value)) {
$db->query("INSERT INTO {$tablepre}profilefields (available, invisible, title, size)
VALUES ('1', '0', '$value', '50')");
$fieldid = $db->insert_id();
$db->query("ALTER TABLE {$tablepre}memberfields ADD field_$fieldid varchar(50) NOT NULL", 'SILENT');
}
}
}
updatecache(array('fields_required', 'fields_optional', 'custominfo'));
cpmsg('fields_edit_succeed', $BASESCRIPT.'?action=profilefields', 'succeed');
}
} elseif($operation == 'edit') {
$field = $db->fetch_first("SELECT * FROM {$tablepre}profilefields WHERE fieldid='$id'");
if(!$field) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
showsubmenu("$lang[profilefields_edit] - $field[title]");
showformheader("profilefields&operation=edit&id=$id");
showtableheader();
showsetting('profilefields_edit_title', 'titlenew', $field['title'], 'text');
showsetting('profilefields_edit_desc', 'descriptionnew', $field['description'], 'text');
showsetting('profilefields_edit_size', 'sizenew', $field['size'], 'text');
showsetting('profilefields_edit_invisible', 'invisiblenew', $field['invisible'], 'radio');
showsetting('profilefields_edit_required', 'requirednew', $field['required'], 'radio');
showsetting('profilefields_edit_unchangeable', 'unchangeablenew', $field['unchangeable'], 'radio');
showsetting('profilefields_edit_selective', 'selectivenew', $field['selective'], 'radio');
showsetting('profilefields_edit_choices', 'choicesnew', $field['choices'], 'textarea');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$titlenew = trim($titlenew);
$sizenew = $sizenew <= 255 ? $sizenew : 255;
if(!$titlenew || !$sizenew) {
cpmsg('fields_edit_invalid', '', 'error');
}
if($sizenew != $field['size']) {
$db->query("ALTER TABLE {$tablepre}memberfields CHANGE field_$id field_$id varchar($sizenew) NOT NULL");
}
$db->query("UPDATE {$tablepre}profilefields SET title='$titlenew', description='$descriptionnew', size='$sizenew', invisible='$invisiblenew', required='$requirednew', unchangeable='$unchangeablenew', selective='$selectivenew', choices='$choicesnew' WHERE fieldid='$id'");
updatecache(array('fields_required', 'fields_optional', 'custominfo'));
cpmsg('fields_edit_succeed', $BASESCRIPT.'?action=profilefields', 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/profilefields.inc.php | PHP | asf20 | 5,370 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: settings.inc.php 21057 2009-11-10 01:05:36Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$settings = array();
$query = $db->query("SELECT * FROM {$tablepre}settings");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
if(!$isfounder) {
unset($settings['ftp']);
}
$extbutton = '';
$operation = $operation ? $operation : 'basic';
if($operation == 'styles') {
$floatwinkeys = array('login', 'register', 'sendpm', 'newthread', 'reply', 'viewratings', 'viewwarning', 'viewthreadmod', 'viewvote', 'tradeorder', 'activity', 'debate', 'nav', 'usergroups', 'task');
$floatwinarray = array();
foreach($floatwinkeys as $k) {
$floatwinarray[] = array($k, $lang['settings_styles_global_allowfloatwin_'.$k]);
}
}
if(!submitcheck('settingsubmit')) {
if($operation == 'ec') {
if($from == 'creditwizard') {
shownav('tools', 'nav_creditwizard', 'settings_ec');
} else {
shownav('extended', 'nav_ec', 'nav_ec_config');
}
} elseif(in_array($operation, array('seo', 'cachethread', 'serveropti'))) {
shownav('global', 'settings_optimize', 'settings_'.$operation);
} elseif($operation == 'styles') {
shownav('style', 'settings_styles');
} elseif($operation == 'editor') {
shownav('style', 'settings_editor');
} else {
shownav('global', 'settings_'.$operation);
}
if(in_array($operation, array('seo', 'cachethread', 'serveropti'))) {
$current = array($operation => 1);
showsubmenu('settings_optimize', array(
array('settings_seo', 'settings&operation=seo', $current['seo']),
array('settings_cachethread', 'settings&operation=cachethread', $current['cachethread']),
array('settings_serveropti', 'settings&operation=serveropti', $current['serveropti'])
));
} elseif($operation == 'ec') {
if($from == 'creditwizard') {
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', 0),
array('creditwizard_step_menu_2', 'creditwizard&step=2', 0),
array('creditwizard_step_menu_3', 'creditwizard&step=3', 0),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 1),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
array('ec_tenpay', 'ec&operation=tenpay&from=creditwizard', 0),
));
} else {
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 1),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_tenpay', 'ec&operation=tenpay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0)
));
}
} elseif($operation == 'access') {
$anchor = in_array($anchor, array('register', 'access')) ? $anchor : 'register';
showsubmenuanchors('settings_access', array(
array('settings_access_register', 'register', $anchor == 'register'),
array('settings_access_access', 'access', $anchor == 'access')
));
} elseif($operation == 'mail') {
$anchor = in_array($anchor, array('settings', 'check')) ? $anchor : 'settings';
showsubmenuanchors('settings_mail', array(
array('settings_mail_settings', 'mailsettings', $anchor == 'settings'),
array('settings_mail_check', 'mailcheck', $anchor == 'check')
));
} elseif($operation == 'sec') {
$anchor = in_array($anchor, array('seclevel', 'seccode', 'secqaa')) ? $anchor : 'seclevel';
showsubmenuanchors('settings_sec', array(
array('settings_sec_seclevel', 'seclevel', $anchor == 'seclevel'),
array('settings_sec_seccode', 'seccode', $anchor == 'seccode'),
array('settings_sec_secqaa', 'secqaa', $anchor == 'secqaa')
));
} elseif($operation == 'attach') {
$anchor = in_array($anchor, array('basic', 'image', 'remote', 'antileech')) ? $anchor : 'basic';
showsubmenuanchors('settings_attach', array(
array('settings_attach_basic', 'basic', $anchor == 'basic'),
array('settings_attach_image', 'image', $anchor == 'image'),
$isfounder ? array('settings_attach_remote', 'remote', $anchor == 'remote') : '',
array('settings_attach_antileech', 'antileech', $anchor == 'antileech'),
));
} elseif($operation == 'styles') {
$anchor = in_array($anchor, array('global', 'index', 'forumdisplay', 'viewthread', 'member', 'refresh', 'sitemessage')) ? $anchor : 'global';
$current = array($anchor => 1);
showsubmenu('settings_styles', array(
array('settings_styles_global', 'settings&operation=styles&anchor=global', $current['global']),
array('settings_styles_index', 'settings&operation=styles&anchor=index', $current['index']),
array('settings_styles_forumdisplay', 'settings&operation=styles&anchor=forumdisplay', $current['forumdisplay']),
array('settings_styles_viewthread', 'settings&operation=styles&anchor=viewthread', $current['viewthread']),
array('settings_styles_member', 'settings&operation=styles&anchor=member', $current['member']),
array('settings_styles_customnav', 'misc&operation=customnav', 0),
array(array('menu' => 'jswizard_infoside', 'submenu' => array(
array('jswizard_infoside_global', 'jswizard&operation=infoside&from=style'),
array('jswizard_infoside_2', 'jswizard&operation=infoside&sideid=2&from=style'),
array('jswizard_infoside_0', 'jswizard&operation=infoside&sideid=0&from=style'),
))),
array('settings_styles_refresh', 'settings&operation=styles&anchor=refresh', $current['refresh']),
array('settings_styles_sitemessage', 'settings&operation=styles&anchor=sitemessage', $current['sitemessage'])
));
} elseif($operation == 'functions') {
$anchor = in_array($anchor, array('stat', 'mod', 'tags', 'heatthread', 'recommend', 'other')) ? $anchor : 'stat';
showsubmenuanchors('settings_functions', array(
array('settings_functions_stat', 'stat', $anchor == 'stat'),
array('settings_functions_mod', 'mod', $anchor == 'mod'),
array('settings_functions_tags', 'tags', $anchor == 'tags'),
array('settings_functions_heatthread', 'heatthread', $anchor == 'heatthread'),
array('settings_functions_recommend', 'recommend', $anchor == 'recommend'),
array('settings_functions_other', 'other', $anchor == 'other'),
));
} elseif($operation == 'editor') {
showsubmenu('settings_editor', array(
array('settings_editor_global', 'settings&operation=editor', 1),
array('settings_editor_code', 'misc&operation=bbcode', 0),
));
} elseif($operation == 'msn') {
shownav('extended', 'settings_msn');
} else {
showsubmenu('settings_'.$operation);
}
showformheader('settings&edit=yes');
showhiddenfields(array('operation' => $operation));
if($operation == 'basic') {
showtableheader();
showsetting('settings_basic_bbname', 'settingsnew[bbname]', $settings['bbname'], 'text');
showsetting('settings_basic_sitename', 'settingsnew[sitename]', $settings['sitename'], 'text');
showsetting('settings_basic_siteurl', 'settingsnew[siteurl]', $settings['siteurl'], 'text');
showsetting('settings_basic_index_name', 'settingsnew[indexname]', $settings['indexname'], 'text');
showsetting('settings_basic_icp', 'settingsnew[icp]', $settings['icp'], 'text');
showsetting('settings_basic_boardlicensed', 'settingsnew[boardlicensed]', $settings['boardlicensed'], 'radio');
showsetting('settings_basic_bbclosed', 'settingsnew[bbclosed]', $settings['bbclosed'], 'radio');
showsetting('settings_basic_closedreason', 'settingsnew[closedreason]', $settings['closedreason'], 'textarea');
showsetting('settings_basic_stat', 'settingsnew[statcode]', $settings['statcode'], 'textarea');
} elseif($operation == 'access') {
$wmsgcheck = array($settings['welcomemsg'] =>'checked');
$settings['inviteconfig'] = unserialize($settings['inviteconfig']);
$settings['extcredits'] = unserialize($settings['extcredits']);
$buycredits = $rewardcredist = '';
for($i = 0; $i <= 8; $i++) {
if($settings['extcredits'][$i]['available']) {
$extcredit = 'extcredits'.$i.' ('.$settings['extcredits'][$i]['title'].')';
$buycredits .= '<option value="'.$i.'" '.($i == intval($settings['inviteconfig']['invitecredit']) ? 'selected' : '').'>'.($i ? $extcredit : $lang['none']).'</option>';
$rewardcredits .= '<option value="'.$i.'" '.($i == intval($settings['inviteconfig']['inviterewardcredit']) ? 'selected' : '').'>'.($i ? $extcredit : $lang['none']).'</option>';
}
}
$groupselect = '';
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type='special'");
while($group = $db->fetch_array($query)) {
$groupselect .= "<option value=\"$group[groupid]\" ".($group['groupid'] == $settings['inviteconfig']['invitegroupid'] ? 'selected' : '').">$group[grouptitle]</option>\n";
}
$taskarray = array(array('', lang('select')));
$query = $db->query("SELECT taskid, name FROM {$tablepre}tasks WHERE available='2'");
while($task = $db->fetch_array($query)) {
$taskarray[] = array($task['taskid'], $task['name']);
}
showtableheader('', 'nobottom', 'id="register"'.($anchor != 'register' ? ' style="display: none"' : ''));
showsetting('settings_access_register_status', array('settingsnew[regstatus]', array(
array(0, $lang['settings_access_register_close'], array('showinvite' => 'none')),
array(1, $lang['settings_access_register_open'], array('showinvite' => 'none')),
array(2, $lang['settings_access_register_invite'], array('showinvite' => '')),
array(3, $lang['settings_access_register_open_invite'], array('showinvite' => ''))
)), $settings['regstatus'], 'mradio');
showtagheader('tbody', 'showinvite', $settings['regstatus'] > 1, 'sub');
showsetting('settings_access_register_invite_credit', '', '', '<select name="settingsnew[inviteconfig][inviterewardcredit]">'.$rewardcredits.'</select>');
showsetting('settings_access_register_invite_addcredit', 'settingsnew[inviteconfig][inviteaddcredit]', $settings['inviteconfig']['inviteaddcredit'], 'text');
showsetting('settings_access_register_invite_invitedcredit', 'settingsnew[inviteconfig][invitedaddcredit]', $settings['inviteconfig']['invitedaddcredit'], 'text');
showsetting('settings_access_register_invite_addfriend', 'settingsnew[inviteconfig][inviteaddbuddy]', $settings['inviteconfig']['inviteaddbuddy'], 'radio');
showsetting('settings_access_register_invite_group', '', '', '<select name="settingsnew[inviteconfig][invitegroupid]"><option value="0">'.$lang['usergroups_system_0'].'</option>'.$groupselect.'</select>');
showtagfooter('tbody');
showsetting('settings_access_register_name', 'settingsnew[regname]', $settings['regname'], 'text');
showsetting('settings_access_register_link_name', 'settingsnew[reglinkname]', $settings['reglinkname'], 'text');
showsetting('settings_access_register_censoruser', 'settingsnew[censoruser]', $settings['censoruser'], 'textarea');
showsetting('settings_access_register_verify', array('settingsnew[regverify]', array(
array(0, $lang['none']),
array(1, $lang['settings_access_register_verify_email']),
array(2, $lang['settings_access_register_verify_manual'])
)), $settings['regverify'], 'select');
showsetting('settings_access_register_verify_ipwhite', 'settingsnew[ipverifywhite]', $settings['ipverifywhite'], 'textarea');
showsetting('settings_access_register_ctrl', 'settingsnew[regctrl]', $settings['regctrl'], 'text');
showsetting('settings_access_register_floodctrl', 'settingsnew[regfloodctrl]', $settings['regfloodctrl'], 'text');
showsetting('settings_access_register_ipctrl', 'settingsnew[ipregctrl]', $settings['ipregctrl'], 'textarea');
showsetting('settings_access_register_welcomemsg', array('settingsnew[welcomemsg]', array(
array(0, $lang['settings_access_register_welcomemsg_nosend'], array('welcomemsgext' => 'none')),
array(1, $lang['settings_access_register_welcomemsg_pm'], array('welcomemsgext' => '')),
array(2, $lang['settings_access_register_welcomemsg_email'], array('welcomemsgext' => ''))
)), $settings['welcomemsg'], 'mradio');
showtagheader('tbody', 'welcomemsgext', $settings['welcomemsg'], 'sub');
showsetting('settings_access_register_welcomemsgtitle', 'settingsnew[welcomemsgtitle]', $settings['welcomemsgtitle'], 'text');
showsetting('settings_access_register_welcomemsgtxt', 'settingsnew[welcomemsgtxt]', $settings['welcomemsgtxt'], 'textarea');
showtagfooter('tbody');
showsetting('settings_access_register_bbrules', 'settingsnew[bbrules]', $settings['bbrules'], 'radio', '', 1);
showsetting('settings_access_register_bbrulestxt', 'settingsnew[bbrulestxt]', $settings['bbrulestxt'], 'textarea');
showtagfooter('tbody');
showtablefooter();
showtableheader('', 'nobottom', 'id="access"'.($anchor != 'access' ? ' style="display: none"' : ''));
showsetting('settings_access_access_newbiespan', 'settingsnew[newbiespan]', $settings['newbiespan'], 'text');
showsetting('settings_access_access_ipaccess', 'settingsnew[ipaccess]', $settings['ipaccess'], 'textarea');
showsetting('settings_access_access_adminipaccess', 'settingsnew[adminipaccess]', $settings['adminipaccess'], 'textarea');
showsetting('settings_access_access_domainwhitelist', 'settingsnew[domainwhitelist]', $settings['domainwhitelist'], 'textarea');
showtablefooter();
showtableheader('', 'notop');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'styles') {
$showsettings = str_pad(decbin($settings['showsettings']), 3, 0, STR_PAD_LEFT);
$settings['showsignatures'] = $showsettings{0};
$settings['showavatars'] = $showsettings{1};
$settings['showimages'] = $showsettings{2};
$settings['postnocustom'] = implode("\n", (array)unserialize($settings['postnocustom']));
$settings['sitemessage'] = unserialize($settings['sitemessage']);
$settings['disallowfloat'] = $settings['disallowfloat'] ? unserialize($settings['disallowfloat']) : array();
$settings['allowfloatwin'] = array_diff($floatwinkeys, $settings['disallowfloat']);
$settings['indexhot'] = unserialize($settings['indexhot']);
$settings['customauthorinfo'] = unserialize($settings['customauthorinfo']);
$settings['customauthorinfo'] = $settings['customauthorinfo'][0];
list($settings['zoomstatus'], $settings['imagemaxwidth']) = explode("\t", $settings['zoomstatus']);
$settings['imagemaxwidth'] = !empty($settings['imagemaxwidth']) ? $settings['imagemaxwidth'] : 600;
$stylelist = "<select name=\"settingsnew[styleid]\">\n";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$selected = $style['styleid'] == $settings['styleid'] ? 'selected="selected"' : NULL;
$stylelist .= "<option value=\"$style[styleid]\" $selected>$style[name]</option>\n";
}
$stylelist .= '</select>';
showtips('settings_tips', 'global_tips', $anchor == 'global');
showtips('settings_tips', 'index_tips', $anchor == 'index');
showtips('settings_tips', 'forumdisplay_tips', $anchor == 'forumdisplay');
showtableheader('', 'nobottom', 'id="global"'.($anchor != 'global' ? ' style="display: none"' : ''));
showsetting('settings_styles_global_styleid', '', '', $stylelist);
showsetting('settings_styles_global_stylejump', 'settingsnew[stylejump]', $settings['stylejump'], 'radio');
showsetting('settings_styles_global_jsmenu', 'settingsnew[forumjump]', $settings['forumjump'], 'radio');
showsetting('settings_styles_global_frameon', array('settingsnew[frameon]', array(
array(0, $lang['settings_styles_global_frameon_0'], array('frameonext' => 'none')),
array(1, $lang['settings_styles_global_frameon_1'], array('frameonext' => '')),
array(2, $lang['settings_styles_global_frameon_2'], array('frameonext' => ''))
)), $settings['frameon'], 'mradio');
showtagheader('tbody', 'frameonext', $settings['frameon'], 'sub');
showsetting('settings_styles_global_framewidth', 'settingsnew[framewidth]', $settings['framewidth'], 'text');
showtagfooter('tbody');
showsetting('settings_styles_global_allowfloatwin', array('settingsnew[allowfloatwin]', $floatwinarray), $settings['allowfloatwin'], 'mcheckbox');
showsetting('settings_styles_global_creditnotice', 'settingsnew[creditnotice]', $settings['creditnotice'], 'radio');
showtableheader('', 'nobottom', 'id="index"'.($anchor != 'index' ? ' style="display: none"' : ''));
showsetting('settings_styles_index_allowindextype', 'settingsnew[allowindextype]', $settings['indextype'] ? 1 : 0, 'radio', 0, 1);
showsetting('settings_styles_index_indextype', array('settingsnew[indextype]', array(
array('classics', $lang['settings_styles_index_indextype_classics']),
array('feeds', $lang['settings_styles_index_indextype_feeds'])
)), $settings['indextype'], 'mradio');
showtagfooter('tbody');
showsetting('settings_styles_index_indexhot_status', 'settingsnew[indexhot][status]', $settings['indexhot']['status'], 'radio', 0, 1);
showsetting('settings_styles_index_indexhot_limit', 'settingsnew[indexhot][limit]', $settings['indexhot']['limit'], 'text');
showsetting('settings_styles_index_indexhot_days', 'settingsnew[indexhot][days]', $settings['indexhot']['days'], 'text');
showsetting('settings_styles_index_indexhot_expiration', 'settingsnew[indexhot][expiration]', $settings['indexhot']['expiration'], 'text');
showsetting('settings_styles_index_indexhot_messagecut', 'settingsnew[indexhot][messagecut]', $settings['indexhot']['messagecut'], 'text');
showtagfooter('tbody');
showsetting('settings_styles_index_subforumsindex', 'settingsnew[subforumsindex]', $settings['subforumsindex'], 'radio');
showsetting('settings_styles_index_forumlinkstatus', 'settingsnew[forumlinkstatus]', $settings['forumlinkstatus'], 'radio');
showsetting('settings_styles_index_members', 'settingsnew[maxbdays]', $settings['maxbdays'], 'text');
showsetting('settings_styles_index_moddisplay', array('settingsnew[moddisplay]', array(
array('flat', $lang['settings_styles_index_moddisplay_flat']),
array('selectbox', $lang['settings_styles_index_moddisplay_selectbox'])
)), $settings['moddisplay'], 'mradio');
showsetting('settings_styles_index_whosonline', array('settingsnew[whosonlinestatus]', array(
array(0, $lang['settings_styles_index_display_none']),
array(1, $lang['settings_styles_index_whosonline_index']),
array(2, $lang['settings_styles_index_whosonline_forum']),
array(3, $lang['settings_styles_index_whosonline_both'])
)), $settings['whosonlinestatus'], 'select');
showsetting('settings_styles_index_whosonline_contract', 'settingsnew[whosonline_contract]', $settings['whosonline_contract'], 'radio');
showsetting('settings_styles_index_online_more_members', 'settingsnew[maxonlinelist]', $settings['maxonlinelist'], 'text');
showsetting('settings_styles_index_hideprivate', 'settingsnew[hideprivate]', $settings['hideprivate'], 'radio');
showtablefooter();
showtableheader('', 'nobottom', 'id="forumdisplay"'.($anchor != 'forumdisplay' ? ' style="display: none"' : ''));
showsetting('settings_styles_forumdisplay_tpp', 'settingsnew[topicperpage]', $settings['topicperpage'], 'text');
showsetting('settings_styles_forumdisplay_threadmaxpages', 'settingsnew[threadmaxpages]', $settings['threadmaxpages'], 'text');
showsetting('settings_styles_forumdisplay_globalstick', 'settingsnew[globalstick]', $settings['globalstick'], 'radio');
showsetting('settings_styles_forumdisplay_stick', 'settingsnew[threadsticky]', $settings['threadsticky'], 'text');
showsetting('settings_styles_forumdisplay_part', 'settingsnew[forumseparator]', $settings['forumseparator'], 'radio');
showsetting('settings_styles_forumdisplay_visitedforums', 'settingsnew[visitedforums]', $settings['visitedforums'], 'text');
showtablefooter();
showtagheader('div', 'viewthread', $anchor == 'viewthread');
showtableheader('nav_settings_viewthread', 'nobottom');
showsetting('settings_styles_viewthread_ppp', 'settingsnew[postperpage]', $settings['postperpage'], 'text');
showsetting('settings_styles_viewthread_starthreshold', 'settingsnew[starthreshold]', $settings['starthreshold'], 'text');
showsetting('settings_styles_viewthread_maxsigrows', 'settingsnew[maxsigrows]', $settings['maxsigrows'], 'text');
showsetting('settings_styles_viewthread_sigviewcond', 'settingsnew[sigviewcond]', $settings['sigviewcond'], 'text');
showsetting('settings_styles_viewthread_rate_on', 'settingsnew[ratelogon]', $settings['ratelogon'], 'radio');
showsetting('settings_styles_viewthread_rate_number', 'settingsnew[ratelogrecord]', $settings['ratelogrecord'], 'text');
showsetting('settings_styles_viewthread_show_signature', 'settingsnew[showsignatures]', $settings['showsignatures'], 'radio');
showsetting('settings_styles_viewthread_show_face', 'settingsnew[showavatars]', $settings['showavatars'], 'radio');
showsetting('settings_styles_viewthread_show_images', 'settingsnew[showimages]', $settings['showimages'], 'radio');
showsetting('settings_styles_viewthread_imagemaxwidth', 'settingsnew[imagemaxwidth]', $settings['imagemaxwidth'], 'text');
showsetting('settings_styles_viewthread_zoomstatus', 'settingsnew[zoomstatus]', $settings['zoomstatus'], 'radio');
showsetting('settings_styles_viewthread_fastpost', 'settingsnew[fastpost]', $settings['fastpost'], 'radio');
showsetting('settings_styles_viewthread_vtonlinestatus', array('settingsnew[vtonlinestatus]', array(
array(0, $lang['settings_styles_viewthread_display_none']),
array(1, $lang['settings_styles_viewthread_online_easy']),
array(2, $lang['settings_styles_viewthread_online_exactitude'])
)), $settings['vtonlinestatus'], 'select');
showsetting('settings_styles_viewthread_userstatusby', array('settingsnew[userstatusby]', array(
array(0, $lang['settings_styles_viewthread_display_none']),
array(1, $lang['settings_styles_viewthread_userstatusby_usergroup']),
array(2, $lang['settings_styles_viewthread_userstatusby_rank'])
)), $settings['userstatusby'], 'select');
showsetting('settings_styles_viewthread_postno', 'settingsnew[postno]', $settings['postno'], 'text');
showsetting('settings_styles_viewthread_postnocustom', 'settingsnew[postnocustom]', $settings['postnocustom'], 'textarea');
showsetting('settings_styles_viewthread_maxsmilies', 'settingsnew[maxsmilies]', $settings['maxsmilies'], 'text');
showsetting('settings_styles_viewthread_author_onleft', array('settingsnew[authoronleft]', array(
array(1, lang('settings_styles_viewthread_author_onleft_yes')),
array(0, lang('settings_styles_viewthread_author_onleft_no')))), $settings['authoronleft'], 'mradio');
showtableheader('settings_styles_viewthread_customauthorinfo', 'fixpadding');
$authorinfoitems = array(
'uid' => 'UID',
'posts' => $lang['settings_styles_viewthread_userinfo_posts'],
'threads' => $lang['settings_styles_viewthread_userinfo_threads'],
'digest' => $lang['settings_styles_viewthread_userinfo_digest'],
'credits' => $lang['settings_styles_viewthread_userinfo_credits'],
);
if(!empty($extcredits)) {
foreach($extcredits as $key => $value) {
$authorinfoitems['extcredits'.$key] = $value['title'];
}
}
$query = $db->query("SELECT fieldid,title FROM {$tablepre}profilefields WHERE available='1' AND invisible='0' ORDER BY displayorder");
while($profilefields = $db->fetch_array($query)) {
$authorinfoitems['field_'.$profilefields['fieldid']] = $profilefields['title'];
}
$authorinfoitems = array_merge($authorinfoitems, array(
'readperm' => $lang['settings_styles_viewthread_userinfo_readperm'],
'gender' => $lang['settings_styles_viewthread_userinfo_gender'],
'location' => $lang['settings_styles_viewthread_userinfo_location'],
'oltime' => $lang['settings_styles_viewthread_userinfo_oltime'],
'regtime' => $lang['settings_styles_viewthread_userinfo_regtime'],
'lastdate' => $lang['settings_styles_viewthread_userinfo_lastdate'],
));
showsubtitle(array('', 'settings_styles_viewthread_userinfo_left', 'settings_styles_viewthread_userinfo_menu'));
$authorinfoitemsetting = '';
foreach($authorinfoitems as $key => $value) {
$authorinfoitemsetting .= '<tr><td>'.$value.
'</td><td><input name="settingsnew[customauthorinfo]['.$key.'][left]" type="checkbox" class="checkbox" value="1" '.($settings['customauthorinfo'][$key]['left'] ? 'checked' : '').'>'.
'</td><td><input name="settingsnew[customauthorinfo]['.$key.'][menu]" type="checkbox" class="checkbox" value="1" '.($settings['customauthorinfo'][$key]['menu'] ? 'checked' : '').'>'.
'</td></tr>';
}
echo $authorinfoitemsetting;
showtablefooter();
showtagfooter('div');
showtableheader('', 'nobottom', 'id="member"'.($anchor != 'member' ? ' style="display: none"' : ''));
showsetting('settings_styles_member_mpp', 'settingsnew[memberperpage]', $settings['memberperpage'], 'text');
showsetting('settings_styles_member_maxpages', 'settingsnew[membermaxpages]', $settings['membermaxpages'], 'text');
$settings['msgforward'] = !empty($settings['msgforward']) ? unserialize($settings['msgforward']) : array();
$settings['msgforward']['messages'] = !empty($settings['msgforward']['messages']) ? implode("\n", $settings['msgforward']['messages']) : '';
showtablefooter();
showtableheader('', 'nobottom', 'id="refresh"'.($anchor != 'refresh' ? ' style="display: none"' : ''));
showsetting('settings_styles_refresh_refreshtime', 'settingsnew[msgforward][refreshtime]', $settings['msgforward']['refreshtime'], 'text');
showsetting('settings_styles_refresh_quick', 'settingsnew[msgforward][quick]', $settings['msgforward']['quick'], 'radio', '', 1);
showsetting('settings_styles_refresh_messages', 'settingsnew[msgforward][messages]', $settings['msgforward']['messages'], 'textarea');
showtagfooter('tbody');
showtablefooter();
showtableheader('', 'nobottom', 'id="sitemessage"'.($anchor != 'sitemessage' ? ' style="display: none"' : ''));
showsetting('settings_styles_sitemessage_time', 'settingsnew[sitemessage][time]', $settings['sitemessage']['time'], 'text');
showsetting('settings_styles_sitemessage_register', 'settingsnew[sitemessage][register]', $settings['sitemessage']['register'], 'textarea');
showsetting('settings_styles_sitemessage_login', 'settingsnew[sitemessage][login]', $settings['sitemessage']['login'], 'textarea');
showsetting('settings_styles_sitemessage_newthread', 'settingsnew[sitemessage][newthread]', $settings['sitemessage']['newthread'], 'textarea');
showsetting('settings_styles_sitemessage_reply', 'settingsnew[sitemessage][reply]', $settings['sitemessage']['reply'], 'textarea');
showtagfooter('tbody');
showtablefooter();
showtableheader('', 'notop');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'seo') {
showtips('settings_tips');
showtableheader();
showtitle('settings_seo');
showsetting('settings_seo_archiverstatus', array('settingsnew[archiverstatus]', array(
array(0, $lang['settings_seo_archiverstatus_none']),
array(1, $lang['settings_seo_archiverstatus_full']),
array(2, $lang['settings_seo_archiverstatus_searchengine']),
array(3, $lang['settings_seo_archiverstatus_browser']))), $settings['archiverstatus'], 'mradio');
showsetting('settings_seo_rewritestatus', array('settingsnew[rewritestatus]', array(
$lang['settings_seo_rewritestatus_forumdisplay'],
$lang['settings_seo_rewritestatus_viewthread'],
$lang['settings_seo_rewritestatus_space'],
$lang['settings_seo_rewritestatus_tag'],
$lang['settings_seo_rewritestatus_archiver'])), $settings['rewritestatus'], 'binmcheckbox');
showsetting('settings_seo_rewritecompatible', 'settingsnew[rewritecompatible]', $settings['rewritecompatible'], 'radio');
showsetting('settings_seo_seotitle', 'settingsnew[seotitle]', $settings['seotitle'], 'text');
showsetting('settings_seo_seokeywords', 'settingsnew[seokeywords]', $settings['seokeywords'], 'text');
showsetting('settings_seo_seodescription', 'settingsnew[seodescription]', $settings['seodescription'], 'text');
showsetting('settings_seo_seohead', 'settingsnew[seohead]', $settings['seohead'], 'textarea');
showtitle('nav_settings_sitemap');
showsetting('settings_seo_sitemap_baidu_open', 'settingsnew[baidusitemap]', $settings['baidusitemap'], 'radio', '', 1);
showsetting('settings_seo_sitemap_baidu_expire', 'settingsnew[baidusitemap_life]', $settings['baidusitemap_life'], 'text');
showtagfooter('tbody');
} elseif($operation == 'cachethread') {
include_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="fids[]" multiple="multiple" size="10"><option value="all">'.$lang['all'].'</option><option value=""> </option>'.forumselect(FALSE, 0, 0, TRUE).'</select>';
showtableheader();
showtitle('settings_cachethread');
showsetting('settings_cachethread_indexlife', 'settingsnew[cacheindexlife]', $settings['cacheindexlife'], 'text');
showsetting('settings_cachethread_life', 'settingsnew[cachethreadlife]', $settings['cachethreadlife'], 'text');
showsetting('settings_cachethread_dir', 'settingsnew[cachethreaddir]', $settings['cachethreaddir'], 'text');
showtitle('settings_cachethread_coefficient_set');
showsetting('settings_cachethread_coefficient', 'settingsnew[threadcaches]', '', "<input type=\"text\" class=\"txt\" size=\"30\" name=\"settingsnew[threadcaches]\" value=\"\">");
showsetting('settings_cachethread_coefficient_forum', '', '', $forumselect);
} elseif($operation == 'serveropti') {
$checkgzipfunc = !function_exists('ob_gzhandler') ? 1 : 0;
if($settings['jspath'] == 'include/js/') {
$tjspath['default'] = 'checked="checked"';
$settings['jspath'] = '';
} elseif($settings['jspath'] == 'forumdata/cache/') {
$tjspath['cache'] = 'checked="checked"';
$settings['jspath'] = '';
} else {
$tjspath['custom'] = 'checked="checked"';
}
showtips('settings_tips');
showtableheader();
showtitle('settings_serveropti');
showsetting('settings_serveropti_gzipcompress', 'settingsnew[gzipcompress]', $settings['gzipcompress'], 'radio', $checkgzipfunc);
showsetting('settings_serveropti_delayviewcount', array('settingsnew[delayviewcount]', array(
array(0, lang('none')),
array(1, lang('settings_serveropti_delayviewcount_thread')),
array(2, lang('settings_serveropti_delayviewcount_attach')),
array(3, lang('settings_serveropti_delayviewcount_thread_attach'))
)), $settings['delayviewcount'], 'select');
showsetting('settings_serveropti_nocacheheaders', 'settingsnew[nocacheheaders]', $settings['nocacheheaders'], 'radio');
showsetting('settings_serveropti_transsidstatus', 'settingsnew[transsidstatus]', $settings['transsidstatus'], 'radio');
showsetting('settings_serveropti_maxonlines', 'settingsnew[maxonlines]', $settings['maxonlines'], 'text');
showsetting('settings_serveropti_onlinehold', 'settingsnew[onlinehold]', $settings['onlinehold'], 'text');
showsetting('settings_serveropti_loadctrl', 'settingsnew[loadctrl]', $settings['loadctrl'], 'text');
showsetting('settings_serveropti_floodctrl', 'settingsnew[floodctrl]', $settings['floodctrl'], 'text');
showsetting('settings_serveropti_jspath', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tjspath['default'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="settingsnew[jspath]" value="include/js/" '.$tjspath['default'].'> '.$lang['settings_serveropti_jspath_default'].'</li>
<li'.($tjspath['cache'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="settingsnew[jspath]" value="forumdata/cache/" '.$tjspath['cache'].'> '.$lang['settings_serveropti_jspath_cache'].'</li>
<li'.($tjspath['custom'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="settingsnew[jspath]" value="" '.$tjspath['custom'].'> '.$lang['settings_serveropti_jspath_custom'].' <input type="text" class="txt" style="width: 100px" name="settingsnew[jspathcustom]" value="'.$settings['jspath'].'" size="6"></li></ul>'
);
showtitle('nav_settings_search');
showsetting('settings_serveropti_searchctrl', 'settingsnew[searchctrl]', $settings['searchctrl'], 'text');
showsetting('settings_serveropti_maxspm', 'settingsnew[maxspm]', $settings['maxspm'], 'text');
showsetting('settings_serveropti_maxsearchresults', 'settingsnew[maxsearchresults]', $settings['maxsearchresults'], 'text');
} elseif($operation == 'editor') {
$editoroptions = str_pad(decbin($settings['editoroptions']), 2, 0, STR_PAD_LEFT);
$settings['defaulteditormode'] = $editoroptions{0};
$settings['allowswitcheditor'] = $editoroptions{1};
showtableheader();
showsetting('settings_editor_mode_default', array('settingsnew[defaulteditormode]', array(
array(0, $lang['settings_editor_mode_discuzcode']),
array(1, $lang['settings_editor_mode_wysiwyg']))), $settings['defaulteditormode'], 'mradio');
showsetting('settings_editor_swtich_enable', 'settingsnew[allowswitcheditor]', $settings['allowswitcheditor'], 'radio');
showsetting('settings_editor_smthumb', 'settingsnew[smthumb]', $settings['smthumb'], 'text');
showsetting('settings_editor_smcols', 'settingsnew[smcols]', $settings['smcols'], 'text');
showsetting('settings_editor_smrows', 'settingsnew[smrows]', $settings['smrows'], 'text');
showtablefooter();
} elseif($operation == 'functions') {
showtips('settings_tips', 'stat_tips', $anchor == 'stat');
showtips('settings_tips', 'mod_tips', $anchor == 'mod');
showtips('settings_tips', 'other_tips', $anchor == 'other');
showtips('settings_functions_recommend_tips', 'recommend_tips', $anchor == 'recommend');
showtableheader('', 'nobottom', 'id="stat"'.($anchor != 'stat' ? ' style="display: none"' : ''));
showsetting('settings_functions_stat_status', 'settingsnew[statstatus]', $settings['statstatus'], 'radio');
showsetting('settings_functions_stat_cachelife', 'settingsnew[statscachelife]', $settings['statscachelife'], 'text');
showsetting('settings_functions_stat_pvfrequence', 'settingsnew[pvfrequence]', $settings['pvfrequence'], 'text');
showsetting('settings_functions_stat_oltimespan', 'settingsnew[oltimespan]', $settings['oltimespan'], 'text');
showtablefooter();
showtableheader('', 'nobottom', 'id="mod"'.($anchor != 'mod' ? ' style="display: none"' : ''));
showsetting('settings_functions_mod_status', 'settingsnew[modworkstatus]', $settings['modworkstatus'], 'radio');
showsetting('settings_functions_mod_maxmodworksmonths', 'settingsnew[maxmodworksmonths]', $settings['maxmodworksmonths'], 'text');
showsetting('settings_functions_mod_losslessdel', 'settingsnew[losslessdel]', $settings['losslessdel'], 'text');
showsetting('settings_functions_mod_reasons', 'settingsnew[modreasons]', $settings['modreasons'], 'textarea');
showsetting('settings_functions_mod_bannedmessages', array('settingsnew[bannedmessages]', array(
$lang['settings_functions_mod_bannedmessages_thread'],
$lang['settings_functions_mod_bannedmessages_avatar'],
$lang['settings_functions_mod_bannedmessages_signature'])), $settings['bannedmessages'], 'binmcheckbox');
showsetting('settings_functions_mod_warninglimit', 'settingsnew[warninglimit]', $settings['warninglimit'], 'text');
showsetting('settings_functions_mod_warningexpiration', 'settingsnew[warningexpiration]', $settings['warningexpiration'], 'text');
showtablefooter();
showtableheader('', 'nobottom', 'id="tags"'.($anchor != 'tags' ? ' style="display: none"' : ''));
showsetting('settings_functions_tags_status', array('settingsnew[tagstatus]', array(
array(0, $lang['settings_functions_tags_status_none'], array('tagext' => 'none')),
array(1, $lang['settings_functions_tags_status_use'], array('tagext' => '')),
array(2, $lang['settings_functions_tags_status_quired'], array('tagext' => ''))
)), $settings['tagstatus'], 'mradio');
showtagheader('tbody', 'tagext', $settings['tagstatus'], 'sub');
showsetting('settings_functions_tags_viewthtrad_hottags', 'settingsnew[viewthreadtags]', $settings['viewthreadtags'], 'text');
showtagfooter('tbody');
showtablefooter();
$settings['heatthread'] = unserialize($settings['heatthread']);
$settings['recommendthread'] = unserialize($settings['recommendthread']);
$recommendcreditstrans = '<select name="settingsnew[recommendthread][creditstrans]"><option value="">'.$lang['none'].'</option>';
foreach($extcredits as $key => $value) {
$recommendcreditstrans .= '<option'.($settings['recommendthread']['creditstrans'] == $key ? ' selected="selected"' : '').' value="'.$key.'">extcredits'.$key.' ('.$value['title'].')</option>';
}
$recommendcreditstrans .= '</select>';
$count = count(explode(',', $settings['heatthread']['iconlevels']));
$heatthreadicons = '';
for($i = 0;$i < $count;$i++) {
$heatthreadicons .= '<img src="images/default/hot_'.($i + 1).'.gif" /> ';
}
$count = count(explode(',', $settings['recommendthread']['iconlevels']));
$recommendicons = '';
for($i = 0;$i < $count;$i++) {
$recommendicons .= '<img src="images/default/recommend_'.($i + 1).'.gif" /> ';
}
showtableheader('', 'nobottom', 'id="heatthread"'.($anchor != 'heatthread' ? ' style="display: none"' : ''));
showsetting('settings_functions_heatthread_reply', 'settingsnew[heatthread][reply]', $settings['heatthread']['reply'], 'text');
showsetting('settings_functions_heatthread_recommend', 'settingsnew[heatthread][recommend]', $settings['heatthread']['recommend'], 'text');
showsetting('settings_functions_heatthread_iconlevels', '', '', '<input name="settingsnew[heatthread][iconlevels]" class="txt" type="text" value="'.$settings['heatthread']['iconlevels'].'" /><br />'.$heatthreadicons);
showtablefooter();
showtableheader('', 'nobottom', 'id="recommend"'.($anchor != 'recommend' ? ' style="display: none"' : ''));
showsetting('settings_functions_recommend_status', 'settingsnew[recommendthread][status]', $settings['recommendthread']['status'], 'radio', 0, 1);
showsetting('settings_functions_recommend_addtext', 'settingsnew[recommendthread][addtext]', $settings['recommendthread']['addtext'], 'text');
showsetting('settings_functions_recommend_subtracttext', 'settingsnew[recommendthread][subtracttext]', $settings['recommendthread']['subtracttext'], 'text');
showsetting('settings_functions_recommend_defaultshow', array('settingsnew[recommendthread][defaultshow]', array(
array(0, $lang['settings_functions_recommend_defaultshow_0']),
array(1, $lang['settings_functions_recommend_defaultshow_1']))), $settings['recommendthread']['defaultshow'], 'mradio');
showsetting('settings_functions_recommend_daycount', 'settingsnew[recommendthread][daycount]', intval($settings['recommendthread']['daycount']), 'text');
showsetting('settings_functions_recommend_ownthread', 'settingsnew[recommendthread][ownthread]', $settings['recommendthread']['ownthread'], 'radio');
showsetting('settings_functions_recommend_iconlevels', '', '', '<input name="settingsnew[recommendthread][iconlevels]" class="txt" type="text" value="'.$settings['recommendthread']['iconlevels'].'" /><br />'.$recommendicons);
showtablefooter();
showtableheader('', 'nobottom', 'id="other"'.($anchor != 'other' ? ' style="display: none"' : ''));
showsetting('settings_functions_other_pwdsafety', 'settingsnew[pwdsafety]', $settings['pwdsafety'], 'radio');
showsetting('settings_functions_other_rssstatus', 'settingsnew[rssstatus]', $settings['rssstatus'], 'radio');
showsetting('settings_functions_other_rssttl', 'settingsnew[rssttl]', $settings['rssttl'], 'text');
showsetting('settings_functions_other_send_birthday', 'settingsnew[bdaystatus]', $settings['bdaystatus'], 'radio');
showsetting('settings_functions_other_debug', 'settingsnew[debug]', $settings['debug'], 'radio');
showsetting('settings_functions_other_activity_type', 'settingsnew[activitytype]', $settings['activitytype'], 'textarea');
showtablefooter();
showtableheader('', 'notop');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'permissions') {
include_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="settingsnew[allowviewuserthread][fids][]" multiple="multiple" size="10">'.forumselect(FALSE, 0, 0, TRUE).'</select>';
$settings['allowviewuserthread'] = unserialize($settings['allowviewuserthread']);
if($settings['allowviewuserthread']['fids']) {
foreach($settings['allowviewuserthread']['fids'] as $v) {
$forumselect = str_replace('<option value="'.$v.'">', '<option value="'.$v.'" selected>', $forumselect);
}
}
showtableheader();
showsetting('settings_permissions_allowviewuserthread', 'settingsnew[allowviewuserthread][allow]', $settings['allowviewuserthread']['allow'], 'radio', 0, 1);
showsetting('settings_permissions_allowviewuserthread_fids', '', '', $forumselect);
showtagfooter('tbody');
showsetting('settings_permissions_memliststatus', 'settingsnew[memliststatus]', $settings['memliststatus'], 'radio');
showsetting('settings_permissions_reportpost', 'settingsnew[reportpost]', $settings['reportpost'], 'radio');
showsetting('settings_permissions_minpostsize', 'settingsnew[minpostsize]', $settings['minpostsize'], 'text');
showsetting('settings_permissions_maxpostsize', 'settingsnew[maxpostsize]', $settings['maxpostsize'], 'text');
showsetting('settings_permissions_favorite_storage', 'settingsnew[maxfavorites]', $settings['maxfavorites'], 'text');
showsetting('settings_permissions_maxpolloptions', 'settingsnew[maxpolloptions]', $settings['maxpolloptions'], 'text');
showsetting('settings_permissions_editby', 'settingsnew[editedby]', $settings['editedby'], 'radio');
showtitle('nav_settings_rate');
showsetting('settings_permissions_karmaratelimit', 'settingsnew[karmaratelimit]', $settings['karmaratelimit'], 'text');
showsetting('settings_permissions_modratelimit', 'settingsnew[modratelimit]', $settings['modratelimit'], 'radio');
showsetting('settings_permissions_dupkarmarate', 'settingsnew[dupkarmarate]', $settings['dupkarmarate'], 'radio');
} elseif($operation == 'credits') {
showtips('settings_credits_tips');
if(!empty($projectid)) {
$settings = @array_merge($settings, unserialize($db->result_first("SELECT value FROM {$tablepre}projects WHERE id='$projectid'")));
}
$projectselect = "<select name=\"projectid\" onchange=\"window.location='$BASESCRIPT?action=settings&operation=credits&projectid='+this.options[this.options.selectedIndex].value\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='extcredit'");
while($project = $db->fetch_array($query)) {
$projectselect .= "<option value=\"$project[id]\" ".($project['id'] == $projectid ? 'selected="selected"' : NULL).">$project[name]</option>\n";
}
$projectselect .= '</select>';
showtableheader('settings_credits_scheme_title', 'nobottom');
showsetting('settings_credits_scheme', '', '', $projectselect);
showtablefooter();
echo <<<EOT
<script type="text/JavaScript">
function switchpolicy(obj, col) {
var status = !obj.checked;
$("policy" + col).disabled = status;
var policytable = $("policytable");
for(var row=2; row<14; row++) {
if(is_opera) {
policytable.rows[row].cells[col].firstChild.disabled = true;
} else {
policytable.rows[row].cells[col].disabled = status;
}
}
}
</script>
EOT;
showtableheader('settings_credits_extended', 'fixpadding');
showsubtitle(array('settings_credits_available', 'credits_id', 'credits_img', 'credits_title', 'credits_unit', 'settings_credits_ratio', 'settings_credits_init', 'credits_inport', 'credits_import'), '');
$settings['extcredits'] = unserialize($settings['extcredits']);
$settings['initcredits'] = explode(',', $settings['initcredits']);
for($i = 1; $i <= 8; $i++) {
showtablerow('', array('width="40"', 'class="td22"', 'class="td22"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"settingsnew[extcredits][$i][available]\" value=\"1\" ".($settings['extcredits'][$i]['available'] ? 'checked' : '')." onclick=\"switchpolicy(this, $i)\">",
'extcredits'.$i,
"<input type=\"text\" class=\"txt\" size=\"8\" name=\"settingsnew[extcredits][$i][img]\" value=\"{$settings['extcredits'][$i]['img']}\">",
"<input type=\"text\" class=\"txt\" size=\"8\" name=\"settingsnew[extcredits][$i][title]\" value=\"{$settings['extcredits'][$i]['title']}\">",
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"settingsnew[extcredits][$i][unit]\" value=\"{$settings['extcredits'][$i]['unit']}\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"settingsnew[extcredits][$i][ratio]\" value=\"".(float)$settings['extcredits'][$i]['ratio']."\" onkeyup=\"if(this.value != '0' && \$('allowexchangeout$i').checked == false && \$('allowexchangein$i').checked == false) {\$('allowexchangeout$i').checked = true;\$('allowexchangein$i').checked = true;} else if(this.value == '0') {\$('allowexchangeout$i').checked = false;\$('allowexchangein$i').checked = false;}\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"settingsnew[initcredits][$i]\" value=\"".intval($settings['initcredits'][$i])."\">",
"<input class=\"checkbox\" type=\"checkbox\" size=\"3\" name=\"settingsnew[extcredits][$i][allowexchangeout]\" value=\"1\" ".($settings['extcredits'][$i]['allowexchangeout'] ? 'checked' : '')." id=\"allowexchangeout$i\">",
"<input class=\"checkbox\" type=\"checkbox\" size=\"3\" name=\"settingsnew[extcredits][$i][allowexchangein]\" value=\"1\" ".($settings['extcredits'][$i]['allowexchangein'] ? 'checked' : '')." id=\"allowexchangein$i\">"
));
}
showtablerow('', 'colspan="10" class="lineheight"', $lang['settings_credits_extended_comment']);
showtablefooter();
showtableheader('settings_credits_policy', 'fixpadding', 'id="policytable"');
echo '<tr><th>'.$lang['credits_id'].'</th>';
$settings['creditspolicy'] = unserialize($settings['creditspolicy']);
for($i = 1; $i <= 8; $i++) {
echo "<th id=\"policy$i\" ".($settings['extcredits'][$i]['available'] ? '' : 'disabled')." valign=\"top\"> extcredits$i<br />".($settings['extcredits'][$i]['title'] ? '('.$settings['extcredits'][$i]['title'].')' : '')."</th>";
}
echo '</tr>';
foreach(array('post', 'reply', 'digest', 'postattach', 'getattach', 'sendpm', 'search', 'promotion_visit', 'promotion_register', 'tradefinished', 'votepoll', 'lowerlimit') as $policy) {
showtablerow('title="'.$lang['settings_credits_policy_'.$policy.'_comment'].'"', array('class="td22"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), creditsrow($policy));
}
showtablerow('', 'class="lineheight" colspan="9"', $lang['settings_credits_policy_comment']);
showtablefooter();
showtableheader('settings_credits', 'fixpadding');
showsetting('settings_credits_formula', 'settingsnew[creditsformula]', $settings['creditsformula'], 'textarea');
$settings['creditstrans'] = explode(',', $settings['creditstrans']);
$creditstrans = array();
for($si = 0; $si < 6; $si++) {
$creditstrans[$si] = '';
for($i = 0; $i <= 8; $i++) {
$creditstrans[$si] .= '<option value="'.$i.'" '.($i == $settings['creditstrans'][$si] ? 'selected' : '').'>'.($i ? 'extcredits'.$i.($settings['extcredits'][$i]['title'] ? '('.$settings['extcredits'][$i]['title'].')' : '') : ($si > 0 ? $lang['settings_credits_trans_used'] : $lang['none'])).'</option>';
}
}
showsetting('settings_credits_trans', '', '', '<select onchange="if(this.value > 0) {$(\'creditstransextra\').style.display = \'\';} else {$(\'creditstransextra\').style.display = \'none\';}" name="settingsnew[creditstrans][0]">'.$creditstrans[0].'</select>');
showtagheader('tbody', 'creditstransextra', $settings['creditstrans'][0], 'sub');
showsetting('settings_credits_trans1', '', '' ,'<select name="settingsnew[creditstrans][1]">'.$creditstrans[1].'</select>');
showsetting('settings_credits_trans2', '', '' ,'<select name="settingsnew[creditstrans][2]">'.$creditstrans[2].'</select>');
showsetting('settings_credits_trans3', '', '' ,'<select name="settingsnew[creditstrans][3]">'.$creditstrans[3].'</select>');
showsetting('settings_credits_trans4', '', '' ,'<select name="settingsnew[creditstrans][4]">'.$creditstrans[4].'</select>');
showsetting('settings_credits_trans5', '', '' ,'<select name="settingsnew[creditstrans][5]"><option value="-1">'.$lang['settings_credits_trans5_none'].'</option>'.$creditstrans[5].'</select>');
showtagfooter('tbody');
showsetting('settings_credits_tax', 'settingsnew[creditstax]', $settings['creditstax'], 'text');
showsetting('settings_credits_mintransfer', 'settingsnew[transfermincredits]', $settings['transfermincredits'], 'text');
showsetting('settings_credits_minexchange', 'settingsnew[exchangemincredits]', $settings['exchangemincredits'], 'text');
showsetting('settings_credits_maxincperthread', 'settingsnew[maxincperthread]', $settings['maxincperthread'], 'text');
showsetting('settings_credits_maxchargespan', 'settingsnew[maxchargespan]', $settings['maxchargespan'], 'text');
$extbutton = ' <input name="projectsave" type="hidden" value="0"><input type="button" class="btn" onclick="$(\'cpform\').projectsave.value=1;$(\'cpform\').settingsubmit.click()" value="'.$lang['saveconf'].'">';
} elseif($operation == 'mail' && $isfounder) {
$settings['mail'] = unserialize($settings['mail']);
$passwordmask = $settings['mail']['auth_password'] ? $settings['mail']['auth_password']{0}.'********'.substr($settings['mail']['auth_password'], -2) : '';
showtableheader('', '', 'id="mailsettings"'.($anchor != 'settings' ? ' style="display: none"' : ''));
showsetting('settings_mail_settings_send', array('settingsnew[mail][mailsend]', array(
array(1, $lang['settings_mail_settings_send_1'], array('hidden1' => 'none', 'hidden2' => 'none')),
array(2, $lang['settings_mail_settings_send_2'], array('hidden1' => '', 'hidden2' => '')),
array(3, $lang['settings_mail_settings_send_3'], array('hidden1' => '', 'hidden2' => 'none'))
)), $settings['mail']['mailsend'], 'mradio');
showtagheader('tbody', 'hidden1', $settings['mail']['mailsend'] != 1, 'sub');
showsetting('settings_mail_settings_server', 'settingsnew[mail][server]', $settings['mail']['server'], 'text');
showsetting('settings_mail_settings_port', 'settingsnew[mail][port]', $settings['mail']['port'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'hidden2', $settings['mail']['mailsend'] == 2, 'sub');
showsetting('settings_mail_settings_auth', 'settingsnew[mail][auth]', $settings['mail']['auth'], 'radio');
showsetting('settings_mail_settings_from', 'settingsnew[mail][from]', $settings['mail']['from'], 'text');
showsetting('settings_mail_settings_username', 'settingsnew[mail][auth_username]', $settings['mail']['auth_username'], 'text');
showsetting('settings_mail_settings_password', 'settingsnew[mail][auth_password]', $passwordmask, 'text');
showtagfooter('tbody');
showsetting('settings_mail_settings_delimiter', array('settingsnew[mail][maildelimiter]', array(
array(1, $lang['settings_mail_settings_delimiter_crlf']),
array(0, $lang['settings_mail_settings_delimiter_lf']),
array(2, $lang['settings_mail_settings_delimiter_cr']))), $settings['mail']['maildelimiter'], 'mradio');
showsetting('settings_mail_settings_includeuser', 'settingsnew[mail][mailusername]', $settings['mail']['mailusername'], 'radio');
showsetting('settings_mail_settings_silent', 'settingsnew[mail][sendmail_silent]', $settings['mail']['sendmail_silent'], 'radio');
showsubmit('settingsubmit');
showtablefooter();
showtableheader('', '', 'id="mailcheck"'.($anchor != 'check' ? ' style="display: none"' : ''));
showsetting('settings_mail_check_test_from', 'test_from', '', 'text');
showsetting('settings_mail_check_test_to', 'test_to', '', 'textarea');
showsubmit('', '', '<input type="submit" class="btn" name="mailcheck" value="'.lang('settings_mail_check_submit').'" onclick="this.form.action=\''.$BASESCRIPT.'?action=checktools&operation=mailcheck&frame=no\';this.form.target=\'mailcheckiframe\'">', '<iframe name="mailcheckiframe" style="display: none"></iframe>');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'sec') {
echo '<script type="text/JavaScript">
function updateseccode(op) {
if(isUndefined(op)) {
ajaxget(\'ajax.php?action=updateseccode\', \'seccodeimage\', \'seccodeimage\');
} else {
window.document.seccodeplayer.SetVariable("isPlay", "1");
}
}
</script>';
$checksc = array();
$settings['seccodedata'] = unserialize($settings['seccodedata']);
$seccodetypearray = array(
array(0, lang('settings_sec_seccode_type_image'), array('seccodeimageext' => '', 'seccodeimagewh' => '')),
array(1, lang('settings_sec_seccode_type_chnfont'), array('seccodeimageext' => '', 'seccodeimagewh' => '')),
array(2, lang('settings_sec_seccode_type_flash'), array('seccodeimageext' => 'none', 'seccodeimagewh' => '')),
array(3, lang('settings_sec_seccode_type_wav'), array('seccodeimageext' => 'none', 'seccodeimagewh' => 'none')),
);
showtips('settings_sec_code_tips', 'seccode_tips', $anchor == 'seccode');
showtips('settings_sec_qaa_tips', 'secqaa_tips', $anchor == 'secqaa');
showtableheader('', '', 'id="seclevel"'.($anchor != 'seclevel' ? ' style="display: none"' : ''));
showsetting('settings_sec_seclevel', array('settingsnew[seclevel]', array(
array(0, $lang['settings_sec_seclevel_lower']),
array(1, $lang['settings_sec_seclevel_higher'])
)), $settings['seclevel'], 'mradio');
showsubmit('settingsubmit');
showtablefooter();
showtableheader('', '', 'id="seccode"'.($anchor != 'seccode' ? ' style="display: none"' : ''));
showsetting('settings_sec_seccode_status', array('settingsnew[seccodestatus]', array(
lang('settings_sec_seccode_status_register'),
lang('settings_sec_seccode_status_login'),
lang('settings_sec_seccode_status_post'),
lang('settings_sec_seccode_status_profile')
)), $settings['seccodestatus'], 'binmcheckbox');
showsetting('settings_sec_seccode_minposts', 'settingsnew[seccodedata][minposts]', $settings['seccodedata']['minposts'], 'text');
showsetting('settings_sec_seccode_loginfailedcount', 'settingsnew[seccodedata][loginfailedcount]', $settings['seccodedata']['loginfailedcount'], 'radio');
showsetting('settings_sec_seccode_type', array('settingsnew[seccodedata][type]', $seccodetypearray), $settings['seccodedata']['type'], 'mradio');
showtagheader('tbody', 'seccodeimagewh', $settings['seccodedata']['type'] != 3, 'sub');
showsetting('settings_sec_seccode_width', 'settingsnew[seccodedata][width]', $settings['seccodedata']['width'], 'text');
showsetting('settings_sec_seccode_height', 'settingsnew[seccodedata][height]', $settings['seccodedata']['height'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'seccodeimageext', $settings['seccodedata']['type'] != 2 && $settings['seccodedata']['type'] != 3, 'sub');
showsetting('settings_sec_seccode_background', 'settingsnew[seccodedata][background]', $settings['seccodedata']['background'], 'radio');
showsetting('settings_sec_seccode_adulterate', 'settingsnew[seccodedata][adulterate]', $settings['seccodedata']['adulterate'], 'radio');
showsetting('settings_sec_seccode_ttf', 'settingsnew[seccodedata][ttf]', $settings['seccodedata']['ttf'], 'radio', !function_exists('imagettftext'));
showsetting('settings_sec_seccode_angle', 'settingsnew[seccodedata][angle]', $settings['seccodedata']['angle'], 'radio');
showsetting('settings_sec_seccode_color', 'settingsnew[seccodedata][color]', $settings['seccodedata']['color'], 'radio');
showsetting('settings_sec_seccode_size', 'settingsnew[seccodedata][size]', $settings['seccodedata']['size'], 'radio');
showsetting('settings_sec_seccode_shadow', 'settingsnew[seccodedata][shadow]', $settings['seccodedata']['shadow'], 'radio');
showsetting('settings_sec_seccode_animator', 'settingsnew[seccodedata][animator]', $settings['seccodedata']['animator'], 'radio', !function_exists('imagegif'));
showtagfooter('tbody');
showsubmit('settingsubmit');
showtablefooter();
echo '<script language="JavaScript">updateseccode()</script>';
$settings['secqaa'] = unserialize($settings['secqaa']);
$page = max(1, intval($page));
$start_limit = ($page - 1) * 10;
$secqaanums = $db->result_first("SELECT COUNT(*) FROM {$tablepre}itempool");
$multipage = multi($secqaanums, 10, $page, $BASESCRIPT.'?action=settings&operation=sec&anchor=secqaa');
$query = $db->query("SELECT * FROM {$tablepre}itempool LIMIT $start_limit, 10");
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1,''], [1,'<input name="newquestion[]" type="text" class="txt">','td26'], [1, '<input name="newanswer[]" type="text" class="txt">']],
];
</script>
EOT;
showtagheader('div', 'secqaa', $anchor == 'secqaa');
showtableheader('settings_sec_secqaa', 'nobottom');
showsetting('settings_sec_secqaa_status', array('settingsnew[secqaa][status]', array(
lang('settings_sec_seccode_status_register'),
lang('settings_sec_seccode_status_post')
)), $settings['secqaa']['status'], 'binmcheckbox');
showsetting('settings_sec_secqaa_minposts', 'settingsnew[secqaa][minposts]', $settings['secqaa']['minposts'], 'text');
showtablefooter();
showtableheader('settings_sec_secqaa_qaa', 'noborder fixpadding');
showsubtitle(array('', 'settings_sec_secqaa_question', 'settings_sec_secqaa_answer'));
while($item = $db->fetch_array($query)) {
showtablerow('', array('', 'class="td26"'), array(
'<input class="checkbox" type="checkbox" name="delete[]" value="'.$item['id'].'">',
'<input type="text" class="txt" name="question['.$item['id'].']" value="'.dhtmlspecialchars($item['question']).'" class="txtnobd" onblur="this.className=\'txtnobd\'" onfocus="this.className=\'txt\'">',
'<input type="text" class="txt" name="answer['.$item['id'].']" value="'.$item['answer'].'" class="txtnobd" onblur="this.className=\'txtnobd\'" onfocus="this.className=\'txt\'">'
));
}
echo '<tr><td></td><td class="td26"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['settings_sec_secqaa_add'].'</a></div></td><td></td></tr>';
showsubmit('settingsubmit', 'submit', 'del', '', $multipage);
showtablefooter();
showtagfooter('div');
showformfooter();
cpfooter();
exit;
} elseif($operation == 'datetime') {
$checktimeformat = array($settings['timeformat'] == 'H:i' ? 24 : 12 => 'checked');
$settings['userdateformat'] = dateformat($settings['userdateformat']);
$settings['dateformat'] = dateformat($settings['dateformat']);
showtableheader();
showtitle('settings_datetime_format');
showsetting('settings_datetime_dateformat', 'settingsnew[dateformat]', $settings['dateformat'], 'text');
showsetting('settings_datetime_timeformat', '', '', '<input class="radio" type="radio" name="settingsnew[timeformat]" value="24" '.$checktimeformat[24].'> 24 '.$lang['hour'].' <input class="radio" type="radio" name="settingsnew[timeformat]" value="12" '.$checktimeformat[12].'> 12 '.$lang['hour'].'');
showsetting('settings_datetime_dateconvert', 'settingsnew[dateconvert]', $settings['dateconvert'], 'radio');
showsetting('settings_datetime_timeoffset', 'settingsnew[timeoffset]', $settings['timeoffset'], 'text');
showsetting('settings_datetime_customformat', 'settingsnew[userdateformat]', $settings['userdateformat'], 'textarea');
showtitle('settings_datetime_periods');
showsetting('settings_datetime_visitbanperiods', 'settingsnew[visitbanperiods]', $settings['visitbanperiods'], 'textarea');
showsetting('settings_datetime_postbanperiods', 'settingsnew[postbanperiods]', $settings['postbanperiods'], 'textarea');
showsetting('settings_datetime_postmodperiods', 'settingsnew[postmodperiods]', $settings['postmodperiods'], 'textarea');
showsetting('settings_datetime_ban_downtime', 'settingsnew[attachbanperiods]', $settings['attachbanperiods'], 'textarea');
showsetting('settings_datetime_searchbanperiods', 'settingsnew[searchbanperiods]', $settings['searchbanperiods'], 'textarea');
} elseif($operation == 'attach') {
$checkwm = array($settings['watermarkstatus'] => 'checked');
$checkmkdirfunc = !function_exists('mkdir') ? 'disabled' : '';
$settings['watermarktext'] = unserialize($settings['watermarktext']);
$settings['watermarktext']['fontpath'] = str_replace(array('ch/', 'en/'), '', $settings['watermarktext']['fontpath']);
$fontlist = '<select name="settingsnew[watermarktext][fontpath]">';
$dir = opendir(DISCUZ_ROOT.'./images/fonts/en');
while($entry = readdir($dir)) {
if(in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
$fontlist .= '<option value="'.$entry.'"'.($entry == $settings['watermarktext']['fontpath'] ? ' selected>' : '>').$entry.'</option>';
}
}
$dir = opendir(DISCUZ_ROOT.'./images/fonts/ch');
while($entry = readdir($dir)) {
if(in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
$fontlist .= '<option value="'.$entry.'"'.($entry == $settings['watermarktext']['fontpath'] ? ' selected>' : '>').$entry.'</option>';
}
}
$fontlist .= '</select>';
showtableheader('', '', 'id="basic"'.($anchor != 'basic' ? ' style="display: none"' : ''));
showsetting('settings_attach_basic_dir', 'settingsnew[attachdir]', $settings['attachdir'], 'text');
showsetting('settings_attach_basic_url', 'settingsnew[attachurl]', $settings['attachurl'], 'text');
showsetting('settings_attach_basic_imgpost', 'settingsnew[attachimgpost]', $settings['attachimgpost'], 'radio');
showsetting('settings_attach_basic_save', array('settingsnew[attachsave]', array(
array(0, $lang['settings_attach_basic_save_default']),
array(1, $lang['settings_attach_basic_save_forum']),
array(2, $lang['settings_attach_basic_save_type']),
array(3, $lang['settings_attach_basic_save_month']),
array(4, $lang['settings_attach_basic_save_day'])
)), $settings['attachsave'], 'select', $checkmkdirfunc);
$settings['swfupload'] = $settings['swfupload'] == 2 ? array(0, 1) : array($settings['swfupload']);
showsetting('settings_attach_basic_swfupload', array('settingsnew[swfupload]', array(array(0, $lang['settings_attach_basic_simple']), array(1, $lang['settings_attach_basic_multi']))), $settings['swfupload'], 'mcheckbox');
showsetting('settings_attach_basic_allowattachurl', 'settingsnew[allowattachurl]', $settings['allowattachurl'], 'radio');
showsubmit('settingsubmit');
showtablefooter();
showtableheader('', '', 'id="image"'.($anchor != 'image' ? ' style="display: none"' : ''));
showsetting('settings_attach_image_lib', array('settingsnew[imagelib]', array(
array(0, $lang['settings_attach_image_watermarktype_GD'], array('imagelibext' => 'none')),
array(1, $lang['settings_attach_image_watermarktype_IM'], array('imagelibext' => ''))
)), $settings['imagelib'], 'mradio');
showtagheader('tbody', 'imagelibext', $settings['imagelib'], 'sub');
showsetting('settings_attach_image_impath', 'settingsnew[imageimpath]', $settings['imageimpath'], 'text');
showtagfooter('tbody');
showsetting('settings_attach_image_thumbstatus', array('settingsnew[thumbstatus]', array(
array(0, $lang['settings_attach_image_thumbstatus_none'], array('thumbext' => 'none')),
array(1, $lang['settings_attach_image_thumbstatus_add'], array('thumbext' => '')),
array(3, $lang['settings_attach_image_thumbstatus_addfix'], array('thumbext' => '')),
array(2, $lang['settings_attach_image_thumbstatus_replace'], array('thumbext' => ''))
)), $settings['thumbstatus'], 'mradio');
showtagheader('tbody', 'thumbext', $settings['thumbstatus'], 'sub');
showsetting('settings_attach_image_thumbquality', 'settingsnew[thumbquality]', $settings['thumbquality'], 'text');
showsetting('settings_attach_image_thumbwidthheight', array('settingsnew[thumbwidth]', 'settingsnew[thumbheight]'), array(intval($settings['thumbwidth']), intval($settings['thumbheight'])), 'multiply');
showtagfooter('tbody');
showsetting('settings_attach_image_watermarkstatus', '', '', '<table cellspacing="'.INNERBORDERWIDTH.'" cellpadding="'.TABLESPACE.'" style="margin-bottom: 3px; margin-top:3px;"><tr><td colspan="3"><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="0" '.$checkwm[0].'>'.$lang['settings_attach_image_watermarkstatus_none'].'</td></tr><tr><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="1" '.$checkwm[1].'> #1</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="2" '.$checkwm[2].'> #2</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="3" '.$checkwm[3].'> #3</td></tr><tr><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="4" '.$checkwm[4].'> #4</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="5" '.$checkwm[5].'> #5</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="6" '.$checkwm[6].'> #6</td></tr><tr><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="7" '.$checkwm[7].'> #7</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="8" '.$checkwm[8].'> #8</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="9" '.$checkwm[9].'> #9</td></tr></table>');
showsetting('settings_attach_image_watermarkminwidthheight', array('settingsnew[watermarkminwidth]', 'settingsnew[watermarkminheight]'), array(intval($settings['watermarkminwidth']), intval($settings['watermarkminheight'])), 'multiply');
showsetting('settings_attach_image_watermarktype', array('settingsnew[watermarktype]', array(
array(0, $lang['settings_attach_image_watermarktype_gif'], array('watermarktypeext' => 'none')),
array(1, $lang['settings_attach_image_watermarktype_png'], array('watermarktypeext' => 'none')),
array(2, $lang['settings_attach_image_watermarktype_text'], array('watermarktypeext' => ''))
)), $settings['watermarktype'], 'mradio');
showsetting('settings_attach_image_watermarktrans', 'settingsnew[watermarktrans]', $settings['watermarktrans'], 'text');
showsetting('settings_attach_image_watermarkquality', 'settingsnew[watermarkquality]', $settings['watermarkquality'], 'text');
showtagheader('tbody', 'watermarktypeext', $settings['watermarktype'] == 2, 'sub');
showsetting('settings_attach_image_watermarktext_text', 'settingsnew[watermarktext][text]', $settings['watermarktext']['text'], 'textarea');
showsetting('settings_attach_image_watermarktext_fontpath', '', '', $fontlist);
showsetting('settings_attach_image_watermarktext_size', 'settingsnew[watermarktext][size]', $settings['watermarktext']['size'], 'text');
showsetting('settings_attach_image_watermarktext_angle', 'settingsnew[watermarktext][angle]', $settings['watermarktext']['angle'], 'text');
showsetting('settings_attach_image_watermarktext_color', 'settingsnew[watermarktext][color]', $settings['watermarktext']['color'], 'color');
showsetting('settings_attach_image_watermarktext_shadowx', 'settingsnew[watermarktext][shadowx]', $settings['watermarktext']['shadowx'], 'text');
showsetting('settings_attach_image_watermarktext_shadowy', 'settingsnew[watermarktext][shadowy]', $settings['watermarktext']['shadowy'], 'text');
showsetting('settings_attach_image_watermarktext_shadowcolor', 'settingsnew[watermarktext][shadowcolor]', $settings['watermarktext']['shadowcolor'], 'color');
showsetting('settings_attach_image_watermarktext_imtranslatex', 'settingsnew[watermarktext][translatex]', $settings['watermarktext']['translatex'], 'text');
showsetting('settings_attach_image_watermarktext_imtranslatey', 'settingsnew[watermarktext][translatey]', $settings['watermarktext']['translatey'], 'text');
showsetting('settings_attach_image_watermarktext_imskewx', 'settingsnew[watermarktext][skewx]', $settings['watermarktext']['skewx'], 'text');
showsetting('settings_attach_image_watermarktext_imskewy', 'settingsnew[watermarktext][skewy]', $settings['watermarktext']['skewy'], 'text');
showtagfooter('tbody');
showsubmit('settingsubmit');
showtablefooter();
if($isfounder) {
$settings['ftp'] = unserialize($settings['ftp']);
$settings['ftp'] = is_array($settings['ftp']) ? $settings['ftp'] : array();
$settings['ftp']['password'] = authcode($settings['ftp']['password'], 'DECODE', md5($authkey));
$settings['ftp']['password'] = $settings['ftp']['password'] ? $settings['ftp']['password']{0}.'********'.$settings['ftp']['password']{strlen($settings['ftp']['password']) - 1} : '';
showtableheader('', '', 'id="remote"'.($anchor != 'remote' ? ' style="display: none"' : ''));
showsetting('settings_attach_remote_enabled', array('settingsnew[ftp][on]', array(
array(1, $lang['yes'], array('ftpext' => '', 'ftpcheckbutton' => '')),
array(0, $lang['no'], array('ftpext' => 'none', 'ftpcheckbutton' => 'none'))
), TRUE), $settings['ftp']['on'], 'mradio');
showtagheader('tbody', 'ftpext', $settings['ftp']['on'], 'sub');
showsetting('settings_attach_remote_enabled_ssl', 'settingsnew[ftp][ssl]', $settings['ftp']['ssl'], 'radio');
showsetting('settings_attach_remote_ftp_host', 'settingsnew[ftp][host]', $settings['ftp']['host'], 'text');
showsetting('settings_attach_remote_ftp_port', 'settingsnew[ftp][port]', $settings['ftp']['port'], 'text');
showsetting('settings_attach_remote_ftp_user', 'settingsnew[ftp][username]', $settings['ftp']['username'], 'text');
showsetting('settings_attach_remote_ftp_pass', 'settingsnew[ftp][password]', $settings['ftp']['password'], 'text');
showsetting('settings_attach_remote_ftp_pasv', 'settingsnew[ftp][pasv]', $settings['ftp']['pasv'], 'radio');
showsetting('settings_attach_remote_dir', 'settingsnew[ftp][attachdir]', $settings['ftp']['attachdir'], 'text');
showsetting('settings_attach_remote_url', 'settingsnew[ftp][attachurl]', $settings['ftp']['attachurl'], 'text');
showsetting('settings_attach_remote_timeout', 'settingsnew[ftp][timeout]', $settings['ftp']['timeout'], 'text');
showsetting('settings_attach_remote_mirror', array('settingsnew[ftp][mirror]', array(
array(1, lang('settings_attach_remote_mirror_1')),
//array(2, lang('settings_attach_remote_mirror_2')),
array(0, lang('settings_attach_remote_mirror_0'))
)), intval($settings['ftp']['mirror']), 'mradio');
showsetting('settings_attach_remote_allowedexts', 'settingsnew[ftp][allowedexts]', $settings['ftp']['allowedexts'], 'textarea');
showsetting('settings_attach_remote_disallowedexts', 'settingsnew[ftp][disallowedexts]', $settings['ftp']['disallowedexts'], 'textarea');
showsetting('settings_attach_remote_minsize', 'settingsnew[ftp][minsize]', $settings['ftp']['minsize'], 'text');
showtagfooter('tbody');
showsubmit('settingsubmit', 'submit', '', '<span id="ftpcheckbutton" style="display: '.($settings['ftp']['on'] ? '' : 'none').'"><input type="submit" class="btn" name="ftpcheck" value="'.$lang['settings_attach_remote_ftpcheck'].'" onclick="this.form.action=\''.$BASESCRIPT.'?action=checktools&operation=ftpcheck&frame=no\';this.form.target=\'ftpcheckiframe\';"></span><iframe name="ftpcheckiframe" style="display: none"></iframe>');
showtablefooter();
}
showtableheader('', '', 'id="antileech"'.($anchor != 'antileech' ? ' style="display: none"' : ''));
showsetting('settings_attach_antileech_expire', 'settingsnew[attachexpire]', $settings['attachexpire'], 'text');
showsetting('settings_attach_antileech_refcheck', 'settingsnew[attachrefcheck]', $settings['attachrefcheck'], 'radio');
showsetting('settings_attach_antileech_remote_hide_dir', 'settingsnew[ftp][hideurl]', $settings['ftp']['hideurl'], 'radio');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'wap') {
$settings['wapdateformat'] = dateformat($settings['wapdateformat']);
showtableheader();
showsetting('settings_wap_status', 'settingsnew[wapstatus]', $settings['wapstatus'], 'radio', '', 1);
showsetting('settings_wap_register', 'settingsnew[wapregister]', $settings['wapregister'], 'radio');
showsetting('settings_wap_charset', array('settingsnew[wapcharset]', array(
array(1, 'UTF-8'),
array(2, 'UNICODE'))), $settings['wapcharset'], 'mradio');
showsetting('settings_wap_tpp', 'settingsnew[waptpp]', $settings['waptpp'], 'text');
showsetting('settings_wap_ppp', 'settingsnew[wapppp]', $settings['wapppp'], 'text');
showsetting('settings_wap_dateformat', 'settingsnew[wapdateformat]', $settings['wapdateformat'], 'text');
showsetting('settings_wap_mps', 'settingsnew[wapmps]', $settings['wapmps'], 'text');
showtagfooter('tbody');
} elseif($operation == 'dzfeed') {
$usergroups_member = array();
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type='member'");
while($row = $db->fetch_array($query)) {
$usergroups_member[] = array($row['groupid'], $row['grouptitle']);
}
$settings['dzfeed_limit'] = unserialize($settings['dzfeed_limit']);
foreach(array('thread_replies', 'thread_views', 'thread_rate', 'post_rate', 'user_credit', 'user_threads', 'user_posts', 'user_digest') as $v) {
$settings['dzfeed_limit'][$v] = isset($settings['dzfeed_limit'][$v]) && is_array($settings['dzfeed_limit'][$v]) ? implode(', ', $settings['dzfeed_limit'][$v]) : 0;
}
showtableheader();
showsetting('settings_dzfeed_thread_replies', 'settingsnew[dzfeed_limit][thread_replies]', $settings['dzfeed_limit']['thread_replies'], 'text');
showsetting('settings_dzfeed_thread_views', 'settingsnew[dzfeed_limit][thread_views]', $settings['dzfeed_limit']['thread_views'], 'text');
showsetting('settings_dzfeed_thread_rate', 'settingsnew[dzfeed_limit][thread_rate]', $settings['dzfeed_limit']['thread_rate'], 'text');
showsetting('settings_dzfeed_post_rate', 'settingsnew[dzfeed_limit][post_rate]', $settings['dzfeed_limit']['post_rate'], 'text');
showsetting('settings_dzfeed_user_usergroup', array('settingsnew[dzfeed_limit][user_usergroup]', $usergroups_member), $settings['dzfeed_limit']['user_usergroup'], 'mcheckbox');
showsetting('settings_dzfeed_user_credit', 'settingsnew[dzfeed_limit][user_credit]', $settings['dzfeed_limit']['user_credit'], 'text');
showsetting('settings_dzfeed_user_threads', 'settingsnew[dzfeed_limit][user_threads]', $settings['dzfeed_limit']['user_threads'], 'text');
showsetting('settings_dzfeed_user_posts', 'settingsnew[dzfeed_limit][user_posts]', $settings['dzfeed_limit']['user_posts'], 'text');
showsetting('settings_dzfeed_user_digest', 'settingsnew[dzfeed_limit][user_digest]', $settings['dzfeed_limit']['user_digest'], 'text');
} elseif($operation == 'uc' && $isfounder) {
$disable = !is_writeable('./config.inc.php');
showtips('settings_uc_tips');
showtableheader();
showsetting('settings_uc_appid', 'settingsnew[uc][appid]', UC_APPID, 'text', $disable);
showsetting('settings_uc_key', 'settingsnew[uc][key]', UC_KEY, 'text', $disable);
showsetting('settings_uc_api', 'settingsnew[uc][api]', UC_API, 'text', $disable);
showsetting('settings_uc_ip', 'settingsnew[uc][ip]', UC_IP, 'text', $disable);
showsetting('settings_uc_connect', array('settingsnew[uc][connect]', array(
array('mysql', $lang['settings_uc_connect_mysql'], array('ucmysql' => '')),
array('', $lang['settings_uc_connect_api'], array('ucmysql' => 'none')))), UC_CONNECT, 'mradio', $disable);
list($ucdbname, $uctablepre) = explode('.', str_replace('`', '', UC_DBTABLEPRE));
showtagheader('tbody', 'ucmysql', UC_CONNECT, 'sub');
showsetting('settings_uc_dbhost', 'settingsnew[uc][dbhost]', UC_DBHOST, 'text', $disable);
showsetting('settings_uc_dbuser', 'settingsnew[uc][dbuser]', UC_DBUSER, 'text', $disable);
showsetting('settings_uc_dbpass', 'settingsnew[uc][dbpass]', '********', 'text', $disable);
showsetting('settings_uc_dbname', 'settingsnew[uc][dbname]', $ucdbname, 'text', $disable);
showsetting('settings_uc_dbtablepre', 'settingsnew[uc][dbtablepre]', $uctablepre, 'text', $disable);
showtagfooter('tbody');
showsetting('settings_uc_activation', 'settingsnew[ucactivation]', $settings['ucactivation'], 'radio');
showsetting('settings_uc_avatarmethod', array('settingsnew[avatarmethod]', array(
array(0, $lang['settings_uc_avatarmethod_0']),
array(1, $lang['settings_uc_avatarmethod_1']),
)), $settings['avatarmethod'], 'mradio');
} elseif($operation == 'ec') {
$settings['tradetypes'] = unserialize($settings['tradetypes']);
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE special='1' ORDER BY displayorder");
$tradetypeselect = '<select name="settingsnew[tradetypes][]" size="10" multiple="multiple">';
while($type = $db->fetch_array($query)) {
$checked = @in_array($type['typeid'], $settings['tradetypes']);
$tradetypeselect .= '<option value="'.$type['typeid'].'"'.($checked ? ' selected="selected"' : '').'>'.$type['name'].'</option>';
}
$tradetypeselect .= '</select>';
showtableheader();
showtitle('settings_ec_credittrade');
showsetting('settings_ec_ratio', 'settingsnew[ec_ratio]', $settings['ec_ratio'], 'text');
showsetting('settings_ec_mincredits', 'settingsnew[ec_mincredits]', $settings['ec_mincredits'], 'text');
showsetting('settings_ec_maxcredits', 'settingsnew[ec_maxcredits]', $settings['ec_maxcredits'], 'text');
showsetting('settings_ec_maxcreditspermonth', 'settingsnew[ec_maxcreditspermonth]', $settings['ec_maxcreditspermonth'], 'text');
showtitle('settings_ec_goodstrade');
showsetting('settings_ec_type', '', '', $tradetypeselect);
} elseif($operation == 'msn') {
$settings['msn'] = unserialize($settings['msn']);
showtips('settings_msn_tips');
showtableheader();
showtitle('settings_msn_basic');
showsetting('settings_msn_on', 'settingsnew[msn][on]', $settings['msn']['on'], 'radio');
showsetting('settings_msn_domain', 'msndomain', $settings['msn']['domain'], 'text');
showsubmit('settingsubmit', 'submit', '', '<input type="button" class="btn" name="msncheck" value="'.$lang['settings_msn_domain_check'].'" onclick="window.open(\'https://domains.live.com/members/signup.aspx?domain=\'+this.form.msndomain.value)" />');
showtablefooter();
exit;
} else {
cpmsg('undefined_action');
}
showsubmit('settingsubmit', 'submit', '', $extbutton.(!empty($from) ? '<input type="hidden" name="from" value="'.$from.'">' : ''));
showtablefooter();
showformfooter();
} else {
if($operation == 'credits') {
$extcredits_exists = 0;
foreach($settingsnew['extcredits'] as $val) {
if(isset($val['available']) && $val['available'] == 1) {
$extcredits_exists = 1;
break;
}
}
if(!$extcredits_exists) {
cpmsg('settings_extcredits_must_available');
}
}
if($operation == 'uc' && is_writeable('./config.inc.php') && $isfounder) {
$ucdbpassnew = $settingsnew['uc']['dbpass'] == '********' ? UC_DBPW : $settingsnew['uc']['dbpass'];
if($settingsnew['uc']['connect']) {
$uc_dblink = @mysql_connect($settingsnew['uc']['dbhost'], $settingsnew['uc']['dbuser'], $ucdbpassnew, 1);
if(!$uc_dblink) {
cpmsg('uc_database_connect_error', '', 'error');
} else {
mysql_close($uc_dblink);
}
}
$fp = fopen('./config.inc.php', 'r');
$configfile = fread($fp, filesize('./config.inc.php'));
$configfile = trim($configfile);
$configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;
fclose($fp);
$connect = '';
if($settingsnew['uc']['connect']) {
require './config.inc.php';
$connect = 'mysql';
$samelink = ($dbhost == $settingsnew['uc']['dbhost'] && $dbuser == $settingsnew['uc']['dbuser'] && $dbpw == $ucdbpassnew);
$samecharset = !($dbcharset == 'gbk' && UC_DBCHARSET == 'latin1' || $dbcharset == 'latin1' && UC_DBCHARSET == 'gbk');
$configfile = insertconfig($configfile, "/define\('UC_DBHOST',\s*'.*?'\);/i", "define('UC_DBHOST', '".$settingsnew['uc']['dbhost']."');");
$configfile = insertconfig($configfile, "/define\('UC_DBUSER',\s*'.*?'\);/i", "define('UC_DBUSER', '".$settingsnew['uc']['dbuser']."');");
$configfile = insertconfig($configfile, "/define\('UC_DBPW',\s*'.*?'\);/i", "define('UC_DBPW', '".$ucdbpassnew."');");
$configfile = insertconfig($configfile, "/define\('UC_DBNAME',\s*'.*?'\);/i", "define('UC_DBNAME', '".$settingsnew['uc']['dbname']."');");
$configfile = insertconfig($configfile, "/define\('UC_DBTABLEPRE',\s*'.*?'\);/i", "define('UC_DBTABLEPRE', '`".$settingsnew['uc']['dbname'].'`.'.$settingsnew['uc']['dbtablepre']."');");
//$configfile = insertconfig($configfile, "/define\('UC_LINK',\s*'?.*?'?\);/i", "define('UC_LINK', ".($samelink && $samecharset ? 'TRUE' : 'FALSE').");");
}
$configfile = insertconfig($configfile, "/define\('UC_CONNECT',\s*'.*?'\);/i", "define('UC_CONNECT', '$connect');");
$configfile = insertconfig($configfile, "/define\('UC_KEY',\s*'.*?'\);/i", "define('UC_KEY', '".$settingsnew['uc']['key']."');");
$configfile = insertconfig($configfile, "/define\('UC_API',\s*'.*?'\);/i", "define('UC_API', '".$settingsnew['uc']['api']."');");
$configfile = insertconfig($configfile, "/define\('UC_IP',\s*'.*?'\);/i", "define('UC_IP', '".$settingsnew['uc']['ip']."');");
$configfile = insertconfig($configfile, "/define\('UC_APPID',\s*'?.*?'?\);/i", "define('UC_APPID', '".$settingsnew['uc']['appid']."');");
$fp = fopen('./config.inc.php', 'w');
if(!($fp = @fopen('./config.inc.php', 'w'))) {
cpmsg('uc_config_write_error', '', 'error');
}
@fwrite($fp, trim($configfile));
@fclose($fp);
}
$nohtmlarray = array('bbname', 'regname', 'reglinkname', 'icp', 'sitemessage');
foreach($nohtmlarray as $k) {
if(isset($settingsnew[$k])) {
$settingsnew[$k] = dhtmlspecialchars($settingsnew[$k]);
}
}
if(isset($settingsnew['censoruser'])) {
$settingsnew['censoruser'] = trim(preg_replace("/\s*(\r\n|\n\r|\n|\r)\s*/", "\r\n", $settingsnew['censoruser']));
}
if(isset($settingsnew['ipregctrl'])) {
$settingsnew['ipregctrl'] = trim(preg_replace("/\s*(\r\n|\n\r|\n|\r)\s*/", "\r\n", $settingsnew['ipregctrl']));
}
if(isset($settingsnew['ipaccess'])) {
if($settingsnew['ipaccess'] = trim(preg_replace("/(\s*(\r\n|\n\r|\n|\r)\s*)/", "\r\n", $settingsnew['ipaccess']))) {
if(!ipaccess($onlineip, $settingsnew['ipaccess'])) {
cpmsg('settings_ipaccess_invalid', '', 'error');
}
}
}
if(isset($settingsnew['adminipaccess'])) {
if($settingsnew['adminipaccess'] = trim(preg_replace("/(\s*(\r\n|\n\r|\n|\r)\s*)/", "\r\n", $settingsnew['adminipaccess']))) {
if(!ipaccess($onlineip, $settingsnew['adminipaccess'])) {
cpmsg('settings_adminipaccess_invalid', '', 'error');
}
}
}
if(isset($settingsnew['welcomemsgtitle'])) {
$settingsnew['welcomemsgtitle'] = cutstr(trim(dhtmlspecialchars($settingsnew['welcomemsgtitle'])), 75);
}
if(isset($settingsnew['showsignatures']) && isset($settingsnew['showavatars']) && isset($settingsnew['showimages'])) {
$settingsnew['showsettings'] = bindec($settingsnew['showsignatures'].$settingsnew['showavatars'].$settingsnew['showimages']);
}
if(!empty($settingsnew['globalstick'])) {
updatecache('globalstick');
}
if(isset($settingsnew['inviteconfig'])) {
$settingsnew['inviteconfig'] = addslashes(serialize($settingsnew['inviteconfig']));
}
if(isset($settingsnew['sitemessage'])) {
$settingsnew['sitemessage'] = addslashes(serialize($settingsnew['sitemessage']));
}
if(isset($settingsnew['smthumb'])) {
$settingsnew['smthumb'] = intval($settingsnew['smthumb']) >= 20 && intval($settingsnew['smthumb']) <= 40 ? intval($settingsnew['smthumb']) : 20;
}
if(isset($settingsnew['allowindextype'])) {
if(!$settingsnew['allowindextype']) {
$settingsnew['indextype'] = '';
}
unset($settingsnew['allowindextype']);
}
if(isset($settingsnew['indexhot'])) {
$settingsnew['indexhot']['limit'] = intval($settingsnew['indexhot']['limit']) ? $settingsnew['indexhot']['limit'] : 10;
$settingsnew['indexhot']['days'] = intval($settingsnew['indexhot']['days']) ? $settingsnew['indexhot']['days'] : 7;
$settingsnew['indexhot']['expiration'] = intval($settingsnew['indexhot']['expiration']) ? $settingsnew['indexhot']['expiration'] : 900;
$settingsnew['indexhot']['width'] = intval($settingsnew['indexhot']['width']) ? $settingsnew['indexhot']['width'] : 100;
$settingsnew['indexhot']['height'] = intval($settingsnew['indexhot']['height']) ? $settingsnew['indexhot']['height'] : 70;
$settingsnew['indexhot']['messagecut'] = intval($settingsnew['indexhot']['messagecut']) ? $settingsnew['indexhot']['messagecut'] : 200;
$indexhot = $settingsnew['indexhot'];
$settingsnew['indexhot'] = addslashes(serialize($settingsnew['indexhot']));
updatecache('heats');
}
if(isset($settingsnew['defaulteditormode']) && isset($settingsnew['allowswitcheditor'])) {
$settingsnew['editoroptions'] = bindec($settingsnew['defaulteditormode'].$settingsnew['allowswitcheditor']);
}
if(isset($settingsnew['myrecorddays'])) {
$settingsnew['myrecorddays'] = intval($settingsnew['myrecorddays']) > 0 ? intval($settingsnew['myrecorddays']) : 30;
}
if(!empty($settingsnew['thumbstatus']) && !function_exists('imagejpeg')) {
$settingsnew['thumbstatus'] = 0;
}
if(isset($settingsnew['creditsformula']) && isset($settingsnew['extcredits']) && isset($settingsnew['creditspolicy']) && isset($settingsnew['initcredits']) && isset($settingsnew['creditstrans']) && isset($settingsnew['creditstax'])) {
if(!preg_match("/^([\+\-\*\/\.\d\(\)]|((extcredits[1-8]|digestposts|posts|threads|pageviews|oltime)([\+\-\*\/\(\)]|$)+))+$/", $settingsnew['creditsformula']) || !is_null(@eval(preg_replace("/(digestposts|posts|threads|pageviews|oltime|extcredits[1-8])/", "\$\\1", $settingsnew['creditsformula']).';'))) {
cpmsg('settings_creditsformula_invalid', '', 'error');
}
$extcreditsarray = array();
if(is_array($settingsnew['extcredits'])) {
foreach($settingsnew['extcredits'] as $key => $value) {
if($value['available'] && !$value['title']) {
cpmsg('settings_credits_title_invalid', '', 'error');
}
$extcreditsarray[$key] = array
(
'img' => dhtmlspecialchars(stripslashes($value['img'])),
'title' => dhtmlspecialchars(stripslashes($value['title'])),
'unit' => dhtmlspecialchars(stripslashes($value['unit'])),
'ratio' => ($value['ratio'] > 0 ? (float)$value['ratio'] : 0),
'available' => $value['available'],
'lowerlimit' => intval($settingsnew['creditspolicy']['lowerlimit'][$key]),
'showinthread' => $value['showinthread'],
'allowexchangein' => $value['allowexchangein'],
'allowexchangeout' => $value['allowexchangeout']
);
$settingsnew['initcredits'][$key] = intval($settingsnew['initcredits'][$key]);
}
}
if(is_array($settingsnew['creditspolicy'])) {
foreach($settingsnew['creditspolicy'] as $key => $value) {
for($i = 1; $i <= 8; $i++) {
if(empty($value[$i])) {
unset($settingsnew['creditspolicy'][$key][$i]);
} else {
$value[$i] = $value[$i] > 99 ? 99 : ($value[$i] < -99 ? -99 : $value[$i]);
$settingsnew['creditspolicy'][$key][$i] = intval($value[$i]);
}
}
}
} else {
$settingsnew['creditspolicy'] = array();
}
for($si = 0; $si < 6; $si++) {
$creditstransi = $si > 0 && !$settingsnew['creditstrans'][$si] ? $settingsnew['creditstrans'][0] : $settingsnew['creditstrans'][$si];
if($creditstransi && empty($settingsnew['extcredits'][$creditstransi]['available']) && $settingsnew['creditstrans'][$si] != -1) {
cpmsg('settings_creditstrans_invalid', '', 'error');
}
}
$settingsnew['creditspolicy'] = addslashes(serialize($settingsnew['creditspolicy']));
$settingsnew['creditsformulaexp'] = $settingsnew['creditsformula'];
foreach(array('digestposts', 'posts', 'threads', 'oltime', 'pageviews', 'extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8') as $var) {
if($extcreditsarray[$creditsid = preg_replace("/^extcredits(\d{1})$/", "\\1", $var)]['available']) {
$replacement = $extcreditsarray[$creditsid]['title'];
} else {
$replacement = $lang['settings_credits_formula_'.$var];
}
$settingsnew['creditsformulaexp'] = str_replace($var, '<u>'.$replacement.'</u>', $settingsnew['creditsformulaexp']);
}
$settingsnew['creditsformulaexp'] = addslashes('<u>'.$lang['settings_credits_formula_credits'].'</u>='.$settingsnew['creditsformulaexp']);
$initformula = str_replace('posts', '0', $settingsnew['creditsformula']);
for($i = 1; $i <= 8; $i++) {
$initformula = str_replace('extcredits'.$i, $settingsnew['initcredits'][$i], $initformula);
}
eval("\$initcredits = round($initformula);");
$settingsnew['extcredits'] = addslashes(serialize($extcreditsarray));
$settingsnew['initcredits'] = $initcredits.','.implode(',', $settingsnew['initcredits']);
if($settingsnew['creditstax'] < 0 || $settingsnew['creditstax'] >= 1) {
$settingsnew['creditstax'] = 0;
}
$settingsnew['creditstrans'] = implode(',', $settingsnew['creditstrans']);
}
if(isset($settingsnew['gzipcompress'])) {
if(!function_exists('ob_gzhandler') && $settingsnew['gzipcompress']) {
cpmsg('settings_gzip_invalid', '', 'error');
}
}
if(isset($settingsnew['maxonlines'])) {
if($settingsnew['maxonlines'] > 65535 || !is_numeric($settingsnew['maxonlines'])) {
cpmsg('settings_maxonlines_invalid', '', 'error');
}
$db->query("ALTER TABLE {$tablepre}sessions MAX_ROWS=$settingsnew[maxonlines]");
if($settingsnew['maxonlines'] < $settings['maxonlines']) {
$db->query("DELETE FROM {$tablepre}sessions");
}
}
if(isset($settingsnew['seccodedata'])) {
$settingsnew['seccodedata']['width'] = intval($settingsnew['seccodedata']['width']);
$settingsnew['seccodedata']['height'] = intval($settingsnew['seccodedata']['height']);
if($settingsnew['seccodedata']['type'] != 3) {
$settingsnew['seccodedata']['width'] = $settingsnew['seccodedata']['width'] < 100 ? 100 : ($settingsnew['seccodedata']['width'] > 200 ? 200 : $settingsnew['seccodedata']['width']);
$settingsnew['seccodedata']['height'] = $settingsnew['seccodedata']['height'] < 50 ? 50 : ($settingsnew['seccodedata']['height'] > 80 ? 80 : $settingsnew['seccodedata']['height']);
} else {
$settingsnew['seccodedata']['width'] = 85;
$settingsnew['seccodedata']['height'] = 25;
}
$settingsnew['seccodedata']['loginfailedcount'] = !empty($settingsnew['seccodedata']['loginfailedcount']) ? 3 : 0;
$settingsnew['seccodedata'] = addslashes(serialize($settingsnew['seccodedata']));
}
if(isset($settingsnew['allowviewuserthread'])) {
$settingsnew['allowviewuserthread'] = addslashes(serialize($settingsnew['allowviewuserthread']));
}
if($operation == 'sec') {
$settingsnew['seccodestatus'] = bindec(intval($settingsnew['seccodestatus'][5]).intval($settingsnew['seccodestatus'][4]).intval($settingsnew['seccodestatus'][3]).intval($settingsnew['seccodestatus'][2]).intval($settingsnew['seccodestatus'][1]));
if(is_array($delete)) {
$db->query("DELETE FROM {$tablepre}itempool WHERE id IN (".implodeids($delete).")");
}
if(is_array($question)) {
foreach($question as $key => $q) {
$q = trim($q);
$a = cutstr(dhtmlspecialchars(trim($answer[$key])), 50);
if($q !== '' && $a !== '') {
$db->query("UPDATE {$tablepre}itempool SET question='$q', answer='$a' WHERE id='$key'");
}
}
}
if(is_array($newquestion) && is_array($newanswer)) {
foreach($newquestion as $key => $q) {
$q = trim($q);
$a = cutstr(dhtmlspecialchars(trim($newanswer[$key])), 50);
if($q !== '' && $a !== '') {
$db->query("INSERT INTO {$tablepre}itempool (question, answer) VALUES ('$q', '$a')");
}
}
}
updatecache('secqaa');
$settingsnew['secqaa']['status'] = bindec(intval($settingsnew['secqaa']['status'][3]).intval($settingsnew['secqaa']['status'][2]).intval($settingsnew['secqaa']['status'][1]));
$settingsnew['secqaa'] = serialize($settingsnew['secqaa']);
}
if($operation == 'seo') {
$settingsnew['rewritestatus'] = bindec(intval($settingsnew['rewritestatus'][5]).intval($settingsnew['rewritestatus'][4]).intval($settingsnew['rewritestatus'][3]).intval($settingsnew['rewritestatus'][2]).intval($settingsnew['rewritestatus'][1]));
$settingsnew['baidusitemap_life'] = max(1, min(24, intval($settingsnew['baidusitemap_life'])));
}
if($operation == 'functions') {
$settingsnew['bannedmessages'] = bindec(intval($settingsnew['bannedmessages'][3]).intval($settingsnew['bannedmessages'][2]).intval($settingsnew['bannedmessages'][1]));
}
if($operation == 'ec') {
if($settingsnew['ec_ratio']) {
if($settingsnew['ec_ratio'] < 0) {
cpmsg('alipay_ratio_invalid', '', 'error');
}
} else {
$settingsnew['ec_mincredits'] = $settingsnew['ec_maxcredits'] = 0;
}
foreach(array('ec_ratio', 'ec_mincredits', 'ec_maxcredits', 'ec_maxcreditspermonth', 'tradeimagewidth', 'tradeimageheight') as $key) {
$settingsnew[$key] = intval($settingsnew[$key]);
}
$settingsnew['tradetypes'] = addslashes(serialize($settingsnew['tradetypes']));
}
if(isset($settingsnew['visitbanperiods']) && isset($settingsnew['postbanperiods']) && isset($settingsnew['postmodperiods']) && isset($settingsnew['searchbanperiods'])) {
foreach(array('visitbanperiods', 'postbanperiods', 'postmodperiods', 'searchbanperiods') as $periods) {
$periodarray = array();
foreach(explode("\n", $settingsnew[$periods]) as $period) {
if(preg_match("/^\d{1,2}\:\d{2}\-\d{1,2}\:\d{2}$/", $period = trim($period))) {
$periodarray[] = $period;
}
}
$settingsnew[$periods] = implode("\r\n", $periodarray);
}
}
if(isset($settingsnew['infosidestatus'])) {
$settingsnew['infosidestatus'] = addslashes(serialize($settingsnew['infosidestatus']));
}
if(isset($settingsnew['heatthread'])) {
$settingsnew['heatthread']['reply'] = $settingsnew['heatthread']['reply'] > 0 ? intval($settingsnew['heatthread']['reply']) : 5;
$settingsnew['heatthread']['recommend'] = $settingsnew['heatthread']['recommend'] > 0 ? intval($settingsnew['heatthread']['recommend']) : 3;
$settingsnew['heatthread']['hottopic'] = !empty($settingsnew['heatthread']['hottopic']) ? $settingsnew['heatthread']['hottopic'] : '50,100,200';
$settingsnew['heatthread'] = addslashes(serialize($settingsnew['heatthread']));
}
if(isset($settingsnew['recommendthread'])) {
$settingsnew['recommendthread'] = addslashes(serialize($settingsnew['recommendthread']));
}
if(isset($settingsnew['timeformat'])) {
$settingsnew['timeformat'] = $settingsnew['timeformat'] == '24' ? 'H:i' : 'h:i A';
}
if(isset($settingsnew['dateformat'])) {
$settingsnew['dateformat'] = dateformat($settingsnew['dateformat'], 'format');
}
if(isset($settingsnew['userdateformat'])) {
$settingsnew['userdateformat'] = dateformat($settingsnew['userdateformat'], 'format');
}
if($isfounder && isset($settingsnew['ftp'])) {
$settings['ftp'] = unserialize($settings['ftp']);
$settings['ftp']['password'] = authcode($settings['ftp']['password'], 'DECODE', md5($authkey));
if(!empty($settingsnew['ftp']['password'])) {
$pwlen = strlen($settingsnew['ftp']['password']);
if($pwlen < 3) {
cpmsg('ftp_password_short', '', 'error');
}
if($settingsnew['ftp']['password']{0} == $settings['ftp']['password']{0} && $settingsnew['ftp']['password']{$pwlen - 1} == $settings['ftp']['password']{strlen($settings['ftp']['password']) - 1} && substr($settingsnew['ftp']['password'], 1, $pwlen - 2) == '********') {
$settingsnew['ftp']['password'] = $settings['ftp']['password'];
}
$settingsnew['ftp']['password'] = authcode($settingsnew['ftp']['password'], 'ENCODE', md5($authkey));
}
$settingsnew['ftp'] = serialize($settingsnew['ftp']);
}
if($isfounder && isset($settingsnew['mail'])) {
$settings['mail'] = unserialize($settings['mail']);
$passwordmask = $settings['mail']['auth_password'] ? $settings['mail']['auth_password']{0}.'********'.substr($settings['mail']['auth_password'], -2) : '';
$settingsnew['mail']['auth_password'] = $settingsnew['mail']['auth_password'] == $passwordmask ? $settings['mail']['auth_password'] : $settingsnew['mail']['auth_password'];
$settingsnew['mail'] = serialize($settingsnew['mail']);
}
if(isset($settingsnew['jsrefdomains'])) {
$settingsnew['jsrefdomains'] = trim(preg_replace("/(\s*(\r\n|\n\r|\n|\r)\s*)/", "\r\n", $settingsnew['jsrefdomains']));
}
if(isset($settingsnew['jsdateformat'])) {
$settingsnew['jsdateformat'] = dateformat($settingsnew['jsdateformat'], 'format');
}
if(isset($settingsnew['wapdateformat'])) {
$settingsnew['wapdateformat'] = dateformat($settingsnew['wapdateformat'], 'format');
}
if(isset($settingsnew['cachethreaddir']) && isset($settingsnew['threadcaches'])) {
if($settingsnew['cachethreaddir'] && !is_writable(DISCUZ_ROOT.'./'.$settingsnew['cachethreaddir'])) {
cpmsg('cachethread_dir_noexists', '', 'error');
}
if(!empty($fids)) {
$sqladd = in_array('all', $fids) ? '' : " WHERE fid IN ('".implode("', '", $fids)."')";
$db->query("UPDATE {$tablepre}forums SET threadcaches='$settingsnew[threadcaches]'$sqladd");
}
}
if($operation == 'attach') {
$settingsnew['thumbwidth'] = intval($settingsnew['thumbwidth']) > 0 ? intval($settingsnew['thumbwidth']) : 200;
$settingsnew['thumbheight'] = intval($settingsnew['thumbheight']) > 0 ? intval($settingsnew['thumbheight']) : 300;
$settingsnew['swfupload'] = isset($settingsnew['swfupload'][1]) ? 2 : (isset($settingsnew['swfupload'][0]) ? $settingsnew['swfupload'][0] : 0);
}
if(isset($settingsnew['watermarktext'])) {
$settingsnew['watermarktext']['size'] = intval($settingsnew['watermarktext']['size']);
$settingsnew['watermarktext']['angle'] = intval($settingsnew['watermarktext']['angle']);
$settingsnew['watermarktext']['shadowx'] = intval($settingsnew['watermarktext']['shadowx']);
$settingsnew['watermarktext']['shadowy'] = intval($settingsnew['watermarktext']['shadowy']);
$settingsnew['watermarktext']['fontpath'] = str_replace(array('\\', '/'), '', $settingsnew['watermarktext']['fontpath']);
if($settingsnew['watermarktype'] == 2 && $settingsnew['watermarktext']['fontpath']) {
$fontpath = $settingsnew['watermarktext']['fontpath'];
$fontpathnew = 'ch/'.$fontpath;
$settingsnew['watermarktext']['fontpath'] = file_exists('images/fonts/'.$fontpathnew) ? $fontpathnew : '';
if(!$settingsnew['watermarktext']['fontpath']) {
$fontpathnew = 'en/'.$fontpath;
$settingsnew['watermarktext']['fontpath'] = file_exists('images/fonts/'.$fontpathnew) ? $fontpathnew : '';
}
if(!$settingsnew['watermarktext']['fontpath']) {
cpmsg('watermarkpreview_fontpath_error', '', 'error');
}
}
$settingsnew['watermarktext'] = addslashes(serialize($settingsnew['watermarktext']));
}
if(isset($settingsnew['msgforward'])) {
if(!empty($settingsnew['msgforward']['messages'])) {
$tempmsg = explode("\n", $settingsnew['msgforward']['messages']);
$settingsnew['msgforward']['messages'] = array();
foreach($tempmsg as $msg) {
if($msg = strip_tags(trim($msg))) {
$settingsnew['msgforward']['messages'][] = $msg;
}
}
} else {
$settingsnew['msgforward']['messages'] = array();
}
$tmparray = array(
'refreshtime' => intval($settingsnew['msgforward']['refreshtime']),
'quick' => $settingsnew['msgforward']['quick'] ? 1 : 0,
'messages' => $settingsnew['msgforward']['messages']
);
$settingsnew['msgforward'] = addslashes(serialize($tmparray));
}
if(isset($settingsnew['onlinehold'])) {
$settingsnew['onlinehold'] = intval($settingsnew['onlinehold']) > 0 ? intval($settingsnew['onlinehold']) : 15;
}
if(isset($settingsnew['postno'])) {
$settingsnew['postno'] = trim($settingsnew['postno']);
}
if(isset($settingsnew['postnocustom'])) {
$settingsnew['postnocustom'] = addslashes(serialize(explode("\n", $settingsnew['postnocustom'])));
}
$updatestyles = FALSE;
if($operation == 'styles') {
$settingsnew['disallowfloat'] = array_diff($floatwinkeys, isset($settingsnew['allowfloatwin']) ? $settingsnew['allowfloatwin'] : array());
$settingsnew['disallowfloat'] = addslashes(serialize($settingsnew['disallowfloat']));
$settingsnew['customauthorinfo'] = addslashes(serialize(array($settingsnew['customauthorinfo'])));
list(, $imagemaxwidth) = explode("\t", $settings['zoomstatus']);
if($imagemaxwidth != $settingsnew['imagemaxwidth']) {
$updatestyles = TRUE;
}
$settingsnew['zoomstatus'] = $settingsnew['zoomstatus']."\t".$settingsnew['imagemaxwidth'];
}
if(isset($settingsnew['smcols'])) {
$settingsnew['smcols'] = $settingsnew['smcols'] >= 8 && $settingsnew['smcols'] <= 12 ? $settingsnew['smcols'] : 8;
}
if(isset($settingsnew['msn'])) {
$settingsnew['msn']['domain'] = $msndomain;
$settingsnew['msn'] = addslashes(serialize($settingsnew['msn']));
}
if(isset($settingsnew['jspath'])) {
if(!$settingsnew['jspath']) {
$settingsnew['jspath'] = $settingsnew['jspathcustom'];
}
}
if(isset($settingsnew['domainwhitelist'])) {
$settingsnew['domainwhitelist'] = trim(preg_replace("/(\s*(\r\n|\n\r|\n|\r)\s*)/", "\r\n", $settingsnew['domainwhitelist']));
}
$updatecache = FALSE;
foreach($settingsnew as $key => $val) {
if(isset($settings[$key]) && $settings[$key] != $val) {
$$key = $val;
$updatecache = TRUE;
if(in_array($key, array('newbiespan', 'topicperpage', 'postperpage', 'memberperpage', 'hottopic', 'starthreshold', 'delayviewcount', 'attachexpire',
'visitedforums', 'maxsigrows', 'timeoffset', 'statscachelife', 'pvfrequence', 'oltimespan', 'seccodestatus',
'maxprice', 'rssttl', 'rewritestatus', 'bdaystatus', 'maxonlines', 'loadctrl', 'floodctrl', 'regctrl', 'regfloodctrl',
'searchctrl', 'extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6',
'extcredits7', 'extcredits8', 'transfermincredits', 'exchangemincredits', 'maxincperthread', 'maxchargespan',
'maxspm', 'maxsearchresults', 'maxsmilies', 'threadmaxpages', 'membermaxpages', 'maxpostsize', 'minpostsize',
'maxpolloptions', 'karmaratelimit', 'losslessdel', 'smcols',
'watermarktrans', 'watermarkquality', 'jscachelife', 'waptpp', 'wapppp', 'wapmps', 'maxmodworksmonths', 'frameon', 'maxonlinelist'))) {
$val = (float)$val;
}
if($key == 'dzfeed_limit') {
foreach(array('thread_replies', 'thread_views', 'thread_rate', 'post_rate', 'user_credit', 'user_threads', 'user_posts', 'user_digest') as $v) {
if(preg_match_all('/(\d+)/is', $val[$v], $match)) {
$val[$v] = $match[1];
} else {
$val[$v] = 0;
}
}
$val = addslashes(serialize($val));
}
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$key', '$val')");
}
}
if($updatecache) {
updatecache('settings');
if(isset($settingsnew['forumlinkstatus']) && $settingsnew['forumlinkstatus'] != $settings['forumlinkstatus']) {
updatecache('forumlinks');
}
if(isset($settingsnew['userstatusby']) && $settingsnew['userstatusby'] != $settings['userstatusby']) {
updatecache('usergroups');
updatecache('ranks');
}
if((isset($settingsnew['tagstatus']) && $settingsnew['tagstatus'] != $settings['tagstatus']) || (isset($settingsnew['viewthreadtags']) && $settingsnew['viewthreadtags'] != $settings['viewthreadtags'])) {
updatecache(array('tags_index', 'tags_viewthread'));
}
if((isset($settingsnew['smthumb']) && $settingsnew['smthumb'] != $settings['smthumb']) || (isset($settingsnew['smcols']) && $settingsnew['smcols'] != $settings['smcols']) || (isset($settingsnew['smrows']) && $settingsnew['smrows'] != $settings['smrows'])) {
updatecache('smilies_js');
}
if(isset($settingsnew['customauthorinfo']) && $settingsnew['customauthorinfo'] != $settings['customauthorinfo']) {
updatecache('custominfo');
}
if($operation == 'credits') {
updatecache('custominfo');
}
if($operation == 'access') {
updatecache('ipctrl');
}
if($updatestyles) {
updatecache('styles');
}
if(isset($settingsnew['domainwhitelist'])) {
updatecache('domainwhitelist');
}
}
if($operation == 'credits' && $projectsave) {
$projectid = intval($projectid);
dheader("Location: $boardurl$BASESCRIPT?action=project&operation=add&type=extcredit&projectid=$projectid");
}
cpmsg('settings_update_succeed', $BASESCRIPT.'?action=settings&operation='.$operation.(!empty($anchor) ? '&anchor='.$anchor : '').(!empty($from) ? '&from='.$from : ''), 'succeed');
}
function creditsrow($policy) {
global $settings;
$policyarray = array(lang('settings_credits_policy_'.$policy));
for($i = 1; $i <= 8; $i++) {
$policyarray[] = "<input type=\"text\" class=\"txt\" size=\"2\" name=\"settingsnew[creditspolicy][$policy][$i]\" ".($settings['extcredits'][$i]['available'] ? '' : 'readonly')." value=\"".intval($settings['creditspolicy'][$policy][$i])."\">";
}
return $policyarray;
}
function dateformat($string, $operation = 'formalise') {
$string = htmlspecialchars(trim($string));
$replace = $operation == 'formalise' ? array(array('n', 'j', 'y', 'Y'), array('mm', 'dd', 'yy', 'yyyy')) : array(array('mm', 'dd', 'yyyy', 'yy'), array('n', 'j', 'Y', 'y'));
return str_replace($replace[0], $replace[1], $string);
}
function insertconfig($s, $find, $replace) {
if(preg_match($find, $s)) {
$s = preg_replace($find, $replace, $s);
} else {
$s .= "\r\n".$replace;
}
return $s;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/settings.inc.php | PHP | asf20 | 107,598 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: styles.inc.php 21213 2009-11-20 04:55:21Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$operation = empty($operation) ? 'admin' : $operation;
if($operation == 'export' && $id) {
$stylearray = $db->fetch_first("SELECT s.name, s.templateid, t.name AS tplname, t.directory, t.copyright FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON t.templateid=s.templateid WHERE styleid='$id'");
if(!$stylearray) {
cpheader();
cpmsg('styles_export_invalid', '', 'error');
}
$query = $db->query("SELECT * FROM {$tablepre}stylevars WHERE styleid='$id'");
while($style = $db->fetch_array($query)) {
$stylearray['style'][$style['variable']] = $style['substitute'];
}
$stylearray['version'] = strip_tags($version);
exportdata('Discuz! Style', $stylearray['name'], $stylearray);
}
cpheader();
$predefinedvars = array('available' => array(), 'boardimg' => array(), 'imgdir' => array(), 'styleimgdir' => array(), 'stypeid' => array(),
'headerbgcolor' => array(0, $lang['styles_edit_type_bg']),
'bgcolor' => array(0),
'sidebgcolor' => array(0, '', '#FFF sidebg.gif repeat-y 100% 0'),
'headerborder' => array(1, $lang['styles_edit_type_header'], '1px'),
'headerbordercolor' => array(0),
'headertext' => array(0),
'footertext' => array(0),
'font' => array(1, $lang['styles_edit_type_font']),
'fontsize' => array(1),
'smfont' => array(1),
'smfontsize' => array(1),
'tabletext' => array(0),
'midtext' => array(0),
'lighttext' => array(0),
'link' => array(0, $lang['styles_edit_type_url']),
'highlightlink' => array(0),
'wrapwidth' => array(1, $lang['styles_edit_type_wrap'], '98%'),
'wrapbg' => array(0),
'wrapborder' => array(1, '', '0'),
'wrapbordercolor' => array(0),
'msgfontsize' => array(1, $lang['styles_edit_type_post'], '14px'),
'msgbigsize' => array(1, '', '16px'),
'contentwidth' => array(1),
'contentseparate' => array(0),
'menuborder' => array(0, $lang['styles_edit_type_menu']),
'menubgcolor' => array(0),
'menutext' => array(0),
'menuhover' => array(0),
'menuhovertext' => array(0),
'inputborder' => array(0, $lang['styles_edit_type_input']),
'inputborderdarkcolor' => array(0),
'inputbg' => array(0, '', '#FFF'),
'dropmenuborder' => array(0, $lang['styles_edit_type_dropmenu']),
'dropmenubgcolor' => array(0),
'floatbgcolor' => array(0, $lang['styles_edit_type_float']),
'floatmaskbgcolor' => array(0),
'commonborder' => array(0, $lang['styles_edit_type_other']),
'commonbg' => array(0),
'specialborder' => array(0),
'specialbg' => array(0),
'interleavecolor' => array(0),
'noticetext' => array(0),
);
if($operation == 'admin') {
$query = $db->query("SELECT s.styleid, s.available, s.name, t.name AS tplname, t.directory, t.copyright FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON t.templateid=s.templateid ORDER BY s.available desc, s.styleid");
$sarray = $tpldirs = array();
while($row = $db->fetch_array($query)) {
$sarray[$row['styleid']] = $row;
$tpldirs[] = realpath($row['directory']);
}
$defaultid = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='styleid'");
if(!submitcheck('stylesubmit')) {
$narray = array();
$dir = DISCUZ_ROOT.'./templates';
$templatedir = dir($dir);$i = -1;
while($entry = $templatedir->read()) {
$tpldir = realpath($dir.'/'.$entry);
if(!in_array($entry, array('.', '..')) && !in_array($tpldir, $tpldirs) && is_dir($tpldir)) {
$styleexist = 0;
$searchdir = dir($tpldir);
while($searchentry = $searchdir->read()) {
if(substr($searchentry, 0, 13) == 'discuz_style_' && fileext($searchentry) == 'xml') {
$styleexist++;
}
}
if($styleexist) {
$narray[$i] = array(
'styleid' => '',
'available' => '',
'name' => $entry,
'directory' => './templates/'.$entry,
'name' => $entry,
'tplname' => $entry,
'filemtime' => @filemtime($dir.'/'.$entry),
'stylecount' => $styleexist
);
$i--;
}
}
}
uasort($narray, 'filemtimesort');
$sarray += $narray;
$stylelist = '';
$i = 0;
foreach($sarray as $id => $style) {
$style['name'] = dhtmlspecialchars($style['name']);
$isdefault = $id == $defaultid ? 'checked' : '';
$available = $style['available'] ? 'checked' : NULL;
$preview = file_exists($style['directory'].'/preview.jpg') ? $style['directory'].'/preview.jpg' : './images/admincp/stylepreview.gif';
$stylelist .= ($i == 0 ? '<tr>' : '').
'<td width="33%" '.($available ? 'style="background: #F2F9FD"' : '').'><table cellspacing="0" cellpadding="0" style="margin-left: 10px; width: 200px;"><tr><td style="width: 120px; text-align: center; border-top: none;">'.
($id > 0 ? "<p style=\"margin-bottom: 2px;\"> </p>".
($available ? "<a href=\"$indexname?styleid=$id\" target=\"_blank\">" : '' )."<img src=\"$preview\" alt=\"$lang[preview]\"/></a>
<p style=\"margin: 2px 0\"><span style=\"float: left; dispaly: inline; margin-left: 4px; width: 20px; height: 20px; background: ".($styleicons[$id] ? $styleicons[$id] : 'url(./images/admincp/transparent.gif)')."\"> </span><input type=\"text\" class=\"txt\" name=\"namenew[$id]\" value=\"$style[name]\" size=\"30\" style=\"margin-right:0; width: 80px;\"></p>
<p class=\"lightfont\">($style[tplname])</p></td><td style=\"padding-top: 17px; width: 80px; border-top: none; vertical-align: top;\">
<p style=\"margin: 2px 0\">$lang[available] <input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$id]\" value=\"1\" $available></p>
<p style=\"margin: 2px 0\">$lang[default] <input type=\"radio\" class=\"radio\" name=\"defaultnew\" value=\"$id\" $isdefault></p>
<p style=\"margin: 2px 0\">$lang[styles_uninstall] ".($isdefault ? '<input class="checkbox" type="checkbox" disabled="disabled" />' : '<input class="checkbox" type="checkbox" name="delete[]" value="'.$id.'" />')."</p>
<p style=\"margin: 8px 0 2px\"><a href=\"$BASESCRIPT?action=styles&operation=edit&id=$id\">$lang[edit]</a></p>
<p style=\"margin: 2px 0\"><a href=\"$BASESCRIPT?action=styles&operation=export&id=$id\">$lang[export]</a></p>
<p style=\"margin: 2px 0\"><a href=\"$BASESCRIPT?action=styles&operation=copy&id=$id\">$lang[copy]</a></p>" :
"<p style=\"margin-bottom: 2px;\"> </p>
<img src=\"$preview\" />
<p style=\"margin: 13px 0\" class=\"lightfont\">($style[tplname])</p></td><td style=\"padding-top: 17px; width: 80px; border-top: none; vertical-align: top;\">
<p style=\"margin: 2px 0\"><a href=\"$BASESCRIPT?action=styles&operation=import&dir=$style[name]\">$lang[styles_install]</a></p>
<p style=\"margin: 2px p\">$lang[styles_stylecount]$style[stylecount]</p>".
($style['filemtime'] > $timestamp - 86400 ? '<p style=\"margin-bottom: 2px;\"><font color="red">New!</font></p>' : '')).
"</td></tr></table></td>\n".($i == 3 ? '</tr>' : '');
$i++;
if($i == 3) {
$i = 0;
}
}
if($i > 0) {
$stylelist .= str_repeat('<td></td>', 3 - $i);
}
shownav('style', 'styles_admin');
showsubmenu('styles_admin', array(
array('admin', 'styles', '1'),
array('import', 'styles&operation=import', '0')
));
showtips('styles_admin_tips');
showformheader('styles');
showhiddenfields(array('updatecsscache' => 0));
showtableheader('', 'tdhover');
echo $stylelist;
showtablefooter();
showtableheader();
echo '<tr><td>'.$lang['add_new'].'</td><td><input type="text" class="txt" name="newname" size="18"></td><td colspan="5"> </td></tr>';
showsubmit('stylesubmit', 'submit', 'del', '<input onclick="this.form.updatecsscache.value=1" type="submit" class="btn" name="stylesubmit" value="'.lang('styles_csscache_update').'">');
showtablefooter();
showformfooter();
} else {
if($updatecsscache) {
updatecache('styles');
cpmsg('csscache_update', $BASESCRIPT.'?action=styles', 'succeed');
} else {
if(is_numeric($defaultnew) && $defaultid != $defaultnew && isset($sarray[$defaultnew])) {
$defaultid = $defaultnew;
$db->query("UPDATE {$tablepre}settings SET value='$defaultid' WHERE variable='styleid'");
}
$availablenew[$defaultid] = 1;
foreach($sarray as $id => $old) {
$namenew[$id] = trim($namenew[$id]);
$availablenew[$id] = $availablenew[$id] ? 1 : 0;
if($namenew[$id] != $old['name'] || $availablenew[$id] != $old['available']) {
$db->query("UPDATE {$tablepre}styles SET name='$namenew[$id]', available='$availablenew[$id]' WHERE styleid='$id'");
}
}
if(!empty($delete) && is_array($delete)) {
$did = array();
foreach($delete as $id) {
$id = intval($id);
if($id == $defaultid) {
cpmsg('styles_delete_invalid', '', 'error');
} elseif($id != 1){
$did[] = intval($id);
}
}
if($did && ($ids = implodeids($did))) {
$query = $db->query("SELECT templateid FROM {$tablepre}styles");
$tplids = array();
while($style = $db->fetch_array($query)) {
$tplids[$style['templateid']] = $style['templateid'];
}
$db->query("DELETE FROM {$tablepre}styles WHERE styleid IN ($ids)");
$db->query("DELETE FROM {$tablepre}stylevars WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}members SET styleid='0' WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}forums SET styleid='0' WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}sessions SET styleid='$defaultid' WHERE styleid IN ($ids)");
$query = $db->query("SELECT templateid FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
unset($tplids[$style['templateid']]);
}
if($tplids) {
$db->query("DELETE FROM {$tablepre}templates WHERE templateid IN (".implodeids($tplids).")");
}
}
}
if($newname) {
$db->query("INSERT INTO {$tablepre}styles (name, templateid) VALUES ('$newname', '1')");
$styleidnew = $db->insert_id();
foreach(array_keys($predefinedvars) as $variable) {
$substitute = isset($predefinedvars[$variable][2]) ? $predefinedvars[$variable][2] : '';;
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$styleidnew', '$variable', '$substitute')");
}
}
updatecache('settings');
updatecache('styles');
cpmsg('styles_edit_succeed', $BASESCRIPT.'?action=styles', 'succeed');
}
}
} elseif($operation == 'import') {
if(!submitcheck('importsubmit') && !isset($dir)) {
shownav('style', 'styles_admin');
showsubmenu('styles_admin', array(
array('admin', 'styles', '0'),
array('import', 'styles&operation=import', '1')
));
showformheader('styles&operation=import', 'enctype');
showtableheader('styles_import');
showimportdata();
showtablerow('', '', '<input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> '.lang('styles_import_ignore_version').'</label>');
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
require_once DISCUZ_ROOT.'./admin/importdata.func.php';
$renamed = import_styles($ignoreversion, $dir);
cpmsg(!empty($dir) ? 'styles_install_succeed' : ($renamed ? 'styles_import_succeed_renamed' : 'styles_import_succeed'), $BASESCRIPT.'?action=styles', 'succeed');
}
} elseif($operation == 'copy') {
$style = $db->fetch_first("SELECT * FROM {$tablepre}styles WHERE styleid='$id'");
$style['name'] .= '_'.random(4);
$db->query("INSERT INTO {$tablepre}styles (name, available, templateid)
VALUES ('$style[name]', '$style[available]', '$style[templateid]')");
$styleidnew = $db->insert_id();
$query = $db->query("SELECT * FROM {$tablepre}stylevars WHERE styleid='$id'");
while($stylevar = $db->fetch_array($query)) {
$stylevar['substitute'] = addslashes($stylevar['substitute']);
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$styleidnew', '$stylevar[variable]', '$stylevar[substitute]')");
}
updatecache('styles');
updatecache('settings');
cpmsg('styles_copy_succeed', $BASESCRIPT.'?action=styles', 'succeed');
} elseif($operation == 'edit') {
if(!submitcheck('editsubmit')) {
if(empty($id)) {
$stylelist = "<select name=\"id\" style=\"width: 150px\">\n";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$stylelist .= "<option value=\"$style[styleid]\">$style[name]</option>\n";
}
$stylelist .= '</select>';
cpmsg('styles_nonexistence', $BASESCRIPT.'?action=styles&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $stylelist);
}
$style = $db->fetch_first("SELECT name, templateid FROM {$tablepre}styles WHERE styleid='$id'");
if(!$style) {
cpmsg('undefined_action', '', 'error');
}
$stylecustom = '';
$stylestuff = $existvars = array();
$query = $db->query("SELECT * FROM {$tablepre}stylevars WHERE styleid='$id'");
while($stylevar = $db->fetch_array($query)) {
if(array_key_exists($stylevar['variable'], $predefinedvars)) {
$stylestuff[$stylevar['variable']] = array('id' => $stylevar['stylevarid'], 'subst' => $stylevar['substitute']);
$existvars[] = $stylevar['variable'];
} else {
$stylecustom .= showtablerow('', array('class="td25"', 'class="td24 bold"', 'class="td26"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$stylevar[stylevarid]\">",
'{'.strtoupper($stylevar['variable']).'}',
"<textarea name=\"stylevar[$stylevar[stylevarid]]\" style=\"height: 45px\" cols=\"50\" rows=\"2\">$stylevar[substitute]</textarea>",
), TRUE);
}
}
if($diffvars = array_diff(array_keys($predefinedvars), $existvars)) {
foreach($diffvars as $variable) {
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$id', '$variable', '')");
$stylestuff[$variable] = array('id' => $db->insert_id(), 'subst' => '');
}
}
$tplselect = array();
$query = $db->query("SELECT templateid, name FROM {$tablepre}templates");
while($template = $db->fetch_array($query)) {
$tplselect[] = array($template['templateid'], $template['name']);
}
$smileytypes = array();
$query = $db->query("SELECT typeid, name FROM {$tablepre}imagetypes WHERE available='1'");
while($type = $db->fetch_array($query)) {
$smileytypes[] = array($type['typeid'], $type['name']);
}
$adv = !empty($adv) ? 1 : 0;
shownav('style', 'styles_edit');
showsubmenu('styles_admin', array(
array('admin', 'styles', '0'),
array('import', 'styles&operation=import', '0'),
array(array('menu' => 'edit' , 'submenu' => array(
array('styles_edit_simple', 'styles&operation=edit&id='.$id, !$adv),
array('styles_edit_adv', 'styles&operation=edit&id='.$id.'&adv=1', $adv),
)), '', 1)
));
if($adv) {
?>
<script type="text/JavaScript">
function imgpre_onload(obj) {
if(!obj.complete) {
setTimeout(function() {imgpre_resize(obj)}, 100);
}
imgpre_resize(obj);
}
function imgpre_resize(obj) {
if(obj.width > 350) {
obj.style.width = '350px';
}
}
function imgpre_update(id, obj) {
url = obj.value;
if(url) {
re = /^http:\/\//i;
var matches = re.exec(url);
if(matches == null) {
url = ($('styleimgdir').value ? $('styleimgdir').value : ($('imgdir').value ? $('imgdir').value : 'images/default')) + '/' + url;
}
$('bgpre_' + id).style.backgroundImage = 'url(' + url + ')';
} else {
$('bgpre_' + id).style.backgroundImage = 'url(images/common/none.gif)';
}
}
function imgpre_switch(id) {
if($('bgpre_' + id).innerHTML == '') {
url = $('bgpre_' + id).style.backgroundImage.substring(4, $('bgpre_' + id).style.backgroundImage.length - 1);
$('bgpre_' + id).innerHTML = '<img onload="imgpre_onload(this)" src="' + url + '" />';
$('bgpre_' + id).backgroundImage = $('bgpre_' + id).style.backgroundImage;
$('bgpre_' + id).style.backgroundImage = '';
} else {
$('bgpre_' + id).style.backgroundImage = $('bgpre_' + id).backgroundImage;
$('bgpre_' + id).innerHTML = '';
}
}
</script>
<?
showformheader("styles&operation=edit&id=$id&adv=1");
showtableheader($lang['styles_edit'].' - '.$style['name'], 'nobottom');
showsetting('styles_edit_name', 'namenew', $style['name'], 'text');
showsetting('styles_edit_tpl', array('templateidnew', $tplselect), $style['templateid'], 'select');
showsetting('styles_edit_smileytype', array("stylevar[{$stylestuff[stypeid][id]}]", $smileytypes), $stylestuff['stypeid']['subst'], 'select');
showsetting('styles_edit_imgdir', '', '', '<input type="text" class="txt" name="stylevar['.$stylestuff['imgdir']['id'].']" id="imgdir" value="'.$stylestuff['imgdir']['subst'].'" />');
showsetting('styles_edit_styleimgdir', '', '', '<input type="text" class="txt" name="stylevar['.$stylestuff['styleimgdir']['id'].']" id="styleimgdir" value="'.$stylestuff['styleimgdir']['subst'].'" />');
showsetting('styles_edit_logo', "stylevar[{$stylestuff[boardimg][id]}]", $stylestuff['boardimg']['subst'], 'text');
foreach($predefinedvars as $predefinedvar => $v) {
if($v !== array()) {
if(!empty($v[1])) {
showtitle($v[1]);
}
$type = $v[0] == 1 ? 'text' : 'color';
$extra = '';
$comment = ($type == 'text' ? $lang['styles_edit_'.$predefinedvar.'_comment'] : $lang['styles_edit_hexcolor']).$lang['styles_edit_'.$predefinedvar.'_comment'];
if(substr($predefinedvar, -7, 7) == 'bgcolor') {
$stylestuff[$predefinedvar]['subst'] = explode(' ', $stylestuff[$predefinedvar]['subst']);
$bgimg = $stylestuff[$predefinedvar]['subst'][1];
$bgextra = implode(' ', array_slice($stylestuff[$predefinedvar]['subst'], 2));
$stylestuff[$predefinedvar]['subst'] = $stylestuff[$predefinedvar]['subst'][0];
$bgimgpre = $bgimg ? (preg_match('/^http:\/\//i', $bgimg) ? $bgimg : ($stylestuff['styleimgdir']['subst'] ? $stylestuff['styleimgdir']['subst'] : ($stylestuff['imgdir']['subst'] ? $stylestuff['imgdir']['subst'] : 'images/default')).'/'.$bgimg) : 'images/common/none.gif';
$comment .= '<div id="bgpre_'.$stylestuff[$predefinedvar]['id'].'" onclick="imgpre_switch('.$stylestuff[$predefinedvar]['id'].')" style="background-image:url('.$bgimgpre.');cursor:pointer;float:right;width:350px;height:40px;overflow:hidden;border: 1px solid #ccc"></div>'.$lang['styles_edit_'.$predefinedvar.'_comment'].$lang['styles_edit_bg'];
$extra = '<br /><input name="stylevarbgimg['.$stylestuff[$predefinedvar]['id'].']" value="'.$bgimg.'" onchange="imgpre_update('.$stylestuff[$predefinedvar]['id'].', this)" type="text" class="txt" style="margin:5px 0;" />'.
'<br /><input name="stylevarbgextra['.$stylestuff[$predefinedvar]['id'].']" value="'.$bgextra.'" type="text" class="txt" />';
$varcomment = ' {'.strtoupper($predefinedvar).'},{'.strtoupper(substr($predefinedvar, 0, -7)).'BGCODE}:';
} else {
$varcomment = ' {'.strtoupper($predefinedvar).'}:';
}
showsetting(lang('styles_edit_'.$predefinedvar).$varcomment, 'stylevar['.$stylestuff[$predefinedvar]['id'].']', $stylestuff[$predefinedvar]['subst'], $type, '', 0, $comment, $extra);
}
}
showtablefooter();
showtableheader('styles_edit_customvariable', 'notop');
showsubtitle(array('', 'styles_edit_variable', 'styles_edit_subst'));
echo $stylecustom;
showtablerow('', array('class="td25"', 'class="td24 bold"', 'class="td26"'), array(
lang('add_new'),
'<input type="text" class="txt" name="newcvar">',
'<textarea name="newcsubst" class="tarea" style="height: 45px" cols="50" rows="2"></textarea>'
));
showsubmit('editsubmit', 'submit', 'del', '<input type="button" class="btn" onclick="location.href=\''.$BASESCRIPT.'?action=styles&operation=edit&id='.$id.'\'" value="'.$lang['styles_edit_simple_switch'].'">');
showtablefooter();
showformfooter();
} else {
showformheader("styles&operation=edit&id=$id&adv=1");
showtableheader($lang['styles_edit'].' - '.$style['name'], 'nobottom');
showsetting('styles_edit_name', 'namenew', $style['name'], 'text');
showsetting('styles_edit_tpl', array('templateidnew', $tplselect), $style['templateid'], 'select');
showsetting('styles_edit_smileytype', array("stylevar[{$stylestuff[stypeid][id]}]", $smileytypes), $stylestuff['stypeid']['subst'], 'select');
showsetting('styles_edit_imgdir', '', '', '<input type="text" class="txt" name="stylevar['.$stylestuff['imgdir']['id'].']" id="imgdir" value="'.$stylestuff['imgdir']['subst'].'" onchange="imgdirurl_update()" />');
showsetting('styles_edit_styleimgdir', '', '', '<input type="text" class="txt" name="stylevar['.$stylestuff['styleimgdir']['id'].']" id="styleimgdir" value="'.$stylestuff['styleimgdir']['subst'].'" onchange="imgdirurl_update()" />');
showtitle('styles_edit_visual');
?>
<tr><td colspan="2">
<table cellpadding="0" cellspacing="0" width="100%" id="previewbody"><tr><td valign="top" width="560" style="border: none;">
<style>
#style_preview p, #style_preview ul, #style_preview li { margin: 0; padding: 0; list-style: none; }
#sp_menu li { float: left; margin-left: 5px; padding: 0 10px; height: 25px; border-style: solid; border-width: 1px 1px 0; line-height: 25px; }
#sp_wrap th, #sp_wrap td { border: 0; }
#previewbody .colorwd { float: none; width: 21px; margin-left: 3px; }
#previewbody div.color { float:left; width: 120px;}
</style>
<div id="style_preview" style="width: 550px; border: 1px solid #333; background: #0D2345 url(images/default/bodybg.gif) repeat-x scroll 0 90px; font-size: 12px; color: #444;">
<div id="sp_header" style="position: relative; padding: 20px 10px 20px 10px; border-bottom: 1px solid #00B2E8; background: #00A2D2 url(images/default/header.gif) repeat-x scroll 0 100%;">
<img id="sp_logo" src="images/default/logo.gif" />
<div id="sp_umenu" style="position: absolute; right: 10px; top: 10px; color: #97F2FF;"><?=$discuz_userss?> | <?=$lang['styles_edit_visual_exit']?></div>
<ul id="sp_menu" style="position: absolute; right: 10px; bottom: -1px; color: #666;">
<li id="sp_menucurrent" style="border-color: #00B2E8; background: #1E4B7E; color: #FFF;"><?=$lang['styles_edit_visual_menu_current']?></li>
<li id="sp_menuitem" style="border-color: #00B2E8; background: #EBF4FD url(images/default/mtabbg.gif) repeat-x scroll 0 100%;"><?=$lang['styles_edit_visual_menu']?></li>
</ul>
</div>
<div id="sp_wrap" style="margin: 10px 10px 5px; border: 0px solid #000; background: #FFF url(images/default/sidebg.gif) repeat-y scroll 100% 0;">
<div id="sp_content" style="padding: 10px; width: 350px; w\idth: 330px;">
<div id="sp_backcolor" style="background: #F7F7F7;"><?=$lang['styles_edit_visual_text']?></div>
<div id="sp_line" style="margin: 5px 0 0 0; height: 2px; background: #E6E7E1; line-height: 2px; overflow: hidden;"></div>
<p id="sp_smalltext" style="padding: 5px 0 20px 0; text-align: right; color: #999; font-size: 0.83em;">---- Comsenz.Com</p>
<table cellpadding="0" cellspacing="0">
<?
function getcolor($colorid, $id) {
return "<input id=\"c$colorid\" onclick=\"c{$colorid}_frame.location='images/admincp/getcolor.htm?c{$colorid}|{$id}';showMenu({'ctrlid':'c$colorid'})\" type=\"button\" class=\"colorwd\" value=\"\" style=\"background: $background\"><span id=\"c{$colorid}_menu\" style=\"display: none\"><iframe name=\"c{$colorid}_frame\" src=\"\" frameborder=\"0\" width=\"166\" height=\"186\" scrolling=\"no\"></iframe></span>";
}
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_commonborder'].'</td><td><input id="commonborder" name="stylevar['.$stylestuff['commonborder']['id'].']" value="'.$stylestuff['commonborder']['subst'].'" size="10" onchange="$(\'sp_line\').style.backgroundColor = this.value;updatecolorpreview(\'c18\', \'commonborder\')" onclick="setfocus(this)" />'.getcolor(18, 'commonborder').'</td></tr>';
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_commonbg'].'</td><td><input id="commonbg" name="stylevar['.$stylestuff['commonbg']['id'].']" value="'.$stylestuff['commonbg']['subst'].'" size="10" onchange="$(\'sp_backcolor\').style.backgroundColor = this.value;updatecolorpreview(\'c19\', \'commonbg\')" onclick="setfocus(this)" />'.getcolor(19, 'commonbg').'</td></tr>';
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_font'].'</td><td><input name="stylevar['.$stylestuff['font']['id'].']" value="'.$stylestuff['font']['subst'].'" size="15" onchange="$(\'sp_tabletext\').style.fontFamily = this.value" />'.
' <input name="stylevar['.$stylestuff['fontsize']['id'].']" value="'.$stylestuff['fontsize']['subst'].'" size="5" onchange="$(\'sp_tabletext\').style.fontSize = this.value" /></td></tr>';
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_smfont'].'</td><td><input name="stylevar['.$stylestuff['smfont']['id'].']" value="'.$stylestuff['smfont']['subst'].'" size="15" onchange="$(\'sp_smalltext\').style.fontFamily = this.value" />'.
' <input name="stylevar['.$stylestuff['smfontsize']['id'].']" value="'.$stylestuff['smfontsize']['subst'].'" size="5" onchange="$(\'sp_smalltext\').style.fontSize = this.value" /></td></tr>';
echo '<tr><td width="100" id="spt_tabletext">'.$lang['styles_edit_visual_setting_tabletext'].'</td><td><input id="tabletext" name="stylevar['.$stylestuff['tabletext']['id'].']" value="'.$stylestuff['tabletext']['subst'].'" size="10" onchange="$(\'spt_tabletext\').style.color = $(\'sp_tabletext\').style.color = this.value;updatecolorpreview(\'c20\', \'tabletext\')" onclick="setfocus(this)" />'.getcolor(20, 'tabletext').'</td></tr>';
echo '<tr><td width="100" id="spt_midtext">'.$lang['styles_edit_visual_setting_midtext'].'</td><td><input id="midtext" name="stylevar['.$stylestuff['midtext']['id'].']" value="'.$stylestuff['midtext']['subst'].'" size="10" onchange="$(\'spt_midtext\').style.color = $(\'sp_midtext\').style.color = this.value;updatecolorpreview(\'c21\', \'midtext\')" onclick="setfocus(this)" />'.getcolor(21, 'midtext').'</td></tr>';
echo '<tr><td width="100" id="spt_lighttext">'.$lang['styles_edit_visual_setting_lighttext'].'</td><td><input id="lighttext" name="stylevar['.$stylestuff['lighttext']['id'].']" value="'.$stylestuff['lighttext']['subst'].'" size="10" onchange="$(\'spt_lighttext\').style.color = $(\'sp_smalltext\').style.color = this.value;updatecolorpreview(\'c22\', \'lighttext\')" onclick="setfocus(this)" />'.getcolor(22, 'lighttext').'</td></tr>';
echo '<tr><td width="100" id="spt_link">'.$lang['styles_edit_visual_setting_link'].'</td><td><input id="link" name="stylevar['.$stylestuff['link']['id'].']" value="'.$stylestuff['link']['subst'].'" size="10" onchange="$(\'spt_link\').style.color = $(\'sp_link\').style.color = this.value;updatecolorpreview(\'c23\', \'link\')" onclick="setfocus(this)" />'.getcolor(23, 'link').'</td></tr>';
echo '<tr><td width="100" id="spt_highlightlink">'.$lang['styles_edit_visual_setting_highlightlink'].'</td><td><input id="highlightlink" name="stylevar['.$stylestuff['highlightlink']['id'].']" value="'.$stylestuff['highlightlink']['subst'].'" size="10" onchange="$(\'spt_highlightlink\').style.color = $(\'sp_link\').style.color = this.value;updatecolorpreview(\'c24\', \'highlightlink\')" onclick="setfocus(this)" />'.getcolor(24, 'highlightlink').'</td></tr>';
echo '<tr><td width="100" id="spt_noticetext">'.$lang['styles_edit_visual_setting_noticetext'].'</td><td><input id="noticetext" name="stylevar['.$stylestuff['noticetext']['id'].']" value="'.$stylestuff['noticetext']['subst'].'" size="10" onchange="$(\'spt_noticetext\').style.color = $(\'sp_notice\').style.color = this.value;updatecolorpreview(\'c25\', \'noticetext\')" onclick="setfocus(this)" />'.getcolor(25, 'noticetext').'</td></tr>';
?>
</table>
</div>
</div>
<div id="sp_footer" style="margin: 0 auto 20px; color: #8691A2; text-align: center;">
<?=$lang['styles_edit_visual_footer']?>
</div>
</div>
</td><td valign="top" style="border: none;">
<script type="text/JavaScript">
var imgdirurl = '<? echo $imgdirurl = $stylestuff['styleimgdir']['subst'] ? $stylestuff['styleimgdir']['subst'] : ($stylestuff['imgdir']['subst'] ? $stylestuff['imgdir']['subst'] : 'images/default');?>/';
function imgdirurl_update() {
imgdirurl = ($('styleimgdir').value ? $('styleimgdir').value : ($('imgdir').value ? $('imgdir').value : 'images/default')) + '/';
}
function updatecolorpreview(obj, objv) {
$(obj).style.background = $(objv).value;
}
var colorfocus;
function setfocus(obj) {
colorfocus = obj;
}
function setgcolor(color) {
if(!colorfocus) {
alert('<?=$lang['styles_edit_visual_selectcolorbox']?>');
return;
}
colorfocus.value = color;
var change = colorfocus.onchange.toString();
if(change) {
var start = change.indexOf('{');
var end = change.lastIndexOf('}');
s = change.substring(start + 1, end);
s = s.replace(/this\.value/ig, "'" + colorfocus.value + "'");
eval(s)
}
}
</script>
<table cellpadding="0" cellspacing="0" width="100%" style="table-layout:fixed">
<?
$copystyle = array(
'wrapbg' => array('inputbg','dropmenubgcolor'),
'commonborder' => array('specialborder', 'dropmenuborder', 'floatmaskbgcolor', 'inputborder', 'inputborderdarkcolor', 'contentseparate'),
'commonbg' => array('specialbg', 'interleavecolor', 'floatbgcolor')
);
foreach($copystyle as $copysrc => $copydescs) {
foreach($copydescs as $copydesc) {
if($stylestuff[$copysrc]['subst'] == $stylestuff[$copydesc]['subst']) {
echo '<input type="hidden" name="copyids['.$stylestuff[$copysrc]['id'].'][]" value="'.$stylestuff[$copydesc]['id'].'" />';
}
}
}
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_boardimg'].'</td><td><input name="stylevar['.$stylestuff['boardimg']['id'].']" value="'.$stylestuff['boardimg']['subst'].'" size="10" onchange="$(\'sp_logo\').src = this.value ? imgdirurl + this.value : \'images/common/none.gif\'" /></td></tr>';
$stylestuff['headerbgcolor']['subst'] = explode(' ', $stylestuff['headerbgcolor']['subst']);
$headerbgcolor = $stylestuff['headerbgcolor']['subst'][0];
$headerbgimg = $stylestuff['headerbgcolor']['subst'][1];
$headerbgextra = implode(' ', array_slice($stylestuff['headerbgcolor']['subst'], 2));
echo '<tr><td>'.$lang['styles_edit_visual_setting_headerbgcolor'].'</td><td><div class="color"><input id="headerbgcolor" name="stylevar['.$stylestuff['headerbgcolor']['id'].']" value="'.$headerbgcolor.'" size="10" onchange="$(\'sp_header\').style.background = this.value + \' url(\' + imgdirurl + $(\'headerbgcolorimg\').value + \') \' + $(\'headerbgcolorextra\').value;updatecolorpreview(\'c1\', \'headerbgcolor\')" onclick="setfocus(this)" />'.getcolor(1, 'headerbgcolor').'</div>'.
' <input id="headerbgcolorimg" name="stylevarbgimg['.$stylestuff['headerbgcolor']['id'].']" value="'.$headerbgimg.'" size="10" onchange="$(\'sp_header\').style.background = $(\'headerbgcolor\').value + \' url(\' + imgdirurl + this.value + \') \' + $(\'headerbgcolorextra\').value" />'.
' <input id="headerbgcolorextra" name="stylevarbgextra['.$stylestuff['headerbgcolor']['id'].']" value="'.$headerbgextra.'" size="10" onchange="$(\'sp_header\').style.background = $(\'headerbgcolor\').value + \' url(\' + imgdirurl + $(\'headerbgcolorimg\').value + \') \' + this.value" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_headerborder'].'</td><td><div class="color"><input id="headerbordercolor" name="stylevar['.$stylestuff['headerbordercolor']['id'].']" value="'.$stylestuff['headerbordercolor']['subst'].'" size="10" onchange="$(\'sp_menucurrent\').style.borderColor = this.value;$(\'sp_header\').style.borderBottom = $(\'headerborder\').value + \' solid \' + this.value;updatecolorpreview(\'c2\', \'headerbordercolor\')" onclick="setfocus(this)" />'.getcolor(2, 'headerbordercolor').'</div>'.
' <input id="headerborder" name="stylevar['.$stylestuff['headerborder']['id'].']" value="'.$stylestuff['headerborder']['subst'].'" size="10" onchange="$(\'sp_header\').style.borderBottom = this.value + \' solid \' + $(\'headerbordercolor\').value" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_headertext'].'</td><td><div class="color"><input id="headertext" name="stylevar['.$stylestuff['headertext']['id'].']" value="'.$stylestuff['headertext']['subst'].'" size="10" onchange="$(\'sp_umenu\').style.color = this.value;updatecolorpreview(\'c3\', \'headertext\')" onclick="setfocus(this)" />'.getcolor(3, 'headertext').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_menuborder'].'</td><td><div class="color"><input id="menuborder" name="stylevar['.$stylestuff['menuborder']['id'].']" value="'.$stylestuff['menuborder']['subst'].'" size="10" onchange="$(\'sp_menuitem\').style.borderColor = this.value;updatecolorpreview(\'c4\', \'menuborder\')" onclick="setfocus(this)" />'.getcolor(4, 'menuborder').'</div></td></tr>';
$stylestuff['menubgcolor']['subst'] = explode(' ', $stylestuff['menubgcolor']['subst']);
$menubgcolor = $stylestuff['menubgcolor']['subst'][0];
$menubgimg = $stylestuff['menubgcolor']['subst'][1];
$menubgextra = implode(' ', array_slice($stylestuff['menubgcolor']['subst'], 2));
echo '<tr><td>'.$lang['styles_edit_visual_setting_menubgcolor'].'</td><td><div class="color"><input id="menubgcolor" name="stylevar['.$stylestuff['menubgcolor']['id'].']" value="'.$menubgcolor.'" size="10" onchange="$(\'sp_menuitem\').style.background = this.value + \' url(\' + imgdirurl + $(\'menubgcolorimg\').value + \') \' + $(\'menubgcolorextra\').value;updatecolorpreview(\'c5\', \'menubgcolor\')" onclick="setfocus(this)" />'.getcolor(5, 'menubgcolor').'</div>'.
' <input id="menubgcolorimg" name="stylevarbgimg['.$stylestuff['menubgcolor']['id'].']" value="'.$menubgimg.'" size="10" onchange="$(\'sp_menuitem\').style.background = $(\'menubgcolor\').value + \' url(\' + imgdirurl + this.value + \') \' + $(\'menubgcolorextra\').value;" />'.
' <input id="menubgcolorextra" name="stylevarbgextra['.$stylestuff['menubgcolor']['id'].']" value="'.$menubgextra.'" size="10" onchange="$(\'sp_menuitem\').style.background = $(\'menubgcolor\').value + \' url(\' + imgdirurl + $(\'menubgcolorimg\').value + \') \' + this.value" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_menutext'].'</td><td><div class="color"><input id="menutext" name="stylevar['.$stylestuff['menutext']['id'].']" value="'.$stylestuff['menutext']['subst'].'" size="10" onchange="$(\'sp_menu\').style.color = this.value;updatecolorpreview(\'c6\', \'menutext\')" onclick="setfocus(this)" />'.getcolor(6, 'menutext').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_menuhover'].'</td><td><div class="color"><input id="menuhover" name="stylevar['.$stylestuff['menuhover']['id'].']" value="'.$stylestuff['menuhover']['subst'].'" size="10" onchange="$(\'sp_menucurrent\').style.backgroundColor = this.value;updatecolorpreview(\'c7\', \'menuhover\')" onclick="setfocus(this)" />'.getcolor(7, 'menuhover').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_menuhovertext'].'</td><td><div class="color"><input id="menuhovertext" name="stylevar['.$stylestuff['menuhovertext']['id'].']" value="'.$stylestuff['menuhovertext']['subst'].'" size="10" onchange="$(\'sp_menucurrent\').style.color = this.value;updatecolorpreview(\'c8\', \'menuhovertext\')" onclick="setfocus(this)" />'.getcolor(8, 'menuhovertext').'</div></td></tr>';
$stylestuff['bgcolor']['subst'] = explode(' ', $stylestuff['bgcolor']['subst']);
$bgcolor = $stylestuff['bgcolor']['subst'][0];
$bgcolorimg = $stylestuff['bgcolor']['subst'][1];
$bgcolorextra = implode(' ', array_slice($stylestuff['bgcolor']['subst'], 2));
echo '<tr><td>'.$lang['styles_edit_visual_setting_bgcolor'].'</td><td><div class="color"><input id="bgcolor" name="stylevar['.$stylestuff['bgcolor']['id'].']" value="'.$bgcolor.'" size="10" onchange="$(\'style_preview\').style.background = this.value + \' url(\' + imgdirurl + $(\'bgcolorimg\').value + \') \' + $(\'bgcolorextra\').value;updatecolorpreview(\'c9\', \'bgcolor\')" onclick="setfocus(this)" />'.getcolor(9, 'bgcolor').'</div>'.
' <input id="bgcolorimg" name="stylevarbgimg['.$stylestuff['bgcolor']['id'].']" value="'.$bgcolorimg.'" size="10" onchange="$(\'style_preview\').style.background = $(\'bgcolor\').value + \' url(\' + imgdirurl + this.value + \') \' + $(\'bgcolorextra\').value" />'.
' <input id="bgcolorextra" name="stylevarbgextra['.$stylestuff['bgcolor']['id'].']" value="'.$bgcolorextra.'" size="10" onchange="$(\'style_preview\').style.background = $(\'bgcolor\').value + \' url(\' + imgdirurl + $(\'bgcolorimg\').value + \') \' + this.value" /></td></tr>';
$stylestuff['sidebgcolor']['subst'] = explode(' ', $stylestuff['sidebgcolor']['subst']);
$sidebgcolor = $stylestuff['sidebgcolor']['subst'][0];
$sidebgcolorimg = $stylestuff['sidebgcolor']['subst'][1];
$sidebgcolorextra = implode(' ', array_slice($stylestuff['sidebgcolor']['subst'], 2));
echo '<tr><td>'.$lang['styles_edit_visual_setting_sidebgcolor'].'</td><td><input id="sidebgcolorimg" name="stylevarbgimg['.$stylestuff['sidebgcolor']['id'].']" value="'.$sidebgcolorimg.'" size="10" onchange="$(\'sp_wrap\').style.backgroundImage = \'url(\' + imgdirurl + this.value + \')\'" /><input name="stylevar['.$stylestuff['sidebgcolor']['id'].']" type="hidden" value="'.$sidebgcolor.'"><input name="stylevarbgextra['.$stylestuff['sidebgcolor']['id'].']" type="hidden" value="'.$sidebgcolorextra.'"></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_wrapwidth'].'</td><td><input name="stylevar['.$stylestuff['wrapwidth']['id'].']" value="'.$stylestuff['wrapwidth']['subst'].'" size="10" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_wrapbg'].'</td><td><div class="color"><input id="wrapbg" name="stylevar['.$stylestuff['wrapbg']['id'].']" value="'.$stylestuff['wrapbg']['subst'].'" size="10" onchange="$(\'sp_wrap\').style.backgroundColor = this.value;updatecolorpreview(\'c10\', \'wrapbg\')" onclick="setfocus(this)" />'.getcolor(10, 'wrapbg').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_wrapborder'].'</td><td><div class="color"><input id="wrapbordercolor" name="stylevar['.$stylestuff['wrapbordercolor']['id'].']" value="'.$stylestuff['wrapbordercolor']['subst'].'" size="10" onchange="$(\'sp_wrap\').style.border = $(\'wrapborder\').value + \' solid \' + this.value;updatecolorpreview(\'c11\', \'wrapbordercolor\')" onclick="setfocus(this)" />'.getcolor(11, 'wrapbordercolor').'</div>'.
' <input id="wrapborder" name="stylevar['.$stylestuff['wrapborder']['id'].']" value="'.$stylestuff['wrapborder']['subst'].'" size="10" onchange="$(\'sp_wrap\').style.border = this.value + \' solid \' + $(\'wrapbordercolor\').value" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_footertext'].'</td><td><div class="color"><input id="footertext" name="stylevar['.$stylestuff['footertext']['id'].']" value="'.$stylestuff['footertext']['subst'].'" size="10" onchange="$(\'sp_footer\').style.color = this.value;updatecolorpreview(\'c12\', \'footertext\')" onclick="setfocus(this)" />'.getcolor(12, 'footertext').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_getcolorfromimg'].'</td><td><input id="imgurl" size="10"> <a href="javascript:;" onclick="ajaxget(\''.$BASESCRIPT.'?action=styles&operation=getcolor&file=\' + $(\'imgurl\').value, \'colorlist\')">'.$lang['styles_edit_visual_getcolor'].'</a></td></tr>';
echo '<tr><td></td><td><div id="colorlist"></div></td></tr>';
?>
</td><tr></table>
</td><tr></table>
<script>
var inps = $('previewbody').getElementsByTagName('INPUT');
for(i = 0;i < inps.length;i++) {
if(inps[i].onchange) {
var change = inps[i].onchange.toString();
if(change) {
var start = change.indexOf('{');
var end = change.lastIndexOf('}');
s = change.substring(start + 1, end);
s = s.replace(/this\.value/ig, "'" + inps[i].value + "'");
eval(s)
}
}
}
</script>
</td></tr>
<?
showsubmit('editsubmit', 'submit', '', '<input type="button" class="btn" onclick="location.href=\''.$BASESCRIPT.'?action=styles&operation=edit&id='.$id.'&adv=1\'" value="'.$lang['styles_edit_adv_switch'].'">');
showtablefooter();
showformfooter();
}
} else {
if($newcvar && $newcsubst) {
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}stylevars WHERE variable='$newcvar' AND styleid='$id'")) {
cpmsg('styles_edit_variable_duplicate', '', 'error');
} elseif(!preg_match("/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/", $newcvar)) {
cpmsg('styles_edit_variable_illegal', '', 'error');
}
$newcvar = strtolower($newcvar);
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$id', '$newcvar', '$newcsubst')");
}
$db->query("UPDATE {$tablepre}styles SET name='$namenew', templateid='$templateidnew' WHERE styleid='$id'");
foreach($stylevar as $varid => $substitute) {
if(!empty($stylevarbgimg[$varid])) {
$substitute .= ' '.$stylevarbgimg[$varid];
if(!empty($stylevarbgextra[$varid])) {
$substitute .= ' '.$stylevarbgextra[$varid];
}
}
$substitute = @htmlspecialchars($substitute);
$stylevarids = "'$varid'";
if(!empty($copyids[$varid])) {
$stylevarids .= ','.implodeids($copyids[$varid]);
}
$db->query("UPDATE {$tablepre}stylevars SET substitute='$substitute' WHERE stylevarid IN ($stylevarids) AND styleid='$id'");
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}stylevars WHERE stylevarid IN ($ids) AND styleid='$id'");
}
updatecache('styles');
cpmsg('styles_edit_succeed', $BASESCRIPT.'?action=styles'.($newcvar && $newcsubst ? '&operation=edit&id='.$id : ''), 'succeed');
}
} elseif($operation == 'getcolor') {
$imginfo = @getimagesize($file);
if(!$imginfo) {
$inajax = 1;showmessage($lang['styles_edit_visual_getcolor_fileerror']);
}
$im = '';
switch($imginfo['mime']) {
case 'image/jpeg':
$im = function_exists('imagecreatefromjpeg') ? imagecreatefromjpeg($file) : '';
break;
case 'image/gif':
$im = function_exists('imagecreatefromgif') ? imagecreatefromgif($file) : '';
break;
case 'image/png':
$im = function_exists('imagecreatefrompng') ? imagecreatefrompng($file) : '';
break;
}
if(!$im || !function_exists('imageistruecolor') ||
!function_exists('imagetruecolortopalette') ||
!function_exists('imagecreatetruecolor') ||
!function_exists('imagecopy') ||
!function_exists('imagecolorstotal') ||
!function_exists('imagecolorsforindex')) {
$inajax = 1;showmessage($lang['styles_edit_visual_getcolor_nosupport']);
}
if(!imageistruecolor($im)) {
$imt = imagecreatetruecolor($imginfo[0], $imginfo[1]);
imagecopy($imt, $im, 0, 0, 0, 0, $imginfo[0], $imginfo[1]);
$im = $imt;
}
imagetruecolortopalette($im, 1, 64);
$colorn = imagecolorstotal($im);
$colors = array();
for($i = 0;$i < $colorn;$i++) {
$rgb = imagecolorsforindex($im, $i);
$color = sprintf('%02s', dechex($rgb['red'])).sprintf('%02s', dechex($rgb['green'])).sprintf('%02s', dechex($rgb['blue']));
if($color != 'ffffff') {
$colors[] = $color;
}
}
$colors = array_unique($colors);
sort($colors);
include template('header_ajax');
for($i = 0;$i < count($colors);$i++) {
echo '<p onclick="setgcolor(\'#'.$colors[$i].'\')" style="float:left;width:20px;height:20px;cursor:pointer;background-color: #'.$colors[$i].'"> </p>';
}
include template('footer_ajax');
exit;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/styles.inc.php | PHP | asf20 | 44,392 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: faq.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$operation = $operation ? $operation : 'list';
if($operation == 'list') {
if(!submitcheck('faqsubmit')) {
shownav('extended', 'faq');
showsubmenu('faq');
showformheader('faq&operation=list');
showtableheader();
echo '<tr><th class="td25"></th><th>'.$lang['display_order'].'</th><th style="width:350px">'.$lang['faq_thread'].'</th><th class="td24">'.$lang['faq_sortup'].'</th><th></th></tr>';
$faqparent = $faqsub = array();
$faqlists = $faqselect = '';
$query = $db->query("SELECT * FROM {$tablepre}faqs ORDER BY displayorder");
while($faq = $db->fetch_array($query)) {
if(empty($faq['fpid'])) {
$faqparent[$faq['id']] = $faq;
$faqselect .= "<option value=\"$faq[id]\">$faq[title]</option>";
} else {
$faqsub[$faq['fpid']][] = $faq;
}
}
foreach($faqparent as $parent) {
$disabled = !empty($faqsub[$parent['id']]) ? 'disabled' : '';
showtablerow('', array('', 'class="td23 td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$parent[id]\" $disabled>",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$parent[id]]\" value=\"$parent[displayorder]\">",
"<div class=\"parentnode\"><input type=\"text\" class=\"txt\" size=\"30\" name=\"title[$parent[id]]\" value=\"".dhtmlspecialchars($parent['title'])."\"></div>",
$lang[none],
"<a href=\"$BASESCRIPT?action=faq&operation=detail&id=$parent[id]\" class=\"act\">".$lang['detail']."</a>"
));
if(!empty($faqsub[$parent['id']])) {
foreach($faqsub[$parent['id']] as $sub) {
showtablerow('', array('', 'class="td23 td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$sub[id]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$sub[id]]\" value=\"$sub[displayorder]\">",
"<div class=\"node\"><input type=\"text\" class=\"txt\" size=\"30\" name=\"title[$sub[id]]\" value=\"".dhtmlspecialchars($sub['title'])."\"></div>",
$faqparent[$sub['fpid']][title],
"<a href=\"$BASESCRIPT?action=faq&operation=detail&id=$sub[id]\" class=\"act\">".$lang['detail']."</a>"
));
}
}
echo '<tr><td></td><td></td><td colspan="3"><div class="lastnode"><a href="###" onclick="addrow(this, 1, '.$parent['id'].')" class="addtr">'.lang('faq_additem').'</a></div></td></tr>';
}
echo '<tr><td></td><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0, 0)" class="addtr">'.lang('faq_addcat').'</a></div></td></tr>';
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1,''], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td25'], [1, '<input name="newtitle[]" value="" size="30" type="text" class="txt">'], [2, '<input type="hidden" name="newfpid[]" value="0" />']],
[[1,''], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td25'], [1, '<div class=\"node\"><input name="newtitle[]" value="" size="30" type="text" class="txt"></div>'], [2, '<input type="hidden" name="newfpid[]" value="{1}" />']]
];
</script>
EOT;
showsubmit('faqsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}faqs WHERE id IN ($ids)");
}
if(is_array($title)) {
foreach($title as $id => $val) {
$db->query("UPDATE {$tablepre}faqs SET displayorder='$displayorder[$id]', title='$title[$id]' WHERE id='$id'");
}
}
if(is_array($newtitle)) {
foreach($newtitle as $k => $v) {
$v = trim($v);
if($v) {
$db->query("INSERT INTO {$tablepre}faqs (fpid, displayorder, title)
VALUES ('".intval($newfpid[$k])."', '".intval($newdisplayorder[$k])."', '$v')");
}
}
}
cpmsg('faq_list_update', $BASESCRIPT.'?action=faq&operation=list', 'succeed');
}
} elseif($operation == 'detail') {
if(!submitcheck('detailsubmit')) {
$faq = $db->fetch_first("SELECT * FROM {$tablepre}faqs WHERE id='$id'");
if(!$faq) {
cpmsg('undefined_action', '', 'error');
}
$query = $db->query("SELECT * FROM {$tablepre}faqs WHERE fpid='0' ORDER BY displayorder, fpid ");
while($parent = $db->fetch_array($query)) {
$faqselect .= "<option value=\"$parent[id]\" ".($faq['fpid'] == $parent['id'] ? 'selected' : '').">$parent[title]</option>";
}
shownav('extended', 'faq');
showsubmenu('faq');
showformheader("faq&operation=detail&id=$id");
showtableheader();
showtitle('faq_edit');
showsetting('faq_title', 'titlenew', $faq['title'], 'text');
if(!empty($faq['fpid'])) {
showsetting('faq_sortup', '', '', '<select name="fpidnew"><option value=\"\">'.$lang['none'].'</option>'.$faqselect.'</select>');
showsetting('faq_identifier', 'identifiernew', $faq['identifier'], 'text');
showsetting('faq_keywords', 'keywordnew', $faq['keyword'], 'text');
showsetting('faq_content', 'messagenew', $faq['message'], 'textarea');
}
showsubmit('detailsubmit');
showtablefooter();
showformfooter();
} else {
if(!$titlenew) {
cpmsg('faq_no_title', '', 'error');
}
if(!empty($identifiernew)) {
$query = $db->query("SELECT id FROM {$tablepre}faqs WHERE identifier='$identifiernew' AND id!='$id'");
if($db->num_rows($query)) {
cpmsg('faq_identifier_invalid', '', 'error');
}
}
if(strlen($keywordnew) > 50) {
cpmsg('faq_keyword_toolong', '', 'error');
}
$fpidnew = $fpidnew ? intval($fpidnew) : 0;
$titlenew = trim($titlenew);
$messagenew = trim($messagenew);
$identifiernew = trim($identifiernew);
$keywordnew = trim($keywordnew);
$db->query("UPDATE {$tablepre}faqs SET fpid='$fpidnew', identifier='$identifiernew', keyword='$keywordnew', title='$titlenew', message='$messagenew' WHERE id='$id'");
updatecache('faqs');
cpmsg('faq_list_update', $BASESCRIPT.'?action=faq&operation=list', 'succeed');
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/faq.inc.php | PHP | asf20 | 6,333 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: jswizard.inc.php 20835 2009-10-27 02:59:05Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(!empty($previewurl)) {
include_once DISCUZ_ROOT.'./forumdata/cache/cache_request.php';
require_once DISCUZ_ROOT.'./include/request.func.php';
parse_str($jsurl.'&nocache=yes', $requestdata);
if($requestdata['function'] == 'side') {
$tags = '<div id="wrap" class="wrap with_side s_clear" style="width:90%;height:auto;min-height:50px !important"><div class="main"><div class="content"></div></div><div id="sidebar" class="side"><div>';
} else {
$tags = '<div id="wrap" class="wrap s_clear" style="width:90%;height:auto;min-height:50px !important"><div class="main"><div class="content">';
}
echo '<!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"><meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" /><head><script type="text/javascript" src="include/js/common.js"></script></head><link rel="stylesheet" type="text/css" href="forumdata/cache/style_'.STYLEID.'_common.css" />';
echo "\n\n<body><div id=\"append_parent\"></div><div id=\"ajaxwaitid\"></div>$tags\n\n".parse_request($requestdata, '', 0)."\n\n</div></div></div></body>\n\n</html>";
exit;
}
cpheader();
$jstypes = array(0 => 'threads', 1 => 'forums', 2 => 'memberrank', 3 => 'stats', 4 => 'images', 5 => 'module', -2 => 'side', -1 => 'custom');
$from = $action == 'jswizard' && $operation != 'infoside' ? 'jswizard' : $from;
$infosidemenu = array(array('menu' => 'nav_infoside', 'submenu' => array(
array('jswizard_infoside_global', 'jswizard&operation=infoside&from='.$from),
array('jswizard_infoside_2', 'jswizard&operation=infoside&sideid=2&from='.$from),
array('jswizard_infoside_0', 'jswizard&operation=infoside&sideid=0&from='.$from),
)), '', $operation == 'infoside' ? 1 : 0);
$addmenu = array();
foreach($jstypes as $k => $v) {
if($k != 5) {
$addmenu[] = array('jswizard_'.$v, 'jswizard&type='.$v);
}
}
if(!$operation) {
shownav('tools', 'nav_javascript');
$jswizard = array();
$query = $db->query("SELECT * FROM {$tablepre}request WHERE variable LIKE '".($jssetting != '' ? $jssetting : ($jskey != '' ? $jskey : '%'))."'");
while($settings = $db->fetch_array($query)) {
if($settings['system']) {
continue;
}
$jswizard[$settings['variable']] = unserialize($settings['value']);
$jswizard[$settings['variable']]['type'] = $settings['type'];
}
$type = !empty($function) ? $function : (isset($type) ? $type : '');
$edit = isset($edit) ? $edit : NULL;
$jskeyempty = 0;
$editext = ($jssetting || $edit) ? '<input type="hidden" name="edit" value="'.dhtmlspecialchars($jssetting ? $jssetting : $edit).'">' : '';
ksort($jswizard);
if(!empty($type)) {
list($keypre, $keyp) = explode('_', $jssetting);
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 0),
$infosidemenu,
array('admin', 'jswizard'.($keyp ? '&openkeypre='.$keypre : ''), 0),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', $type != 'module' ? 1 : 0),
array('jswizard_module', 'jswizard&type=module', $type != 'module' ? 0 : 1),
array('import', 'jswizard&operation=import', 0),
));
if(empty($jskey)) {
$jskey = $lang['jswizard_'.$type].'_'.random(3);
$jskeyempty = 1;
}
$jspreview = '';
$comment = !empty($comment) ? $comment : $jswizard[$jssetting]['comment'];
if(!empty($function) && !empty($jssetting) && isset($jswizard[$jssetting]['url'])) {
$parameter = $jswizard[$jssetting]['parameter'];
$jskey = $jssetting;
$jssetting = $jswizard[$jssetting]['url'];
$preview = $jssubmit = TRUE;
$jskeyempty = 0;
} else {
$jssetting = '';
}
}
$jskey = stripslashes(trim($jskey));
if(empty($type)) {
list($keypre, $keyp) = explode('_', $jssetting);
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 0),
$infosidemenu,
array('admin', 'jswizard', 1),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
array('jswizard_module', 'jswizard&type=module', 0),
array('import', 'jswizard&operation=import', 0)
));
if(!submitcheck('jsdelsubmit') && !submitcheck('jsexportsubmit')) {
showformheader('jswizard');
showtableheader();
showsubtitle(array('', 'jswizard_key', 'jswizard_desc', 'jswizard_cache', 'type', ''));
$lastpre = '';
$openkeypre = isset($openkeypre) ? $openkeypre : '';
echo '<tbody>';
foreach($jswizard as $key => $jssetting) {
list($keypre, $keyp) = explode('_', $key);
if($keyp) {
if($keypre != $lastpre) {
echo '</tbody>';
showtablerow('', array('class="td25"', '', 'width="40%"', 'width="10%"', 'width="20%"'), array(
'',
'<a href="javascript:;" onclick="display(\'key_'.$keypre.'\')"><span class="bold">['.$keypre.']</span></a>',
'',
'',
'',
''
));
echo '<tbody id="key_'.$keypre.'"'.($keypre != $openkeypre ? 'style="display: none"' : '').'>';
$inpre = ' ';
}
} else {
echo '<tbody>';
$inpre = '';
}
$lastpre = $keypre;
showtablerow('', array('class="td25"', '', 'width="40%"', 'width="10%"', 'width="20%"'), array(
!@in_array($key, $infosidestatus) ? '<input class="checkbox" type="checkbox" name="keyarray[]" value="'.dhtmlspecialchars($key).'">' : '<input class="checkbox" type="checkbox" disabled="disabled">',
$inpre.'<a href="'.$BASESCRIPT.'?action=jswizard&function='.$jstypes[$jssetting['type']].'&jssetting='.rawurlencode($key).'"><span class="bold">'.($inpre ? substr($key, strlen($keypre) + 1) : $key).'</span></a>',
$jssetting['comment'].' ',
($jssetting['parameter']['cachelife'] !== '' ? $jssetting['parameter']['cachelife'] : '<font class="lightfont">'.$jscachelife.'</font>'),
(in_array($jstypes[$jssetting['type']], array('custom', 'side')) ? '<b>'.$lang['jswizard_'.$jstypes[$jssetting['type']]].'</b>' : $lang['jswizard_'.$jstypes[$jssetting['type']]]).
($jssetting['parameter']['sidestatus'] ? ' ('.$lang['jswizard_for_side'].')' : ''),
'<a href="'.$BASESCRIPT.'?action=jswizard&function='.$jstypes[$jssetting['type']].'&jssetting='.rawurlencode($key).'">'.$lang['edit'].'</a> '.
'<a href="'.$BASESCRIPT.'?action=jswizard&operation=copy&jssetting='.rawurlencode($key).'">'.$lang['copy'].'</a> '
));
}
echo '</tbody>';
showtablerow('', array('', 'colspan="5"'), array(
'<input type="checkbox" name="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'keyarray\')">'.lang('select_all'),
'<input type="submit" class="btn" name="jsdelsubmit" value="'.$lang['delete'].'"> <input type="submit" class="btn" name="jsexportsubmit" value="'.$lang['export'].'">'
));
showtablefooter();
showformfooter();
} elseif(submitcheck('jsdelsubmit')) {
if(is_array($keyarray)) {
$keys = implode("','", $keyarray);
$db->query("DELETE FROM {$tablepre}request WHERE variable IN ('$keys')");
updatecache('request');
cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizard', 'succeed');
} else {
header("location: $boardurl$BASESCRIPT?action=jswizard");
dexit();
}
} elseif(submitcheck('jsexportsubmit')) {
if(is_array($keyarray)) {
$keys = implode("','", $keyarray);
$query = $db->query("SELECT * FROM {$tablepre}request WHERE variable IN ('$keys')");
$exportdataarray = array();
while($exportdata = $db->fetch_array($query)) {
$value = unserialize($exportdata['value']);
$value['type'] = $exportdata['type'];
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[$exportdata['variable']] = serialize($value);
}
exportdata('Discuz! Request', date('Ymd'), $exportdataarray);
} else {
header("location: {$boardurl}$BASESCRIPT?action=jswizard");
dexit();
}
}
} elseif($type == 'threads') {
$tcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'lastpost') => 'checked');
for($i = 0; $i <= 6; $i++) {
$tcheckspecial[$i] = !empty($parameter['special'][$i]) ? 'checked' : '';
$tcheckdigest[$i] = !empty($parameter['digest'][$i]) ? 'checked' : '';
$tcheckstick[$i] = !empty($parameter['stick'][$i]) ? 'checked' : '';
}
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
$jsthreadtypeselect = '<select multiple="multiple" name="parameter[typeids][]" size="10"><option value="all">'.$lang['jswizard_all_typeids'].'</optoin><option value=""> </option>';
$jsthreadsortselect = '<select multiple="multiple" name="parameter[sortids][]" size="10"><option value="all">'.$lang['jswizard_all_sortids'].'</optoin><option value=""> </option>';
$query = $db->query("SELECT typeid, name, special FROM {$tablepre}threadtypes ORDER BY typeid DESC");
while($threadtype = $db->fetch_array($query)) {
if($threadtype['special']) {
$jsthreadsortselect .= '<option value="'.$threadtype['typeid'].'" '.(isset($parameter['sortids']) && in_array($threadtype['typeid'], $parameter['sortids']) ? 'selected' : '').'>'.$threadtype['name'].'</option>';
} else {
$jsthreadtypeselect .= '<option value="'.$threadtype['typeid'].'" '.(isset($parameter['typeids']) && in_array($threadtype['typeid'], $parameter['typeids']) ? 'selected' : '').'>'.$threadtype['name'].'</option>';
}
}
$jsthreadtypeselect .= '</select>';
$jsthreadsortselect .= '</select>';
$trewardstatus = array(intval($parameter['rewardstatus']) => 'checked');
if($jssubmit && $function == 'threads') {
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['threads_forums'] && !in_array('all', $parameter['threads_forums'])? '&fids='.jsfids($parameter['threads_forums']) : '').
"&sidestatus=$parameter[sidestatus]".
"&maxlength=$parameter[maxlength]".
"&fnamelength=$parameter[fnamelength]".
"&messagelength=$parameter[messagelength]".
"&startrow=$parameter[startrow]".
"&picpre=".rawurlencode($parameter['picpre']).
"&items=$parameter[items]".
"&tag=".rawurlencode($parameter[tag]).
'&tids='.str_replace(',', '_', $parameter['tids']).
($parameter['keyword'] ? '&keyword='.rawurlencode($parameter['keyword']) : '').
($parameter['typeids'] && !in_array('all', $parameter['typeids'])? '&typeids='.jsfids($parameter['typeids']) : '').
($parameter['sortids'] && !in_array('all', $parameter['sortids'])? '&sortids='.jsfids($parameter['sortids']) : '').
"&special=".bindec(intval($parameter['special'][1]).intval($parameter['special'][2]).intval($parameter['special'][3]).intval($parameter['special'][4]).intval($parameter['special'][5]).intval($parameter['special'][6]).intval($parameter['special'][0])).
"&rewardstatus=$parameter[rewardstatus]".
"&digest=".bindec(intval($parameter['digest'][1]).intval($parameter['digest'][2]).intval($parameter['digest'][3]).intval($parameter['digest'][4])).
"&stick=".bindec(intval($parameter['stick'][1]).intval($parameter['stick'][2]).intval($parameter['stick'][3]).intval($parameter['stick'][4])).
"&recommend=$parameter[recommend]".
"&newwindow=$parameter[newwindow]".
"&threadtype=$parameter[threadtype]".
"&threadsort=$parameter[threadsort]".
"&highlight=$parameter[highlight]".
"&orderby=$parameter[orderby]".
"&hours=".intval($parameter['hours']).
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(0);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=threads#'.$lang['jswizard_threads']);
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_threads').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_threads_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{prefix} {subject}<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader();
showtitle('jswizard_threads');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
showsetting('jswizard_threads_fids', '', '', jsforumselect('threads'));
showsetting('jswizard_sidestatus', 'parameter[sidestatus]', $parameter['sidestatus'], 'radio');
showsetting('jswizard_threads_startrow', 'parameter[startrow]', intval($parameter['startrow']), 'text');
showsetting('jswizard_threads_items', 'parameter[items]', isset($parameter['items']) ? $parameter['items'] : 10, 'text');
showsetting('jswizard_threads_maxlength', 'parameter[maxlength]', isset($parameter['maxlength']) ? $parameter['maxlength'] : 50, 'text');
showsetting('jswizard_threads_fnamelength', 'parameter[fnamelength]', $parameter['fnamelength'], 'radio');
showsetting('jswizard_threads_messagelength', 'parameter[messagelength]', $parameter['messagelength'], 'text');
showsetting('jswizard_threads_picpre', 'parameter[picpre]', $parameter['picpre'], 'text');
showsetting('jswizard_threads_tids', 'parameter[tids]', ($parameter['tids'] ? str_replace('_', ',', $parameter['tids']) : ''), 'text');
showsetting('jswizard_threads_keyword', 'parameter[keyword]', $parameter['keyword'], 'text');
showsetting('jswizard_threads_tag', 'parameter[tag]', $parameter['tag'], 'text');
showsetting('jswizard_threads_typeids', '', '', $jsthreadtypeselect);
showsetting('jswizard_threads_threadtype', 'parameter[threadtype]', $parameter['threadtype'], 'radio');
showsetting('jswizard_threads_sortids', '', '', $jsthreadsortselect);
showsetting('jswizard_threads_threadsort', 'parameter[threadsort]', $parameter['threadsort'], 'radio');
showsetting('jswizard_threads_highlight', 'parameter[highlight]', $parameter['highlight'], 'radio');
showsetting('jswizard_threads_special', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckspecial[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][1]" value="1" '.$tcheckspecial[1].'> '.$lang['thread_poll'].'</li>
<li'.($tcheckspecial[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][2]" value="1" '.$tcheckspecial[2].'> '.$lang['thread_trade'].'</li>
<li'.($tcheckspecial[3] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" onclick="$(\'special_reward_ext\').style.display = this.checked ? \'\' : \'none\'" name="parameter[special][3]" value="1" '.$tcheckspecial[3].'> '.$lang['thread_reward'].'</li>
<li'.($tcheckspecial[4] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][4]" value="1" '.$tcheckspecial[4].'> '.$lang['thread_activity'].'</li>
<li'.($tcheckspecial[5] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][5]" value="1" '.$tcheckspecial[5].'> '.$lang['thread_debate'].'</li>
<li'.($tcheckspecial[0] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][0]" value="1" '.$tcheckspecial[0].'> '.$lang['jswizard_special_0'].'</li></ul>'
);
showtagheader('tbody', 'special_reward_ext', $tcheckspecial[3], 'sub');
showsetting('jswizard_threads_special_reward', array('parameter[rewardstatus]', array(
array(0, $lang['jswizard_threads_special_reward_0']),
array(1, $lang['jswizard_threads_special_reward_1']),
array(2, $lang['jswizard_threads_special_reward_2'])
), 1), $parameter['rewardstatus'], 'mradio');
showtagfooter('tbody');
showsetting('jswizard_threads_digest', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckdigest[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][1]" value="1" '.$tcheckdigest[1].'> '.$lang['jswizard_digest_1'].'</li>
<li'.($tcheckdigest[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][2]" value="1" '.$tcheckdigest[2].'> '.$lang['jswizard_digest_2'].'</li>
<li'.($tcheckdigest[3] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][3]" value="1" '.$tcheckdigest[3].'> '.$lang['jswizard_digest_3'].'</li>
<li'.($tcheckdigest[4] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][4]" value="1" '.$tcheckdigest[4].'> '.$lang['jswizard_digest_0'].'</li></ul>'
);
showsetting('jswizard_threads_stick', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckstick[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[stick][1]" value="1" '.$tcheckstick[1].'> '.$lang['jswizard_stick_1'].'</li>
<li'.($tcheckstick[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[stick][2]" value="1" '.$tcheckstick[2].'> '.$lang['jswizard_stick_2'].'</li>
<li'.($tcheckstick[3] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[stick][3]" value="1" '.$tcheckstick[3].'> '.$lang['jswizard_stick_3'].'</li>
<li'.($tcheckstick[4] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[stick][4]" value="1" '.$tcheckstick[4].'> '.$lang['jswizard_stick_0'].'</li></ul>'
);
showsetting('jswizard_threads_recommend', 'parameter[recommend]', $parameter['recommend'], 'radio');
showsetting('jswizard_threads_newwindow', 'parameter[newwindow]', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tradionewwindow[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="0" '.$tradionewwindow[0].'> '.$lang['jswizard_newwindow_self'].'</li>
<li'.($tradionewwindow[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="1" '.$tradionewwindow[1].'> '.$lang['jswizard_newwindow_blank'].'</li>
<li'.($tradionewwindow[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="2" '.$tradionewwindow[2].'> '.$lang['jswizard_newwindow_main'].'</li></ul>'
);
showsetting('jswizard_threads_orderby', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckorderby['lastpost'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="lastpost" '.$tcheckorderby['lastpost'].'> '.$lang['jswizard_threads_orderby_lastpost'].'</li>
<li'.($tcheckorderby['dateline'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="dateline" '.$tcheckorderby['dateline'].'> '.$lang['jswizard_threads_orderby_dateline'].'</li>
<li'.($tcheckorderby['replies'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="replies" '.$tcheckorderby['replies'].'> '.$lang['jswizard_threads_orderby_replies'].'</li>
<li'.($tcheckorderby['views'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="views" '.$tcheckorderby['views'].'> '.$lang['jswizard_threads_orderby_views'].'</li>
<li'.($tcheckorderby['heats'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="heats" '.$tcheckorderby['heats'].'> '.$lang['jswizard_threads_orderby_heats'].'</li>
<li'.($tcheckorderby['recommends'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="recommends" '.$tcheckorderby['recommends'].'> '.$lang['jswizard_threads_orderby_recommends'].'</li>
<li'.($tcheckorderby['hourviews'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="hourviews" '.$tcheckorderby['hourviews'].'> <input type="text" class="txt" name="parameter[hours]" value="'.$parameter['hours'].'" style="width: 50px;" size="6"> '.$lang['jswizard_threads_orderby_hourviews'].'</li>
<li'.($tcheckorderby['todayviews'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="todayviews" '.$tcheckorderby['todayviews'].'> '.$lang['jswizard_threads_orderby_todayviews'].'</li>
<li'.($tcheckorderby['weekviews'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="weekviews" '.$tcheckorderby['weekviews'].'> '.$lang['jswizard_threads_orderby_weekviews'].'</li>
<li'.($tcheckorderby['monthviews'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="monthviews" '.$tcheckorderby['monthviews'].'> '.$lang['jswizard_threads_orderby_monthviews'].'</li></ul>'
);
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'forums') {
$fcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'displayorder') => 'checked');
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
if($jssubmit && $function == 'forums') {
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['forums_forums'] && !in_array('all', $parameter['forums_forums'])? '&fups='.jsfids($parameter['forums_forums']) : '').
"&startrow=$parameter[startrow]".
"&items=$parameter[items]".
"&newwindow=$parameter[newwindow]".
"&orderby=$parameter[orderby]".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(1);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=forums#'.$lang['jswizard_forums']);
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_forums').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_forums_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{forumname}<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader();
showtitle('jswizard_forums');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
showsetting('jswizard_forums_fups', '', '', jsforumselect('forums'));
showsetting('jswizard_forums_startrow', 'parameter[startrow]', intval($parameter['startrow']), 'text');
showsetting('jswizard_forums_items', 'parameter[items]', intval($parameter['items']), 'text');
showsetting('jswizard_forums_newwindow', 'parameter[newwindow]', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tradionewwindow[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="0" '.$tradionewwindow[0].'> '.$lang['jswizard_newwindow_self'].'</li>
<li'.($tradionewwindow[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="1" '.$tradionewwindow[1].'> '.$lang['jswizard_newwindow_blank'].'</li>
<li'.($tradionewwindow[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="2" '.$tradionewwindow[2].'> '.$lang['jswizard_newwindow_main'].'</li></ul>'
);
showsetting('jswizard_forums_orderby', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($fcheckorderby['displayorder'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="displayorder" '.$fcheckorderby['displayorder'].'> '.$lang['jswizard_forums_orderby_displayorder'].'</li>
<li'.($fcheckorderby['threads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="threads" '.$fcheckorderby['threads'].'> '.$lang['jswizard_forums_orderby_threads'].'</li>
<li'.($fcheckorderby['posts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="posts" '.$fcheckorderby['posts'].'> '.$lang['jswizard_forums_orderby_posts'].'</li></ul>'
);
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'memberrank') {
$mcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'credits') => 'checked');
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
if($jssubmit && $function == 'memberrank') {
$jsurl = $jssetting ? $jssetting : "function=$function".
"&startrow=$parameter[startrow]".
"&items=$parameter[items]".
"&newwindow=$parameter[newwindow]".
"&extcredit=$parameter[extcredit]".
"&orderby=$parameter[orderby]".
"&hours=".intval($parameter['hours']).
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(2);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=memberrank#'.$lang['jswizard_memberrank']);
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_memberrank').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_memberrank_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{regdate} {member} {value}<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
$extcreditsselect = '<select name="parameter[extcredit]">';
for($i = 1;$i <= 8;$i++) {
$extcreditsselect .= '<option value="'.$i.'"'.($parameter['extcredit'] == $i ? ' selected' : '').'>extcredits'.$i.($extcredits[$i]['title'] != '' ? ' ('.$extcredits[$i]['title'].')' : '').'</option>';
}
$extcreditsselect .= '</select>';
showtableheader();
showtitle('jswizard_memberrank');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
showsetting('jswizard_memberrank_startrow', 'parameter[startrow]', intval($parameter['startrow']), 'text');
showsetting('jswizard_memberrank_items', 'parameter[items]', isset($parameter['items']) ? $parameter['items'] : 10, 'text');
showsetting('jswizard_memberrank_newwindow', 'parameter[newwindow]', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tradionewwindow[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="0" '.$tradionewwindow[0].'> '.$lang['jswizard_newwindow_self'].'</li>
<li'.($tradionewwindow[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="1" '.$tradionewwindow[1].'> '.$lang['jswizard_newwindow_blank'].'</li>
<li'.($tradionewwindow[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="2" '.$tradionewwindow[2].'> '.$lang['jswizard_newwindow_main'].'</li></ul>'
);
showsetting('jswizard_memberrank_orderby', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($mcheckorderby['credits'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="credits" '.$mcheckorderby['credits'].'> '.$lang['jswizard_memberrank_orderby_credits'].'</li>
<li'.($mcheckorderby['extcredits'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="extcredits" '.$mcheckorderby['extcredits'].'> '.$lang['jswizard_memberrank_orderby_extcredits'].'<br />'.$extcreditsselect.'</li>
<li'.($mcheckorderby['posts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="posts" '.$mcheckorderby['posts'].'> '.$lang['jswizard_memberrank_orderby_posts'].'</li>
<li'.($mcheckorderby['digestposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="digestposts" '.$mcheckorderby['digestposts'].'> '.$lang['jswizard_memberrank_orderby_digestposts'].'</li>
<li'.($mcheckorderby['regdate'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="regdate" '.$mcheckorderby['regdate'].'> '.$lang['jswizard_memberrank_orderby_regdate'].'</li>
<li'.($mcheckorderby['hourposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="hourposts" '.$mcheckorderby['hourposts'].'> <input name="parameter[hours]" value="'.$parameter['hours'].'" size="6"> '.$lang['jswizard_memberrank_orderby_hourposts'].'</li>
<li'.($mcheckorderby['todayposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="todayposts" '.$mcheckorderby['todayposts'].'> '.$lang['jswizard_memberrank_orderby_todayposts'].'</li>
<li'.($mcheckorderby['weekposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="weekposts" '.$mcheckorderby['weekposts'].'> '.$lang['jswizard_memberrank_orderby_weekposts'].'</li>
<li'.($mcheckorderby['monthposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="monthposts" '.$mcheckorderby['monthposts'].'> '.$lang['jswizard_memberrank_orderby_monthposts'].'</li></ul>'
);
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'stats') {
$predefined = array('forums', 'threads', 'posts', 'members', 'online', 'onlinemembers');
if($jssubmit && $function == 'stats') {
if($jssetting) {
$jsurl = $jssetting;
} else {
$jsurl = "function=$function".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]";
asort($displayorder);
foreach($displayorder as $key => $order) {
if($parameter[$key]['display']) {
$jsurl .= "&info[$key]=".rawurlencode($parameter[$key]['title']);
}
}
}
$jsurl .= ($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(3);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=stats#'.$lang['jswizard_stats']);
echo '<a name="'.$lang['jswizard_stats'].'"></a>';
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_stats').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_stats_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{name} {value}<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader('jswizard_stats', 'nobottom');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
showtablefooter();
showtableheader('', 'noborder fixpadding');
showsubtitle(array('jswizard_stats_display', 'display_order', 'jswizard_stats_display_title', 'jswizard_stats_display_name'));
$order = 0;
foreach($predefined as $key) {
showtablerow('', array('class="td25"', 'class="td25"'), array(
'<input class="checkbox" type="checkbox" name="parameter['.$key.'][display]" value="1" '.(!isset($parameter[$key]) || $parameter[$key]['display'] ? 'checked' : '').'>',
'<input type="text" class="txt" name="displayorder['.$key.']" size="3" value="'.(isset($displayorder[$key]) ? intval($displayorder[$key]) : ++$order).'">',
$lang['jswizard_stats_'.$key],
'<input type="text" class="txt" name="parameter['.$key.'][title]" size="15" value="'.($parameter[$key]['title'] ? $parameter[$key]['title'] : $lang['jswizard_stats_'.$key].':').'">'
));
}
showtablefooter();
showtableheader('', 'notop');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1" /></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'images') {
$tcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'dateline') => 'checked');
for($i = 1; $i <= 4; $i++) {
$icheckdigest[$i] = !empty($parameter['digest'][$i]) ? 'checked' : '';
}
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$parameter['isimage'] = isset($parameter['isimage']) ? $parameter['isimage'] : 1;
$parameter['threadmethod'] = isset($parameter['threadmethod']) ? $parameter['threadmethod'] : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
if($jssubmit && $function == 'images') {
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['images_forums'] && !in_array('all', $parameter['images_forums'])? '&fids='.jsfids($parameter['images_forums']) : '').
"&sidestatus=$parameter[sidestatus]".
"&isimage=$parameter[isimage]".
"&threadmethod=$parameter[threadmethod]".
"&maxwidth=$parameter[maxwidth]".
"&maxheight=$parameter[maxheight]".
"&startrow=$parameter[startrow]".
"&items=$parameter[items]".
"&orderby=$parameter[orderby]".
"&hours=".intval($parameter['hours']).
"&digest=".bindec(intval($parameter['digest'][1]).intval($parameter['digest'][2]).intval($parameter['digest'][3]).intval($parameter['digest'][4])).
"&newwindow=$parameter[newwindow]".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(4);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=images#'.$lang['jswizard_images']);
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_images').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_images_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{file} ({filesize} Bytes)<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader();
showtitle('jswizard_images');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
showsetting('jswizard_images_fids', '', '', jsforumselect('images'));
showsetting('jswizard_sidestatus', 'parameter[sidestatus]', $parameter['sidestatus'], 'radio');
showsetting('jswizard_images_startrow', 'parameter[startrow]', intval($parameter['startrow']), 'text');
showsetting('jswizard_images_items', 'parameter[items]', isset($parameter['items']) ? $parameter['items'] : 5, 'text');
showsetting('jswizard_images_isimage', array('parameter[isimage]', array(
array(0, $lang['jswizard_images_isimage_0'], array('imgsetting' => 'none')),
array(1, $lang['jswizard_images_isimage_1'], array('imgsetting' => '')),
array(2, $lang['jswizard_images_isimage_2'], array('imgsetting' => 'none'))
), 1), $parameter['isimage'], 'mradio');
showtagheader('tbody', 'imgsetting', $parameter['isimage'] == 1, 'sub');
showsetting('jswizard_images_maxwidth', 'parameter[maxwidth]', isset($parameter['maxwidth']) ? $parameter['maxwidth'] : 200, 'text');
showsetting('jswizard_images_maxheight', 'parameter[maxheight]', isset($parameter['maxheight']) ? $parameter['maxheight'] : 200, 'text');
showtagfooter('tbody');
showsetting('jswizard_images_thread', 'parameter[threadmethod]', $parameter['threadmethod'], 'radio');
showsetting('jswizard_images_digest', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($icheckdigest[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][1]" value="1" '.$icheckdigest[1].'> '.$lang['jswizard_digest_1'].'</li>
<li'.($icheckdigest[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][2]" value="1" '.$icheckdigest[2].'> '.$lang['jswizard_digest_2'].'</li>
<li'.($icheckdigest[3] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][3]" value="1" '.$icheckdigest[3].'> '.$lang['jswizard_digest_3'].'</li>
<li'.($icheckdigest[4] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][4]" value="1" '.$icheckdigest[4].'> '.$lang['jswizard_digest_0'].'</li></ul>'
);
showtagfooter('tbody');
showsetting('jswizard_images_newwindow', 'parameter[newwindow]', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tradionewwindow[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="0" '.$tradionewwindow[0].'> '.$lang['jswizard_newwindow_self'].'</li>
<li'.($tradionewwindow[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="1" '.$tradionewwindow[1].'> '.$lang['jswizard_newwindow_blank'].'</li>
<li'.($tradionewwindow[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="2" '.$tradionewwindow[2].'> '.$lang['jswizard_newwindow_main'].'</li></ul>'
);
showsetting('jswizard_images_orderby', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckorderby['dateline'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="dateline" '.$tcheckorderby['dateline'].'> '.$lang['jswizard_images_orderby_dateline'].'</li>
<li'.($tcheckorderby['downloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="downloads" '.$tcheckorderby['downloads'].'> '.$lang['jswizard_images_orderby_downloads'].'</li>
<li'.($tcheckorderby['hourdownloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="hourdownloads" '.$tcheckorderby['hourdownloads'].'> <input type="text" class="txt" style="width: 50px;" name="parameter[hours]" value="'.$parameter['hours'].'" size="6"> '.$lang['jswizard_images_orderby_hourdownloads'].'</li>
<li'.($tcheckorderby['todaydownloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="todaydownloads" '.$tcheckorderby['todaydownloads'].'> '.$lang['jswizard_images_orderby_todaydownloads'].'</li>
<li'.($tcheckorderby['weekdownloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="weekdownloads" '.$tcheckorderby['weekdownloads'].'> '.$lang['jswizard_images_orderby_weekdownloads'].'</li>
<li'.($tcheckorderby['monthdownloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="monthdownloads" '.$tcheckorderby['monthdownloads'].'> '.$lang['jswizard_images_orderby_monthdownloads'].'</li></ul>'
);
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'module') {
$parameter['module'] = !empty($module) ? $module : $parameter['module'];
$parameter['module'] = str_replace(array('..', '/', '\\'), array('', '', ''), $parameter['module']);
$parameter['module'] = file_exists(DISCUZ_ROOT.'./include/request/'.$parameter['module']) ? $parameter['module'] : '';
include language('request');
if($parameter['module']) {
$requestrun = FALSE;
include_once DISCUZ_ROOT.'./include/request/'.$parameter['module'];
}
if($jssubmit && $function == 'module' && $parameter['module']) {
$settingsenc = rawurlencode(serialize($parameter['settings']));
$jsurl = $jssetting ? $jssetting : "function=$function".
"&module=$parameter[module]".
"&settings=$settingsenc".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '');
if(!$preview) {
jssavesetting(5);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br /><br />'.jspreviewcode($jsurl).'<br />';
}
if(!empty($request_name)) {
echo '<div class="colorbox"><h4>'.$request_name.' '.$request_version.'</h4>'.$request_description.'<div style="width:95%" align="right">'.$request_copyright.'</div></div><br /><br />';
}
if($jspreview) {
echo '<div class="colorbox">';
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
echo '<br /><input type="button" class="btn" onclick="$(\'cpform\').jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="$(\'cpform\').preview.value=0;$(\'cpform\').jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
}
showformheader('jswizard&function=module#'.$lang['jswizard_module']);
jsinsertunit();
showtableheader();
if($parameter['module']) {
if($jskeyempty) {
$jskey = str_replace(' ', '_', $request_name).'_'.random(3);
}
showtitle($lang['jswizard_module']);
echo '<input type="hidden" name="parameter[module]" value="'.$parameter['module'].'">';
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
if(is_array($request_settings)) {
foreach($request_settings as $settingvar => $setting) {
$varname = in_array($setting[2], array('mradio', 'mcheckbox', 'select', 'mselect')) ? array('parameter[settings]['.$settingvar.']', $setting[3]) : 'parameter[settings]['.$settingvar.']';
$value = $parameter['settings'][$settingvar] != '' ? stripslashes($parameter['settings'][$settingvar]) : $setting[4];
showsetting($setting[0].':', $varname, $value, $setting[2], '', 0, $setting[1]);
}
}
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
} else {
$requests = jsgetrequests();
showtips('jswizard_module_tips');
showtableheader('', 'fixpadding');
if($requests) {
showsubtitle(array('name', 'jswizard_module', 'jswizard_module_version', 'copyright', ''));
foreach($requests as $request) {
showtablerow('', '', array(
$request[1].($request['filemtime'] > $timestamp - 86400 ? ' <font color="red">New!</font>' : ''),
$request[0],
$request[2],
$request[3],
"<a href=\"$BASESCRIPT?action=jswizard&type=module&module=$request[0]\">$lang[add]</a>"
));
}
} else {
showtablerow('', '', $lang['jswizard_request_nonexistence']);
}
echo '<input type="hidden" id="parametermodule" name="parameter[module]"><input name="preview" type="hidden" value="1">';
}
showtablefooter();
showformfooter();
} elseif(in_array($type, array('custom', 'side'))) {
if($type == 'side') {
$jskey = substr($jskey, 0, strlen($lang['jswizard_infoside_pre'])) == $lang['jswizard_infoside_pre'] ? $jskey : $lang['jswizard_infoside_pre'].$jskey;
}
if($jssubmit && $function == $type) {
if($function == 'side' && !empty($parameter['selectmodule'])) {
$parameter['jstemplate'] = '';
$splitbar = '';
foreach($parameter['selectmodule'] as $value) {
$parameter['jstemplate'] .= $splitbar.'[module]'.$value.'[/module]';
$splitbar = '<hr class="shadowline"/>';
}
}
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting($type == 'custom' ? -1 : -2);
}
$jspreview = ($type == 'custom' ? $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />' : '').jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview && in_array($type, array('custom', 'side'))) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
$jsmodule = '';$selectarray = $requests = array();
$requests = array();
$query = $db->query("SELECT * FROM {$tablepre}request WHERE type>=0");
while($settings = $db->fetch_array($query)) {
$value = unserialize($settings['value']);
$optionitem = '<option value="'.$settings['variable'].'">'.($value['parameter']['sidestatus'] ? '* ' : '').($value['comment'] != '' ? $value['comment'] : '').'['.$settings['variable'].']'.'</option>';
if($type == 'side' && !empty($parameter['selectmodule'])) {
$key = array_search($settings['variable'], $parameter['selectmodule']);
if($key !== FALSE && $key !== NULL) {
$selectarray[$key] = $optionitem;
} else {
$jsmodule .= $optionitem;
}
} else {
$jsmodule .= $optionitem;
}
}
if($type == 'side' && !empty($selectarray)) {
ksort($selectarray);
$selectmodule = implode($selectarray);
}
showformheader('jswizard&function='.$type.'#'.$lang['jswizard_'.$type]);
if($type == 'custom') {
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_custom').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">';
echo $lang['jswizard_custom_jstemplate_comment'].'</div><select onchange="insertunit(\'[module]\'+this.value+\'[/module]\')"><option>'.$lang['jswizard_custom_jstemplate_current_module'].'</option>'.$jsmodule.'</select><br /><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '').'</textarea>';
} else {
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_side').'</h4><div class="extcredits">';
echo '<tr><td colspan="2">'.$lang['jswizard_sidemodule_comment'].'</div>';
echo '<script type="text/JavaScript">
function moveselect(fromitem, toitem) {
var selectindex = $(fromitem).selectedIndex;
if(selectindex == -1) return;
var itemtext = $(fromitem).options[selectindex].text;
var itemvalue = $(fromitem).value;
$(fromitem).removeChild($(fromitem).options[selectindex]);
var newoption = new Option(itemtext, itemvalue);
$(toitem).options.add(newoption);
}
function orderselect(option) {
var selectindex = $(\'selectmodule\').selectedIndex;
if(selectindex == -1) return;
var itemtext = $(\'selectmodule\').options[selectindex].text;
var itemvalue = $(\'selectmodule\').value;
var itemcount = $(\'selectmodule\').options.length;
if(option == 1 && selectindex == 0 || option == 0 && selectindex == itemcount - 1) return;
if(option == 1) {
if(selectindex == 0) return;var swapindex = selectindex - 1;
} else {
if(selectindex == itemcount - 1) return;var swapindex = selectindex + 1;
}
var tmptext = $(\'selectmodule\').options[swapindex].text;
var tmpvalue = $(\'selectmodule\').options[swapindex].value;
$(\'selectmodule\').options[swapindex].text = $(\'selectmodule\').options[selectindex].text;
$(\'selectmodule\').options[swapindex].value = $(\'selectmodule\').options[selectindex].value;
$(\'selectmodule\').options[selectindex].text = tmptext;
$(\'selectmodule\').options[selectindex].value = tmpvalue;
$(\'selectmodule\').selectedIndex = swapindex;
}
function selectall() {
var itemcount = $(\'selectmodule\').options.length;
for(i = 0;i < itemcount;i++) {
$(\'selectmodule\').options[i].selected = true;
}
}
</script>
<table width="95%" border="0" cellpadding="0" cellspacing="0"><tr><td style="text-align:center;border: 0">
<button class=button onclick="orderselect(1);return false">'.$lang['jswizard_custom_jstemplate_up'].'</button>
<br /><br /><button class=button onclick="orderselect(0);return false">'.$lang['jswizard_custom_jstemplate_down'].'</button>
</td><td width="40%" style="border: 0">
'.$lang['jswizard_custom_jstemplate_selected_module'].'<select ondblclick="moveselect(\'selectmodule\', \'currentmodule\')" id="selectmodule" name="parameter[selectmodule][]" multiple="multiple" size="10" style="width: 100%">'.$selectmodule.'</select>
</td><td style="text-align:center;border: 0">
<button class=button onclick="moveselect(\'currentmodule\', \'selectmodule\');return false">'.$lang['jswizard_custom_jstemplate_select'].'</button>
<br /><br /><button class=button onclick="moveselect(\'selectmodule\', \'currentmodule\');return false">'.$lang['jswizard_custom_jstemplate_remove'].'</button>
</td><td width="40%" style="border: 0">
'.$lang['jswizard_custom_jstemplate_current_module'].'<select ondblclick="moveselect(\'currentmodule\', \'selectmodule\')" id="currentmodule" multiple="multiple" size="10" style="width:100%">'.$jsmodule.'</select>
</td></tr></table>
';
}
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader();
showtitle('jswizard_'.$type);
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife_custom', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
if($type == 'custom') {
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit"'.($type == 'side' ? ' onclick="selectall()"' : '').' value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
}
} elseif($operation == 'import') {
if(!submitcheck('importsubmit')) {
shownav('tools', 'nav_javascript');
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 0),
$infosidemenu,
array('admin', 'jswizard', 0),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
array('jswizard_module', 'jswizard&type=module', 0),
array('import', 'jswizard&operation=import', 1)
));
showformheader('jswizard&operation=import', 'enctype');
showtableheader('jswizard_import');
showimportdata();
showtablerow('', 'class="rowform"', mradio('importrewrite', array(
0 => lang('jswizard_import_default'),
1 => lang('jswizard_import_norewrite'),
2 => lang('jswizard_import_rewrite'),
), 0, FALSE));
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
require_once DISCUZ_ROOT.'./admin/importdata.func.php';
import_request($importrewrite);
cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizard', 'succeed');
}
} elseif($operation == 'copy') {
$requestdata = $db->fetch_first("SELECT * FROM {$tablepre}request WHERE variable='$jssetting'");
$requestdata = daddslashes($requestdata, 1);
$requestdata['variable'] = $requestdata['variable'].'_'.random(3);
$db->query("INSERT INTO {$tablepre}request (variable, value, `type`) VALUES ('$requestdata[variable]', '$requestdata[value]', '$requestdata[type]')");
cpmsg('jswizard_copy_succeed', $BASESCRIPT.'?action=jswizard', 'succeed');
} elseif($operation == 'infoside') {
if(submitcheck('globalsubmit')) {
$infosidestatus['allow'] = $infosidestatusnew['allow'];
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".addslashes(serialize($infosidestatus))."')");
updatecache('settings');
} elseif(submitcheck('submit')) {
if($infosidenew == -1) {
$sidekey = $infosidenew = $newproject ? $lang['jswizard_infoside_pre'].$newproject : '';
}
if($infosidenew) {
$modulearray = array();
$displayorder = 0;
if($availablenew) {
foreach($availablenew as $key) {
if(!$modulearray[$displayordernew[$key]]) {
$modulearray[$displayordernew[$key]] = $key;
} else {
$modulearray[] = $key;
}
}
}
ksort($modulearray);
$sidedata = unserialize($db->result_first("SELECT value FROM {$tablepre}request WHERE variable='$sidekey'"));
$parameter = array(
'selectmodule' => $modulearray,
'cachelife' => intval($cachelifenew),
'jstemplate' => $modulearray ? '[module]'.implode('[/module]<hr class="shadowline"/>[module]', $modulearray).'[/module]' : ''
);
$jsurl = 'function=side&jscharset='.($cachelifenew != '' ? "&cachelife=$cachelifenew" : '').(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
$comment = $sidedata['comment'];
$infosidestatus[$sideid] = $jskey = $sidekey;
$edit = $sidedata ? $jskey : '';
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".addslashes(serialize($infosidestatus))."')");
updatecache('settings');
jssavesetting(-2);
} else {
$infosidestatus[$sideid] = '';
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".addslashes(serialize($infosidestatus))."')");
updatecache('settings');
cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizard&operation=infoside&sideid='.$sideid.'&from='.$from, 'succeed');
}
}
if($from == 'style') {
shownav('style', 'settings_styles');
showsubmenu('settings_styles', array(
array('settings_styles_global', 'settings&operation=styles&anchor=global', 0),
array('settings_styles_index', 'settings&operation=styles&anchor=index', 0),
array('settings_styles_forumdisplay', 'settings&operation=styles&anchor=forumdisplay', 0),
array('settings_styles_viewthread', 'settings&operation=styles&anchor=viewthread', 0),
array('settings_styles_member', 'settings&operation=styles&anchor=member', 0),
array('settings_styles_customnav', 'misc&operation=customnav', 0),
$infosidemenu,
array('settings_styles_refresh', 'settings&operation=styles&anchor=refresh', 0),
array('settings_styles_sitemessage', 'settings&operation=styles&anchor=sitemessage', 0)
));
} else {
shownav('tools', 'nav_javascript');
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 0),
$infosidemenu,
array('admin', 'jswizard'.($keyp ? '&openkeypre='.$keypre : ''), 0),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
array('jswizard_module', 'jswizard&type=module', 0),
array('import', 'jswizard&operation=import', 0),
));
}
if(!isset($sideid)) {
showformheader('jswizard&operation=infoside&from='.$from);
showtableheader('jswizard_infoside');
showsetting('jswizard_infoside_allow', 'infosidestatusnew[allow]', $infosidestatus['allow'], 'radio');
showsubmit('globalsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$query = $db->query("SELECT type, variable FROM {$tablepre}request");
$modules = array();
$sides[] = array('', lang('jswizard_infoside_off'));
while($request = $db->fetch_array($query)) {
if($request['type'] == -2) {
$v = substr($request['variable'], 0, strlen($lang['jswizard_infoside_pre'])) == $lang['jswizard_infoside_pre'] ? substr($request['variable'], strlen($lang['jswizard_infoside_pre'])) : $request['variable'];
$sides[] = array(rawurlencode($request['variable']), $v);
} elseif($request['type'] >= 0) {
$modules[$request['variable']] = $request;
}
}
$sides[] = array('-1', lang('jswizard_infoside_newproject'));
$sidekey = empty($sidekey) ? addslashes($infosidestatus[$sideid]) : $sidekey;
if($sidekey) {
$sidedata = unserialize($db->result_first("SELECT value FROM {$tablepre}request WHERE variable='$sidekey'"));
$selectmodules = $sidedata['parameter']['selectmodule'];
@ksort($selectmodules);
}
showformheader('jswizard&operation=infoside&sideid='.$sideid.'&sidekey='.rawurlencode($sidekey).'&from='.$from);
showtableheader(lang('jswizard_infoside').' - '.lang('jswizard_infoside_'.$sideid), 'nobottom');
showsetting('jswizard_infoside_project', array('infosidenew', $sides), rawurlencode($sidekey), 'select', '', 0, '', "onchange=\"if(this.value && this.value != -1) {window.location='$BASESCRIPT?action=jswizard&operation=infoside&sideid=$sideid&from=$from&sidekey='+this.value} else if(this.value == -1) {\$('newproject').style.display = '';} else {\$('newproject').style.display = 'none';}if(this.value) {\$('modulelist').style.display = '';} else {\$('modulelist').style.display = 'none';}\"");
showtagheader('tbody', 'newproject', 0, 'sub');
showsetting('jswizard_infoside_newprojectname', 'newproject', '', 'text');
showtagfooter('tbody');
showsetting('jswizard_infoside_cachelife', 'cachelifenew', $sidedata['parameter']['cachelife'] != '' ? intval($sidedata['parameter']['cachelife']) : '', 'text');
showtablefooter();
showtableheader('', 'fixpadding', 'id="modulelist"'.(empty($sidekey) ? ' style="display:none"': ''));
showsubtitle(array('jswizard_key', 'available', 'display_order', 'type', ''));
if($selectmodules) {
foreach($selectmodules as $displayorder => $selectmodule) {
$module = $modules[$selectmodule];
$key = htmlspecialchars($module['variable']);
showtablerow('', array('', '', 'class="td28 td24"'), array(
$module['variable'],
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[]\" value=\"$key\" checked=\"checked\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$key]\" value=\"$displayorder\">",
$lang['jswizard_'.$jstypes[$module['type']]],
'<a href="'.$BASESCRIPT.'?action=jswizard&function='.$jstypes[$module['type']].'&jssetting='.rawurlencode($module['variable']).'">'.lang('edit').'</a>'
));
unset($modules[$selectmodule]);
}
}
foreach($modules as $module) {
$key = htmlspecialchars($module['variable']);
showtablerow('', array('', '', 'class="td28 td24"'), array(
$module['variable'],
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[]\" value=\"$key\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$key]\" value=\"$module[displayorder]\">",
$lang['jswizard_'.$jstypes[$module['type']]],
'<a href="'.$BASESCRIPT.'?action=jswizard&function='.$jstypes[$module['type']].'&jssetting='.rawurlencode($module['variable']).'">'.lang('edit').'</a>'
));
}
showtablefooter();
showtableheader('', 'notop');
showsubmit('submit', 'submit', '', '<a href="'.$BASESCRIPT.'?action=jswizard">'.lang('jswizard_infoside_addcomment').'</a>');
showtablefooter();
showformfooter();
}
} elseif($operation == 'config') {
if(!submitcheck('settingsubmit')) {
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 1),
$infosidemenu,
array('admin', 'jswizard', 0),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
array('jswizard_module', 'jswizard&type=module', 0),
array('import', 'jswizard&operation=import', 0),
));
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable IN ('jsstatus', 'jsdateformat', 'jsrefdomains', 'infosidestatus', 'jscachelife')");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
showformheader('jswizard&operation=config', '', 'settings');
showhiddenfields(array('operation' => $operation));
$settings['jsdateformat'] = dateformat($settings['jsdateformat']);
showtableheader();
showsetting('jswizard_config_jsstatus', 'settingsnew[jsstatus]', $settings['jsstatus'], 'radio', '', 1);
showsetting('jswizard_config_jsdateformat', 'settingsnew[jsdateformat]', $settings['jsdateformat'], 'text');
showsetting('jswizard_config_jsrefdomains', 'settingsnew[jsrefdomains]', $settings['jsrefdomains'], 'textarea');
showtagfooter('tbody');
showsetting('jswizard_config_jscachelife', 'settingsnew[jscachelife]', $settings['jscachelife'], 'text');
showtablerow('', 'colspan="2"', '<input type="submit" class="btn" name="settingsubmit" value="'.lang('submit').'" />');
showtablefooter();
showformfooter();
} else {
foreach($settingsnew as $key => $val) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$key', '$val')");
}
updatecache('settings');
cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizard&operation=config', 'succeed');
}
}
function jsforumselect($function) {
global $parameter, $lang, $db, $tablepre;
if(empty($function) || in_array($function, array('forums', 'threads', 'images'))) {
$forumselect = '<select name="parameter['.$function.'_forums][]" size="10" multiple="multiple">'.
'<option value="all" '.(is_array($parameter[$function.'_forums']) && in_array('all', $parameter[$function.'_forums']) ? 'selected="selected"' : '').'> '.$lang['jswizard_all_forums'].'</option>'.
'<option value=""> </option>';
if($function == 'forums') {
$query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE type='group' AND status='1' ORDER BY displayorder");
while($category = $db->fetch_array($query)) {
$forumselect .= '<option value="'.$category['fid'].'">'.strip_tags($category['name']).'</option>';
};
} else {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect .= forumselect(FALSE, 0, 0, TRUE);
}
$forumselect .= '</select>';
if(is_array($parameter[$function.'_forums'])) {
foreach($parameter[$function.'_forums'] as $key => $value) {
if(!$value) {
unset($parameter[$function.'_forums'][$key]);
}
}
if(!in_array('all', $parameter[$function.'_forums'])) {
$forumselect = preg_replace("/(\<option value=\"(".implode('|', $parameter[$function.'_forums']).")\")(\>)/", "\\1 selected=\"selected\"\\3", $forumselect);
}
}
return $forumselect;
}
}
function jspreviewcode($jsurlview) {
global $BASESCRIPT;
return '<div class="jswizard"><iframe id="preview" name="preview" frameborder="0" allowtransparency="true" onload="this.style.height = this.contentWindow.document.body.scrollHeight + \'px\'" width="95%" height="0"></iframe></div>
<form id="previewform" action="'.$BASESCRIPT.'?action=jswizard&previewurl=yes" method="post" target="preview"><input name="jsurl" type="hidden" value="'.htmlspecialchars($jsurlview).'" /></form>
<script type="text/javascript">$(\'previewform\').submit()</script>';
}
function jsfids($fidarray) {
foreach($fidarray as $key => $val) {
if(empty($val)) {
unset($fidarray[$key]);
}
}
return implode('_', $fidarray);
}
function jssavesetting($type) {
global $operation, $db, $tablepre, $jswizard, $jsurl, $parameter, $comment, $jskey, $edit, $BASESCRIPT, $sideid, $from;
$editadd = $edit ? "AND variable!='$edit'" : '';
if($db->result_first("SELECT variable FROM {$tablepre}request WHERE variable='$jskey' $editadd")) {
cpmsg('jswizard_jskey_exists', '', 'error');
}
$jskey = str_replace('&', '', $jskey);
$jswizard = addslashes(serialize(array('url' => $jsurl, 'parameter' => $parameter, 'comment' => $comment)));
if(strlen($jswizard) > 65535) {
cpmsg('jswizard_overflow', '', 'error');
}
if($edit) {
$db->query("UPDATE {$tablepre}request SET variable='$jskey', value='$jswizard' WHERE variable='$edit'");
} else {
$db->query("INSERT INTO {$tablepre}request (variable, value, `type`) VALUES ('$jskey', '$jswizard', '$type')");
}
updatecache('request');
list($keypre, $keyp) = explode('_', $jskey);
$msg = $type != -2 ? 'jswizard_succeed' : 'jswizard_infoside_succeed';
if($operation == 'infoside') {
cpmsg($msg, $BASESCRIPT.'?action=jswizard&operation=infoside&sideid='.$sideid.'&from='.$from, 'succeed');
} else {
cpmsg($msg, $BASESCRIPT.'?action=jswizard'.($keyp ? '&openkeypre='.$keypre : ''), 'succeed');
}
}
function jsinsertunit() {
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, obj) {
if(!obj) {
obj = 'jstemplate';
}
$(obj).focus();
if(!isUndefined($(obj).selectionStart)) {
var opn = $(obj).selectionStart + 0;
$(obj).value = $(obj).value.substr(0, $(obj).selectionStart) + text + $(obj).value.substr($(obj).selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$(obj).value += text;
}
}
</script>
<?
}
function jsgetrequests() {
global $requestlang;
$dir = DISCUZ_ROOT.'./include/request';
$requestdir = dir($dir);
$requests = array();
$requestrun = 0;
while($entry = $requestdir->read()) {
if(!in_array($entry, array('.', '..')) && preg_match("/^[\w\.]+$/", $entry) && substr($entry, -8) == '.inc.php' && strlen($entry) < 30 && is_file($dir.'/'.$entry)) {
include $dir.'/'.$entry;
$requests[$entry] = array($entry, $request_name, $request_version, $request_copyright, 'filemtime' => @filemtime($dir.'/'.$entry));
}
}
uasort($requests, 'filemtimesort');
return $requests;
}
function dateformat($string, $operation = 'formalise') {
$string = htmlspecialchars(trim($string));
$replace = $operation == 'formalise' ? array(array('n', 'j', 'y', 'Y'), array('mm', 'dd', 'yy', 'yyyy')) : array(array('mm', 'dd', 'yyyy', 'yy'), array('n', 'j', 'Y', 'y'));
return str_replace($replace[0], $replace[1], $string);
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/admin/jswizard.inc.php | PHP | asf20 | 78,852 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: viewthread.php 21339 2010-01-06 08:25:41Z zhaoxiongfei $
*/
if(!defined('CURSCRIPT')) {
define('CURSCRIPT', 'viewthread');
}
define('SQL_ADD_THREAD', ' t.dateline, t.special, t.lastpost AS lastthreadpost, ');
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/forum.func.php';
$page = max($page, 1);
if($cachethreadlife && $forum['threadcaches'] && !$discuz_uid && $page == 1 && !$forum['special']) {
viewthread_loadcache();
}
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$discuz_action = 3;
$sdb = loadmultiserver('viewthread');
$thread = $sdb->fetch_first("SELECT * FROM {$tablepre}threads t WHERE tid='$tid'".($auditstatuson ? '' : " AND displayorder>='0'"));
if(!$thread) {
header("HTTP/1.0 404 Not Found");
showmessage('thread_nonexistence');
}
$oldtopics = isset($_DCOOKIE['oldtopics']) ? $_DCOOKIE['oldtopics'] : 'D';
if(strpos($oldtopics, 'D'.$tid.'D') === FALSE) {
$oldtopics = 'D'.$tid.$oldtopics;
if(strlen($oldtopics) > 3072) {
$oldtopics = preg_replace("((D\d+)+D).*$", "\\1", substr($oldtopics, 0, 3072));
}
dsetcookie('oldtopics', $oldtopics, 3600);
}
if($lastvisit < $thread['lastpost'] && (!isset($_DCOOKIE['fid'.$fid]) || $thread['lastpost'] > $_DCOOKIE['fid'.$fid])) {
dsetcookie('fid'.$fid, $thread['lastpost'], 3600);
}
$thisgid = 0;
$thread['subjectenc'] = rawurlencode($thread['subject']);
$fromuid = $creditspolicy['promotion_visit'] && $discuz_uid ? '&fromuid='.$discuz_uid : '';
$feeduid = $thread['authorid'] ? $thread['authorid'] : 0;
$feedpostnum = $thread['replies'] > $ppp ? $ppp : ($thread['replies'] ? $thread['replies'] : 1);
$threadshare = $thread['subject'] ? addslashes($thread['subject']) : '';
$upnavlink = 'forumdisplay.php?fid='.$fid.($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '');
$navigation = ' » <a href="'.$upnavlink.'">'.(strip_tags($forum['name']) ? strip_tags($forum['name']) : $forum['name']).'</a> » '.$thread['subject'];
$navtitle = $thread['subject'].' - '.strip_tags($forum['name']);
if($forum['type'] == 'sub') {
$fup = $sdb->fetch_first("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$navigation = '» <a href="forumdisplay.php?fid='.$fup['fid'].'">'.(strip_tags($fup['name']) ? strip_tags($fup['name']) : $fup['name']).'</a> '.$navigation;
$navtitle = $navtitle.' - '.strip_tags($fup['name']);
}
$navtitle .= ' - ';
$forum['typemodels'] = $forum['typemodels'] ? unserialize($forum['typemodels']) : array();
$threadsort = isset($forum['threadsorts']['types'][$thread['sortid']]) ? 1 : 0;
$typetemplate = $tagscript = '';
$optiondata = $optionlist = $skipaids = $skipaidlist = array();
if($thread['sortid'] && $threadsort) {
if($forum['threadsorts']['types'][$thread['sortid']]) {
if(@include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$thread['sortid'].'.php') {
$query = $sdb->query("SELECT optionid, value FROM {$tablepre}typeoptionvars WHERE tid='$tid'");
while($option = $sdb->fetch_array($query)) {
$optiondata[$option['optionid']] = $option['value'];
}
$searchtitle = $searchvalue = $searchunit = array();
foreach($_DTYPE as $optionid => $option) {
$optionlist[$option['identifier']]['title'] = $_DTYPE[$optionid]['title'];
$optionlist[$option['identifier']]['unit'] = $_DTYPE[$optionid]['unit'];
if($_DTYPE[$optionid]['type'] == 'checkbox') {
$optionlist[$option['identifier']]['value'] = '';
foreach(explode("\t", $optiondata[$optionid]) as $choiceid) {
$optionlist[$option['identifier']]['value'] .= $_DTYPE[$optionid]['choices'][$choiceid].' ';
}
} elseif(in_array($_DTYPE[$optionid]['type'], array('radio', 'select'))) {
$optionlist[$option['identifier']]['value'] = $_DTYPE[$optionid]['choices'][$optiondata[$optionid]];
} elseif($_DTYPE[$optionid]['type'] == 'image') {
$maxwidth = $_DTYPE[$optionid]['maxwidth'] ? 'width="'.$_DTYPE[$optionid]['maxwidth'].'"' : '';
$maxheight = $_DTYPE[$optionid]['maxheight'] ? 'height="'.$_DTYPE[$optionid]['maxheight'].'"' : '';
if(preg_match("/^\[aid=(\d+)\]$/", $optiondata[$optionid], $r)) {
$skipaids[] = $r[1];
$optiondata[$optionid] = 'attachment.php?aid='.aidencode($r[1]);
}
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\"><img src=\"$optiondata[$optionid]\" onload=\"thumbImg(this)\" $maxwidth $maxheight border=\"0\"></a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'url') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\">$optiondata[$optionid]</a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'textarea') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? nl2br($optiondata[$optionid]) : '';
} else {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid];
}
}
if($_DTYPETEMPLATE) {
foreach($_DTYPE as $option) {
$searchtitle[] = '/{('.$option['identifier'].')}/e';
$searchvalue[] = '/\[('.$option['identifier'].')value\]/e';
$searchunit[] = '/\[('.$option['identifier'].')unit\]/e';
}
$typetemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $_DTYPETEMPLATE);
$typetemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $typetemplate);
$typetemplate = preg_replace($searchunit, "showoption('\\1', 'unit')", $typetemplate);
}
}
}
}
$thread['subject'] = ($forum['threadsorts']['types'][$thread['sortid']] ? ($forum['threadsorts']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=sort&sortid='.$thread['sortid'].'">['.$forum['threadsorts']['types'][$thread['sortid']].']</a>' : '['.$forum['threadsorts']['types'][$thread['sortid']].']').' ' : '').
($forum['threadtypes']['types'][$thread['typeid']] ? ($forum['threadtypes']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=type&typeid='.$thread['typeid'].'">['.$forum['threadtypes']['types'][$thread['typeid']].']</a>' : '['.$forum['threadtypes']['types'][$thread['typeid']].']').' ' : '').
$thread['subject'];
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
$navtitle = '';
showmessagenoperm('viewperm', $fid);
}
} elseif($forum['allowview'] == -1) {
$navtitle = '';
showmessage('forum_access_view_disallow');
}
if($forum['formulaperm'] && $adminid != 1) {
formulaperm($forum['formulaperm']);
}
if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
dheader("Location: {$boardurl}forumdisplay.php?fid=$fid&sid=$sid");
}
if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
showmessage('thread_nopermission', NULL, 'NOPERM');
}
$usemagic = array();
if($magicstatus) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_magics.php';
foreach($_DCACHE['magics'] as $id => $magic) {
if($magic['available'] == 1) {
if($magic['type'] == 1) {
$usemagic['thread'][$id]['name'] = $magic['name'];
} elseif($magic['type'] == 2) {
$usemagic['user'][$id]['name'] = $magic['name'];
$usemagic['user'][$id]['pic'] = strtolower($magic['identifier']).'_s.gif';
}
}
}
}
$hiddenreplies = getstatus($thread['status'], 2);
$rushreply = getstatus($thread['status'], 3);
$savepostposition = getstatus($thread['status'], 1);
$threadpay = FALSE;
if($thread['price'] > 0 && $thread['special'] == 0) {
if($maxchargespan && $timestamp - $thread['dateline'] >= $maxchargespan * 3600) {
$db->query("UPDATE {$tablepre}threads SET price='0' WHERE tid='$tid'");
$thread['price'] = 0;
} else {
$exemptvalue = $forum['ismoderator'] ? 128 : 16;
if(!($exempt & $exemptvalue) && $thread['authorid'] != $discuz_uid) {
$query = $sdb->query("SELECT tid FROM {$tablepre}paymentlog WHERE tid='$tid' AND uid='$discuz_uid'");
if(!$sdb->num_rows($query)) {
require_once DISCUZ_ROOT.'./include/threadpay.inc.php';
$threadpay = TRUE;
}
}
}
}
$raterange = $modratelimit && $adminid == 3 && !$forum['ismoderator'] ? array() : $raterange;
$extra = rawurlencode($extra);
$allowgetattach = !empty($forum['allowgetattach']) || ($allowgetattach && !$forum['getattachperm']) || forumperm($forum['getattachperm']);
$attachcredits = '';
$getattachcredits = $forum['getattachcredits'] ? $forum['getattachcredits'] : $creditspolicy['getattach'];
if($getattachcredits) {
$exemptvalue = $ismoderator ? 32 : 4;
if(!($exempt & $exemptvalue)) {
foreach($getattachcredits as $creditid => $v) {
if($v) {
$attachcredits .= $extcredits[$creditid]['title'].' '.$v.' '.$extcredits[$creditid]['unit'].' ';
}
}
}
}
$seccodecheck = ($seccodestatus & 4) && (!$seccodedata['minposts'] || $posts < $seccodedata['minposts']);
$secqaacheck = $secqaa['status'][2] && (!$secqaa['minposts'] || $posts < $secqaa['minposts']);
$postlist = $attachtags = $attachlist = $threadstamp = array();
$aimgcount = 0;
$attachpids = -1;
if(empty($action) && $tid) {
$thisgid = $forum['type'] == 'forum' ? $forum['fup'] : $_DCACHE['forums'][$forum['fup']]['fup'];
$lastmod = $thread['moderated'] ? viewthread_lastmod() : array();
if(!$threadstamp && getstatus($thread['status'], 5)) {
$query = $db->query("SELECT action, stamp FROM {$tablepre}threadsmod WHERE tid='$tid' ORDER BY dateline DESC");
while($stamp = $db->fetch_array($query)) {
if($stamp['action'] == 'SPA') {
$threadstamp = $_DCACHE['stamps'][$stamp['stamp']];
break;
} elseif($stamp['action'] == 'SPD') {
break;
}
}
}
$showsettings = str_pad(decbin($showsettings), 3, '0', STR_PAD_LEFT);
$customshow = $discuz_uid ? str_pad(base_convert($customshow, 10, 3), 4, '0', STR_PAD_LEFT) : '2222';
$disableddateconvert = $customshow{0};
$showsignatures = $customshow{1} == 2 ? $showsettings{0} : $customshow{1};
$showavatars = $customshow{2} == 2 ? $showsettings{1} : $customshow{2};
$showimages = $customshow{3} == 2 ? $showsettings{2} : $customshow{3};
$highlightstatus = isset($highlight) && str_replace('+', '', $highlight) ? 1 : 0;
$usesigcheck = $discuz_uid && $sigstatus ? 1 : 0;
$allowpostreply = ($forum['allowreply'] != -1) && ((!$thread['closed'] && !checkautoclose()) || $forum['ismoderator']) && ((!$forum['replyperm'] && $allowreply) || ($forum['replyperm'] && forumperm($forum['replyperm'])) || $forum['allowreply']);
$allowpost = $forum['allowpost'] != -1 && ((!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])) || $forum['allowpost']);
$addfeedcheck = $customaddfeed & 4 ? 1 : 0;
if($allowpost) {
$allowpostpoll = $allowpostpoll && ($forum['allowpostspecial'] & 1);
$allowposttrade = $allowposttrade && ($forum['allowpostspecial'] & 2);
$allowpostreward = $allowpostreward && ($forum['allowpostspecial'] & 4) && isset($extcredits[$creditstrans]);
$allowpostactivity = $allowpostactivity && ($forum['allowpostspecial'] & 8);
$allowpostdebate = $allowpostdebate && ($forum['allowpostspecial'] & 16);
} else {
$allowpostpoll = $allowposttrade = $allowpostreward = $allowpostactivity = $allowpostdebate = FALSE;
}
$forum['threadplugin'] = $allowpost && $threadplugins ? unserialize($forum['threadplugin']) : array();
$visitedforums = $visitedforums ? visitedforums() : '';
$forummenu = '';
if($forumjump) {
$forummenu = forumselect(FALSE, 1);
}
$relatedthreadlist = array();
$relatedthreadupdate = $tagupdate = FALSE;
$relatedkeywords = $tradekeywords = $metakeywords = $firstpid = '';
$randnum = $qihoo['relate']['webnum'] ? rand(1, 1000) : '';
$statsdata = !empty($statsdata) ? dhtmlspecialchars($statsdata) : '';
if($qihoo['relate']['bbsnum']) {
$site = site();
$query = $db->query("SELECT type, expiration, keywords, relatedthreads FROM {$tablepre}relatedthreads WHERE tid='$tid'");
if($db->num_rows($query)) {
while($related = $db->fetch_array($query)) {
if($related['expiration'] <= $timestamp) {
$relatedthreadupdate = TRUE;
$qihoo_up = 1;
} elseif($qihoo['relate']['bbsnum'] && $related['type'] == 'general') {
$relatedthreadlist = unserialize($related['relatedthreads']);
if($related['keywords']) {
$keywords = str_replace("\t", ' ', $related['keywords']);
$searchkeywords = rawurlencode($keywords);
$statskeywords = urlencode($keywords);
$statsurl = urlencode($boardurl.'viewthread.php?tid='.$tid);
$prefix = '';
foreach(explode("\t", $related['keywords']) as $keyword) {
$relatedkeywords .= $keyword ? $prefix.'<a href="http://www.qihoo.com/wenda.php?kw='.rawurlencode($keyword).'&do=search&noq=q" target="_blank">'.$keyword.'</a>' : '';
$prefix = ', ';
$metakeywords .= $keyword ? $keyword.',' : '';
}
}
} elseif($related['type'] == 'trade') {
$tradekeywords = explode("\t", $related['keywords']);
$tradekeywords = $tradekeywords[array_rand($tradekeywords)];
}
}
} else {
$relatedthreadupdate = TRUE;
$qihoo_up = 0;
}
$relatedthreadupdate && $verifykey = md5($authkey.$tid.$thread['subjectenc'].$charset.$site);
}
$relatedthreads = array();
if(!empty($relatedthreadlist)) {
if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'relatedthreads') === FALSE) {
$relatedthreads['img'] = 'collapsed_no.gif';
$relatedthreads['style'] = '';
} else {
$relatedthreads['img'] = 'collapsed_yes.gif';
$relatedthreads['style'] = 'display: none';
}
}
if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'modarea_c') === FALSE) {
$collapseimg['modarea_c'] = 'collapsed_no';
$collapse['modarea_c'] = '';
} else {
$collapseimg['modarea_c'] = 'collapsed_yes';
$collapse['modarea_c'] = 'display: none';
}
$threadtag = array();
$tagstatus = $tagstatus && $forum['allowtag'] ? ($tagstatus == 2 ? 2 : $forum['allowtag']) : 0;
if($tagstatus) {
$query = $sdb->query("SELECT tagname FROM {$tablepre}threadtags WHERE tid='$tid'");
$thread['tags'] = $prefix = '';
while($tags = $sdb->fetch_array($query)) {
$metakeywords .= $tags['tagname'].',';
$thread['tags'] .= $prefix.'<a href="tag.php?name='.rawurlencode($tags['tagname']).'" target="_blank">'.$tags['tagname'].'</a>';
$prefix = ', ';
}
if($tagstatus == 2 && !$thread['tags'] || $relatedthreadupdate) {
$tagupdate = TRUE;
}
$relatedthreadupdate && $thread['tagsenc'] = rawurlencode(strip_tags($thread['tags']));
}
viewthread_updateviews();
@extract($_DCACHE['custominfo']);
$infosidestatus['posts'] = $infosidestatus[1] && isset($infosidestatus['f'.$fid]['posts']) ? $infosidestatus['f'.$fid]['posts'] : $infosidestatus['posts'];
$infoside = $infosidestatus[1] && $thread['replies'] > $infosidestatus['posts'];
$specialadd1 = $specialadd2 = $specialextra = '';
if($thread['special'] == 2) {
$specialadd1 = "LEFT JOIN {$tablepre}trades tr ON p.pid=tr.pid";
$specialadd2 = "AND tr.tid IS null";
} elseif($thread['special'] == 5) {
if(isset($stand) && $stand >= 0 && $stand < 3) {
$specialadd1 .= "LEFT JOIN {$tablepre}debateposts dp ON p.pid=dp.pid";
if($stand) {
$specialadd2 .= "AND (dp.stand='$stand' OR p.first='1')";
} else {
$specialadd2 .= "AND (dp.stand='0' OR dp.stand IS NULL OR p.first='1')";
}
$specialextra = "&stand=$stand";
} else {
$specialadd1 = "LEFT JOIN {$tablepre}debateposts dp ON p.pid=dp.pid";
}
$fieldsadd .= ", dp.stand, dp.voters";
}
$onlyauthoradd = $threadplughtml = '';
if(empty($viewpid)) {
$ordertype = !isset($_GET['ordertype']) && getstatus($thread['status'], 4) ? 1 : intval($ordertype);
$authorid = intval($authorid);
if($authorid) {
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' AND authorid='$authorid'") - 1;
if($thread['replies'] < 0) {
showmessage('undefined_action');
}
$onlyauthoradd = "AND p.authorid='$authorid'";
} elseif($thread['special'] == 5) {
if(isset($stand) && $stand >= 0 && $stand < 3) {
if($stand) {
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}debateposts WHERE tid='$tid' AND stand='$stand'");
} else {
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}posts p LEFT JOIN {$tablepre}debateposts dp ON p.pid=dp.pid WHERE p.tid='$tid' AND (dp.stand='0' OR dp.stand IS NULL)");
}
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}debateposts WHERE tid='$tid' AND stand='$stand'");
} else {
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0'") - 1;
}
} elseif($thread['special'] == 2) {
$tradenum = $db->result_first("SELECT count(*) FROM {$tablepre}trades WHERE tid='$tid'");
$thread['replies'] -= $tradenum;
}
$ppp = $forum['threadcaches'] && !$discuz_uid ? $_DCACHE['settings']['postperpage'] : $ppp;
$totalpage = ceil(($thread['replies'] + 1) / $ppp);
$page > $totalpage && $page = $totalpage;
$pagebydesc = $page > 50 && $page > ($totalpage / 2) ? TRUE : FALSE;
if($pagebydesc) {
$firstpagesize = ($thread['replies'] + 1) % $ppp;
$ppp3 = $ppp2 = $page == $totalpage && $firstpagesize ? $firstpagesize : $ppp;
$realpage = $totalpage - $page + 1;
$start_limit = max(0, ($realpage - 2) * $ppp + $firstpagesize);
$numpost = ($page - 1) * $ppp;
if($ordertype != 1) {
$pageadd = "ORDER BY dateline DESC LIMIT $start_limit, $ppp2";
} else {
$numpost = $thread['replies'] + 2 - $numpost + ($page > 1 ? 1 : 0);
$pageadd = "ORDER BY first ASC,dateline ASC LIMIT $start_limit, $ppp2";
}
} else {
$start_limit = $numpost = ($page - 1) * $ppp;
if($start_limit > $thread['replies']) {
$start_limit = $numpost = 0;
$page = 1;
}
if($ordertype != 1) {
$pageadd = "ORDER BY dateline LIMIT $start_limit, $ppp";
} else {
$numpost = $thread['replies'] + 2 - $numpost + ($page > 1 ? 1 : 0);
$pageadd = "ORDER BY first DESC,dateline DESC LIMIT $start_limit, $ppp";
}
}
$multipage = multi($thread['replies'] + 1, $ppp, $page, "viewthread.php?tid=$tid&extra=$extra".($ordertype && $ordertype != getstatus($thread['status'], 4) ? "&ordertype=$ordertype" : '').(isset($highlight) ? "&highlight=".rawurlencode($highlight) : '').(!empty($authorid) ? "&authorid=$authorid" : '').$specialextra);
} else {
$viewpid = intval($viewpid);
$pageadd = "AND p.pid='$viewpid'";
}
$newpostanchor = $postcount = $ratelogpids = 0;
$onlineauthors = array();
$query = "SELECT p.*, m.uid, m.username, m.groupid, m.adminid, m.regdate, m.lastactivity, m.posts, m.threads, m.digestposts, m.oltime,
m.pageviews, m.credits, m.extcredits1, m.extcredits2, m.extcredits3, m.extcredits4, m.extcredits5, m.extcredits6,
m.extcredits7, m.extcredits8, m.email, m.gender, m.showemail, m.invisible, mf.nickname, mf.site,
mf.icq, mf.qq, mf.yahoo, mf.msn, mf.taobao, mf.alipay, mf.location, mf.medals,
mf.sightml AS signature, mf.customstatus, mf.spacename $fieldsadd
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}members m ON m.uid=p.authorid
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
$specialadd1 ";
$cachepids = $positionlist = array();
if($savepostposition && empty($onlyauthoradd) && empty($specialadd2) && empty($viewpid) && $ordertype != 1) {
$start = ($page - 1) * $ppp + 1;
$end = $start + $ppp;
$q2 = $db->query("SELECT pid, position FROM {$tablepre}postposition WHERE tid='$tid' AND position>='$start' AND position < $end ORDER BY position");
while ($post = $db->fetch_array($q2)) {
$cachepids[] = $post['pid'];
$positionlist[$post['pid']] = $post['position'];
}
$cachepids = implodeids($cachepids);
$pagebydesc = false;
}
$query .= $savepostposition && $cachepids ? "WHERE p.pid in($cachepids) ORDER BY pid ".($ordertype !=1 ? 'DESC' : 'ASC') : ("WHERE p.tid='$tid'".($auditstatuson ? '' : " AND p.invisible='0'")." $specialadd2 $onlyauthoradd $pageadd");
/*
"WHERE p.tid='$tid'".($auditstatuson ? '' : " AND p.invisible='0'")." $specialadd2 $onlyauthoradd $pageadd");
$query = $sdb->query("SELECT p.*, m.uid, m.username, m.groupid, m.adminid, m.regdate, m.lastactivity, m.posts, m.threads, m.digestposts, m.oltime,
m.pageviews, m.credits, m.extcredits1, m.extcredits2, m.extcredits3, m.extcredits4, m.extcredits5, m.extcredits6,
m.extcredits7, m.extcredits8, m.email, m.gender, m.showemail, m.invisible, mf.nickname, mf.site,
mf.icq, mf.qq, mf.yahoo, mf.msn, mf.taobao, mf.alipay, mf.location, mf.medals,
mf.sightml AS signature, mf.customstatus, mf.spacename $fieldsadd
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}members m ON m.uid=p.authorid
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
$specialadd1
WHERE p.tid='$tid'".($auditstatuson ? '' : " AND p.invisible='0'")." $specialadd2 $onlyauthoradd $pageadd");
*/
$query = $sdb->query($query);
while($post = $sdb->fetch_array($query)) {
if(($onlyauthoradd && $post['anonymous'] == 0) || !$onlyauthoradd) {
$postlist[$post['pid']] = viewthread_procpost($post);
}
}
if($savepostposition && $positionlist) {
foreach ($positionlist as $pid => $position)
$postlist[$pid]['number'] = $position;
}
if($thread['special'] > 0 && (empty($viewpid) || $viewpid == $firstpid)) {
$thread['starttime'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
$thread['remaintime'] = '';
switch($thread['special']) {
case 1: include_once DISCUZ_ROOT.'./include/viewthread_poll.inc.php'; break;
case 2: include_once DISCUZ_ROOT.'./include/viewthread_trade.inc.php'; break;
case 3: include_once DISCUZ_ROOT.'./include/viewthread_reward.inc.php'; break;
case 4: include_once DISCUZ_ROOT.'./include/viewthread_activity.inc.php'; break;
case 5: include_once DISCUZ_ROOT.'./include/viewthread_debate.inc.php'; break;
case 127:
$sppos = strrpos($postlist[$firstpid]['message'], chr(0).chr(0).chr(0));
$specialextra = substr($postlist[$firstpid]['message'], $sppos + 3);
if($specialextra) {
if(array_key_exists($specialextra, $threadplugins)) {
@include_once DISCUZ_ROOT.'./plugins/'.$threadplugins[$specialextra]['module'].'.class.php';
$classname = 'threadplugin_'.$specialextra;
if(method_exists($classname, 'viewthread')) {
$threadpluginclass = new $classname;
$threadplughtml = $threadpluginclass->viewthread($tid);
}
}
$postlist[$firstpid]['message'] = substr($postlist[$firstpid]['message'], 0, $sppos);
}
break;
}
}
if(empty($authorid) && empty($postlist)) {
$replies = intval($db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0'")) - 1;
if($thread['replies'] != $replies && $replies > 0) {
$db->query("UPDATE {$tablepre}threads SET replies='$replies' WHERE tid='$tid'");
dheader("Location: redirect.php?tid=$tid&goto=lastpost");
}
}
if($pagebydesc) {
$postlist = array_reverse($postlist, TRUE);
}
if($vtonlinestatus == 2 && $onlineauthors) {
$query = $db->query("SELECT uid FROM {$tablepre}sessions WHERE uid IN(".(implode(',', $onlineauthors)).") AND invisible=0");
$onlineauthors = array();
while($author = $db->fetch_array($query)) {
$onlineauthors[$author['uid']] = 1;
}
} else {
$onlineauthors = array();
}
$ratelogs = array();
if($ratelogpids) {
$query = $db->query("SELECT * FROM {$tablepre}ratelog WHERE pid IN ($ratelogpids) ORDER BY dateline DESC");
while($ratelog = $db->fetch_array($query)) {
if(count($postlist[$ratelog['pid']]['ratelog']) < $ratelogrecord) {
$ratelogs[$ratelog['pid']][$ratelog['uid']]['username'] = $ratelog['username'];
$ratelogs[$ratelog['pid']][$ratelog['uid']]['score'][$ratelog['extcredits']] = $ratelog['score'];
$ratelogs[$ratelog['pid']][$ratelog['uid']]['reason'] = dhtmlspecialchars($ratelog['reason']);
$postlist[$ratelog['pid']]['ratelog'][$ratelog['uid']] = $ratelogs[$ratelog['pid']][$ratelog['uid']];
}
if(!$postlist[$ratelog['pid']]['totalrate'] || !in_array($ratelog['uid'], $postlist[$ratelog['pid']]['totalrate'])) {
$postlist[$ratelog['pid']]['totalrate'][] = $ratelog['uid'];
}
}
}
if($attachpids != '-1') {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
parseattach($attachpids, $attachtags, $postlist, $showimages, $skipaids);
}
if(empty($postlist)) {
showmessage('undefined_action', NULL, 'HALTED');
} else {
$seodescription = current($postlist);
$seodescription = !$thread['price'] ? str_replace(array("\r", "\n"), '', cutstr(htmlspecialchars(strip_tags($seodescription['message'])), 150)) : '';
}
viewthread_parsetags();
if($prompts['newbietask'] && $newbietaskid && substr($newbietasks[$newbietaskid]['scriptname'], 0, 4) == 'post') {
require_once DISCUZ_ROOT.'./include/task.func.php';
task_newbie_complete();
}
if(empty($viewpid)) {
include template('viewthread');
} else {
$admode = 0;
$post = $postlist[$viewpid];
$post['number'] = $sdb->result_first("SELECT count(*) FROM {$tablepre}posts WHERE tid='$post[tid]' AND dateline<='$post[dbdateline]'");
include template('header_ajax');
include template('viewthread_node');
include template('footer_ajax');
}
} elseif($action == 'printable' && $tid) {
require_once DISCUZ_ROOT.'./include/printable.inc.php';
}
function viewthread_updateviews() {
global $delayviewcount, $timestamp, $tablepre, $tid, $db, $adminid, $thread, $do;
if($delayviewcount == 1 || $delayviewcount == 3) {
$logfile = './forumdata/cache/cache_threadviews.log';
if(substr($timestamp, -2) == '00') {
require_once DISCUZ_ROOT.'./include/misc.func.php';
updateviews('threads', 'tid', 'views', $logfile);
}
if(@$fp = fopen(DISCUZ_ROOT.$logfile, 'a')) {
fwrite($fp, "$tid\n");
fclose($fp);
} elseif($adminid == 1) {
showmessage('view_log_invalid');
}
} else {
$db->query("UPDATE LOW_PRIORITY {$tablepre}threads SET views=views+1 WHERE tid='$tid'", 'UNBUFFERED');
if(is_array($dzfeed_limit['thread_views']) && in_array(($thread['views'] + 1), $dzfeed_limit['thread_views'])) {
$arg = $data = array();
$arg['type'] = 'thread_views';
$arg['fid'] = $thread['fid'];
$arg['typeid'] = $thread['typeid'];
$arg['sortid'] = $thread['sortid'];
$arg['uid'] = $thread['authorid'];
$arg['username'] = addslashes($thread['author']);
$data['title']['actor'] = $thread['authorid'] ? "<a href=\"space.php?uid={$thread[authorid]}\" target=\"_blank\">{$thread[author]}</a>" : $thread['author'];
$data['title']['forum'] = "<a href=\"forumdisplay.php?fid={$thread[fid]}\" target=\"_blank\">".$GLOBALS['forum']['name'].'</a>';
$data['title']['count'] = $thread['replies'] + 1;
$data['title']['subject'] = "<a href=\"viewthread.php?tid={$thread[tid]}\" target=\"_blank\">{$thread[subject]}</a>";
add_feed($arg, $data);
}
}
}
function viewthread_procpost($post, $special = 0) {
global $_DCACHE, $newpostanchor, $numpost, $thisbg, $postcount, $ratelogpids, $onlineauthors, $lastvisit, $thread,
$attachpids, $attachtags, $forum, $dateformat, $timeformat, $timeoffset, $userstatusby, $allowgetattach,
$ratelogrecord, $showimages, $forum, $discuz_uid, $showavatars, $pagebydesc, $ppp, $ppp2, $ppp3,
$firstpid, $threadpay, $sigviewcond, $ordertype;
if(!$newpostanchor && $post['dateline'] > $lastvisit) {
$post['newpostanchor'] = '<a name="newpost"></a>';
$newpostanchor = 1;
} else {
$post['newpostanchor'] = '';
}
$post['lastpostanchor'] = ($ordertype != 1 && $numpost == $thread['replies']) || ($ordertype == 1 && $numpost == $thread['replies'] + 2) ? '<a name="lastpost"></a>' : '';
if($pagebydesc) {
if($ordertype != 1) {
$post['number'] = $numpost + $ppp2--;
} else {
$post['number'] = $post['first'] == 1 ? 1 : $numpost - $ppp2--;
}
$post['count'] = $ppp == $ppp3 ? $ppp - $postcount - 1 : $ppp3 - $postcount - 1;
} else {
if($ordertype != 1) {
$post['number'] = ++$numpost;
} else {
$post['number'] = $post['first'] == 1 ? 1 : --$numpost;
}
$post['count'] = $postcount;
}
$postcount++;
$post['dbdateline'] = $post['dateline'];
$post['dateline'] = dgmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
$post['groupid'] = $_DCACHE['usergroups'][$post['groupid']] ? $post['groupid'] : 7;
if($post['username']) {
$onlineauthors[] = $post['authorid'];
$post['usernameenc'] = rawurlencode($post['username']);
!$special && $post['groupid'] = getgroupid($post['authorid'], $_DCACHE['usergroups'][$post['groupid']], $post);
$post['readaccess'] = $_DCACHE['usergroups'][$post['groupid']]['readaccess'];
if($_DCACHE['usergroups'][$post['groupid']]['userstatusby'] == 1) {
$post['authortitle'] = $_DCACHE['usergroups'][$post['groupid']]['grouptitle'];
$post['stars'] = $_DCACHE['usergroups'][$post['groupid']]['stars'];
} elseif($_DCACHE['usergroups'][$post['groupid']]['userstatusby'] == 2) {
foreach($_DCACHE['ranks'] as $rank) {
if($post['posts'] > $rank['postshigher']) {
$post['authortitle'] = $rank['ranktitle'];
$post['stars'] = $rank['stars'];
break;
}
}
}
$post['taobaoas'] = addslashes($post['taobao']);
$post['authoras'] = !$post['anonymous'] ? ' '.addslashes($post['author']) : '';
$post['regdate'] = gmdate($dateformat, $post['regdate'] + $timeoffset * 3600);
$post['lastdate'] = gmdate($dateformat, $post['lastactivity'] + $timeoffset * 3600);
if($post['medals']) {
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
foreach($post['medals'] = explode("\t", $post['medals']) as $key => $medalid) {
list($medalid, $medalexpiration) = explode("|", $medalid);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$post['medals'][$key] = $_DCACHE['medals'][$medalid];
} else {
unset($post['medals'][$key]);
}
}
}
if($showavatars) {
$post['avatar'] = discuz_uc_avatar($post['authorid']);
if($_DCACHE['usergroups'][$post['groupid']]['groupavatar']) {
$post['avatar'] .= '<br /><img src="'.$_DCACHE['usergroups'][$post['groupid']]['groupavatar'].'" border="0" alt="" />';
}
} else {
$post['avatar'] = '';
}
$post['banned'] = $post['status'] & 1;
$post['warned'] = ($post['status'] & 2) >> 1;
$post['msn'] = explode("\t", $post['msn']);
} else {
if(!$post['authorid']) {
$post['useip'] = substr($post['useip'], 0, strrpos($post['useip'], '.')).'.x';
}
}
$post['attachments'] = array();
if($post['attachment']) {
if($allowgetattach && !$threadpay) {
$attachpids .= ",$post[pid]";
$post['attachment'] = 0;
if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $post['message'], $matchaids)) {
$attachtags[$post['pid']] = $matchaids[1];
}
} else {
$post['message'] = preg_replace("/\[attach\](\d+)\[\/attach\]/i", '', $post['message']);
}
}
$ratelogpids .= ($ratelogrecord && $post['rate']) ? ','.$post['pid'] : '';
$forum['allowbbcode'] = $forum['allowbbcode'] ? ($_DCACHE['usergroups'][$post['groupid']]['allowcusbbcode'] ? 2 : 1) : 0;
$post['signature'] = $post['usesig'] ? ($sigviewcond ? (strlen($post['message']) > $sigviewcond ? $post['signature'] : '') : $post['signature']) : '';
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $forum['allowsmilies'], $forum['allowbbcode'], ($forum['allowimgcode'] && $showimages ? 1 : 0), $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0), 0, $post['authorid'], $forum['allowmediacode'], $post['pid']);
$post['first'] && $firstpid = $post['pid'];
$firstpid = intval($firstpid);
return $post;
}
function showoption($var, $type) {
global $optionlist;
if($optionlist[$var][$type]) {
return $optionlist[$var][$type];
} else {
return '';
}
}
function viewthread_loadcache() {
global $tid, $forum, $timestamp, $cachethreadlife, $_DCACHE, $gzipcompress, $debug, $styleid;
$forum['livedays'] = ceil(($timestamp - $forum['dateline']) / 86400);
$forum['lastpostdays'] = ceil(($timestamp - $forum['lastthreadpost']) / 86400);
$threadcachemark = 100 - (
$forum['displayorder'] * 15 +
$forum['digest'] * 10 +
min($forum['views'] / max($forum['livedays'], 10) * 2, 50) +
max(-10, (15 - $forum['lastpostdays'])) +
min($forum['replies'] / $_DCACHE['settings']['postperpage'] * 1.5, 15));
if($threadcachemark < $forum['threadcaches']) {
$threadcache = getcacheinfo($tid);
if($timestamp - $threadcache['filemtime'] > $cachethreadlife) {
@unlink($threadcache['filename']);
define('CACHE_FILE', $threadcache['filename']);
$styleid = $_DCACHE['settings']['styleid'];
@include DISCUZ_ROOT.'./forumdata/cache/style_'.$styleid.'.php';
} else {
readfile($threadcache['filename']);
viewthread_updateviews();
$debug && debuginfo();
$debug ? die('<script type="text/javascript">document.getElementById("debuginfo").innerHTML = " '.($debug ? 'Updated at '.gmdate("H:i:s", $threadcache['filemtime'] + 3600 * 8).', Processed in '.$debuginfo['time'].' second(s), '.$debuginfo['queries'].' Queries'.($gzipcompress ? ', Gzip enabled' : '') : '').'";</script>') : die();
}
}
}
function viewthread_lastmod() {
global $db, $tablepre, $dateformat, $timeformat, $threadstamp, $timeoffset, $tid, $_DCACHE;
if($lastmod = $db->fetch_first("SELECT uid AS moduid, username AS modusername, dateline AS moddateline, action AS modaction, magicid, stamp
FROM {$tablepre}threadsmod
WHERE tid='$tid' ORDER BY dateline DESC LIMIT 1")) {
include language('modactions');
$lastmod['modusername'] = $lastmod['modusername'] ? $lastmod['modusername'] : 'System';
$lastmod['moddateline'] = dgmdate("$dateformat $timeformat", $lastmod['moddateline'] + $timeoffset * 3600);
$threadstamp = $lastmod['modaction'] != 'SPA' ? array() : $_DCACHE['stamps'][$lastmod['stamp']];
$lastmod['modaction'] = ($modactioncode[$lastmod['modaction']] ? $modactioncode[$lastmod['modaction']] : '').($lastmod['modaction'] != 'SPA' ? '' : ' '.$_DCACHE['stamps'][$lastmod['stamp']]['text']);
if($lastmod['magicid']) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_magics.php';
$lastmod['magicname'] = $_DCACHE['magics'][$lastmod['magicid']]['name'];
}
} else {
$db->query("UPDATE {$tablepre}threads SET moderated='0' WHERE tid='$tid'", 'UNBUFFERED');
}
return $lastmod;
}
function viewthread_parsetags() {
global $tagstatus, $_DCACHE, $firstpid, $postlist, $forum, $tagscript;
if($firstpid && $tagstatus && $forum['allowtag'] && !($postlist[$firstpid]['htmlon'] & 2) && !empty($_DCACHE['tags'])) {
$tagscript = '<script type="text/javascript">var tagarray = '.$GLOBALS['_DCACHE']['tags'][0].';var tagencarray = '.$GLOBALS['_DCACHE']['tags'][1].';parsetag('.$firstpid.');</script>';
}
}
function remaintime($time) {
$days = intval($time / 86400);
$time -= $days * 86400;
$hours = intval($time / 3600);
$time -= $hours * 3600;
$minutes = intval($time / 60);
$time -= $minutes * 60;
$seconds = $time;
return array((int)$days, (int)$hours, (int)$minutes, (int)$seconds);
}
?>
| zyyhong | trunk/jiaju001/newbbs/bbs/viewthread.php | PHP | asf20 | 36,198 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: index.php 20890 2009-10-29 01:12:33Z zhaoxiongfei $
*/
$kw_spiders = 'Bot|Crawl|Spider';
// keywords regular expression of search engine spiders
$kw_browsers = 'MSIE|Netscape|Opera|Konqueror|Mozilla';
// keywords regular expression of Internet browsers
$kw_searchengines = 'google|yahoo|msn|baidu|yisou|sogou|iask|zhongsou|sohu|sina|163';
// keywords regular expression of search engine names
error_reporting(0);
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
ob_start();
define('DISCUZ_ROOT', '../');
define('IN_DISCUZ', TRUE);
define('CURSCRIPT', 'archiver');
require_once '../forumdata/cache/cache_settings.php';
if(!$_DCACHE['settings']['archiverstatus']) {
exit('Sorry, Discuz! Archiver is not available.');
} elseif($_DCACHE['settings']['bbclosed']) {
exit('Sorry, the bulletin board has been closed temporarily.');
}
require_once '../config.inc.php';
require_once '../include/db_'.$database.'.class.php';
require_once '../templates/default/archiver.lang.php';
require_once '../forumdata/cache/cache_forums.php';
require_once '../forumdata/cache/cache_archiver.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
$db->select_db($dbname);
if(!function_exists('loadmultiserver')) {
function loadmultiserver($type = '') {
global $db, $dbcharset, $multiserver;
$type = empty($type) && defined('CURSCRIPT') ? CURSCRIPT : $type;
static $sdb = null;
if($type && !empty($multiserver['enable'][$type])) {
if(!is_a($sdb, 'dbstuff')) $sdb = new dbstuff();
if($sdb->link > 0) {
return $sdb;
} elseif($sdb->link === null && (!empty($multiserver['slave']['dbhost']) || !empty($multiserver[$type]['dbhost']))) {
$setting = !empty($multiserver[$type]['host']) ? $multiserver[$type] : $multiserver['slave'];
$sdb->connect($setting['dbhost'], $setting['dbuser'], $setting['dbpw'], $setting['dbname'], $setting['pconnect'], false, $dbcharset);
if($sdb->link) {
return $sdb;
} else {
$sdb->link = -32767;
}
}
}
return $db;
}
}
$sdb = loadmultiserver();
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$_SERVER = empty($_SERVER) ? $HTTP_SERVER_VARS : $_SERVER;
$PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$boardurl = 'http://'.$_SERVER['HTTP_HOST'].substr($PHP_SELF, 0, strpos($PHP_SELF, 'archiver/'));
$groupid = 7;
$extgroupids = '';
$fid = $page = $tid = 0;
$qm = $_DCACHE['settings']['rewritestatus'] & 16 ? '' : '?';
$fullversion = array('title' => $_DCACHE['settings']['bbname'], 'link' => $_DCACHE['settings']['indexname']);
$querystring = preg_replace("/\.html$/i", '', trim($_SERVER['QUERY_STRING']));
if($querystring) {
$queryparts = explode('-', $querystring);
$lastpart = '';
foreach($queryparts as $querypart) {
if(empty($lastpart)) {
$lastpart = in_array($querypart, array('fid', 'page', 'tid')) ? $querypart : '';
} else {
$$lastpart = intval($querypart);
$lastpart = '';
}
}
}
$navtitle = $meta_contentadd = $advlist = null;
if($tid) {
$action = 'thread';
$forward = 'viewthread.php?tid='.$tid;
} elseif($fid) {
$action = 'forum';
$forward = 'forumdisplay.php?fid='.$fid;
} else {
$action = 'index';
$forward = 'index.php';
}
if($_DCACHE['settings']['archiverstatus'] != 1 && !preg_match("/($kw_spiders)/i", $_SERVER['HTTP_USER_AGENT']) &&
(($_DCACHE['settings']['archiverstatus'] == 2 && preg_match("/($kw_searchengines)/", $_SERVER['HTTP_REFERER'])) ||
($_DCACHE['settings']['archiverstatus'] == 3 && preg_match("/($kw_browsers)/", $_SERVER['HTTP_USER_AGENT'])))) {
header("Location: $boardurl$forward");
exit;
}
if(($globaladvs = $_DCACHE['settings']['globaladvs']) || !empty($_DCACHE['advs'])) {
$redirectadvs = $_DCACHE['settings']['redirectadvs'];
require_once '../include/advertisements.inc.php';
}
$headernav = '<a href="archiver/"><strong>'.$_DCACHE['settings']['bbname'].'</strong></a> ';
$headerbanner = !empty($advlist['headerbanner']) ? $advlist[headerbanner] : '';
require_once "./include/$action.inc.php";
showfooter();
function multi($total, $page, $perpage, $link) {
$pages = @ceil($total / $perpage) + 1;
$pagelink = '';
if($pages > 1) {
$pagelink .= "{$GLOBALS[lang][page]}: \n";
$pagestart = $page - 10 < 1 ? 1 : $page - 10;
$pageend = $page + 10 >= $pages ? $pages : $page + 10;
for($i = $pagestart; $i < $pageend; $i++) {
$pagelink .= ($i == $page ? "<strong>[$i]</strong>" : "<a href=archiver/$link-page-$i.html>$i</a>")." \n";
}
}
return $pagelink;
}
function forumperm($viewperm) {
return (empty($viewperm) || ($viewperm && strstr($viewperm, "\t7\t")));
}
function forumformulaperm($formula) {
$formula = unserialize($formula);$formula = $formula[1];
if(!$formula) {
return TRUE;
}
$_DSESSION = array();
@eval("\$formulaperm = ($formula) ? TRUE : FALSE;");
return $formulaperm;
}
function showheader() {
header('Content-Type: text/html; charset='.$charset);
global $boardurl, $_DCACHE, $charset, $navtitle, $headerbanner, $headernav;
echo <<<EOT
<!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">
<base href="{$boardurl}" />
<title>{$navtitle} {$_DCACHE['settings']['bbname']} {$_DCACHE['settings']['seotitle']} - Powered by Discuz! Archiver</title>
{$_DCACHE['settings']['seohead']}
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta name="keywords" content="Discuz!,Board,Comsenz,forums,bulletin board,{$_DCACHE['settings']['seokeywords']}" />
<meta name="description" content="{$meta_contentadd} {$_DCACHE['settings']['bbname']} {$_DCACHE['settings']['seodescription']} - Discuz! Archiver" />
<meta name="generator" content="Discuz! Archiver {$_DCACHE['settings']['version']}" />
<meta name="author" content="Discuz! Team & Comsenz UI Team" />
<meta name="copyright" content="2001-2009 Comsenz Inc." />
<style type="text/css">
body {font-family: Verdana;FONT-SIZE: 12px;MARGIN: 0;color: #000000;background: #ffffff;}
img {border:0;}
li {margin-top: 8px;}
.page {padding: 4px; border-top: 1px #EEEEEE solid}
.author {background-color:#EEEEFF; padding: 6px; border-top: 1px #ddddee solid}
#nav, #content, #footer {padding: 8px; border: 1px solid #EEEEEE; clear: both; width: 95%; margin: auto; margin-top: 10px;}
</style>
</head>
<body vlink="#333333" link="#333333">
<h2 style="text-align: center; margin-top: 20px">{$_DCACHE[settings][bbname]}'s Archiver </h2>
<center>{$headerbanner}</center>
<div id="nav">$headernav</div>
<div id="content">
EOT;
}
function showfooter() {
global $lang, $fullversion, $advlist, $_DCACHE;
echo "</div><div id=\"footer\">{$lang['full_version']}: <strong><a href=\"{$fullversion['link']}\" target=\"_blank\">{$fullversion['title']}</a></strong></div>";
empty($advlist['footerbanner1']) or print '<div class="archiver_banner">'.$advlist[footerbanner1].'</div>';
empty($advlist['footerbanner2']) or print '<div class="archiver_banner">'.$advlist[footerbanner2].'</div>';
empty($advlist['footerbanner3']) or print '<div class="archiver_banner">'.$advlist[footerbanner3].'</div>';
echo <<<EOT
<br /><center>
<div style="text-algin: center; font-size: 11px">Powered by <strong><a href="http://www.discuz.net" target="_blank">Discuz! Archiver</a></strong> {$_DCACHE['settings']['version']}
© 2001-2009 <a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a><br /><br /></div>
</center>
</body>
</html>
EOT;
}
function getstatus($status, $position) {
$t = $status & pow(2, $position - 1) ? 1 : 0;
return $t;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/archiver/index.php | PHP | asf20 | 7,941 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: thread.inc.php 20890 2009-10-29 01:12:33Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$thread = $sdb->fetch_first("SELECT *, t.status AS threadstatus FROM {$tablepre}threads t
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid
WHERE t.tid='$tid' AND t.readperm='0' AND t.price<='0' AND t.displayorder>='0'
AND f.status='1' AND ff.password=''");
$page = max(1, intval($page));
$navtitle = $thread['subject']. '('.$lang['page'].' '.$page.') '.
($thread['type'] == 'sub' ? ' - '.strip_tags($_DCACHE['forums'][$thread['fup']]['name']) : '').' - '.strip_tags($thread['name']).' - ';
if(!$thread || !(!$thread['viewperm'] || ($thread['viewperm'] && forumperm($thread['viewperm']))) || !forumformulaperm($thread['formulaperm'])) {
$navtitle = '';
showheader();
echo $lang['thread_nonexistence'];
} else {
$headernav .= ' » ';
$headernav .= $navsub = $thread['type'] == 'sub' ? " <a href=\"archiver/{$qm}fid-$thread[fup].html\">{$_DCACHE[forums][$thread[fup]][name]}</a> <b>»</b> ": '';
$headernav .= '<a href="archiver/'.$qm.'fid-'.$thread['fid'].'.html">'.$thread['name'].'</a> » '.$thread[subject];
$fullversion = array('title' => $thread['subject'], 'link' => "viewthread.php?tid=$tid");
$ppp = $_DCACHE['settings']['postperpage'] * 2;
$start = ($page - 1) * $ppp;
$query = $sdb->query("SELECT p.author, p.dateline, p.subject, p.message, p.anonymous, p.status, p.first, m.groupid
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}members m ON p.authorid=m.uid
WHERE p.tid='$tid' AND p.invisible='0'
ORDER BY dateline LIMIT $start, $ppp");
if($firstpost = $sdb->fetch_array($query)) {
if(in_array($firstpost['groupid'], array(4, 5, 6))) {
include_once language('misc');
$firstpost['message'] = $language['post_banned'];
} elseif($firstpost['status'] & 1) {
include_once language('misc');
$firstpost['message'] = $language['post_single_banned'];
}
$meta_contentadd = cutstr(strip_tags(str_replace(array("\r", "\n", "\t"), array('', '', ''), $firstpost['message'])), 200);
}
showheader();
$needhiddenreply = getstatus($thread['threadstatus'], 2);
while(($post = $firstpost) || ($post = $sdb->fetch_array($query))) {
if(in_array($post['groupid'], array(4, 5, 6))) {
include_once language('misc');
$post['message'] = $language['post_banned'];
} elseif($post['status'] & 1) {
include_once language('misc');
$post['message'] = $language['post_single_banned'];
} elseif($needhiddenreply && !$post['first']) {
include_once language('misc');
$post['message'] = $language['message_ishidden_hiddenreplies'];
}
if(!empty($firstpost)) $firstpost = array();
$post['dateline'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $post['dateline'] + $_DCACHE['settings']['timeoffset'] * 3600);
$post['message'] = ($post['subject'] ? '<h3>'.$post['subject'].'</h3>' : '').nl2br(preg_replace(array('/&(#\d{3,5};)/', "/\[hide=?\d*\](.+?)\[\/hide\]/is"),
array('&\\1', '<b>**** Hidden Message *****</b>'),
str_replace(array('&', '"', '<', '>', "\t", ' ', ' '),
array('&', '"', '<', '>', ' ', ' ', ' '),
$post['message'])));
if($thread['jammer']) {
$post['message'] = preg_replace("/\<br \/\>/e", "jammer()", $post['message']);
}
$post['author'] = !$post['anonymous'] ? $post['author'] : $lang['anonymous'];
echo "<p class=\"author\"><strong>$post[author]</strong> $lang[post_time] $post[dateline]</p>\n$post[message]";
}
echo "\n<br /><br />\n<div class=\"page\">".multi($thread['replies'] + 1, $page, $ppp, "{$qm}tid-$tid")."</div>";
}
function jammer() {
$randomstr = '';
for($i = 0; $i < mt_rand(5, 15); $i++) {
$randomstr .= chr(mt_rand(0, 59)).chr(mt_rand(63, 126));
}
return mt_rand(0, 1) ? '<font style="font-size:0px;color:'.ALTBG2.'">'.$randomstr.'</font><br />' :
'<br /><span style="display:none">'.$randomstr.'</span>';
}
function cutstr($string, $length) {
$strcut = '';
if(strlen($string) > $length) {
for($i = 0; $i < $length - 3; $i++) {
$strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
}
return $strcut.' ...';
} else {
return $string;
}
}
function language($file, $templateid = 0, $tpldir = '') {
$tpldir = $tpldir ? $tpldir : TPLDIR;
$templateid = $templateid ? $templateid : TEMPLATEID;
$languagepack = DISCUZ_ROOT.'./'.$tpldir.'/'.$file.'.lang.php';
if(file_exists($languagepack)) {
return $languagepack;
} elseif($templateid != 1 && $tpldir != './templates/default') {
return language($file, 1, './templates/default');
} else {
return FALSE;
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/archiver/include/thread.inc.php | PHP | asf20 | 4,961 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forum.inc.php 18819 2009-07-23 10:38:43Z liuqiang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$forum = $sdb->fetch_first("SELECT * FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING (fid)
WHERE f.fid='$fid' AND f.status='1' AND f.type<>'group' AND ff.password=''");
if($forum['redirect']) {
header("Location: $forum[redirect]");
exit();
}
$page = max(1, intval($page));
$navtitle = ($forum['type'] == 'sub' ? ' - '.strip_tags($_DCACHE['forums'][$forum['fup']]['name']) : '').
strip_tags($forum['name']).'('.$lang['page'].' '.$page.') - ';
if(!$forum || !forumperm($forum['viewperm']) || !forumformulaperm($forum['formulaperm'])) {
showheader();
echo $lang['forum_nonexistence'];
} else {
$headernav .= ' » ';
$headernav .= $forum['type'] == 'sub' ? "<a href=\"archiver/{$qm}fid-$forum[fup].html\">{$_DCACHE[forums][$forum[fup]][name]}</a> » ": '';
$headernav .= '<a href="archiver/'.$qm.'fid-'.$fid.'.html">'.$forum['name'].'</a>';
showheader();
$fullversion = array('title' => $forum['name'], 'link' => "forumdisplay.php?fid=$fid");
$tpp = $_DCACHE['settings']['topicperpage'] * 2;
$start = ($page - 1) * $tpp;
echo "<ul type=\"1\" start=\"".($start + 1)."\">\n";
$query = $sdb->query("SELECT * FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' ORDER BY displayorder DESC, lastpost DESC LIMIT $start, $tpp");
while($thread = $sdb->fetch_array($query)) {
echo "<li><a href=\"archiver/{$qm}tid-$thread[tid].html\">$thread[subject]</a> ($thread[replies] $lang[replies])</li>\n";
}
echo "</ul>\n";
echo '<div class="page">'.multi($forum['threads'], $page, $tpp, "{$qm}fid-$fid").'</div>';
}
?>
| zyyhong | trunk/jiaju001/newbbs/bbs/archiver/include/forum.inc.php | PHP | asf20 | 1,853 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: index.inc.php 20759 2009-10-19 02:07:04Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
showheader();
$forums = $subforums = array();
$categories = array(0 => array('fid' => 0, 'name' => $_DCACHE['settings']['bbname']));
foreach($_DCACHE['forums'] as $forum) {
if(forumperm($forum['viewperm']) && $forum['status']) {
if($forum['type'] == 'group') {
$categories[] = $forum;
} else {
$forum['type'] == 'sub' ? $subforums[$forum['fup']][] = $forum : $forums[$forum['fup']][] = $forum;
}
}
}
foreach($categories as $category) {
if(isset($forums[$category['fid']])) {
echo "<h3>$category[name]</h3>\n<ul>\n";
foreach($forums[$category['fid']] as $forum) {
echo "<li><a href=\"archiver/{$qm}fid-{$forum[fid]}.html\">$forum[name]</a>\n";
if(isset($subforums[$forum['fid']])) {
echo "<ul>\n";
foreach($subforums[$forum['fid']] as $subforum) {
echo "<li><a href=\"archiver/{$qm}fid-$subforum[fid].html\">$subforum[name]</a></li>\n";
}
echo "</ul></li>\n";
}
}
echo "</li></ul>\n";
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/archiver/include/index.inc.php | PHP | asf20 | 1,215 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: topicadmin.php 20962 2009-11-04 02:55:39Z zhaoxiongfei $
*/
define('CURSCRIPT', 'topicadmin');
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/post.func.php';
require_once DISCUZ_ROOT.'./include/misc.func.php';
$discuz_action = 201;
$modpostsnum = 0;
$resultarray = $thread = array();
if(!$discuz_uid || !$forum['ismoderator']) {
showmessage('admin_nopermission', NULL, 'HALTED');
}
$frommodcp = !empty($frommodcp) ? intval($frommodcp) : 0;
/*
if($forum['type'] == 'forum') {
$navigation = "» <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a>";
$navtitle = strip_tags($forum['name']);
} else {
$fup = $db->fetch_first("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$navigation = "» <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> » <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a> ";
$navtitle = strip_tags($fup['name']).' - '.strip_tags($forum['name']);
}
*/
if(!empty($tid)) {
$thread = $db->fetch_first("SELECT * FROM {$tablepre}threads WHERE tid='$tid' AND fid='$fid' AND displayorder>='0'");
if(!$thread) {
showmessage('thread_nonexistence');
}
$navigation .= " » <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a> ";
$navtitle .= ' - '.$thread['subject'].' - ';
if(($thread['special'] && in_array($action, array('copy', 'split', 'merge'))) || ($thread['digest'] == '-1' && !in_array($action, array('delpost', 'banpost', 'getip')))) {
showmessage('special_noaction');
}
}
// Reason P.M. Preprocess Start
//$reasonpmcheck = $reasonpm == 2 || $reasonpm == 3 ? 'checked="checked" disabled' : '';
if(($reasonpm == 2 || $reasonpm == 3) || !empty($sendreasonpm)) {
$forumname = strip_tags($forum['name']);
$sendreasonpm = 1;
} else {
$sendreasonpm = 0;
}
// End
$postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
$replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
$digestcredits = $forum['digestcredits'] ? $forum['digestcredits'] : $creditspolicy['digest'];
$postattachcredits = $forum['postattachcredits'] ? $forum['postattachcredits'] : $creditspolicy['postattach'];
$handlekey = 'mods';
if($action == 'moderate') {
require_once DISCUZ_ROOT.'./include/moderation.inc.php';
} elseif($action == 'delpost' && $allowdelpost) {
$modpostsnum = count($topiclist);
if(!($deletepids = implodeids($topiclist))) {
showmessage('admin_delpost_invalid');
} elseif(!$allowdelpost || !$tid) {
showmessage('admin_nopermission', NULL, 'HALTED');
} else {
$query = $db->query("SELECT pid FROM {$tablepre}posts WHERE pid IN ($deletepids) AND first='1'");
if($db->num_rows($query)) {
dheader("location: {$boardurl}topicadmin.php?action=moderate&operation=delete&optgroup=3&fid=$fid&moderate[]=$thread[tid]&inajax=yes".($infloat ? "&infloat=yes&handlekey=$handlekey" : ''));
}
}
if(!submitcheck('modsubmit')) {
$deleteid = '';
foreach($topiclist as $id) {
$deleteid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
}
include template('topicadmin_action');
} else {
checkreasonpm();
$pids = 0;
$posts = $uidarray = $puidarray = $auidarray = array();
$losslessdel = $losslessdel > 0 ? $timestamp - $losslessdel * 86400 : 0;
$query = $db->query("SELECT pid, authorid, dateline, message, first FROM {$tablepre}posts WHERE pid IN ($deletepids) AND tid='$tid'");
while($post = $db->fetch_array($query)) {
if(!$post['first']) {
$posts[] = $post;
$pids .= ','.$post['pid'];
if($post['dateline'] < $losslessdel) {
$uidarray[] = $post['authorid'];
} else {
$puidarray[] = $post['authorid'];
}
$modpostsnum ++;
}
}
if($uidarray) {
updatepostcredits('-', $uidarray, array());
}
if($puidarray) {
updatepostcredits('-', $puidarray, $replycredits);
}
$query = $db->query("SELECT uid, attachment, thumb, remote FROM {$tablepre}attachments WHERE pid IN ($pids)");
while($attach = $db->fetch_array($query)) {
if(in_array($attach['uid'], $puidarray)) {
$auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
}
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
if($auidarray) {
updateattachcredits('-', $auidarray, $postattachcredits);
}
$logs = array();
$query = $db->query("SELECT r.extcredits, r.score, p.authorid, p.author FROM {$tablepre}ratelog r LEFT JOIN {$tablepre}posts p ON r.pid=p.pid WHERE r.pid IN ($pids)");
while($author = $db->fetch_array($query)) {
if($author['score'] > 0) {
$db->query("UPDATE {$tablepre}members SET extcredits{$author[extcredits]}=extcredits{$author[extcredits]}-($author[score]) WHERE uid = $author[authorid]");
$author[score] = $extcredits[$id]['title'].' '.-$author['score'].' '.$extcredits[$id]['unit'];
$logs[] = dhtmlspecialchars("$timestamp\t$discuz_userss\t$adminid\t$author[author]\t$author[extcredits]\t$author[score]\t$thread[tid]\t$thread[subject]\t$delpostsubmit");
}
}
if(!empty($logs)) {
writelog('ratelog', $logs);
unset($logs);
}
$db->query("DELETE FROM {$tablepre}ratelog WHERE pid IN ($pids)");
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pids)");
$db->query("DELETE FROM {$tablepre}attachmentfields WHERE pid IN ($pids)");
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pids)");
getstatus($thread['status'], 1) && $db->query("DELETE FROM {$tablepre}postposition WHERE pid IN ($pids)");
if($thread['special']) {
$db->query("DELETE FROM {$tablepre}trades WHERE pid IN ($pids)");
}
updatethreadcount($tid, 1);
updateforumcount($fid);
$forum['threadcaches'] && deletethreadcaches($thread['tid']);
$modaction = 'DLP';
$resultarray = array(
'redirect' => "viewthread.php?tid=$tid&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post') : array()),
'modtids' => 0,
'modlog' => $thread
);
procreportlog('', $pids, TRUE);
}
} elseif($action == 'refund' && $allowrefund && $thread['price'] > 0) {
if(!isset($extcredits[$creditstransextra[1]])) {
showmessage('credits_transaction_disabled');
}
if($thread['special'] != 0) {
showmessage('special_refundment_invalid');
}
if(!submitcheck('modsubmit')) {
$payment = $db->fetch_first("SELECT COUNT(*) AS payers, SUM(netamount) AS netincome FROM {$tablepre}paymentlog WHERE tid='$tid'");
include template('topicadmin_action');
} else {
$modaction = 'RFD';
$modpostsnum ++;
checkreasonpm();
$totalamount = 0;
$amountarray = array();
$logarray = array();
$query = $db->query("SELECT * FROM {$tablepre}paymentlog WHERE tid='$tid'");
while($log = $db->fetch_array($query)) {
$totalamount += $log['amount'];
$amountarray[$log['amount']][] = $log['uid'];
}
$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[1]=extcredits$creditstransextra[1]-$totalamount WHERE uid='$thread[authorid]'");
$db->query("UPDATE {$tablepre}threads SET price='-1', moderated='1' WHERE tid='$thread[tid]'");
foreach($amountarray as $amount => $uidarray) {
$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[1]=extcredits$creditstransextra[1]+$amount WHERE uid IN (".implode(',', $uidarray).")");
}
$db->query("UPDATE {$tablepre}paymentlog SET amount='0', netamount='0' WHERE tid='$tid'");
$resultarray = array(
'redirect' => "viewthread.php?tid=$tid",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_moderate') : array()),
'modtids' => $thread['tid'],
'modlog' => $thread
);
}
} elseif($action == 'repair' && $allowrepairthread) {
$replies = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0'") - 1;
$query = $db->query("SELECT a.aid FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='$tid' AND a.pid=p.pid AND p.invisible='0' LIMIT 1");
$attachment = $db->num_rows($query) ? 1 : 0;
$firstpost = $db->fetch_first("SELECT pid, subject, rate FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline LIMIT 1");
$firstpost['subject'] = addslashes(cutstr($firstpost['subject'], 79));
@$firstpost['rate'] = $firstpost['rate'] / abs($firstpost['rate']);
$lastpost = $db->fetch_first("SELECT author, dateline FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline DESC LIMIT 1");
$db->query("UPDATE {$tablepre}threads SET subject='$firstpost[subject]', replies='$replies', lastpost='$lastpost[dateline]', lastposter='".addslashes($lastpost['author'])."', rate='$firstpost[rate]', attachment='$attachment' WHERE tid='$tid'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}posts SET first='1', subject='$firstpost[subject]' WHERE pid='$firstpost[pid]'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}posts SET first='0' WHERE tid='$tid' AND pid<>'$firstpost[pid]'", 'UNBUFFERED');
showmessage('admin_repair_succeed');
} elseif($action == 'getip' && $allowviewip) {
$member = $db->fetch_first("SELECT m.adminid, p.first, p.useip FROM {$tablepre}posts p
LEFT JOIN {$tablepre}members m ON m.uid=p.authorid
WHERE pid='$pid' AND tid='$tid'");
if(!$member) {
showmessage('thread_nonexistence', NULL, 'HALTED');
} elseif(($member['adminid'] == 1 && $adminid > 1) || ($member['adminid'] == 2 && $adminid > 2)) {
showmessage('admin_getip_nopermission', NULL, 'HALTED');
} elseif($member['first'] && $thread['digest'] == '-1') {
showmessage('special_noaction');
}
$member['iplocation'] = convertip($member['useip']);
include template('topicadmin_getip');
} elseif($action == 'split' && $allowsplitthread) {
if(!submitcheck('modsubmit')) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$replies = $thread['replies'];
if($replies <= 0) {
showmessage('admin_split_invalid');
}
$postlist = array();
$query = $db->query("SELECT * FROM {$tablepre}posts WHERE tid='$tid' ORDER BY dateline");
while($post = $db->fetch_array($query)) {
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml']);
$postlist[] = $post;
}
include template('topicadmin_action');
} else {
if(!trim($subject)) {
showmessage('admin_split_subject_invalid');
} elseif(!($nos = explode(',', $split))) {
showmessage('admin_split_new_invalid');
}
sort($nos);
$maxno = $nos[count($nos) - 1];
$maxno = $maxno > $thread['replies'] + 1 ? $thread['replies'] + 1 : $maxno;
$maxno = max(1, intval($maxno));
$query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline LIMIT $maxno");
$i = 1;
$pids = array();
while($post = $db->fetch_array($query)) {
if(in_array($i, $nos)) {
$pids[] = $post['pid'];
}
$i++;
}
if(!($pids = implode(',',$pids))) {
showmessage('admin_split_new_invalid');
}
$modaction = 'SPL';
checkreasonpm();
$subject = dhtmlspecialchars($subject);
$db->query("INSERT INTO {$tablepre}threads (fid, subject) VALUES ('$fid', '$subject')");
$newtid = $db->insert_id();
$db->query("UPDATE {$tablepre}posts SET tid='$newtid' WHERE pid IN ($pids)");
$db->query("UPDATE {$tablepre}attachments SET tid='$newtid' WHERE pid IN ($pids)");
$splitauthors = array();
$query = $db->query("SELECT pid, tid, authorid, subject, dateline FROM {$tablepre}posts WHERE tid='$newtid' AND invisible='0' GROUP BY authorid ORDER BY dateline");
while($splitauthor = $db->fetch_array($query)) {
$splitauthor['subject'] = $subject;
$splitauthors[] = $splitauthor;
}
$db->query("UPDATE {$tablepre}posts SET first='1', subject='$subject' WHERE pid='".$splitauthors[0]['pid']."'", 'UNBUFFERED');
$fpost = $db->fetch_first("SELECT pid, author, authorid, dateline FROM {$tablepre}posts WHERE tid='$tid' ORDER BY dateline LIMIT 1");
$db->query("UPDATE {$tablepre}threads SET author='".addslashes($fpost['author'])."', authorid='$fpost[authorid]', dateline='$fpost[dateline]', moderated='1' WHERE tid='$tid'");
$db->query("UPDATE {$tablepre}posts SET subject='".addslashes($thread['subject'])."' WHERE pid='$fpost[pid]'");
$fpost = $db->fetch_first("SELECT author, authorid, dateline, rate FROM {$tablepre}posts WHERE tid='$newtid' ORDER BY dateline ASC LIMIT 1");
$db->query("UPDATE {$tablepre}threads SET author='".addslashes($fpost['author'])."', authorid='$fpost[authorid]', dateline='$fpost[dateline]', rate='".intval(@($fpost['rate'] / abs($fpost['rate'])))."', moderated='1' WHERE tid='$newtid'");
updatethreadcount($tid);
updatethreadcount($newtid);
updateforumcount($fid);
$forum['threadcaches'] && deletethreadcaches($thread['tid']);
$modpostsnum++;
$resultarray = array(
'redirect' => "forumdisplay.php?fid=$fid",
'reasonpm' => ($sendreasonpm ? array('data' => $splitauthors, 'var' => 'thread', 'item' => 'reason_moderate') : array()),
'modtids' => $thread['tid'].','.$newtid,
'modlog' => array($thread, array('tid' => $newtid, 'subject' => $subject))
);
}
} elseif($action == 'merge' && $allowmergethread) {
if(!submitcheck('modsubmit')) {
include template('topicadmin_action');
} else {
$modaction = 'MRG';
checkreasonpm();
$other = $db->fetch_first("SELECT tid, fid, authorid, subject, views, replies, dateline, special FROM {$tablepre}threads WHERE tid='$othertid' AND displayorder>='0'");
if(!$other) {
showmessage('admin_merge_nonexistence');
} elseif($other['special']) {
showmessage('special_noaction');
}
if($othertid == $tid || ($adminid == 3 && $other['fid'] != $forum['fid'])) {
showmessage('admin_merge_invalid');
}
$other['views'] = intval($other['views']);
$other['replies']++;
$firstpost = $db->fetch_first("SELECT pid, fid, authorid, author, subject, dateline FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline LIMIT 1");
$db->query("UPDATE {$tablepre}posts SET tid='$tid' WHERE tid='$othertid'");
$postsmerged = $db->affected_rows();
$db->query("UPDATE {$tablepre}attachments SET tid='$tid' WHERE tid='$othertid'");
$db->query("DELETE FROM {$tablepre}threads WHERE tid='$othertid'");
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid='$othertid'");
$db->query("UPDATE {$tablepre}posts SET first=(pid='$firstpost[pid]'), fid='$firstpost[fid]' WHERE tid='$tid'");
$db->query("UPDATE {$tablepre}threads SET authorid='$firstpost[authorid]', author='".addslashes($firstpost['author'])."', subject='".addslashes($firstpost['subject'])."', dateline='$firstpost[dateline]', views=views+$other[views], replies=replies+$other[replies], moderated='1' WHERE tid='$tid'");
if($fid == $other['fid']) {
$db->query("UPDATE {$tablepre}forums SET threads=threads-1 WHERE fid='$fid'");
} else {
$db->query("UPDATE {$tablepre}forums SET threads=threads-1, posts=posts-$postsmerged WHERE fid='$other[fid]'");
$db->query("UPDATE {$tablepre}forums SET posts=$posts+$postsmerged WHERE fid='$fid'");
}
$forum['threadcaches'] && deletethreadcaches($thread['tid']);
$modpostsnum ++;
$resultarray = array(
'redirect' => "forumdisplay.php?fid=$fid",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_merge') : array()),
'modtids' => $thread['tid'],
'modlog' => array($thread, $other)
);
}
} elseif($action == 'copy' && $allowcopythread && $thread) {
if(!submitcheck('modsubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = forumselect();
include template('topicadmin_action');
} else {
$modaction = 'CPY';
checkreasonpm();
$toforum = $db->fetch_first("SELECT fid, name, modnewposts FROM {$tablepre}forums WHERE fid='$copyto' AND status='1' AND type<>'group'");
if(!$toforum) {
showmessage('admin_copy_invalid');
} else {
$modnewthreads = (!$allowdirectpost || $allowdirectpost == 1) && $toforum['modnewposts'] ? 1 : 0;
$modnewreplies = (!$allowdirectpost || $allowdirectpost == 2) && $toforum['modnewposts'] ? 1 : 0;
if($modnewthreads || $modnewreplies) {
showmessage('admin_copy_hava_mod');
}
}
$thread['tid'] = '';
$thread['fid'] = $copyto;
$thread['dateline'] = $thread['lastpost'] = $timestamp;
$thread['lastposter'] = $thread['author'];
$thread['views'] = $thread['replies'] = $thread['highlight'] = $thread['digest'] = 0;
$thread['rate'] = $thread['displayorder'] = $thread['attachment'] = 0;
$db->query("INSERT INTO {$tablepre}threads VALUES ('".implode("', '", daddslashes($thread, 1))."')");
$threadid = $db->insert_id();
if($post = $db->fetch_first("SELECT * FROM {$tablepre}posts WHERE tid='$tid' AND first=1 LIMIT 1")) {
$post['pid'] = '';
$post['tid'] = $threadid;
$post['fid'] = $copyto;
$post['dateline'] = $timestamp;
$post['attachment'] = 0;
$post['invisible'] = $post['rate'] = $post['ratetimes'] = 0;
$db->query("INSERT INTO {$tablepre}posts VALUES ('".implode("', '", daddslashes($post, 1))."')");
}
updatepostcredits('+', $post['authorid'], '');
updateforumcount($copyto);
updateforumcount($fid);
$modpostsnum ++;
$resultarray = array(
'redirect' => "forumdisplay.php?fid=$fid",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_copy') : array()),
'modtids' => $thread['tid'],
'modlog' => array($thread, $other)
);
}
} elseif($action == 'removereward' && $allowremovereward) {
if(!is_array($thread) || $thread['special'] != '3') {
showmessage('reward_end');
}
$modaction = 'RMR';
$answererid = $db->result_first("SELECT answererid FROM {$tablepre}rewardlog WHERE tid='$thread[tid]'");
$rewardprice = abs($thread['price']);
if($thread['price'] < 0) {
$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]-'$rewardprice' WHERE uid='$answererid'", 'UNBUFFERED');
}
$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]+'$rewardprice' WHERE uid='$thread[authorid]'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SET special='0', price='0' WHERE tid='$thread[tid]'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='$thread[tid]'", 'UNBUFFERED');
showmessage('admin_succeed');
} elseif($action == 'banpost' && $allowbanpost) {
$modpostsnum = count($topiclist);
if(!($banpids = implodeids($topiclist))) {
showmessage('admin_banpost_invalid');
} elseif(!$allowbanpost || !$tid) {
showmessage('admin_nopermission', NULL, 'HALTED');
}
$posts = array();$banstatus = 0;
$query = $db->query("SELECT pid, first, authorid, status, dateline, message FROM {$tablepre}posts WHERE pid IN ($banpids) AND tid='$tid'");
while($post = $db->fetch_array($query)) {
if($post['first'] && $thread['digest'] == '-1') {
showmessage('special_noaction');
}
$banstatus = ($post['status'] & 1) || $banstatus;
$posts[] = $post;
}
if(!submitcheck('modsubmit')) {
$banid = $checkunban = $checkban = '';
foreach($topiclist as $id) {
$banid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
}
$banstatus ? $checkunban = 'checked="checked"' : $checkban = 'checked="checked"';
include template('topicadmin_action');
} else {
$banned = intval($banned);
$modaction = $banned ? 'BNP' : 'UBN';
checkreasonpm();
$pids = $comma = '';
foreach($posts as $k => $post) {
if($banned) {
$db->query("UPDATE {$tablepre}posts SET status=status|1 WHERE pid='$post[pid]'", 'UNBUFFERED');
} else {
$db->query("UPDATE {$tablepre}posts SET status=status^1 WHERE pid='$post[pid]' AND status=status|1", 'UNBUFFERED');
}
$pids .= $comma.$post['pid'];
$comma = ',';
}
$resultarray = array(
'redirect' => "viewthread.php?tid=$tid&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_ban_post') : array()),
'modtids' => 0,
'modlog' => $thread
);
procreportlog('', $pids);
}
} elseif($action == 'warn' && $allowwarnpost) {
if(!($warnpids = implodeids($topiclist))) {
showmessage('admin_warn_invalid');
} elseif(!$allowbanpost || !$tid) {
showmessage('admin_nopermission', NULL, 'HALTED');
}
$posts = $authors = array();
$authorwarnings = $warningauthor = $warnstatus = '';
$query = $db->query("SELECT p.pid, p.authorid, p.author, p.status, p.dateline, p.message, m.adminid FROM {$tablepre}posts p LEFT JOIN {$tablepre}members m ON p.authorid=m.uid WHERE pid IN ($warnpids) AND p.tid='$tid'");
while($post = $db->fetch_array($query)) {
if($post['adminid'] == 0 || $post['adminid'] == -1) {
$warnstatus = ($post['status'] & 2) || $warnstatus;
$authors[$post['authorid']] = 1;
$posts[] = $post;
}
}
if(!$posts) {
showmessage('admin_warn_nopermission', NULL, 'HALTED');
}
$authorcount = count(array_keys($authors));
$modpostsnum = count($posts);
if($modpostsnum == 1 || $authorcount == 1) {
$authorwarnings = $db->result_first("SELECT COUNT(*) FROM {$tablepre}warnings WHERE authorid='{$posts[0][authorid]}'");
$warningauthor = $posts[0]['author'];
}
if(!submitcheck('modsubmit')) {
$warnpid = $checkunwarn = $checkwarn = '';
foreach($topiclist as $id) {
$warnpid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
}
$warnstatus ? $checkunwarn = 'checked="checked"' : $checkwarn = 'checked="checked"';
include template('topicadmin_action');
} else {
$warned = intval($warned);
$modaction = $warned ? 'WRN' : 'UWN';
checkreasonpm();
$pids = $comma = '';
foreach($posts as $k => $post) {
if($post['adminid'] == 0) {
if($warned && !($post['status'] & 2)) {
$db->query("UPDATE {$tablepre}posts SET status=status|2 WHERE pid='$post[pid]'", 'UNBUFFERED');
$reason = cutstr(dhtmlspecialchars($reason), 40);
$db->query("INSERT INTO {$tablepre}warnings (pid, operatorid, operator, authorid, author, dateline, reason) VALUES ('$post[pid]', '$discuz_uid', '$discuz_user', '$post[authorid]', '".addslashes($post['author'])."', '$timestamp', '$reason')", 'UNBUFFERED');
$authorwarnings = $db->result_first("SELECT COUNT(*) FROM {$tablepre}warnings WHERE authorid='$post[authorid]' AND dateline>=$timestamp-$warningexpiration*86400");
if($authorwarnings >= $warninglimit) {
$member = $db->fetch_first("SELECT adminid, groupid FROM {$tablepre}members WHERE uid='$post[authorid]'");
if($member && $member['groupid'] != 4) {
$banexpiry = $timestamp + $warningexpiration * 86400;
$groupterms = array();
$groupterms['main'] = array('time' => $banexpiry, 'adminid' => $member['adminid'], 'groupid' => $member['groupid']);
$groupterms['ext'][4] = $banexpiry;
$db->query("UPDATE {$tablepre}members SET groupid='4', groupexpiry='".groupexpiry($groupterms)."' WHERE uid='$post[authorid]'");
$db->query("UPDATE {$tablepre}memberfields SET groupterms='".addslashes(serialize($groupterms))."' WHERE uid='$post[authorid]'");
}
}
$pids .= $comma.$post['pid'];
$comma = ',';
} elseif(!$warned && ($post['status'] & 2)) {
$db->query("UPDATE {$tablepre}posts SET status=status^2 WHERE pid='$post[pid]' AND status=status|2", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}warnings WHERE pid='$post[pid]'", 'UNBUFFERED');
$pids .= $comma.$post['pid'];
$comma = ',';
}
}
}
$resultarray = array(
'redirect' => "viewthread.php?tid=$tid&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_warn_post') : array()),
'modtids' => 0,
'modlog' => $thread
);
procreportlog('', $pids);
}
} elseif($action == 'stamp' && $allowstampthread) {
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_stamps.php';
if(!submitcheck('modsubmit')) {
include template('topicadmin_action');
} else {
$modaction = $stamp !== '' ? 'SPA' : 'SPD';
checkreasonpm();
$db->query("UPDATE {$tablepre}threads SET moderated='1', ".buildbitsql('status', 5, $stamp !== '')." WHERE tid='$tid'");
$resultarray = array(
'redirect' => "viewthread.php?tid=$tid&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => $stamp !== '' ? 'reason_stamp_update' : 'reason_stamp_delete') : array()),
'modaction' => $stamp !== '' ? 'S'.sprintf('%02d', $stamp) : 'SPD',
'modlog' => $thread
);
$modpostsnum = 1;
updatemodlog($tid, $modaction);
$db->query("UPDATE {$tablepre}threadsmod SET stamp='$stamp' WHERE tid='$tid' ORDER BY dateline DESC LIMIT 1");
}
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
if($resultarray) {
if($resultarray['modtids']) {
updatemodlog($resultarray['modtids'], $modaction, $resultarray['expiration']);
}
updatemodworks($modaction, $modpostsnum);
if(is_array($resultarray['modlog'])) {
if(isset($resultarray['modlog']['tid'])) {
modlog($resultarray['modlog'], $modaction);
} else {
foreach($resultarray['modlog'] as $thread) {
modlog($thread, $modaction);
}
}
}
if($resultarray['reasonpm']) {
include language('modactions');
$modaction = $modactioncode[$modaction];
foreach($resultarray['reasonpm']['data'] as ${$resultarray['reasonpm']['var']}) {
sendreasonpm($resultarray['reasonpm']['var'], $resultarray['reasonpm']['item']);
}
}
showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/topicadmin.php | PHP | asf20 | 26,438 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: redirect.php 21051 2009-11-09 08:13:08Z monkey $
*/
define('CURSCRIPT', 'viewthread');
require_once './include/common.inc.php';
if(empty($goto) && !empty($ptid)) {
$ptid = intval($ptid);
$postno = intval($postno);
if($ordertype != 1) {
$postno = $postno > 0 ? $postno - 1 : 0;
$pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$ptid' AND invisible='0' ORDER BY dateline LIMIT $postno, 1");
} else {
$postno = $postno > 1 ? $postno - 1 : 0;
if($postno) {
$pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$ptid' AND invisible='0' ORDER BY dateline LIMIT $postno, 1");
} else {
$pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$ptid' AND first='1' LIMIT 1");
}
}
$goto = 'findpost';
}
if($goto == 'findpost') {
$pid = intval($pid);
$ptid = intval($ptid);
if($post = $db->fetch_first("SELECT p.tid, p.dateline, t.status, t.special, t.replies FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE p.pid='$pid'")) {
$ordertype = !isset($_GET['ordertype']) && getstatus($post['status'], 4) ? 1 : intval($ordertype);
$sqladd = $post['special'] ? "AND first=0" : '';
$curpostnum = $db->result_first("SELECT count(*) FROM {$tablepre}posts WHERE tid='$post[tid]' AND dateline<='$post[dateline]' $sqladd");
if($ordertype != 1) {
$page = ceil($curpostnum / $ppp);
} else {
if($curpostnum > 1) {
$page = ceil(($post['replies'] - $curpostnum + 3) / $ppp);
} else {
$page = 1;
}
}
if(!empty($special) && $special == 'trade') {
dheader("Location: viewthread.php?do=tradeinfo&tid=$post[tid]&pid=$pid");
} else {
$extra = '';
if($discuz_uid && empty($postno)) {
if($db->result_first("SELECT count(*) FROM {$tablepre}favoritethreads WHERE tid='$post[tid]' AND uid='$discuz_uid'")) {
$db->query("UPDATE {$tablepre}favoritethreads SET newreplies=0 WHERE tid='$post[tid]' AND uid='$discuz_uid'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}promptmsgs WHERE uid='$discuz_uid' AND typeid='".$prompts['threads']['id']."' AND extraid='$post[tid]'", 'UNBUFFERED');
$extra = '&fav=yes';
}
}
dheader("Location: viewthread.php?tid=$post[tid]&rpid=$pid$extra&ordertype=$ordertype&page=$page".(isset($_GET['modthreadkey']) && ($modthreadkey=modthreadkey($post['tid'])) ? "&modthreadkey=$modthreadkey": '')."#pid$pid");
}
} else {
$ptid = !empty($ptid) ? intval($ptid) : 0;
if($ptid) {
dheader("location: viewthread.php?tid=$ptid");
}
showmessage('post_check', NULL, 'HALTED');
}
}
$tid = $forum['closed'] < 2 ? $tid : $forum['closed'];
if(empty($tid)) {
showmessage('thread_nonexistence');
}
if(isset($fid) && empty($forum)) {
showmessage('forum_nonexistence', NULL, 'HALTED');
}
@include DISCUZ_ROOT.'./forumdata/cache/cache_viewthread.php';
if($goto == 'lastpost') {
if($tid) {
$query = $db->query("SELECT tid, replies, special, status FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
} else {
$query = $db->query("SELECT tid, replies, special, status FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
}
if(!$thread = $db->fetch_array($query)) {
showmessage('thread_nonexistence');
}
if(!getstatus($thread['status'], 4)) {
$page = ceil(($thread['special'] ? $thread['replies'] : $thread['replies'] + 1) / $ppp);
} else {
$page = 1;
}
$tid = $thread['tid'];
require_once DISCUZ_ROOT.'./viewthread.php';
exit();
} elseif($goto == 'nextnewset') {
if($fid && $tid) {
$this_lastpost = $db->result_first("SELECT lastpost FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
if($next = $db->fetch_first("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' AND lastpost>'$this_lastpost' ORDER BY lastpost ASC LIMIT 1")) {
$tid = $next['tid'];
require_once DISCUZ_ROOT.'./viewthread.php';
exit();
} else {
showmessage('redirect_nextnewset_nonexistence');
}
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
} elseif($goto == 'nextoldset') {
if($fid && $tid) {
$this_lastpost = $db->result_first("SELECT lastpost FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
if($last = $db->fetch_first("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' AND lastpost<'$this_lastpost' ORDER BY lastpost DESC LIMIT 1")) {
$tid = $last['tid'];
require_once DISCUZ_ROOT.'./viewthread.php';
exit();
} else {
showmessage('redirect_nextoldset_nonexistence');
}
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/redirect.php | PHP | asf20 | 4,912 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ajax.php 21155 2009-11-18 00:36:45Z monkey $
*/
define('CURSCRIPT', 'ajax');
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
if($action == 'updatesecqaa') {
$message = '';
if($secqaa) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_secqaa.php';
$secqaa = max(1, random(1, 1));
$message = $_DCACHE['secqaa'][$secqaa]['question'];
if($seclevel) {
$seccode = $secqaa * 1000000 + substr($seccode, -6);
updatesession();
} else {
dsetcookie('secq', authcode($secqaa."\t".$timestamp."\t".$discuz_uid, 'ENCODE'), 3600);
}
}
showmessage($message);
} elseif($action == 'updateseccode') {
$message = '';
if($seccodestatus) {
$secqaa = substr($seccode, 0, 1);
$seccode = random(6, 1);
$rand = random(5, 1);
if($seclevel) {
$seccode += $secqaa * 1000000;
updatesession();
} else {
$key = $seccodedata['type'] != 3 ? '' : $_DCACHE['settings']['authkey'].date('Ymd');
dsetcookie('secc', authcode($seccode."\t".$timestamp."\t".$discuz_uid, 'ENCODE', $key), 3600);
}
if($seccodedata['type'] == 2) {
$message = '<div style="width:'.$seccodedata['width'].'px; height:'.$seccodedata['height'].'px;" id="seccodeswf_'.$secchecktype.'"></div>'.(extension_loaded('ming') ? "<script type=\"text/javascript\" reload=\"1\">\n$('seccodeswf_$secchecktype').innerHTML=AC_FL_RunContent(
'width', '$seccodedata[width]', 'height', '$seccodedata[height]', 'src', 'seccode.php?update=$rand',
'quality', 'high', 'wmode', 'transparent', 'bgcolor', '#ffffff',
'align', 'middle', 'menu', 'false', 'allowScriptAccess', 'sameDomain');\n</script>" :
"<script type=\"text/javascript\" reload=\"1\">\n$('seccodeswf_$secchecktype').innerHTML=AC_FL_RunContent(
'width', '$seccodedata[width]', 'height', '$seccodedata[height]', 'src', '{$boardurl}images/seccode/flash/flash2.swf',
'FlashVars', 'sFile={$boardurl}seccode.php?update=$rand', 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true');\n</script>");
} elseif($seccodedata['type'] == 3) {
$flashcode = "<span id=\"seccodeswf_$secchecktype\"></span><script type=\"text/javascript\" reload=\"1\">\n$('seccodeswf_$secchecktype').innerHTML=AC_FL_RunContent(
'id', 'seccodeplayer', 'name', 'seccodeplayer', 'width', '0', 'height', '0', 'src', '{$boardurl}images/seccode/flash/flash1.swf',
'FlashVars', 'sFile={$boardurl}seccode.php?update=$rand', 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true');\n</script>";
$message = 'seccode_player';
} else {
$message = '<img onclick="updateseccode'.$secchecktype.'()" width="'.$seccodedata['width'].'" height="'.$seccodedata['height'].'" src="seccode.php?update='.$rand.'" class="absmiddle" alt="" />';
}
}
showmessage($message);
} elseif($action == 'checkseccode') {
if($seclevel) {
$tmp = $seccode;
} else {
$key = $seccodedata['type'] != 3 ? '' : $_DCACHE['settings']['authkey'].date('Ymd');
list($tmp, $expiration, $seccodeuid) = explode("\t", authcode($_DCOOKIE['secc'], 'DECODE', $key));
if($seccodeuid != $discuz_uid || $timestamp - $expiration > 600) {
showmessage('submit_seccode_invalid');
}
}
seccodeconvert($tmp);
strtoupper($seccodeverify) != $tmp && showmessage('submit_seccode_invalid');
showmessage('succeed');
} elseif($action == 'checksecanswer') {
if($seclevel) {
$tmp = $seccode;
} else {
list($tmp, $expiration, $seccodeuid) = explode("\t", authcode($_DCOOKIE['secq'], 'DECODE'));
if($seccodeuid != $discuz_uid || $timestamp - $expiration > 600) {
showmessage('submit_secqaa_invalid');
}
}
require_once DISCUZ_ROOT.'./forumdata/cache/cache_secqaa.php';
!$headercharset && @dheader('Content-Type: text/html; charset='.$charset);
if(md5($secanswer) != $_DCACHE['secqaa'][substr($tmp, 0, 1)]['answer']) {
showmessage('submit_secqaa_invalid');
}
showmessage('succeed');
} elseif($action == 'checkusername') {
$username = trim($username);
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucresult = uc_user_checkname($username);
if($ucresult == -1) {
showmessage('profile_username_illegal', '', 1);
} elseif($ucresult == -2) {
showmessage('profile_username_protect', '', 1);
} elseif($ucresult == -3) {
if($db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$username'")) {
showmessage('register_check_found', '', 1);
} else {
showmessage('register_activation', '', 1);
}
}
} elseif($action == 'checkemail') {
$email = trim($email);
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucresult = uc_user_checkemail($email);
if($ucresult == -4) {
showmessage('profile_email_illegal', '', 1);
} elseif($ucresult == -5) {
showmessage('profile_email_domain_illegal', '', 1);
} elseif($ucresult == -6) {
showmessage('profile_email_duplicate', '', 1);
}
} elseif($action == 'checkuserexists') {
$check = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='".trim($username)."'");
$check ? showmessage('<img src="'.IMGDIR.'/check_right.gif" width="13" height="13">')
: showmessage('username_nonexistence');
} elseif($action == 'checkinvitecode') {
$invitecode = trim($invitecode);
$check = $db->result_first("SELECT invitecode FROM {$tablepre}invites WHERE invitecode='".trim($invitecode)."' AND status IN ('1', '3')");
if(!$check) {
showmessage('invite_invalid', '', 1);
} else {
$query = $db->query("SELECT m.username FROM {$tablepre}invites i, {$tablepre}members m WHERE invitecode='".trim($invitecode)."' AND i.uid=m.uid");
$inviteuser = $db->fetch_array($query);
$inviteuser = $inviteuser['username'];
showmessage('invite_send');
}
} elseif($action == 'attachlist') {
require_once DISCUZ_ROOT.'./include/post.func.php';
$attachlist = getattach(intval($posttime));
$attachlist = $attachlist['attachs']['unused'];
include template('header_ajax');
include template('ajax_attachlist');
include template('footer_ajax');
dexit();
} elseif($action == 'imagelist') {
require_once DISCUZ_ROOT.'./include/post.func.php';
$attachlist = getattach();
$imagelist = $attachlist['imgattachs']['unused'];
include template('header_ajax');
include template('ajax_imagelist');
include template('footer_ajax');
dexit();
} elseif($action == 'displaysearch_adv') {
$display = $display == 1 ? 1 : '';
dsetcookie('displaysearch_adv', $display);
}
showmessage($reglinkname, '', 2);
?> | zyyhong | trunk/jiaju001/newbbs/bbs/ajax.php | PHP | asf20 | 6,668 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: space.php 21055 2009-11-10 00:33:11Z monkey $
*/
if(!defined('CURSCRIPT')) {
define('CURSCRIPT', 'profile');
}
require_once './include/common.inc.php';
$allowviewpro = $discuz_uid && ($uid == $discuz_uid || $username == $discuz_user) ? 1 : $allowviewpro;
if($my_status && $from) {
$funcstatinfo[] = 'manyou2dz,20090727';
}
if(!$allowviewpro) {
showmessage('group_nopermission', NULL, 'NOPERM');
}
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
require_once DISCUZ_ROOT.'./include/forum.func.php';
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_viewpro.php';
@extract($_DCACHE['custominfo']);
$discuz_action = 61;
if($oltimespan) {
$oltimeadd1 = ', o.thismonth AS thismonthol, o.total AS totalol';
$oltimeadd2 = "LEFT JOIN {$tablepre}onlinetime o ON o.uid=m.uid";
} else {
$oltimeadd1 = $oltimeadd2 = '';
}
$member = $db->fetch_first("SELECT m.*, mf.*, u.grouptitle, u.type, u.creditshigher, u.creditslower, u.readaccess,
u.color AS groupcolor, u.stars AS groupstars, u.allownickname, r.ranktitle,
r.color AS rankcolor, r.stars AS rankstars $oltimeadd1
FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
LEFT JOIN {$tablepre}ranks r ON m.posts>=r.postshigher
$oltimeadd2
WHERE ".($uid ? "m.uid='$uid'" : "m.username='$username'")."ORDER BY r.postshigher DESC LIMIT 1");
if(!$member) {
header("HTTP/1.0 404 Not Found");
showmessage('member_nonexistence');
}
$usemagic = array();
if($magicstatus) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_magics.php';
foreach($_DCACHE['magics'] as $id => $magic) {
if($magic['available'] == 1 && $magic['type'] == 2) {
$usemagic['user'][$id]['name'] = $magic['name'];
$usemagic['user'][$id]['pic'] = strtolower($magic['identifier']).'_s.gif';
}
}
}
$profileuid = $member['uid'];
$member['online'] = $db->result_first("SELECT lastactivity FROM {$tablepre}sessions WHERE uid='$member[uid]' AND invisible='0'");
if($member['groupid'] != ($member['groupidnew'] = getgroupid($member['uid'], $member, $member))) {
$member = array_merge($member, $db->fetch_first("SELECT groupid, grouptitle, type, creditshigher, creditslower, color AS groupcolor,
stars AS groupstars, allownickname
FROM {$tablepre}usergroups WHERE groupid='$member[groupidnew]'"));
}
$modforums = $comma = '';
if($member['adminid'] > 0) {
$query = $db->query("SELECT m.fid, f.name, f.type FROM {$tablepre}moderators m, {$tablepre}forums f WHERE m.uid='$member[uid]' AND m.inherited='0' AND f.fid=m.fid");
while($forum = $db->fetch_array($query)) {
$modforums .= "$comma<a href=\"".($forum['type'] == 'group' ? "$indexname?gid=" : "forumdisplay.php?fid=")."$forum[fid]\">$forum[name]</a>";
$comma = ', ';
}
}
$member['groupterms'] = $member['groupterms'] ? unserialize($member['groupterms']) : array();
$extgrouplist = array();
if($member['extgroupids']) {
$temp = array_map('intval', explode("\t", $member['extgroupids']));
if($temp = implodeids($temp)) {
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE groupid IN ($temp)");
while($group = $db->fetch_array($query)) {
$extgrouplist[] = array('title' => $group['grouptitle'], 'expiry' => (isset($member['groupterms']['ext'][$group['groupid']]) ? gmdate($dateformat, $member['groupterms']['ext'][$group['groupid']] + $timeoffset * 3600) : ''));
}
}
}
@$percent = round($member['posts'] * 100 / $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts"), 2);
$postperday = $timestamp - $member['regdate'] > 86400 ? round(86400 * $member['posts'] / ($timestamp - $member['regdate']), 2) : $member['posts'];
$member['grouptitle'] = $member['groupcolor'] ? '<font color="'.$member['groupcolor'].'">'.$member['grouptitle'].'</font>' : $member['grouptitle'];
$member['ranktitle'] = $member['rankcolor'] ? '<font color="'.$member['rankcolor'].'">'.$member['ranktitle'].'</font>' : $member['ranktitle'];
if($oltimespan) {
$member['totalol'] = round($member['totalol'] / 60, 2);
$member['thismonthol'] = gmdate('Yn', $member['lastactivity']) == gmdate('Yn', $timestamp) ? round($member['thismonthol'] / 60, 2) : 0;
}
$member['usernameenc'] = rawurlencode($member['username']);
$member['regdate'] = gmdate($dateformat, $member['regdate'] + $timeoffset * 3600);
$member['email'] = emailconv($member['email']);
$member['msn']= explode("\t", $member['msn']);
$member['replies'] = $member['posts'] - $member['threads'];
$member['lastvisit'] = dgmdate("$dateformat $timeformat", $member['lastvisit'] + ($timeoffset * 3600));
$member['lastpost'] = $member['lastpost'] ? dgmdate("$dateformat $timeformat", $member['lastpost'] + ($timeoffset * 3600)) : 'x';
$member['lastdate'] = gmdate($dateformat, $member['lastactivity'] + ($timeoffset * 3600));
$member['taobaoas'] = str_replace("'", '', addslashes($member['taobao']));
$member['olupgrade'] = $member['totalol'] ? 20 - $member['totalol'] % 20 : 20;
list($year, $month, $day) = explode('-', $member['bday']);
$member['bday'] = intval($year) ? $dateformat : preg_replace("/[^nj]*[Yy][^nj]*/", '', $dateformat);
$member['bday'] = str_replace('n', $month, $member['bday']);
$member['bday'] = str_replace('j', $day, $member['bday']);
$member['bday'] = str_replace('Y', $year, $member['bday']);
$member['bday'] = str_replace('y', substr($year, 2, 4), $member['bday']);
if($member['groupexpiry'] && isset($member['groupterms']['main']['time'])) {
$member['maingroupexpiry'] = gmdate($dateformat, $member['groupterms']['main']['time'] + $timeoffset * 3600);
}
if($allowviewip && !($adminid == 2 && $member['adminid'] == 1) && !($adminid == 3 && ($member['adminid'] == 1 || $member['adminid'] == 2))) {
require_once DISCUZ_ROOT.'./include/misc.func.php';
$member['regiplocation'] = convertip($member['regip']);
$member['lastiplocation'] = convertip($member['lastip']);
} else {
$allowviewip = 0;
}
$_DCACHE['fields_required'] = is_array($_DCACHE['fields_required']) ? $_DCACHE['fields_required'] : array();
$_DCACHE['fields_optional'] = is_array($_DCACHE['fields_optional']) ? $_DCACHE['fields_optional'] : array();
foreach(array_merge($_DCACHE['fields_required'], $_DCACHE['fields_optional']) as $field) {
if(!$field['invisible'] || $adminid == 1 || $member['uid'] == $discuz_uid) {
$_DCACHE['fields'][] = $field;
}
}
unset($_DCACHE['fields_required'], $_DCACHE['fields_optional']);
if($member['medals']) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
foreach($member['medals'] = explode("\t", $member['medals']) as $key => $medalid) {
list($medalid, $medalexpiration) = explode("|", $medalid);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$member['medals'][$key] = $_DCACHE['medals'][$medalid];
} else {
unset($member['medals'][$key]);
}
}
}
$member['buyerrank'] = 0;
if($member['buyercredit']){
foreach($ec_credit['rank'] AS $level => $credit) {
if($member['buyercredit'] <= $credit) {
$member['buyerrank'] = $level;
break;
}
}
}
$member['sellerrank'] = 0;
if($member['sellercredit']){
foreach($ec_credit['rank'] AS $level => $credit) {
if($member['sellercredit'] <= $credit) {
$member['sellerrank'] = $level;
break;
}
}
}
if($my_status) {
require_once DISCUZ_ROOT.'./manyou/sources/profile.func.php';
$my_list = getmyml($member['uid']);
}
include template('viewpro_classic');
function emailconv($email, $tolink = 1) {
$email = str_replace(array('@', '.'), array('@', '.'), $email);
return $tolink ? '<a href="mailto:'.$email.'">'.$email.'</a>': $email;
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/space.php | PHP | asf20 | 8,021 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: modcp.php 21068 2009-11-10 04:48:56Z monkey $
*/
define('NOROBOT', TRUE);
define('IN_MODCP', true);
define('CURSCRIPT', 'modcp');
$action = !empty($_REQUEST['action']) ? (!empty($_GET['action']) ? $_GET['action'] : '') : (!empty($_POST['action']) ? $_POST['action'] : '');
require_once './include/common.inc.php';
require_once './admin/cpanel.share.php';
$discuz_action = 210;
$action = empty($action) && $fid ? 'threads' : $action;
$cpscript = basename($PHP_SELF);
$modsession = new AdminSession($discuz_uid, $groupid, $adminid, $onlineip);
if($modsession->cpaccess == 1) {
if($action == 'login' && $cppwd && submitcheck('submit')) {
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucresult = uc_user_login($discuz_uid, $cppwd, 1);
if($ucresult[0] > 0) {
$modsession->errorcount = '-1';
$url_forward = $modsession->get('url_forward');
$modsession->clear(true);
$url_forward && dheader("Location: $cpscript?$url_forward");
$action = 'home';
} else{
$modsession->errorcount ++;
$modsession->update();
}
} else {
$action = 'login';
}
}
if($action == 'logout') {
$modsession->destroy();
showmessage('modcp_logout_succeed', $indexname);
}
$modforums = $modsession->get('modforums');
if($modforums === null) {
$modforums = array('fids' => '', 'list' => array(), 'recyclebins' => array());
$comma = '';
if($adminid == 3) {
$query = $db->query("SELECT m.fid, f.name, f.recyclebin
FROM {$tablepre}moderators m
LEFT JOIN {$tablepre}forums f ON f.fid=m.fid
WHERE m.uid='$discuz_uid' AND f.status='1' AND f.type<>'group'");
while($tforum = $db->fetch_array($query)) {
$modforums['fids'] .= $comma.$tforum['fid']; $comma = ',';
$modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
$modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
}
} else {
$sql = !empty($accessmasks) ?
"SELECT f.fid, f.name, f.threads, f.recyclebin, ff.viewperm, a.allowview FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid
LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid
WHERE f.status='1' AND ff.redirect=''"
: "SELECT f.fid, f.name, f.threads, f.recyclebin, ff.viewperm, ff.redirect FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING(fid)
WHERE f.status='1' AND f.type<>'group' AND ff.redirect=''";
$query = $db->query($sql);
while ($tforum = $db->fetch_array($query)) {
if($tforum['allowview'] == 1 || ($tforum['allowview'] == 0 && ((!$tforum['viewperm'] && $readaccess) || ($tforum['viewperm'] && forumperm($tforum['viewperm']))))) {
$modforums['fids'] .= $comma.$tforum['fid']; $comma = ',';
$modforums['recyclebins'][$tforum['fid']] = $tforum['recyclebin'];
$modforums['list'][$tforum['fid']] = strip_tags($tforum['name']);
}
}
}
$modsession->set('modforums', $modforums, true);
}
if($fid && $forum['ismoderator']) {
dsetcookie('modcpfid', $fid);
$forcefid = "&fid=$fid";
} elseif(!empty($modforums) && count($modforums['list']) == 1) {
$forcefid = "&fid=$modforums[fids]";
} else {
$forcefid = '';
}
$script = $modtpl = '';
switch ($action) {
case 'announcements':
$allowpostannounce && $script = 'announcements';
break;
case 'members':
$op == 'edit' && $allowedituser && $script = 'members';
$op == 'ban' && $allowbanuser && $script = 'members';
$op == 'ipban' && $allowbanip && $script = 'members';
break;
case 'report':
$allowviewreport && $script = 'report';
break;
case 'moderate':
($op == 'threads' || $op == 'replies') && $allowmodpost && $script = 'moderate';
$op == 'members' && $allowmoduser && $script = 'moderate';
break;
case 'forums':
$op == 'editforum' && $alloweditforum && $script = 'forums';
$op == 'recommend' && $allowrecommendthread && $script = 'forums';
break;
case 'forumaccess':
$allowedituser && $script = 'forumaccess';
break;
case 'logs':
$allowviewlog && $script = 'logs';
break;
case 'login':
$script = $modsession->cpaccess == 1 ? 'login' : 'home';
break;
case 'threads':
$script = 'threads';
break;
case 'recyclebins':
$script = 'recyclebins';
break;
case 'plugin':
$script = 'plugin';
break;
default:
$action = $script = 'home';
$modtpl = 'modcp_home';
}
$script = empty($script) ? 'noperm' : $script;
$modtpl = empty($modtpl) ? (!empty($script) ? 'modcp_'.$script : '') : $modtpl;
$op = isset($op) ? trim($op) : '';
if($script != 'logs') {
$extra = implodearray(array('GET' => $_GET, 'POST' => $_POST), array('cppwd', 'formhash', 'submit', 'addsubmit'));
$modcplog = array($timestamp, $discuz_user, $adminid, $onlineip, $action, $op, $fid, $extra);
writelog('modcp', implode("\t", clearlogstring($modcplog)));
}
require DISCUZ_ROOT.'./modcp/'.$script.'.inc.php';
$reportnum = $modpostnum = $modthreadnum = $modforumnum = 0;
$modforumnum = count($modforums['list']);
if($modforumnum) {
$reportnum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}reportlog WHERE fid IN($modforums[fids]) AND status='1'");
$modnum = ($allowmodpost ? ($db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE invisible='-2' AND first='0' and fid IN($modforums[fids])") +
$db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid IN($modforums[fids]) AND displayorder='-2'")) : 0) +
($allowmoduser ? $db->result_first("SELECT COUNT(*) FROM {$tablepre}validating WHERE status='0'") : 0);
}
switch($adminid) {
case 1: $access = '1,2,3,4,5,6,7'; break;
case 2: $access = '2,3,6,7'; break;
default: $access = '1,3,5,7'; break;
}
$notenum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}adminnotes WHERE access IN ($access)");
include template('modcp');
?> | zyyhong | trunk/jiaju001/newbbs/bbs/modcp.php | PHP | asf20 | 5,989 |
{template header}
<div id="nav"><a href="$indexname">$bbname</a> » {lang ie8:submit_from_acc}</div>
<style type="text/css">
span.tips { font-size: 16px; line-height: 20px; color: #0b85b5; }
div.separator { margin: 20px 0; width: 700px; height: 1px; border-top: 1px solid #d9d9d9; }
h1.step { padding-left: 25px; background: url('plugins/ie8/images/arrow.gif') no-repeat left; }
div.type { margin: 0 0 30px 20px; }
div.type label { color: #999; }
div.type label:hover { color: #000; }
div.login { margin: 0 0 30px 30px; }
div.login input { width: 100px; }
div.login button { margin: 5px 5px 0 0; }
div.forums { margin: 0 0 30px 30px; }
div.forums div { padding-left: 15px; line-height: 17px; background: url('plugins/ie8/images/item.gif') no-repeat 0 4px; }
div.forums div a { color: #999; }
div.forums div a:hover { color: #000; }
#forums_show_link { margin: 0 0 30px 30px; }
#forums_show_link a { color: #069; }
</style>
<div id="wrap" class="wrap s_clear">
<div class="main">
<div id="main_content" class="content">
<span class="tips">{lang ie8:submit_tips}</span>
<div class="separator"></div>
<h1 class="step">{lang ie8:submit_selectmethod}</h1>
<div class="type">
<input type="radio" name="type" id="type_message" checked /> <label for="type_message">{lang ie8:submit_method_content}</label><br />
<input type="radio" name="type" id="type_subject" /> <label for="type_subject">{lang ie8:submit_method_subject}</label>
</div>
<!--{if $myfavorites}-->
<h1 class="step">{lang ie8:submit_tofavorite}</h1>
<div class="forums">
<!--{loop $myfavorites $fid $html}-->
<div><a href="javascript:;" onclick="submitfid('$fid')">$html</a></div>
<!--{/loop}-->
</div>
<h1 class="item">{lang ie8:submit_toforums}</h1>
<!--{else}-->
<h1 class="step">{lang ie8:submit_toallforums}</h1>
<!--{/if}-->
<div id="forums_show" class="forums" style="display: none;">
<!--{loop $forums $fid $html}-->
<div><a href="javascript:;" onclick="submitfid('$fid')">$html</a></div>
<!--{/loop}-->
</div>
<div id="forums_show_link">
<a href="javascript:;" onclick="forums_show()">{lang ie8:submit_showallforums}</a>
</div>
</div>
</div>
</div>
<form id="post_form" action="post.php?action=newthread&fid=" method="post"><input type="hidden" name="" id="post_content" value="" /></form>
<input type="hidden" id="selection_subject" value="$selection_subject" />
<input type="hidden" id="selection_message" value="$selection_message" />
<script type="text/javascript">
function forums_show() {
$('forums_show_link').style.display = 'none';
$('forums_show').style.display = '';
}
function submitfid(fid) {
if($('type_message').checked) {
$('post_content').name = 'message';
$('post_content').value = $('selection_message').value;
} else {
$('post_content').name = 'postinfo[subject]';
$('post_content').value = $('selection_subject').value;
}
$('post_form').action += fid;
$('post_form').submit();
}
</script>
<!--{if !$myfavorites}-->
<script type="text/javascript">forums_show();</script>
<!--{/if}-->
{template footer} | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/ie8/templates/ie8_submit.htm | HTML | asf20 | 3,215 |
{template header}
<div id="nav"><a href="$indexname">$bbname</a> » $name</div>
<style type="text/css">
div.ie8 { float: left; margin: 20px; width: 220px; height: 420px; border-right: 1px solid #d9d9d9; }
div.ie8 img { margin: 0 0 10px 10px; }
div.ie8 span { margin: 0 0 0 5px; line-height: 20px; font-size: 14px; }
div.ie8 div.acc { margin: 25px 0 0 0; padding: 0; width: 200px; border-top: 1px solid #ccc; }
div.ie8 div.acc h2 { margin: 20px 0 15px 5px; padding-left: 25px; font-weight: normal; font-size: 14px; color: #888888; background: url('plugins/ie8/images/arrow.gif') no-repeat left; }
div.ie8 div.acc div { margin: 0 8px 0 15px; color: #646464; word-break: break-all; }
div.install { float: left; margin: 20px 20px 20px 0; }
div.install span { font-size: 16px; line-height: 20px; color: #0b85b5; }
div.install div.accelerator { margin: 30px 0 0 0; }
div.install div.accelerator h1 { font-weight: normal; font-size: 16px; }
div.install div.accelerator div { margin: 10px 20px 25px 20px; line-height: 24px; color: #777; }
div.install div.accelerator img.install { margin: 0 0 0 15px; cursor: pointer; }
</style>
<div id="wrap" class="wrap s_clear">
<div class="ie8">
{lang ie8:tour_title}
</div>
<div class="install">
{lang ie8:tour_content}
</div>
</div>
<script type="text/javascript">
function install() {
if(!BROWSER.ie) {
showDialog('{lang ie8:message_noie}', 'alert');
return;
}
if(parseInt(BROWSER.ie) < 8) {
showDialog('{lang ie8:message_noie8}', 'alert');
return;
}
if(install_check()) {
showDialog('{lang ie8:message_installed}', 'notice');
return;
}
window.external.AddService('{$boardurl}plugin.php?id=ie8:install&xml=yes');
install_confirm();
}
function install_confirm() {
if(install_check()) {
showDialog('{lang ie8:message_install_succeed}', 'notice');
return;
}
window.setTimeout(function () { install_confirm(); }, 500);
}
function install_check() {
return window.external.IsServiceInstalled('$boardurl', '$ie8_acc_category');
}
</script>
{template footer} | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/ie8/templates/ie8_install.htm | HTML | asf20 | 2,107 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc. & (C)2005-2009 mfboy
This is NOT a freeware, use is subject to license terms
$Id: submit.inc.php 20544 2009-10-09 01:04:35Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
@include_once DISCUZ_ROOT.'./forumdata/cache/plugin_'.$identifier.'.php';
unset($name, $directory, $vars);
extract($_DPLUGIN[$identifier], EXTR_SKIP);
extract($vars);
if($charset != 'UTF-8') {
require_once DISCUZ_ROOT.'./include/chinese.class.php';
$chs = new Chinese('UTF-8', $charset);
$selection = $chs->Convert($selection);
unset($chs);
}
$selection = stripslashes($selection);
$selection_subject = cutstr(str_replace(array("\n", "\r", "\t"), ' ', $selection), 75);
$selection_message = htmlspecialchars($selection);
if(!$selection_subject || !$selection_message) {
showmessage('ie8:message_invalid');
}
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$forums = $myfavorites = $myfavfids = array();
foreach($_DCACHE['forums'] as $fid => $forum) {
$forumfup = $_DCACHE['forums'][$forum['fup']];
if($forum['type'] == 'forum') {
$forums[$fid] = $_DCACHE['forums'][$forum['fup']]['name'].' » '.$forum['name'];
} elseif($forum['type'] == 'sub') {
$forums[$fid] = $_DCACHE['forums'][$forumfup['fup']]['name'].' » '.$_DCACHE['forums'][$forum['fup']]['name'].' » '.$forum['name'];
}
}
if($discuz_uid) {
$query = $db->query("SELECT fid FROM {$tablepre}favorites WHERE uid='$discuz_uid' AND fid>0");
while($fav = $db->fetch_array($query)) {
$myfavfids[] = $fav['fid'];
}
}
foreach($myfavfids as $fid) {
$forum = $_DCACHE['forums'][$fid];
$forumfup = $_DCACHE['forums'][$forum['fup']];
if($forum['type'] == 'forum') {
$myfavorites[$fid] = $_DCACHE['forums'][$forum['fup']]['name'].' » '.$forum['name'];
} elseif ($forum['type'] == 'sub') {
$myfavorites[$fid] = $_DCACHE['forums'][$forumfup['fup']]['name'].' » '.$_DCACHE['forums'][$forum['fup']]['name'].' » '.$forum['name'];
}
}
include plugintemplate('ie8_submit');
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/ie8/submit.inc.php | PHP | asf20 | 2,113 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc. & (C)2005-2009 mfboy
This is NOT a freeware, use is subject to license terms
$Id: install.inc.php 20544 2009-10-09 01:04:35Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
@include_once DISCUZ_ROOT.'./forumdata/cache/plugin_'.$identifier.'.php';
unset($name, $directory, $vars);
extract($_DPLUGIN['ie8'], EXTR_SKIP);
extract($vars);
if(!$ie8_acc_name || !$ie8_acc_category) {
showmessage($adminid == 1 ? 'ie8:invalid_1' : 'ie8:invalid_2');
}
if(!empty($xml)) {
$xml = "<?xml version=\"1.0\" encoding=\"$charset\"?>\n".
"<os:openServiceDescription xmlns:os=\"http://www.microsoft.com/schemas/openservicedescription/1.0\">\n".
"<os:homepageUrl>$boardurl</os:homepageUrl>\n".
"<os:display>\n".
"<os:name>$ie8_acc_name</os:name>\n".
($ie8_acc_icon ? "<os:icon>$boardurl$ie8_acc_icon</os:icon>\n" : '').
($ie8_acc_description ? "<os:description>$ie8_acc_description</os:description>\n" : '').
"</os:display>\n".
"<os:activity category=\"$ie8_acc_category\">\n".
"<os:activityAction context=\"selection\">\n".
"<os:execute method=\"post\" action=\"{$boardurl}plugin.php?id=$identifier:submit\">\n".
"<os:parameter name=\"selection\" value=\"{selection}\" type=\"text\" />\n".
"</os:execute>\n".
"</os:activityAction>\n".
"</os:activity>\n".
"</os:openServiceDescription>";
ob_end_clean();
ob_start();
header("Expires: -1");
header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", false);
header("Pragma: no-cache");
header('Content-Encoding: none');
header("Content-type: application/xml; charset=".$charset);
echo $xml;
exit;
} else {
$navtitle = $name.' - ';
include plugintemplate('ie8_install');
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/ie8/install.inc.php | PHP | asf20 | 1,797 |
<!--{block return}-->
<style>
.hslice { margin-bottom: 5px; }
.entry-content, .hslice { background-color: {WRAPBG}; }
#homegrids_e { text-align: center; margin-top: 10px; }
#homegrids_e a { color: {HIGHLIGHTLINK}; font-weight: 700; }
#homegrid_Img { color: {HIGHLIGHTLINK}; }
.entry-content table#homegrids_t { width: 100%; border: 1px solid {SPECIALBORDER}; table-layout:fixed; }
.entry-content table#homegrids_t th div.slideouter { border: 0 !important; }
.entry-content #homegrids_t th { width: {$widthA}px; background-color: {INTERLEAVECOLOR}; }
.entry-content #homegrids_t td { border: {WRAPBORDER} solid {WRAPBORDERCOLOR}; }
.entry-content h4 { background-color: {INTERLEAVECOLOR}; padding: 5px; text-align: left; }
.entry-content h4 span { cursor: pointer; padding-right: 10px; font-weight: normal; }
.entry-content h4 span.current { font-weight: 700; }
.entry-content ul { background: url('{$boardurl}plugins/homegrids/images/prefix.gif') no-repeat; }
.entry-content li { text-overflow: ellipsis; overflow: hidden; list-style-image: none; height: 21px; line-height: 21px; text-indent: 20px; border-bottom: 1px dashed {COMMONBORDER}; }
.entry-content li span { float: right; padding-right: 10px; }
.entry-content .textinfolist { text-align: left; }
.entry-title { display: none; }
</style>
<script type="text/javascript">var slideSpeed = 5000, slideImgsize = [{$widthA},{$heightA}], slideBorderColor = '{COMMONBORDER}', slideBgColor = '{INTERLEAVECOLOR}', slideImgs = new Array(), slideImgLinks = new Array(), slideImgTexts = new Array(), slideSwitchColor = '{TABLETEXT}', slideSwitchbgColor = '{COMMONBG}', slideSwitchHiColor = '{COMMONBORDER}';</script>
<div class="hslice" id="homegrids">
<h2 class="entry-title">{lang homegrids:hslice_title}</h2>
<div class="entry-content">
<table id="homegrids_t" cellspacing="0" cellpadding="0">
<!--{if $moduleA}--><tr><th valign="top"><h4>$titleA</h4>$moduleA<div id="homegrids_e"><a href="$boardurl">{lang homegrids:hslice_entrylink}</a></div></th><!--{/if}-->
<td valign="top">
<h4 id="homegrids_t_0" style="display:none">$navB</h4>
$moduleB
</td>
<!--{if $moduleC}-->$moduleC<!--{/if}-->
</tr>
</table>
</div>
</div>
<!--{if $navcount}-->
<script type="text/javascript">
switchTab('homegrids', 1, $navcount);
$('homegrids_t_0').style.display = '';
{if $moduleA}$('homegrids_e').style.display = 'none';{/if}
for(i = 1;i <= $navcount;i++) $('homegrids_t_' + i).style.display = 'none';
</script>
<!--{/if}-->
<!--{/block}--> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/homegrids/templates/homegrids.htm | HTML | asf20 | 2,575 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: uninstall.php 20526 2009-10-04 07:06:00Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($installlang['homegrids']['requestpre']) {
$sql = "DELETE FROM cdb_request WHERE variable like '".$installlang['homegrids']['requestpre']."%'";
runquery($sql);
}
$finish = TRUE; | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/homegrids/uninstall.php | PHP | asf20 | 425 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: homegrids.class.php 20541 2009-10-09 00:34:37Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class plugin_homegrids {
function index_hot() {
@include_once DISCUZ_ROOT.'./forumdata/cache/plugin_homegrids.php';
$modules = explode("\n", $_DPLUGIN['homegrids']['vars']['modules']);
$boardurl = $GLOBALS['boardurl'];
$moduleA = $titleA = $widthA = $heightA = $moduleB = $moduleC = $navB = '';
$navi = 1;
foreach($modules as $m) {
list($type, $m, $title, $width, $height) = explode(',', $m);
if($type == 'A') {
$titleA = $title;
$moduleA .= request($m, 0, 0, 1);
$widthA = intval($width);
$heightA = intval($height);
} elseif($type == 'B') {
$navB .= '<span '.($navi == 1 ? 'class="current" ' : '').'onmouseover="switchTab(\'homegrids\', '.$navi.', {navi})" id="homegrids_'.$navi.'">'.$title.'</span>';
$moduleB .= '<h4 id="homegrids_t_'.$navi.'">'.$title.'</h4><div class="homegridslist" id="homegrids_c_'.$navi.'">'.request($m, 0, 0, 1).'</div>';
$navi++;
} elseif($type == 'C') {
$moduleC .= '<td valign="top" width="'.$width.'"><h4>'.$title.'</h4>'.request($m, 0, 0, 1).'</td>';
}
}
$navcount = $navi - 1;
$navB = str_replace('{navi}', $navcount, $navB);
include template('homegrids:homegrids');
return $return;
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/homegrids/homegrids.class.php | PHP | asf20 | 1,463 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: plugin.class.php 20939 2009-11-02 01:14:31Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class plugin_uchome {
function profile_baseinfo_top() {
return '<div id="uch_feed"></div>';
}
function profile_side_top() {
return '<div id="profile_stats"></div>';
}
function profile_side_bottom_output() {
global $uchomeurl, $_DCACHE, $discuz_uid, $infosidestatus, $profileuid;
if($uchomeurl && $_DCACHE['settings']['uchomeurl'] && $discuz_uid) {
return '<script type="text/javascript" src="'.$uchomeurl.'/api/discuz.php?pagetype=profile&status='.$_DCACHE['settings']['homeshow'].'&uid='.$discuz_uid.'&infosidestatus='.$infosidestatus['allow'].'&updateuid='.$profileuid.'&plugin=1"></script>';
}
}
function viewthread_postheader() {
global $page, $uchomeurl, $_DCACHE, $discuz_uid;
if($page == 1 && $uchomeurl && $_DCACHE['settings']['uchomeurl'] && $discuz_uid) {
return array('<span id="authorfeed"></span>');
} else {
return array();
}
}
function viewthread_bottom_output() {
global $page, $uchomeurl, $_DCACHE, $discuz_uid, $infosidestatus, $feedpostnum, $feeduid, $firstpid, $postlist;
if($page == 1 && $uchomeurl && $_DCACHE['settings']['uchomeurl'] && $discuz_uid && !$postlist[$firstpid]['anonymous']) {
return '<div id="authornewfeed_menu" style="display:none"></div><script type="text/javascript" src="'.$uchomeurl.'/api/discuz.php?pagetype=viewthread&status='.$_DCACHE['settings']['homeshow'].'&uid='.$discuz_uid.'&infosidestatus='.$infosidestatus['allow'].'&feedpostnum='.$feedpostnum.'&updateuid='.$feeduid.'&pid='.$firstpid.'&plugin=1"></script>';
}
}
function global_footer() {
global $uchomeurl, $_DCACHE, $discuz_uid, $infosidestatus;
if(CURSCRIPT != 'viewthread' && CURSCRIPT != 'profile' && $_DCACHE['settings']['uchomeurl'] && $discuz_uid) {
return '<script type="text/javascript" src="'.$uchomeurl.'/api/discuz.php?pagetype='.CURSCRIPT.'&status='.$_DCACHE['settings']['homeshow'].'&uid='.$discuz_uid.'&infosidestatus='.$infosidestatus['allow'].'"></script>';
}
}
} | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/uchome/plugin.class.php | PHP | asf20 | 2,286 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: admincp.inc.php 20873 2009-10-28 04:42:10Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!submitcheck('settingsubmit')) {
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable='uchome'");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
$query = $db->query("SELECT fid, allowfeed FROM {$tablepre}forums");
while($forum = $db->fetch_array($query)) {
if($forum['allowfeed']) {
$allowfeeds[] = $forum['fid'];
}
}
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucapparray = uc_app_ls();
$uchomeopen = FALSE;
$apparraylist = array();
foreach($ucapparray as $apparray) {
if($apparray['appid'] != UC_APPID) {
$apparraylist[] = $apparray;
}
if($apparray['type'] == 'UCHOME') {
$uchomeopen = TRUE;
}
}
require_once DISCUZ_ROOT.'./include/forum.func.php';
$allowfeedsels = '<select name="allowfeedsnew[]" size="10" multiple="multiple"><option value="">'.lang('plugins_empty').'</option>'.forumselect().'</select>';
foreach($allowfeeds as $v) {
$allowfeedsels = str_replace('<option value="'.$v.'">', '<option value="'.$v.'" selected>', $allowfeedsels);
}
if($uchomeopen) {
showformheader('plugins&operation=config&identifier=uchome&mod=admincp');
showtableheader();
$settings['uchome'] = unserialize($settings['uchome']);
foreach($apparraylist as $apparray) {
$checked = $settings['uchome']['navlist'][$apparray['appid']] ? 'checked="checked"': '';
$applist .= "<input type=\"checkbox\" class=\"checkbox\" name=\"appnew[navlist][$apparray[appid]]\" value=\"$apparray[name]\" $checked>$apparray[name] ";
}
showsetting($scriptlang['uchome']['settings_uc_feed'], array('settingsnew[uchome][addfeed]', array(
$scriptlang['uchome']['settings_uc_feed_thread'],
$scriptlang['uchome']['settings_uc_feed_sepcialthread'],
$scriptlang['uchome']['settings_uc_feed_reply'])), $settings['uchome']['addfeed'], 'binmcheckbox', 0, '', $scriptlang['uchome']['settings_uc_feed_comment']);
showsetting($scriptlang['uchome']['settings_uc_home_allowfeed'], '', '', $allowfeedsels, 0, '', $scriptlang['uchome']['settings_uc_home_allowfeed_comment']);
showsetting($scriptlang['uchome']['settings_uc_home_show'], array('settingsnew[uchome][homeshow]', array(
$scriptlang['uchome']['settings_uc_home_avatarshow'],
$scriptlang['uchome']['settings_uc_home_viewproshow'],
$scriptlang['uchome']['settings_uc_home_adshow'],
$scriptlang['uchome']['settings_uc_home_side'])), $settings['uchome']['homeshow'], 'binmcheckbox', 0, '', $scriptlang['uchome']['settings_uc_home_show_comment']);
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
} else {
cpmsg('uchome:settings_uc_home_nonexistence', '', '', '', FALSE);
exit();
}
} else {
$settingsnew['uchome']['addfeed'] = bindec(intval($settingsnew['uchome']['addfeed'][3]).intval($settingsnew['uchome']['addfeed'][2]).intval($settingsnew['uchome']['addfeed'][1]));
$settingsnew['uchome']['homeshow'] = bindec(intval($settingsnew['uchome']['homeshow'][4]).intval($settingsnew['uchome']['homeshow'][3]).intval($settingsnew['uchome']['homeshow'][2]).intval($settingsnew['uchome']['homeshow'][1]));
$settingsnew['uchome'] = addslashes(serialize($settingsnew['uchome']));
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('uchome', '$settingsnew[uchome]')");
$db->query("UPDATE {$tablepre}plugins SET available='1' WHERE identifier='uchome'");
$db->query("UPDATE {$tablepre}forums SET allowfeed='0'");
if($allowfeedsnew) {
$db->query("UPDATE {$tablepre}forums SET allowfeed='1' WHERE fid IN (".implodeids($allowfeedsnew).")");
}
updatecache('plugins');
updatecache('settings');
cpmsg('plugins_settings_succeed', $BASESCRIPT.'?action=plugins&operation=config&identifier=uchome&mod=admincp', 'succeed');
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/uchome/admincp.inc.php | PHP | asf20 | 4,082 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: plugin.class.php 20546 2009-10-09 01:09:29Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class plugin_manyou {
var $feeddata;
var $recommendlimit;
function profile_baseinfo_top_output() {
return '<div id="uch_feed">'.$this->_getfeed($GLOBALS['member']['uid']).'</div>';
}
function profile_baseinfo_bottom_output() {
return '<script>$(\'baseprofile\').style.width=\'48%\';</script>';
}
function index_middle() {
if($GLOBALS['indextype'] != 'classics') {
return;
}
@include_once DISCUZ_ROOT . './forumdata/cache/plugin_manyou.php';
$this->recommendlimit = $_DPLUGIN['manyou']['vars']['limit'];
if(!$this->recommendlimit) {
return;
}
$cachefile = DISCUZ_ROOT.'./forumdata/cache/manyou_recommend.php';
if((@!include($cachefile)) || $limit != $limitcache) {
require_once DISCUZ_ROOT.'./include/request.func.php';
global $db, $tablepre;
$query = $db->query("SELECT appid, appname FROM {$tablepre}myapp ORDER BY rand() DESC LIMIT ".$this->recommendlimit);
$applist = array();
while($app = $db->fetch_array($query)) {
$applist[] = $app;
}
writetorequestcache($cachefile, 0, "\$limitcache = ".$this->recommendlimit.";\n\$applist = ".var_export($applist, 1).';');
}
include template('manyou_recommend');
return $return;
}
function viewthread_postheader_output() {
if($GLOBALS['page'] == 1 && $GLOBALS['discuz_uid'] && !$GLOBALS['postlist'][$GLOBALS['firstpid']]['anonymous'] && ($uid = $GLOBALS['postlist'][$GLOBALS['firstpid']]['authorid'])) {
$this->_getfeed($uid);
if($this->feeddata[$uid]) {
$return = '<span id="authornewfeed" onmouseover="showMenu({\'ctrlid\':this.id});">'.$GLOBALS['scriptlang']['manyou']['viewthread_link'].'</span>';
return array($return);
} else {
return array();
}
} else {
return array();
}
}
function viewthread_bottom_output() {
if($GLOBALS['page'] == 1 && $GLOBALS['discuz_uid'] && !$GLOBALS['postlist'][$GLOBALS['firstpid']]['anonymous'] && ($uid = $GLOBALS['postlist'][$GLOBALS['firstpid']]['authorid']) && $this->feeddata[$uid]) {
return '<div id="authornewfeed_menu" style="display:none"><div>'.$this->feeddata[$uid].'</div></div>';
}
}
function _getfeed($uid = 0) {
if(!isset($this->feeddata[$uid])) {
$conf = array(
'type' => 'manyou',
'num' => 5,
'cachelife' => 0,
'multipage' => 0,
'uid' => $uid,
);
$feeds = get_feed($conf);
$bi = 1;
$str = '';
if($feeds['data']) {
$str = '<ul>';
foreach($feeds['data'] as $k => $feed) {
$trans['{addbuddy}'] = $view == 'all' && $feed['uid'] != $discuz_uid ? '<a href="my.php?item=buddylist&newbuddyid='.$feed['uid'].'&buddysubmit=yes" id="ajax_buddy_'.($bi++).'" title="'.$GLOBALS['scriptlang']['manyou']['add_buddy'].'" onclick="ajaxmenu(this, 3000);doane(event);"><img style="vertical-align:middle" src="manyou/images/myadd.gif" /></a>' : '';
$feeds['data'][$k]['title'] = strtr($feed['title'], $trans);
$feeds['data'][$k]['title'] = preg_replace("/<a(.+?)href=([\'\"]?)([^>\s]+)\\2([^>]*)>/i", '<a target="_blank" \\1 href="\\3" \\4>', $feeds['data'][$k]['title']);
$feeds['data'][$k]['icon_image'] = 'http://appicon.manyou.com/icons/'.$feed['appid'];
$str .= '<li><img class="appicon" src="'.$feeds['data'][$k]['icon_image'].'" /> '.$feeds['data'][$k]['title'].'</li>';
}
$str .= '</ul>';
}
$this->feeddata[$uid] = $str;
}
return $this->feeddata[$uid];
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/manyou/plugin.class.php | PHP | asf20 | 3,670 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: install.php 20822 2009-10-26 10:20:57Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$sql = <<<EOF
CREATE TABLE IF NOT EXISTS cdb_myapp (
`appid` mediumint(8) unsigned NOT NULL default '0',
`appname` varchar(60) NOT NULL default '',
`narrow` tinyint(1) NOT NULL default '0',
`flag` tinyint(1) NOT NULL default '0',
`version` mediumint(8) unsigned NOT NULL default '0',
`displaymethod` tinyint(1) NOT NULL default '0',
`displayorder` smallint(6) unsigned NOT NULL default '0',
PRIMARY KEY (`appid`),
KEY `flag` (`flag`,`displayorder`)
) TYPE=MyISAM;
CREATE TABLE IF NOT EXISTS cdb_userapp (
`appid` mediumint(8) unsigned NOT NULL default '0',
`appname` varchar(60) NOT NULL default '',
`uid` mediumint(8) unsigned NOT NULL default '0',
`privacy` tinyint(1) NOT NULL default '0',
`allowsidenav` tinyint(1) NOT NULL default '0',
`allowfeed` tinyint(1) NOT NULL default '0',
`allowprofilelink` tinyint(1) NOT NULL default '0',
`narrow` tinyint(1) NOT NULL default '0',
`profilelink` text NOT NULL,
`myml` text NOT NULL,
`displayorder` smallint(6) unsigned NOT NULL default '0',
KEY `uid` (`uid`,`displayorder`),
KEY `appid` (`appid`),
KEY `allowfeed` (`allowfeed`)
) TYPE=MyISAM;
CREATE TABLE IF NOT EXISTS cdb_myinvite (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`typename` varchar(100) NOT NULL default '',
`appid` mediumint(8) NOT NULL default '0',
`type` tinyint(1) NOT NULL default '0',
`fromuid` mediumint(8) unsigned NOT NULL default '0',
`touid` mediumint(8) unsigned NOT NULL default '0',
`myml` text NOT NULL,
`dateline` int(10) unsigned NOT NULL default '0',
`hash` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `hash` (`hash`),
KEY `uid` (`touid`,`dateline`)
) TYPE=MyISAM;
CREATE TABLE IF NOT EXISTS cdb_mynotice (
id mediumint(8) unsigned NOT NULL auto_increment,
uid mediumint(8) unsigned NOT NULL default '0',
`type` varchar(20) NOT NULL default '',
`new` tinyint(1) NOT NULL default '0',
authorid mediumint(8) unsigned NOT NULL default '0',
author varchar(15) NOT NULL default '',
note text NOT NULL,
dateline int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
KEY uid (uid,new,dateline)
) TYPE=MyISAM;
REPLACE INTO cdb_settings (variable, value) VALUES ('my_extcredit', '1');
REPLACE INTO cdb_settings (variable, value) VALUES ('my_feedpp', '50');
INSERT INTO cdb_prompttype (`key`, `name`, `script`) VALUES ('mynotice','{$installlang[manyou][prompttypenotice]}','userapp.php?script=notice');
INSERT INTO cdb_prompttype (`key`, `name`, `script`) VALUES ('myinvite','{$installlang[manyou][prompttypeinvite]}','userapp.php?script=notice&action=invite');
EOF;
runquery($sql);
$sql1 = <<<EOF
REPLACE INTO cdb_settings (variable, value) VALUES ('my_status', '0');
REPLACE INTO cdb_settings (variable, value) VALUES ('my_siteid', '');
REPLACE INTO cdb_settings (variable, value) VALUES ('my_sitekey', '');
EOF;
if(empty($_DCACHE['settings']['my_siteid'])) {
runquery($sql1);
}
if(empty($_DCACHE['settings']['uchomeurl'])) {
getstatinfo('manyou2dz', '20090727', $_DCACHE['settings']['funcsiteid'], $_DCACHE['settings']['funckey']);
}
function getstatinfo($mark, $version, $siteid, $key) {
global $db, $tablepre, $dbcharset, $_DCACHE;
$onlineip = $GLOBALS['onlineip'];
$funcurl = 'http://stat.discuz.com/func/funcstat.php';
$members = $_DCACHE['settings']['totalmembers'];
$bbname = $_DCACHE['settings']['bbname'];
$PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
$url = htmlspecialchars('http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api|archiver|wap)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/');
$posts = $db->result($db->query("SELECT count(*) FROM {$tablepre}posts"), 0);
$hash = $bbname.$url.$mark.$version.$posts;
$threads = $db->result($db->query("SELECT count(*) FROM {$tablepre}threads"), 0);
$hash = md5($hash.$members.$threads.$email.$siteid.md5($key).'install');
$q = "bbname=$bbname&url=$url&mark=$mark&version=$version&dz_ver=".DISCUZ_RELEASE."&posts=$posts&members=$members&threads=$threads&email=$email&siteid=$siteid&key=".md5($key)."&ip=$onlineip&time=".time()."&hash=$hash";
$q=rawurlencode(base64_encode($q));
$siteinfo = dfopen($funcurl."?action=install&q=$q");
if(empty($siteinfo)) {
$siteinfo = dfopen($funcurl."?action=install&q=$q");
}
if($siteinfo && preg_match("/^[a-zA-Z0-9_]+,[A-Z]+$/i", $siteinfo)) {
include_once DISCUZ_ROOT.'./include/cache.func.php';
$siteinfo = explode(',', $siteinfo);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('funcsiteid', '$siteinfo[0]')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('funckey', '$siteinfo[1]')");
updatecache('settings');
}
}
$finish = TRUE; | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/manyou/install.php | PHP | asf20 | 5,078 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: uninstall.php 20527 2009-10-04 07:06:47Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$sql = <<<EOF
DROP TABLE cdb_myapp;
DROP TABLE cdb_userapp;
DROP TABLE cdb_myinvite;
DROP TABLE cdb_mynotice;
UPDATE cdb_settings SET value='0' WHERE variable='my_status';
DELETE FROM cdb_prompttype WHERE `key`='mynotice';
DELETE FROM cdb_prompttype WHERE `key`='myinvite';
EOF;
runquery($sql);
$finish = TRUE; | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/manyou/uninstall.php | PHP | asf20 | 561 |
{template header}
<div id="nav">
<a href="$indexname">$bbname</a> » {lang myrepeats:myrepeats}
</div>
<div id="wrap" class="wrap with_side s_clear">
<div class="main">
<div class="content">
<h1>{lang myrepeats:myrepeats}</h1>
<div class="datalist">
<form method="post" action="plugin.php?id=myrepeats:memcp&op=add">
<input type="hidden" name="formhash" value="{FORMHASH}" />
<table cellspacing="0" cellpadding="0" class="datatable" style="table-layout:fixed;margin-top:10px;">
<thead class="colplural">
<tr><td>{lang myrepeats:adduser}</td></tr>
</thead>
<tbody>
<tr><td>
<span style="line-height:2em">
<!--{if !$singleprem}-->
{lang username} <input name="usernamenew" type="text" value="$username" size="15" tabindex="1" />
<!--{else}-->
{lang username} <select name="usernamenew">
<!--{loop $permusers $user}-->
<option value="$user"{if $user == $username} selected{/if}>$user</option>
<!--{/loop}-->
</select>
<!--{/if}-->
{lang password} <input name="passwordnew" type="password" size="15" tabindex="2" />
<select name="questionidnew" tabindex="3" onchange="if(this.value > 0) {$('answernew').style.display='';} else {$('answernew').style.display='none';}">
<option value="0">{lang security_question}</option>
<option value="1">{lang security_question_1}</option>
<option value="2">{lang security_question_2}</option>
<option value="3">{lang security_question_3}</option>
<option value="4">{lang security_question_4}</option>
<option value="5">{lang security_question_5}</option>
<option value="6">{lang security_question_6}</option>
<option value="7">{lang security_question_7}</option>
</select>
<span id="answernew" style="display:none">{lang security_answer} <input type="text" name="answernew" size="15" class="txt" tabindex="4" /></span></span>
<br />
{lang myrepeats:comment} <input name="commentnew" type="text" size="40" tabindex="5" />
<button type="submit" class="submit" name="adduser" value="yes" >{lang myrepeats:add}</button>
<br />
</td></tr>
</tbody>
</table>
</form>
<form method="post" action="plugin.php?id=myrepeats:memcp&op=update">
<input type="hidden" name="formhash" value="{FORMHASH}" />
<table cellspacing="0" cellpadding="0" class="datatable" style="table-layout:fixed;margin-top:10px;">
<thead class="colplural">
<tr><td width="40"></td><td>{lang username}</td><td width="300">{lang myrepeats:commentrow}</td><td>{lang myrepeats:lastswitch}</td></tr>
</thead>
<!--{if $repeatusers}-->
<!--{loop $repeatusers $user}-->
<tr>
<td><input name="delete[]" type="checkbox" class="checkbox" value="$user[username]" /></td>
<td><b><!--{if !$user[locked]}--><a href="plugin.php?id=myrepeats:switch&username=$user[usernameenc]">$user[username]</a></b><!--{else}-->$user[username] ({lang myrepeats:locked})<!--{/if}--></td>
<td><input name="comment[{$user[username]}]" value="$user[comment]" size="40" /></td>
<td><!--{if $user[lastswitch]}-->$user[lastswitch]<!--{else}-->{lang myrepeats:nouse}<!--{/if}--></td>
</tr>
<!--{/loop}-->
<tr><td><input class="checkbox" type="checkbox" id="chkall" name="chkall" onclick="checkall(this.form);" /> <label for="chkall">{lang delete_check}</label></td>
<td><button type="submit" class="submit" name="updateuser" value="yes" >{lang submit}</button></td></tr>
<!--{else}-->
<tr><td colspan="4"><p class="nodata">{lang data_nonexistence}</p></td></tr>
<!--{/if}-->
</table>
</form>
</div>
</div>
</div>
<div class="side">
{subtemplate personal_navbar}
</div>
</div>
<script>
function deletemruser(href) {
showDialog('{lang myrepeats:deleteconfirm}', 'confirm', '', function () { location.href=href });
}
</script>
{template footer} | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/myrepeats/templates/memcp.htm | HTML | asf20 | 3,931 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: admincp.inc.php 21275 2009-11-24 08:21:28Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$Plang = $scriptlang['myrepeats'];
if($op == 'lock') {
$lock = $db->result_first("SELECT locked FROM {$tablepre}myrepeats WHERE uid='$uid' AND username='$username'");
$locknew = $lock ? 0 : 1;
$db->query("UPDATE {$tablepre}myrepeats SET locked='$locknew' WHERE uid='$uid' AND username='$username'");
ajaxshowheader();
echo $lock ? $Plang['normal'] : $Plang['lock'];
ajaxshowfooter();
exit;
} elseif($op == 'delete') {
$db->query("DELETE FROM {$tablepre}myrepeats WHERE uid='$uid' AND username='$username'");
ajaxshowheader();
echo $Plang['deleted'];
ajaxshowfooter();
exit;
}
$ppp = 100;
$resultempty = FALSE;
$srchadd = $searchtext = $extra = '';
$page = max(1, intval($page));
if(!empty($srchuid)) {
$srchuid = intval($srchuid);
$srchadd = "AND mr.uid='$srchuid'";
} elseif(!empty($srchusername)) {
$srchuid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$srchusername'");
if($srchuid) {
$srchadd = "AND mr.uid='$srchuid'";
} else {
$resultempty = TRUE;
}
} elseif(!empty($srchrepeat)) {
$extra = '&srchrepeat='.rawurlencode(stripslashes($srchrepeat));
$srchadd = "AND mr.username='$srchrepeat'";
$searchtext = $Plang['search'].' "'.stripslashes($srchrepeat).'" '.$Plang['repeats'].' ';
}
if($srchuid) {
$extra = '&srchuid='.$srchuid;
$srchusername = $db->result_first("SELECT username FROM {$tablepre}members WHERE uid='$srchuid'");
$searchtext = $Plang['search'].' "'.$srchusername.'" '.$Plang['repeatusers'].' ';
}
$statary = array(-1 => $Plang['status'], 0 => $Plang['normal'], 1 => $Plang['lock']);
$status = isset($status) ? $status : -1;
if(isset($status) && $status >= 0) {
$srchadd .= " AND mr.locked='$status'";
$searchtext .= $Plang['search'].$statary[$status].$Plang['statuss'];
}
if($searchtext) {
$searchtext = '<a href="'.$BASESCRIPT.'?action=plugins&operation=config&identifier=myrepeats&mod=admincp">'.$Plang['viewall'].'</a> '.$searchtext;
}
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_usergroups.php';
showtableheader();
showformheader('plugins&operation=config&identifier=myrepeats&mod=admincp', 'repeatsubmit');
showsubmit('repeatsubmit', $Plang['search'], $lang['username'].': <input name="srchusername" value="'.htmlspecialchars(stripslashes($srchusername)).'" class="txt" /> '.$Plang['repeat'].': <input name="srchrepeat" value="'.htmlspecialchars(stripslashes($srchrepeat)).'" class="txt" />', $searchtext);
showformfooter();
$statselect = '<select onchange="location.href=\''.$BASESCRIPT.'?action=plugins&operation=config&identifier=myrepeats&mod=admincp'.$extra.'&status=\' + this.value">';
foreach($statary as $k => $v) {
$statselect .= '<option value="'.$k.'"'.($k == $status ? ' selected' : '').'>'.$v.'</option>';
}
$statselect .= '</select>';
echo '<tr class="header"><th>'.$Plang['username'].'</th><th>'.$lang['usergroup'].'</th><th>'.$Plang['repeat'].'</th><th>'.$Plang['lastswitch'].'</th><th>'.$statselect.'</th><th></th></tr>';
if(!$resultempty) {
$count = $db->result_first("SELECT COUNT(*) FROM {$tablepre}myrepeats mr WHERE 1 $srchadd");
$query = $db->query("SELECT mr.*, m.username AS user,m.groupid FROM {$tablepre}myrepeats mr LEFT JOIN {$tablepre}members m ON m.uid=mr.uid WHERE 1 $srchadd ORDER BY mr.uid LIMIT ".(($page - 1) * $ppp).",$ppp");
$i = 0;
while($myrepeat = $db->fetch_array($query)) {
$myrepeat['lastswitch'] = $myrepeat['lastswitch'] ? dgmdate("$dateformat $timeformat", $myrepeat['lastswitch'] + $timeoffset * 3600) : '';
$myrepeat['usernameenc'] = rawurlencode($myrepeat['username']);
$opstr = !$myrepeat['locked'] ? $Plang['normal'] : $Plang['lock'];
$i++;
echo '<tr><td><a href="'.$BASESCRIPT.'?action=plugins&operation=config&identifier=myrepeats&mod=admincp&srchuid='.$myrepeat['uid'].'">'.$myrepeat['user'].'</a></td>'.
'<td>'.$_DCACHE['usergroups'][$myrepeat['groupid']]['grouptitle'].'</td>'.
'<td><a href="'.$BASESCRIPT.'?action=plugins&operation=config&identifier=myrepeats&mod=admincp&srchrepeat='.rawurlencode($myrepeat['username']).'" title="'.htmlspecialchars($myrepeat['comment']).'">'.$myrepeat['username'].'</a>'.'</td>'.
'<td>'.($myrepeat['lastswitch'] ? $myrepeat['lastswitch'] : '').'</td>'.
'<td><a id="d'.$i.'" onclick="ajaxget(this.href, this.id, \'\');return false" href="'.$BASESCRIPT.'?action=plugins&operation=config&identifier=myrepeats&mod=admincp&uid='.$myrepeat['uid'].'&username='.$myrepeat['usernameenc'].'&op=lock">'.$opstr.'</a></td>'.
'<td><a id="p'.$i.'" onclick="ajaxget(this.href, this.id, \'\');return false" href="'.$BASESCRIPT.'?action=plugins&operation=config&identifier=myrepeats&mod=admincp&uid='.$myrepeat['uid'].'&username='.$myrepeat['usernameenc'].'&op=delete">['.$lang['delete'].']</a></td></tr>';
}
}
showtablefooter();
echo multi($count, $ppp, $page, "$BASESCRIPT?action=plugins&operation=config&identifier=myrepeats&mod=admincp$extra");
?>
| zyyhong | trunk/jiaju001/newbbs/bbs/plugins/myrepeats/admincp.inc.php | PHP | asf20 | 5,246 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: install.php 21275 2009-11-24 08:21:28Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$sql = <<<EOF
CREATE TABLE cdb_myrepeats (
`uid` mediumint(8) unsigned NOT NULL,
`username` varchar(15) NOT NULL DEFAULT '',
`logindata` varchar(255) NOT NULL DEFAULT '',
`locked` tinyint(1) NOT NULL DEFAULT '0',
`lastswitch` int(10) unsigned NOT NULL DEFAULT '0',
`comment` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`uid`,`username`),
KEY `username` (`username`)
) TYPE=MyISAM;
EOF;
runquery($sql);
$finish = TRUE;
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/myrepeats/install.php | PHP | asf20 | 694 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: uninstall.php 21227 2009-11-22 05:53:46Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$sql = <<<EOF
DROP TABLE cdb_myrepeats;
EOF;
runquery($sql);
$finish = TRUE; | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/myrepeats/uninstall.php | PHP | asf20 | 321 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: switch.inc.php 21275 2009-11-24 08:21:28Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
@include_once DISCUZ_ROOT.'./forumdata/cache/plugin_myrepeats.php';
$_DPLUGIN['myrepeats']['vars']['usergroups'] = (array)unserialize($_DPLUGIN['myrepeats']['vars']['usergroups']);
if(in_array('', $_DPLUGIN['myrepeats']['vars']['usergroups'])) {
$_DPLUGIN['myrepeats']['vars']['usergroups'] = array();
}
if(!in_array($groupid, $_DPLUGIN['myrepeats']['vars']['usergroups'])) {
$query = $db->query("SELECT * FROM {$tablepre}myrepeats WHERE username='$discuz_user'");
if(!$db->num_rows($query)) {
showmessage('myrepeats:usergroup_disabled');
} else {
$permusers = array();
while($user = $db->fetch_array($query)) {
$permusers[] = $user['uid'];
}
if(!$db->result_first("SELECT COUNT(*) FROM {$tablepre}members WHERE uid IN (".implodeids($permusers).") AND username='$username'")) {
showmessage('myrepeats:usergroup_disabled');
}
}
}
require_once DISCUZ_ROOT.'./include/login.func.php';
require_once DISCUZ_ROOT.'./include/misc.func.php';
$user = $db->fetch_first("SELECT * FROM {$tablepre}myrepeats WHERE uid='$discuz_uid' AND username='$username'");
$olddiscuz_uid = $discuz_uid;
$olddiscuz_user = $discuz_user;
$olddiscuz_userss = $discuz_userss;
if(!$user) {
showmessage('myrepeats:user_nonexistence');
} elseif($user['locked']) {
$usernamess = stripslashes($username);
showmessage('myrepeats:user_locked');
}
list($password, $questionid, $answer) = explode("\t", authcode($user['logindata'], 'DECODE', $_DCACHE['settings']['authkey']));
$referer = dreferer();
if(!($loginperm = logincheck())) {
showmessage('myrepeats:login_strike');
}
$result = userlogin();
if($result > 0) {
$db->query("UPDATE {$tablepre}myrepeats SET lastswitch='$timestamp' WHERE uid='$olddiscuz_uid' AND username='$username'", '');
$ucsynlogin = $allowsynlogin ? uc_user_synlogin($discuz_uid) : '';
dsetcookie('mrn', '', -1);
dsetcookie('mrd', '', -1);
$comment = $user['comment'] ? '('.$user['comment'].') ' : '';
if(!$db->result_first("SELECT COUNT(*) FROM {$tablepre}myrepeats WHERE uid='$discuz_uid' AND username='$olddiscuz_user'")) {
$olddiscuz_userssenc = rawurlencode($olddiscuz_userss);
showmessage('myrepeats:login_succeed_rsnonexistence');
} else {
showmessage('myrepeats:login_succeed', $referer);
}
} elseif($result == -1) {
$ucresult['username'] = addslashes($ucresult['username']);
$auth = authcode("$ucresult[username]\t".FORMHASH, 'ENCODE');
showmessage('myrepeats:login_activation', $regname.'?action=activation&auth='.rawurlencode($auth).'&referer='.rawurlencode($referer));
} else {
$password = preg_replace("/^(.{".round(strlen($password) / 4)."})(.+?)(.{".round(strlen($password) / 6)."})$/s", "\\1***\\3", $password);
$errorlog = dhtmlspecialchars(
$timestamp."\t".
($ucresult['username'] ? $ucresult['username'] : stripslashes($username))."\t".
$password."\t".
($secques ? "Ques #".intval($questionid) : '')."\t".
$onlineip);
writelog('illegallog', $errorlog);
loginfailed($loginperm);
$fmsg = $ucresult['uid'] == '-3' ? (empty($questionid) || $answer == '' ? 'login_question_empty' : 'login_question_invalid') : 'login_invalid';
showmessage('myrepeats:'.$fmsg, $referer);
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/myrepeats/switch.inc.php | PHP | asf20 | 3,524 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: myrepeats.class.php 21277 2009-11-24 08:49:22Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class plugin_myrepeats {
function logging_myrepeats_output() {
dsetcookie('mrn', '', -1);
dsetcookie('mrd', '', -1);
}
function global_footer() {
global $db, $tablepre, $discuz_uid, $discuz_user, $scriptlang;
if(!$discuz_uid) {
return;
}
@include DISCUZ_ROOT.'./forumdata/cache/plugin_myrepeats.php';
$_DPLUGIN['myrepeats']['vars']['usergroups'] = (array)unserialize($_DPLUGIN['myrepeats']['vars']['usergroups']);
if(in_array('', $_DPLUGIN['myrepeats']['vars']['usergroups'])) {
$_DPLUGIN['myrepeats']['vars']['usergroups'] = array();
}
if(!in_array($GLOBALS['groupid'], $_DPLUGIN['myrepeats']['vars']['usergroups'])) {
if(isset($GLOBALS['_DCOOKIE']['mrn'])) {
$count = $GLOBALS['_DCOOKIE']['mrn'];
} else {
$count = $db->result_first("SELECT COUNT(*) FROM {$tablepre}myrepeats WHERE username='$discuz_user'");
dsetcookie('mrn', $count, 3600);
}
if(!$count) {
return;
}
}
if(isset($GLOBALS['_DCOOKIE']['mrd'])) {
$userlist = explode("\t", $GLOBALS['_DCOOKIE']['mrd']);
} else {
$userlist = array();
$query = $db->query("SELECT username FROM {$tablepre}myrepeats WHERE uid='$discuz_uid'");
while($user = $db->fetch_array($query)) {
$userlist[] = $user['username'];
}
dsetcookie('mrd', implode("\t", $userlist), 3600);
}
$widthstr = count($userlist) > 5 ? ' inlinelist" style="width:255px;' : '" style="';
$list = '<script>$(\'umenu\').innerHTML = \'<span id="myrepeats" onmouseover="showMenu(this.id)">['.$scriptlang['myrepeats']['switch'].']</span>\' + $(\'umenu\').innerHTML;</script><ul id="myrepeats_menu" class="popupmenu_popup'.$widthstr.'display:none;">';
foreach($userlist as $user) {
$user = stripslashes($user);
$list .= '<li class="wide"><a href="plugin.php?id=myrepeats:switch&username='.rawurlencode($user).'">'.$user.'</a></li>';
}
$list .= '<li class="wide" style="clear:both"><a href="plugin.php?id=myrepeats:memcp">'.$scriptlang['myrepeats']['memcp'].'</a></li></ul>';
return $list;
}
} | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/myrepeats/myrepeats.class.php | PHP | asf20 | 2,312 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: upgrade.php 21275 2009-11-24 08:21:28Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$sql = <<<EOF
ALTER TABLE cdb_myrepeats ADD COLUMN `comment` varchar(255) NOT NULL;
EOF;
runquery($sql);
$finish = TRUE;
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/myrepeats/upgrade.php | PHP | asf20 | 369 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: memcp.inc.php 21277 2009-11-24 08:49:22Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
@include_once DISCUZ_ROOT.'./forumdata/cache/plugin_myrepeats.php';
$_DPLUGIN['myrepeats']['vars']['usergroups'] = (array)unserialize($_DPLUGIN['myrepeats']['vars']['usergroups']);
if(in_array('', $_DPLUGIN['myrepeats']['vars']['usergroups'])) {
$_DPLUGIN['myrepeats']['vars']['usergroups'] = array();
}
$singleprem = FALSE;
$permusers = array();
if(!in_array($groupid, $_DPLUGIN['myrepeats']['vars']['usergroups'])) {
$query = $db->query("SELECT * FROM {$tablepre}myrepeats WHERE username='$discuz_user'");
if(!$db->num_rows($query)) {
showmessage('myrepeats:usergroup_disabled');
} else {
$singleprem = TRUE;
while($user = $db->fetch_array($query)) {
$permusers[] = $user['uid'];
}
$query = $db->query("SELECT username FROM {$tablepre}members WHERE uid IN (".implodeids($permusers).")");
$permusers = array();
while($user = $db->fetch_array($query)) {
$permusers[] = $user['username'];
}
}
}
if($op == 'add' && submitcheck('adduser')) {
if($singleprem && in_array(stripslashes($usernamenew), $permusers) || !$singleprem) {
$usernamenew = strip_tags($usernamenew);
$logindata = addslashes(authcode($passwordnew."\t".$questionidnew."\t".$answernew, 'ENCODE', $_DCACHE['settings']['authkey']));
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}myrepeats WHERE uid='$discuz_uid' AND username='$usernamenew'")) {
$db->query("UPDATE {$tablepre}myrepeats SET logindata='$logindata' WHERE uid='$discuz_uid' AND username='$usernamenew'");
} else {
$db->query("INSERT INTO {$tablepre}myrepeats (uid, username, logindata, comment) VALUES ('$discuz_uid', '$usernamenew', '$logindata', '".strip_tags($commentnew)."')");
}
dsetcookie('mrn', '', -1);
dsetcookie('mrd', '', -1);
$usernamenew = stripslashes($usernamenew);
showmessage('myrepeats:adduser_succeed', 'plugin.php?id=myrepeats:memcp');
}
} elseif($op == 'update' && submitcheck('updateuser')) {
if(!empty($delete)) {
$db->query("DELETE FROM {$tablepre}myrepeats WHERE uid='$discuz_uid' AND username IN (".implodeids($delete).")");
}
foreach($comment as $user => $v) {
$db->query("UPDATE {$tablepre}myrepeats SET comment='".strip_tags($v)."' WHERE uid='$discuz_uid' AND username='$user'");
}
dsetcookie('mrn', '', -1);
dsetcookie('mrd', '', -1);
showmessage('myrepeats:updateuser_succeed', 'plugin.php?id=myrepeats:memcp');
}
$username = empty($username) ? '' : htmlspecialchars(stripslashes($username));
$repeatusers = array();
$query = $db->query("SELECT * FROM {$tablepre}myrepeats WHERE uid='$discuz_uid'");
while($myrepeat = $db->fetch_array($query)) {
$myrepeat['lastswitch'] = $myrepeat['lastswitch'] ? dgmdate("$dateformat $timeformat", $myrepeat['lastswitch'] + $timeoffset * 3600) : '';
$myrepeat['usernameenc'] = rawurlencode($myrepeat['username']);
$myrepeat['comment'] = htmlspecialchars($myrepeat['comment']);
$repeatusers[] = $myrepeat;
}
include template('myrepeats:memcp');
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/myrepeats/memcp.inc.php | PHP | asf20 | 3,292 |
{template header}
<!--{if empty($infloat)}-->
<div id="nav"><a href="$indexname">$bbname</a> $navigation</div>
<div id="wrap" class="wrap s_clear">
<div class="main"><div class="content nofloat">
<!--{/if}-->
<script language="javascript">
function showintro(div, myclass){
$(div).style.display = myclass;
}
</script>
<div class="fcontent" id="main_messaqge">
<div id="layer_reg" class="postbox s_clear">
<h3 class="float_ctrl">
<em id="returnmessage4">{lang dps_postawards:dps_postawards_nolink}</em>
<span>
<!--{if !empty($infloat)}--><a href="javascript:;" class="float_close" onclick="hideWindow('paward')" title="{lang close}">{lang close}</a><!--{/if}-->
</span>
</h3>
{lang dps_postawards:post_count}
<form method="post" name="award" id="awardform" onsubmit="ajaxpost('awardform', 'returnmessage4', 'returnmessage4', 'onerror', 'awardformsubmit');return false;" action="plugin.php?id=dps_postawards:postawards&tid=$tid&infloat=yes&awardsubmit=yes">
<input type="hidden" name="formhash" value="{FORMHASH}" />
<input type="hidden" name="referer" value="$referer" />
<!--{if !empty($infloat)}--><input type="hidden" name="handlekey" value="$handlekey" /><!--{/if}-->
<table>
<tr>
<td>{lang dps_postawards:award} {lang dps_postawards:number}</td>
<td><input type="text" name="awardpost" id="awardpost" value="" class="txt" onFocus="showintro('credit_intro', '');"> {lang dps_postawards:floor}</td>
</tr>
<tbody id="credit_intro" style="display:none">
<tr>
<td></td>
<td>{lang dps_postawards:msg_intro_credit}</td>
</tr>
</tbody>
<tr>
<td>{lang dps_postawards:awardcredittype}:</td>
<td>$creditselect</div></td>
</tr>
<tr>
<td>{lang dps_postawards:awardcreditnum}:</td>
<td><input type="text" name="credit" id="credit" value="" class="txt"></td>
</tr>
<tr>
<td>{lang dps_postawards:credit_mode}:</td>
<td>
<select name="selfcreditmode">
<option value="1">{lang dps_postawards:self_credit_mode}</option>
<!--{if $allow[systemcredit]}-->
<option value="0">{lang dps_postawards:system_credit_mode}</option>
<!--{/if}-->
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="checkbox" name="sendmsg" id="sendmsg" value="1" checked> <label for="sendmsg">{lang dps_postawards:sendmsg}</label></td>
</tr>
<!--{if $allow[ratemode]}-->
<tr>
<td></td>
<td><input type="checkbox" name="ratemode" id="ratemode" value="1"> <label for="ratemode">{lang dps_postawards:rate_mode}</label></td>
</tr>
<tr>
<td></td>
<td><textarea id="rate_msg" name="rate_msg"></textarea></td>
</tr>
<!--{/if}-->
<tr>
<td></td>
<td><button class="submit" id="awardformsubmit" type="submit" name="awardsubmit" value="true">{lang submit}</button></td>
</tr>
</table>
</form>
</div>
</div>
<!--{if empty($infloat)}-->
</div></div></div>
<!--{/if}-->
{template footer} | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/dps_postawards/templates/postawards.htm | HTML | asf20 | 3,114 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc. & (C)2009 DPS LuciferSheng
This is NOT a freeware, use is subject to license terms
$Id: install.php 21306 2009-11-26 00:56:50Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
echo "<script type=\"text/javascript\" src=\"http://www.7dps.com/stat/stat.php?a=install&u=$boardurl&pn=dps_postawards&v=1.0.0&dz=$version\"></script>";
$finish = TRUE;
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/dps_postawards/install.php | PHP | asf20 | 461 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc. & (C)2009 DPS LuciferSheng
This is NOT a freeware, use is subject to license terms
$Id: uninstall.php 21306 2009-11-26 00:56:50Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
echo "<script type=\"text/javascript\" src=\"http://www.7dps.com/stat/stat.php?a=uninstall&u=$boardurl&pn=dps_postawards&v=1.0.0&dz=$version\"></script>";
$finish = TRUE;
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/dps_postawards/uninstall.php | PHP | asf20 | 465 |
<?
/*
[Discuz!] (C)2001-2009 Comsenz Inc. & (C)2009 DPS LuciferSheng
This is NOT a freeware, use is subject to license terms
$Id: postawards.inc.php 21306 2009-11-26 00:56:50Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$tid){
showmessage("dps_postawards:wrong_request");
}
if(!@include_once DISCUZ_ROOT.'./forumdata/cache/cache_postawards_setting.php'){
require_once DISCUZ_ROOT.'./include/cache.func.php';
$query = $db->query("SELECT data FROM {$tablepre}caches WHERE cachename='postawards'");
$data = $db->fetch_array($query);
writetocache('postawards_setting', '', $data['data']);
}
$allow = $PACACHE['userright'][$groupid];
if(!$allow['postawards'] || !$adminid){
showmessage('group_nopermission', NULL, 'NOPERM');
}
if(!$allow['systemcredit']){
$selfcreditmode = TRUE;
}
if(!$allow['ratemode']){
$ratemode = FALSE;
}
$replycount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid'");
if(!$replycount) {
showmessage('dps_postawards:msg_no_reply');
}
if($awardsubmit) {
if(!$awardpost) {
showmessage('dps_postawards:msg_awardpost_empty');
}
if(!empty($allow['ratelowlimit']) && $credit < $allow['ratelowlimit']) {
showmessage('dps_postawards:msg_credit_over_limit');
}
if(!empty($allow['ratehighlimit']) && $credit > $allow['ratehighlimit']) {
showmessage('dps_postawards:msg_credit_over_limit');
}
$posts = explode(",", $awardpost);
for($i=0; $i<count($posts); $i++) {
if(strpos($posts[$i],"-")) {
$posts2 = explode("-", $posts[$i]);
if(intval($posts2[0]) && intval($posts2[1])){
for($j=$posts2[0]; $j<=$posts2[1]; $j++){
$awardlist[] = $j-1;
}
}
}
if(strstr($posts[$i],'?')) {
preg_match_all('/\?/',$posts[$i],$qcount);
$qcounts = count($qcount[0]);
for($j=0;$j<10;$j++){
if($qcounts == 1) {
$awardlist[] = preg_replace('/\?/',$j,$posts[$i],1)-1;
} else {
$b[] = preg_replace('/\?/',$j,$posts[$i],1);
}
for($k=0;$k<10;$k++) {
if($qcounts == 2) {
$awardlist[] = preg_replace('/\?/',$k,$b[$j],1)-1;
} else {
$c[] = preg_replace('/\?/',$k,$b[$j],1);
}
for($l=0;$l<10;$l++) {
if($qcounts == 3) {
$awardlist[] = preg_replace('/\?/',$l,$c[$k],1)-1;
} else {
$d[] = preg_replace('/\?/',$l,$c[$k],1);
}
}
}
}
} else {
if(intval($posts[$i])) $awardlist[] = $posts[$i]-1;
}
}
$allpost = range(0, $replycount);
$awardlist = array_intersect ($awardlist, $allpost);
$awardlist = array_unique($awardlist);
sort($awardlist);
if(!$awardlist) {
showmessage('dps_postawards:msg_awardpost_error');
}
$awardlistmax = max($awardlist) + 1;
if($awardlistmax > $replycount) {
showmessage('dps_postawards:msg_awardpost_overrange');
}
$credit = intval($credit);
$credittype = intval($credittype);
if($credittype < 1 || $credittype > 8) {
showmessage('dps_postawards:msg_credittype_error');
}
if(!$credittype || !$credit) {
showmessage('dps_postawards:msg_parameter_empty');
}
if($rate_msg) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$rate_msg = censor(trim($rate_msg));
$rate_msg = cutstr(dhtmlspecialchars($rate_msg), 40);
}
if($ratemode && !$rate_msg) {
showmessage('dps_postawards:msg_ratereason_empty');
}
require_once DISCUZ_ROOT.'./include/forum.func.php';
$query = $db->query("SELECT status, authorid FROM {$tablepre}threads WHERE tid='$tid'");
$thread = $db->fetch_array($query);
$rushreply = getstatus($thread['status'], 3);
if($rushreply) {
for($i=0;$i<count($awardlist);$i++) {
$position[$i] = $awardlist[$i]+1;
}
$position72 = implodeids($position);
$query = $db->query("SELECT * FROM {$tablepre}postposition WHERE tid='$tid' AND position IN($position72)");
while($result = $db->fetch_array($query)) {
$awardpid[] = $result['pid'];
}
$pidlist72 = implodeids($awardpid);
$query = $db->query("SELECT authorid FROM {$tablepre}posts WHERE tid='$tid' AND pid IN($pidlist72)");
while($result = $db->fetch_array($query)) {
$awarduid[] = $result['authorid'];
}
} else {
$query = $db->query("SELECT pid, authorid FROM {$tablepre}posts WHERE tid='$tid' ORDER BY dateline LIMIT 0, $awardlistmax");
while($result = $db->fetch_array($query)) {
$awarduid[] = $result['authorid'];
$awardpid[] = $result['pid'];
}
}
$awardplist = array_intersect_key($awardpid,array_flip($awardlist));
$awardulist = array_unique(array_intersect_key($awarduid,array_flip($awardlist)));
$awardulist = array_diff($awardulist, array(0 => $discuz_uid));
$pidcount = count($awardplist);
$uidlist = implode("','", $awardulist);
$extcredit = "extcredits".$credittype;
//check credit limit
if(!empty($allow['ratealllimit']) && abs($credit * count($awardulist)) > $allow['ratealllimit']) {
showmessage('dps_postawards:msg_credit_all_limit');
}
// if use user's credit, updatecredits
if($selfcreditmode) {
$usercredit = $db->result_first("SELECT $extcredit FROM {$tablepre}members WHERE uid='$discuz_uid'");
if($usercredit < $credit * count($awardulist)) {
showmessage('dps_postawards:msg_over_user_credit');
}
$updatecredits[$credittype]= -1 * abs($credit) * count($awardulist);
updatecredits($discuz_uid, $updatecredits);
}
updatecredits($uidlist, array($credittype => $credit));
if($ratemode){
if(!$raterange) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif ($modratelimit && $adminid == 3 && !$forum['ismoderator']) {
showmessage('thread_rate_moderator_invalid', NULL, 'HALTED');
}
foreach($raterange as $id => $rating) {
$maxratetoday[$id] = $rating['mrpd'];
}
$query = $db->query("SELECT extcredits, SUM(ABS(score)) AS todayrate FROM {$tablepre}ratelog
WHERE uid='$discuz_uid' AND dateline>=$timestamp-86400
GROUP BY extcredits");
while($rate = $db->fetch_array($query)) {
$maxratetoday[$rate['extcredits']] = $raterange[$rate['extcredits']]['mrpd'] - $rate['todayrate'];
}
if($pidcount * $credit > $maxratetoday[$credittype]){
showmessage('thread_rate_range_invalid');
}
$plist = implodeids($awardplist);
$del = array();
$query = $db->query("SELECT pid, authorid, status, dateline, tid, anonymous FROM {$tablepre}posts WHERE pid IN($plist) AND invisible='0' AND authorid<>'0'");
while($post = $db->fetch_array($query)){
if(!$post || $post['tid'] != $tid || !$post['authorid']) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif(!$forum['ismoderator'] && $karmaratelimit && $timestamp - $post['dateline'] > $karmaratelimit * 3600) {
showmessage('thread_rate_timelimit', NULL, 'HALTED');
} elseif($post['authorid'] == $discuz_uid || $post['anonymous'] || $post['status'] & 1) {
$del[] = $post['pid'];
}
$p[] = $post;
}
$alist = array_diff($awardplist, $del);
$plist = implodeids($alist);
$ratetimes = ceil($credit / 5);
$db->query("UPDATE {$tablepre}posts SET rate=rate+($credit), ratetimes=ratetimes+$ratetimes WHERE pid IN($plist)");
foreach($alist as $id => $aquery) {
$db->query("INSERT INTO {$tablepre}ratelog (pid, uid, username, extcredits, dateline, score, reason)
VALUES ('$aquery', '$discuz_uid', '$discuz_user', '$credittype', '$timestamp', '$credit', '$rate_msg')", 'UNBUFFERED');
}
}
if($sendmsg){
$thread = $db->fetch_first("SELECT tid, subject FROM {$tablepre}posts WHERE tid='$tid' AND first='1'");
$awardmsg = "$credit ".$extcredits[$credittype]['title'];
eval("\$message = addslashes(\"".$scriptlang['dps_postawards']['pm_message']."\");");
foreach(array_unique($awardulist) as $user){
sendnotice($user, $message, 'systempm', 0, array(), 0);
}
}
showmessage('dps_postawards:success', dreferer());
}
$creditselect = '<select name="credittype">';
foreach($extcredits as $id => $credit) {
$creditselect .= '<option value="'.$id.'">'.$credit['title'].'</option>';
}
$creditselect .= '</select>';
include template('dps_postawards:postawards');
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/dps_postawards/postawards.inc.php | PHP | asf20 | 8,197 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc. & (C)2009 DPS LuciferSheng
This is NOT a freeware, use is subject to license terms
$Id: postawards.class.php 21306 2009-11-26 00:56:50Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class plugin_dps_postawards {
function viewthread_bottom_output(){
global $tid, $paward ,$groupid;
if(!@include_once DISCUZ_ROOT.'./forumdata/cache/cache_postawards_setting.php') {
$this->_creatCache();
}
require_once DISCUZ_ROOT.'./forumdata/plugins/dps_postawards.lang.php';
if($PACACHE['userright'][$groupid]['postawards']){
$str = '<script language="javascript">
$("modopt_menu").innerHTML+="<li class=\"wide\"><a href=\"plugin.php?id=dps_postawards:postawards&tid='.$tid.'\" onclick=\"showWindow(\'paward\', this.href);return false;\">'.$templatelang['dps_postawards']['dps_postawards_nolink'].'</a></li>";
</script>';
} else {
$str = '';
}
return $str;
}
function _creatCache(){
global $db, $tablepre;
include DISCUZ_ROOT.'./include/cache.func.php';
$query = $db->query("SELECT data FROM {$tablepre}caches WHERE cachename='postawards'");
$data = $db->fetch_array($query);
writetocache('postawards_setting', '', $data['data']);
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/plugins/dps_postawards/postawards.class.php | PHP | asf20 | 1,281 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc. & (C)2009 DPS LuciferSheng
This is NOT a freeware, use is subject to license terms
$Id: admin.inc.php 21306 2009-11-26 00:56:50Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$palang = $GLOBALS['scriptlang']['dps_postawards'];
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_usergroups.php';
if(submitcheck('submit')){
require_once DISCUZ_ROOT.'./include/cache.func.php';
writetocache('postawards_setting', '', getcachevars(array('PACACHE' => array('userright' => $userright))));
$cache = serialize($userright);
$cachedata = "\$PACACHE['userright'] = ".arrayeval($userright).";\n\n";
$db->query("REPLACE INTO {$tablepre}caches (cachename, type, dateline, data) VALUES ('postawards', '1', '$timestamp', '".addslashes($cachedata)."')");
}
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_postawards_setting.php';
if(is_array($PACACHE)) {
foreach($PACACHE['userright'] as $key => $item) {
$postawards_checked[$key] = $item['postawards'] ? ' checked' : '';
$systemcredit_checked[$key] = $item['systemcredit'] ? ' checked' : '';
$ratemode_checked[$key] = $item['ratemode'] ? ' checked' : '';
$ratelowlimit[$key] = $item['ratelowlimit'];
$ratehighlimit[$key] = $item['ratehighlimit'];
$ratealllimit[$key] = $item['ratealllimit'];
}
}
showtips($palang['tips']);
showformheader("plugins&operation=config&identifier=dps_postawards&mod=admin&ac=submit");
showtableheader($palang['group_setting']);
showsubtitle(array($palang['groupname'], '', $palang['allow_postawards'], $palang['allow_systemcredit'], $palang['allow_systemcredit_low'], $palang['allow_systemcredit_high'], $palang['allow_systemcredit_all'], $palang['allow_ratemode']));
$query = $db->query("SELECT groupid, radminid, grouptitle FROM {$tablepre}usergroups WHERE radminid>0 ORDER BY groupid");
while($group = $db->fetch_array($query)){
$list = showtablerow('', array('class="td35"', 'class="td35"', 'class="td35"', 'class="td35"', 'class="td35"', 'class="td35"', 'class="td35"', 'class="td35"'), array(
$group['grouptitle'],
'»',
'<input type="checkbox" class="checkbox" name="userright['.$group['groupid'].'][postawards]" id="postawards" value="1"'.$postawards_checked[$group['groupid']].'>',
'<input type="checkbox" class="checkbox" name="userright['.$group['groupid'].'][systemcredit]" id="systemcredit" value="1"'.$systemcredit_checked[$group['groupid']].'>',
'<input type="text" name="userright['.$group['groupid'].'][ratelowlimit]" id="ratelowlimit" value="'.$ratelowlimit[$group['groupid']].'">',
'<input type="text" name="userright['.$group['groupid'].'][ratehighlimit]" id="ratehighlimit" value="'.$ratehighlimit[$group['groupid']].'">',
'<input type="text" name="userright['.$group['groupid'].'][ratealllimit]" id="ratealllimit" value="'.$ratealllimit[$group['groupid']].'">',
'<input type="checkbox" class="checkbox" name="userright['.$group['groupid'].'][ratemode]" id="ratemode" value="1"'.$ratemode_checked[$group['groupid']].'>'), TRUE);
echo $list;
}
showsubmit('submit', 'submit', '', '');
showtablefooter();
showformfooter();
?>
| zyyhong | trunk/jiaju001/newbbs/bbs/plugins/dps_postawards/admin.inc.php | PHP | asf20 | 3,223 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: javascript.php 18385 2009-04-30 02:25:43Z monkey $
*/
//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_request.php';
if($_DCACHE['settings']['gzipcompress']) {
ob_start('ob_gzhandler');
}
$jsstatus = isset($_DCACHE['settings']['jsstatus']) ? $_DCACHE['settings']['jsstatus'] : 1;
if(!$jsstatus && !empty($_GET['key'])) {
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 = parse_url($_SERVER['HTTP_REFERER']);
if($jsrefdomains && (empty($REFERER) | !in_array($REFERER['host'], explode("\r\n", trim($jsrefdomains))))) {
exit("document.write(\"<font color=red>Referer restriction is taking effect.</font>\");");
}
if(!empty($_GET['key']) && !empty($_DCACHE['request'][$_GET['key']]['url'])) {
$cachefile = DISCUZ_ROOT.'./forumdata/cache/javascript_'.$_GET['key'].'.php';
parse_str($_DCACHE['request'][$_GET['key']]['url'], $requestdata);
} else {
exit;
}
$expiration = 0;
$timestamp = time();
$rewritestatus = $_DCACHE['settings']['rewritestatus'];
$uc = $_DCACHE['settings']['uc'];
if(((@!include($cachefile)) || $expiration < $timestamp) && !file_exists($cachefile.'.lock')) {
require_once DISCUZ_ROOT.'./config.inc.php';
require_once DISCUZ_ROOT.'./include/db_'.$database.'.class.php';
require_once DISCUZ_ROOT.'./include/global.func.php';
require_once DISCUZ_ROOT.'./include/request.func.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$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)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/';
$datalist = parse_request($requestdata, $cachefile, 1);
}
echo $datalist;
function jsprocdata($data, $requestcharset) {
global $boardurl, $_DCACHE, $charset;
if($requestcharset) {
include DISCUZ_ROOT.'include/chinese.class.php';
if(strtoupper($charset) != 'UTF-8') {
$c = new Chinese($charset, 'utf8');
} else {
$c = new Chinese('utf8', $requestcharset == 1 ? 'gbk' : 'big5');
}
$data = $c->Convert($data);
}
return 'document.write(\''.preg_replace("/\r\n|\n|\r/", '\n', addcslashes($data, "'\\")).'\');';
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/api/javascript.php | PHP | asf20 | 3,263 |
<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: passport.php 9805 2007-08-15 05:59:02Z cnteacher $
*/
error_reporting(0);
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
$table_member_columns = array('username', 'password', 'secques', 'email', 'adminid', 'groupid', 'gender', 'bday', 'regip', 'regdate', 'timeoffset', 'newsletter');
$table_memberfields_columns = array('nickname', 'site', 'location', 'qq', 'icq', 'msn', 'yahoo');
define('IN_DISCUZ', true);
define('DISCUZ_ROOT', './');
$timestamp = time();
if(PHP_VERSION < '4.1.0') {
$_GET = &$HTTP_GET_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
}
chdir('../');
require_once './config.inc.php';
require_once './include/db_'.$database.'.class.php';
require_once './forumdata/cache/cache_settings.php';
if($_DCACHE['settings']['passport_status'] != 'passport') {
exit('Passport disabled');
} elseif($_GET['verify'] != md5($_GET['action'].$_GET['auth'].$_GET['forward'].$_DCACHE['settings']['passport_key'])) {
exit('Illegal request');
}
if($_GET['action'] == 'login') {
$memberfields = $remoteinfo = array();
parse_str(passport_decrypt($_GET['auth'], $_DCACHE['settings']['passport_key']), $member);
foreach($member as $key => $val) {
if(in_array($key, array('username', 'password', 'email', 'credits', 'gender', 'bday', 'regip', 'regdate', 'nickname', 'site', 'qq', 'msn', 'yahoo'))) {
$memberfields[$key] = addslashes($val);
} elseif(in_array($key, array('cookietime', 'time'))) {
$remoteinfo[$key] = $val;
} elseif($key == 'isadmin') {
if($val) {
$memberfields['groupid'] = $memberfields['adminid'] = 1;
}
}
}
if(strlen($memberfields['username'] = preg_replace("/(c:\\con\\con$|[%,\*\"\s\t\<\>\&])/i", "", $memberfields['username'])) > 15) {
$memberfields['username'] = substr($memberfields['username'], 0, 15);
}
if(empty($remoteinfo['time']) || empty($memberfields['username']) || empty($memberfields['password']) || empty($memberfields['email'])) {
exit('Lack of required parameters');
} elseif($timestamp - $remoteinfo['time'] > $_DCACHE['settings']['passport_expire']) {
exit('Request expired');
}
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
if($_DCACHE['settings']['passport_extcredits']) {
$memberfields['extcredits'.$_DCACHE['settings']['passport_extcredits']] = $memberfields['credits'];
$table_member_columns[] = 'extcredits'.$_DCACHE['settings']['passport_extcredits'];
}
$memberfields['regip'] = empty($memberfields['regip']) ? onlineip() : $memberfields['regip'];
$memberfields['regdate'] = empty($memberfields['regdate']) ? $timestamp : $memberfields['regdate'];
$query = $db->query("SELECT uid, secques FROM {$tablepre}members WHERE username='$memberfields[username]'");
if($member = $db->fetch_array($query)) {
$sql = $comma = '';
foreach($table_member_columns as $field) {
if(isset($memberfields[$field]) && !in_array($field, array('regip', 'regdate'))) {
$sql .= "$comma$field='{$memberfields[$field]}'";
$comma = ', ';
}
}
$db->query("UPDATE {$tablepre}members SET $sql WHERE uid='$member[uid]'");
$sql = $comma = '';
foreach($table_memberfields_columns as $field) {
if(isset($memberfields[$field])) {
$sql .= "$comma$field='{$memberfields[$field]}'";
$comma = ', ';
}
}
if($sql) {
$db->query("UPDATE {$tablepre}memberfields SET $sql WHERE uid='$member[uid]'");
}
} else {
if(empty($memberfields['groupid'])) {
$query = $db->query("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditshigher='0'");
$memberfields['groupid'] = $db->result($query, 0);
$memberfields['adminid'] = 0;
}
$memberfields['timeoffset'] = !$memberfields['timeoffset'] ? 9999 : $memberfields['timeoffset'];
$memberfields['newsletter'] = !$memberfields['newsletter'] ? 1 : $memberfields['newsletter'];
$sql1 = $sql2 = $comma = '';
foreach($table_member_columns as $field) {
if(isset($memberfields[$field])) {
$sql1 .= "$comma$field";
$sql2 .= "$comma'{$memberfields[$field]}'";
$comma = ', ';
}
}
$db->query("INSERT INTO {$tablepre}members ($sql1) VALUES ($sql2)");
$table_memberfields_columns[] = 'uid';
$memberfields['uid'] = $member['uid'] = $db->insert_id();
$member['secques'] = '';
$sql1 = $sql2 = $comma = '';
foreach($table_memberfields_columns as $field) {
if(isset($memberfields[$field])) {
$sql1 .= "$comma$field";
$sql2 .= "$comma'{$memberfields[$field]}'";
$comma = ', ';
}
}
$db->query("REPLACE INTO {$tablepre}memberfields ($sql1) VALUES ($sql2)");
$_DCACHE['settings']['lastmember'] = $memberfields['username'];
$_DCACHE['settings']['totalmembers']++;
updatemembercache();
}
$remoteinfo['cookietime'] = 86400;
dsetcookie('sid', '', 86400);
dsetcookie('auth', authcode("$memberfields[password]\t".(isset($memberfields['secques']) ? $memberfields['secques'] : $member['secques'])."\t$member[uid]", 'ENCODE'), ($remoteinfo['cookietime'] ? $remoteinfo['cookietime'] : 0));
header('Location: '.(empty($_GET['forward']) ? $_DCACHE['settings']['passport_url'] : $_GET['forward']));
exit;
} elseif($_GET['action'] == 'logout') {
dsetcookie('auth', '', -86400 * 365);
dsetcookie('sid', '', -86400 * 365);
header('Location: '.(empty($_GET['forward']) ? $_DCACHE['settings']['passport_url'] : $_GET['forward']));
exit;
} else {
exit('Invalid action');
}
function arrayeval($array, $level = 0) {
$space = '';
for($i = 0; $i <= $level; $i++) {
$space .= "\t";
}
$evaluate = "Array\n$space(\n";
$comma = $space;
foreach($array as $key => $val) {
$key = is_string($key) ? '\''.addcslashes($key, '\'\\').'\'' : $key;
$val = !is_array($val) && (!preg_match("/^\d+$/", $val) || strlen($val) > 12) ? '\''.addcslashes($val, '\'\\').'\'' : $val;
if(is_array($val)) {
$evaluate .= "$comma$key => ".arrayeval($val, $level + 1);
} else {
$evaluate .= "$comma$key => $val";
}
$comma = ",\n$space";
}
$evaluate .= "\n$space)";
return $evaluate;
}
function authcode($string, $operation, $key = '') {
global $_DCACHE;
$key = md5($key ? $key : md5($_DCACHE['settings']['authkey'].$_SERVER['HTTP_USER_AGENT']));
$key_length = strlen($key);
$string = $operation == 'DECODE' ? base64_decode($string) : substr(md5($string.$key), 0, 8).$string;
$string_length = strlen($string);
$rndkey = $box = array();
$result = '';
for($i = 0; $i <= 255; $i++) {
$rndkey[$i] = ord($key[$i % $key_length]);
$box[$i] = $i;
}
for($j = $i = 0; $i < 256; $i++) {
$j = ($j + $box[$i] + $rndkey[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for($a = $j = $i = 0; $i < $string_length; $i++) {
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
}
if($operation == 'DECODE') {
if(substr($result, 0, 8) == substr(md5(substr($result, 8).$key), 0, 8)) {
return substr($result, 8);
} else {
return '';
}
} else {
return str_replace('=', '', base64_encode($result));
}
}
function dsetcookie($var, $value, $life = 0, $prefix = 1) {
global $cookiepre, $cookiedomain, $cookiepath, $timestamp, $_SERVER;
setcookie(($prefix ? $cookiepre : '').$var, $value,
$life ? $timestamp + $life : 0, $cookiepath,
$cookiedomain, $_SERVER['SERVER_PORT'] == 443 ? 1 : 0);
}
function onlineip() {
global $_SERVER;
if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
$onlineip = getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
$onlineip = getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
$onlineip = getenv('REMOTE_ADDR');
} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
$onlineip = $_SERVER['REMOTE_ADDR'];
}
$onlineip = preg_match("/[\d\.]{7,15}/", $onlineip, $onlineipmatches);
return $onlineipmatches[0] ? $onlineipmatches[0] : 'unknown';
}
function passport_encrypt($txt, $key) {
srand((double)microtime() * 1000000);
$encrypt_key = md5(rand(0, 32000));
$ctr = 0;
$tmp = '';
for($i = 0;$i < strlen($txt); $i++) {
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
}
return base64_encode(passport_key($tmp, $key));
}
function passport_decrypt($txt, $key) {
$txt = passport_key(base64_decode($txt), $key);
$tmp = '';
for($i = 0;$i < strlen($txt); $i++) {
$md5 = $txt[$i];
$tmp .= $txt[++$i] ^ $md5;
}
return $tmp;
}
function passport_key($txt, $encrypt_key) {
$encrypt_key = md5($encrypt_key);
$ctr = 0;
$tmp = '';
for($i = 0; $i < strlen($txt); $i++) {
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
}
return $tmp;
}
function updatemembercache() {
$dir = './forumdata/cache/';
if(!is_dir($dir)) {
@mkdir($dir, 0777);
}
if(@$fp = fopen($dir.'cache_settings.php', 'w')) {
fwrite($fp, "<?php\n//Discuz! cache file, DO NOT modify me!\n".
"//Created on ".date("M j, Y, G:i")."\n\n\$_DCACHE['settings'] = ".arrayeval($GLOBALS['_DCACHE']['settings'])."?>");
fclose($fp);
} else {
exit('Can not write to cache files, please check directory ./forumdata/ and ./forumdata/cache/ .');
}
}
?>
| zyyhong | trunk/jiaju001/newbbs/bbs/api/passport.php | PHP | asf20 | 9,815 |
<?php
define('IN_DISCUZ', TRUE);
define('UC_CLIENT_VERSION', '1.5.1');
define('UC_CLIENT_RELEASE', '20091001');
define('API_DELETEUSER', 1);
define('API_RENAMEUSER', 1);
define('API_GETTAG', 1);
define('API_SYNLOGIN', 1);
define('API_SYNLOGOUT', 1);
define('API_UPDATEPW', 1);
define('API_UPDATEBADWORDS', 1);
define('API_UPDATEHOSTS', 1);
define('API_UPDATEAPPS', 1);
define('API_UPDATECLIENT', 1);
define('API_UPDATECREDIT', 1);
define('API_GETCREDITSETTINGS', 1);
define('API_GETCREDIT', 1);
define('API_UPDATECREDITSETTINGS', 1);
define('API_RETURN_SUCCEED', '1');
define('API_RETURN_FAILED', '-1');
define('API_RETURN_FORBIDDEN', '-2');
define('DISCUZ_ROOT', substr(dirname(__FILE__), 0, -3));
if(!defined('IN_UC')) {
error_reporting(0);
set_magic_quotes_runtime(0);
defined('MAGIC_QUOTES_GPC') || define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
include_once DISCUZ_ROOT.'./config.inc.php';
$_DCACHE = $get = $post = array();
$code = @$_GET['code'];
parse_str(_authcode($code, 'DECODE', UC_KEY), $get);
if(MAGIC_QUOTES_GPC) {
$get = _stripslashes($get);
}
$timestamp = time();
if(empty($get)) {
exit('Invalid Request');
} elseif($timestamp - $get['time'] > 3600) {
exit('Authracation has expiried');
}
$action = $get['action'];
require_once DISCUZ_ROOT.'./uc_client/lib/xml.class.php';
$post = xml_unserialize(file_get_contents('php://input'));
if(in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcredit', 'getcreditsettings', 'updatecreditsettings'))) {
require_once DISCUZ_ROOT.'./include/db_'.$database.'.class.php';
$GLOBALS['db'] = new dbstuff;
$GLOBALS['db']->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
$GLOBALS['tablepre'] = $tablepre;
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$uc_note = new uc_note();
exit($uc_note->$get['action']($get, $post));
} else {
exit(API_RETURN_FAILED);
}
} else {
/*$uc_note = new uc_note('../', '../config.inc.php');
$uc_note->deleteuser('3');*/
define('DISCUZ_ROOT', $app['extra']['apppath']);
include DISCUZ_ROOT.'./config.inc.php';
require_once DISCUZ_ROOT.'./include/db_'.$database.'.class.php';
$GLOBALS['db'] = new dbstuff;
$GLOBALS['db']->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
$GLOBALS['tablepre'] = $tablepre;
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
}
class uc_note {
var $db = '';
var $tablepre = '';
var $appdir = '';
function _serialize($arr, $htmlon = 0) {
if(!function_exists('xml_serialize')) {
include_once DISCUZ_ROOT.'./uc_client/lib/xml.class.php';
}
return xml_serialize($arr, $htmlon);
}
function uc_note() {
$this->appdir = DISCUZ_ROOT;
$this->db = $GLOBALS['db'];
$this->tablepre = $GLOBALS['tablepre'];
}
function test($get, $post) {
return API_RETURN_SUCCEED;
}
function deleteuser($get, $post) {
$uids = $get['ids'];
!API_DELETEUSER && exit(API_RETURN_FORBIDDEN);
$threads = array();
$query = $this->db->query("SELECT f.fid, t.tid FROM ".$this->tablepre."threads t LEFT JOIN ".$this->tablepre."forums f ON t.fid=f.fid WHERE t.authorid IN ($uids) ORDER BY f.fid");
while($thread = $this->db->fetch_array($query)) {
$threads[$thread['fid']] .= ($threads[$thread['fid']] ? ',' : '').$thread['tid'];
}
if($threads) {
require_once $this->appdir.'./forumdata/cache/cache_settings.php';
foreach($threads as $fid => $tids) {
$query = $this->db->query("SELECT attachment, thumb, remote FROM ".$this->tablepre."attachments WHERE tid IN ($tids)");
while($attach = $this->db->fetch_array($query)) {
@unlink($_DCACHE['settings']['attachdir'].'/'.$attach['attachment']);
$attach['thumb'] && @unlink($_DCACHE['settings']['attachdir'].'/'.$attach['attachment'].'.thumb.jpg');
}
foreach(array('threads', 'threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'debateposts', 'attachments', 'favorites', 'typeoptionvars', 'forumrecommend') as $value) {
$this->db->query("DELETE FROM ".$this->tablepre."$value WHERE tid IN ($tids)", 'UNBUFFERED');
}
require_once $this->appdir.'./include/post.func.php';
updateforumcount($fid);
}
if($globalstick && $stickmodify) {
require_once $this->appdir.'./include/cache.func.php';
updatecache('globalstick');
}
}
$query = $this->db->query("DELETE FROM ".$this->tablepre."members WHERE uid IN ($uids)");
$this->db->query("DELETE FROM ".$this->tablepre."access WHERE uid IN ($uids)", 'UNBUFFERED');
$this->db->query("DELETE FROM ".$this->tablepre."memberfields WHERE uid IN ($uids)", 'UNBUFFERED');
$this->db->query("DELETE FROM ".$this->tablepre."favorites WHERE uid IN ($uids)", 'UNBUFFERED');
$this->db->query("DELETE FROM ".$this->tablepre."moderators WHERE uid IN ($uids)", 'UNBUFFERED');
$this->db->query("DELETE FROM ".$this->tablepre."validating WHERE uid IN ($uids)", 'UNBUFFERED');
$query = $this->db->query("SELECT uid, attachment, thumb, remote FROM ".$this->tablepre."attachments WHERE uid IN ($uids)");
while($attach = $this->db->fetch_array($query)) {
@unlink($_DCACHE['settings']['attachdir'].'/'.$attach['attachment']);
$attach['thumb'] && @unlink($_DCACHE['settings']['attachdir'].'/'.$attach['attachment'].'.thumb.jpg');
}
$this->db->query("DELETE FROM ".$this->tablepre."attachments WHERE uid IN ($uids)");
$this->db->query("DELETE FROM ".$this->tablepre."posts WHERE authorid IN ($uids)");
$this->db->query("DELETE FROM ".$this->tablepre."trades WHERE sellerid IN ($uids)");
return API_RETURN_SUCCEED;
}
function renameuser($get, $post) {
$uid = $get['uid'];
$usernameold = $get['oldusername'];
$usernamenew = $get['newusername'];
if(!API_RENAMEUSER) {
return API_RETURN_FORBIDDEN;
}
$this->db->query("UPDATE ".$this->tablepre."announcements SET author='$usernamenew' WHERE author='$usernameold'");
$this->db->query("UPDATE ".$this->tablepre."banned SET admin='$usernamenew' WHERE admin='$usernameold'");
$this->db->query("UPDATE ".$this->tablepre."forums SET lastpost=REPLACE(lastpost, '\t$usernameold', '\t$usernamenew')");
$this->db->query("UPDATE ".$this->tablepre."members SET username='$usernamenew' WHERE uid='$uid'");
$this->db->query("UPDATE ".$this->tablepre."posts SET author='$usernamenew' WHERE authorid='$uid'");
$this->db->query("UPDATE ".$this->tablepre."threads SET author='$usernamenew' WHERE authorid='$uid'");
$this->db->query("UPDATE ".$this->tablepre."threads SET lastposter='$usernamenew' WHERE lastposter='$usernameold'");
$this->db->query("UPDATE ".$this->tablepre."threadsmod SET username='$usernamenew' WHERE uid='$uid'");
return API_RETURN_SUCCEED;
}
function gettag($get, $post) {
$name = $get['id'];
if(!API_GETTAG) {
return API_RETURN_FORBIDDEN;
}
$name = trim($name);
if(empty($name) || !preg_match('/^([\x7f-\xff_-]|\w|\s)+$/', $name) || strlen($name) > 20) {
return API_RETURN_FAILED;
}
require_once $this->appdir.'./include/misc.func.php';
$tag = $this->db->fetch_first("SELECT * FROM ".$this->tablepre."tags WHERE tagname='$name'");
if($tag['closed']) {
return API_RETURN_FAILED;
}
$tpp = 10;
$PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$boardurl = 'http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/';
$query = $this->db->query("SELECT t.* FROM ".$this->tablepre."threadtags tt LEFT JOIN ".$this->tablepre."threads t ON t.tid=tt.tid AND t.displayorder>='0' WHERE tt.tagname='$name' ORDER BY tt.tid DESC LIMIT $tpp");
$threadlist = array();
while($tagthread = $this->db->fetch_array($query)) {
if($tagthread['tid']) {
$threadlist[] = array(
'subject' => $tagthread['subject'],
'uid' => $tagthread['authorid'],
'username' => $tagthread['author'],
'dateline' => $tagthread['dateline'],
'url' => $boardurl.'viewthread.php?tid='.$tagthread['tid'],
);
}
}
$return = array($name, $threadlist);
return $this->_serialize($return, 1);
}
function synlogin($get, $post) {
$uid = $get['uid'];
$username = $get['username'];
if(!API_SYNLOGIN) {
return API_RETURN_FORBIDDEN;
}
require_once $this->appdir.'./forumdata/cache/cache_settings.php';
$cookietime = 2592000;
$discuz_auth_key = md5($_DCACHE['settings']['authkey'].$_SERVER['HTTP_USER_AGENT']);
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
$uid = intval($uid);
$query = $this->db->query("SELECT username, uid, password, secques FROM ".$this->tablepre."members WHERE uid='$uid'");
if($member = $this->db->fetch_array($query)) {
_setcookie('sid', '', -86400 * 365);
_setcookie('cookietime', $cookietime, 31536000);
_setcookie('auth', _authcode("$member[password]\t$member[secques]\t$member[uid]", 'ENCODE', $discuz_auth_key), $cookietime);
} else {
_setcookie('cookietime', $cookietime, 31536000);
_setcookie('loginuser', $username, $cookietime);
_setcookie('activationauth', _authcode($username, 'ENCODE', $discuz_auth_key), $cookietime);
}
}
function synlogout($get, $post) {
if(!API_SYNLOGOUT) {
return API_RETURN_FORBIDDEN;
}
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
_setcookie('auth', '', -86400 * 365);
_setcookie('sid', '', -86400 * 365);
_setcookie('loginuser', '', -86400 * 365);
_setcookie('activationauth', '', -86400 * 365);
}
function updatepw($get, $post) {
if(!API_UPDATEPW) {
return API_RETURN_FORBIDDEN;
}
$username = $get['username'];
$password = $get['password'];
$newpw = md5(time().rand(100000, 999999));
$this->db->query("UPDATE ".$this->tablepre."members SET password='$newpw' WHERE username='$username'");
return API_RETURN_SUCCEED;
}
function updatebadwords($get, $post) {
if(!API_UPDATEBADWORDS) {
return API_RETURN_FORBIDDEN;
}
$cachefile = $this->appdir.'./uc_client/data/cache/badwords.php';
$fp = fopen($cachefile, 'w');
$data = array();
if(is_array($post)) {
foreach($post as $k => $v) {
$data['findpattern'][$k] = $v['findpattern'];
$data['replace'][$k] = $v['replacement'];
}
}
$s = "<?php\r\n";
$s .= '$_CACHE[\'badwords\'] = '.var_export($data, TRUE).";\r\n";
fwrite($fp, $s);
fclose($fp);
return API_RETURN_SUCCEED;
}
function updatehosts($get, $post) {
if(!API_UPDATEHOSTS) {
return API_RETURN_FORBIDDEN;
}
$cachefile = $this->appdir.'./uc_client/data/cache/hosts.php';
$fp = fopen($cachefile, 'w');
$s = "<?php\r\n";
$s .= '$_CACHE[\'hosts\'] = '.var_export($post, TRUE).";\r\n";
fwrite($fp, $s);
fclose($fp);
return API_RETURN_SUCCEED;
}
function updateapps($get, $post) {
global $_DCACHE;
if(!API_UPDATEAPPS) {
return API_RETURN_FORBIDDEN;
}
$UC_API = $post['UC_API'];
if(empty($post) || empty($UC_API)) {
return API_RETURN_SUCCEED;
}
$cachefile = $this->appdir.'./uc_client/data/cache/apps.php';
$fp = fopen($cachefile, 'w');
$s = "<?php\r\n";
$s .= '$_CACHE[\'apps\'] = '.var_export($post, TRUE).";\r\n";
fwrite($fp, $s);
fclose($fp);
if(is_writeable($this->appdir.'./config.inc.php')) {
$configfile = trim(file_get_contents($this->appdir.'./config.inc.php'));
$configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;
$configfile = preg_replace("/define\('UC_API',\s*'.*?'\);/i", "define('UC_API', '$UC_API');", $configfile);
if($fp = @fopen($this->appdir.'./config.inc.php', 'w')) {
@fwrite($fp, trim($configfile));
@fclose($fp);
}
}
global $_DCACHE;
require_once $this->appdir.'./forumdata/cache/cache_settings.php';
require_once $this->appdir.'./include/cache.func.php';
foreach($post as $appid => $app) {
if(!empty($app['viewprourl'])) {
$_DCACHE['settings']['ucapp'][$appid]['viewprourl'] = $app['url'].$app['viewprourl'];
}
}
updatesettings();
return API_RETURN_SUCCEED;
}
function updateclient($get, $post) {
if(!API_UPDATECLIENT) {
return API_RETURN_FORBIDDEN;
}
$cachefile = $this->appdir.'./uc_client/data/cache/settings.php';
$fp = fopen($cachefile, 'w');
$s = "<?php\r\n";
$s .= '$_CACHE[\'settings\'] = '.var_export($post, TRUE).";\r\n";
fwrite($fp, $s);
fclose($fp);
return API_RETURN_SUCCEED;
}
function updatecredit($get, $post) {
if(!API_UPDATECREDIT) {
return API_RETURN_FORBIDDEN;
}
$credit = $get['credit'];
$amount = $get['amount'];
$uid = $get['uid'];
if(!$this->db->result_first("SELECT count(*) FROM ".$this->tablepre."members WHERE uid='$uid'")) {
return 0;
}
require_once $this->appdir.'./forumdata/cache/cache_settings.php';
$this->db->query("UPDATE ".$this->tablepre."members SET extcredits$credit=extcredits$credit+'$amount' WHERE uid='$uid'");
$discuz_user = $this->db->result_first("SELECT username FROM ".$this->tablepre."members WHERE uid='$uid'");
$this->db->query("INSERT INTO ".$this->tablepre."creditslog (uid, fromto, sendcredits, receivecredits, send, receive, dateline, operation)
VALUES ('$uid', '$discuz_user', '0', '$credit', '0', '$amount', '$timestamp', 'EXC')");
return API_RETURN_SUCCEED;
}
function getcredit($get, $post) {
if(!API_GETCREDIT) {
return API_RETURN_FORBIDDEN;
}
$uid = intval($get['uid']);
$credit = intval($get['credit']);
return $credit >= 1 && $credit <= 8 ? $this->db->result_first("SELECT extcredits$credit FROM ".$this->tablepre."members WHERE uid='$uid'") : 0;
}
function getcreditsettings($get, $post) {
if(!API_GETCREDITSETTINGS) {
return API_RETURN_FORBIDDEN;
}
require_once $this->appdir.'./forumdata/cache/cache_settings.php';
$credits = array();
foreach($_DCACHE['settings']['extcredits'] as $id => $extcredits) {
$credits[$id] = array(strip_tags($extcredits['title']), $extcredits['unit']);
}
return $this->_serialize($credits);
}
function updatecreditsettings($get, $post) {
global $_DCACHE;
if(!API_UPDATECREDITSETTINGS) {
return API_RETURN_FORBIDDEN;
}
$credit = $get['credit'];
$outextcredits = array();
if($credit) {
foreach($credit as $appid => $credititems) {
if($appid == UC_APPID) {
foreach($credititems as $value) {
$outextcredits[] = array(
'appiddesc' => $value['appiddesc'],
'creditdesc' => $value['creditdesc'],
'creditsrc' => $value['creditsrc'],
'title' => $value['title'],
'unit' => $value['unit'],
'ratiosrc' => $value['ratiosrc'],
'ratiodesc' => $value['ratiodesc'],
'ratio' => $value['ratio']
);
}
}
}
}
require_once $this->appdir.'./forumdata/cache/cache_settings.php';
require_once $this->appdir.'./include/cache.func.php';
$this->db->query("REPLACE INTO ".$this->tablepre."settings (variable, value) VALUES ('outextcredits', '".addslashes(serialize($outextcredits))."');", 'UNBUFFERED');
$tmp = array();
foreach($outextcredits as $value) {
$key = $value['appiddesc'].'|'.$value['creditdesc'];
if(!isset($tmp[$key])) {
$tmp[$key] = array('title' => $value['title'], 'unit' => $value['unit']);
}
$tmp[$key]['ratiosrc'][$value['creditsrc']] = $value['ratiosrc'];
$tmp[$key]['ratiodesc'][$value['creditsrc']] = $value['ratiodesc'];
$tmp[$key]['creditsrc'][$value['creditsrc']] = $value['ratio'];
}
$_DCACHE['settings']['outextcredits'] = $tmp;
updatesettings();
return API_RETURN_SUCCEED;
}
}
function _setcookie($var, $value, $life = 0, $prefix = 1) {
global $cookiepre, $cookiedomain, $cookiepath, $timestamp, $_SERVER;
setcookie(($prefix ? $cookiepre : '').$var, $value,
$life ? $timestamp + $life : 0, $cookiepath,
$cookiedomain, $_SERVER['SERVER_PORT'] == 443 ? 1 : 0);
}
function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 4;
$key = md5($key ? $key : UC_KEY);
$keya = md5(substr($key, 0, 16));
$keyb = md5(substr($key, 16, 16));
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
$cryptkey = $keya.md5($keya.$keyc);
$key_length = strlen($cryptkey);
$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
$string_length = strlen($string);
$result = '';
$box = range(0, 255);
$rndkey = array();
for($i = 0; $i <= 255; $i++) {
$rndkey[$i] = ord($cryptkey[$i % $key_length]);
}
for($j = $i = 0; $i < 256; $i++) {
$j = ($j + $box[$i] + $rndkey[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for($a = $j = $i = 0; $i < $string_length; $i++) {
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
}
if($operation == 'DECODE') {
if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
return substr($result, 26);
} else {
return '';
}
} else {
return $keyc.str_replace('=', '', base64_encode($result));
}
}
function _stripslashes($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = _stripslashes($val);
}
} else {
$string = stripslashes($string);
}
return $string;
} | zyyhong | trunk/jiaju001/newbbs/bbs/api/uc.php | PHP | asf20 | 18,121 |
<?php
/*
[UCenter] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: dbbak.php 18358 2009-04-22 01:19:47Z zhaoxiongfei $
*/
error_reporting(0);
define('IN_COMSENZ', TRUE);
define('ROOT_PATH', dirname(__FILE__).'/../');
define('EXPLOR_SUCCESS', 0);
define('IMPORT_SUCCESS', 0);
define('DELETE_SQLPATH_SUCCESS', 4);
define('MKDIR_ERROR', 1);
define('DATABASE_EXPORT_FILE_INVALID', 2);
define('RUN_SQL_ERROR', 3);
define('SQLPATH_NULL_NOEXISTS', 4);
define('SQLPATH_NOMATCH_BAKFILE', 5);
define('BAK_FILE_LOSE', 6);
define('DIR_NO_EXISTS', 7);
define('DELETE_DUMPFILE_ERROR', 8);
define('DB_API_NO_MATCH', 9);
$sizelimit = 2000;
$usehex = true;
$code = @$_GET['code'];
$apptype = @$_GET['apptype'];
$apptype = strtolower($apptype);
if($apptype == 'discuz') {
require ROOT_PATH.'./config.inc.php';
} elseif($apptype == 'uchome' || $apptype == 'supesite' || $apptype == 'supev') {
require ROOT_PATH.'./config.php';
} elseif($apptype == 'ucenter') {
require ROOT_PATH.'./data/config.inc.php';
} elseif($apptype == 'ecmall') {
require ROOT_PATH.'./data/inc.config.php';
} elseif($apptype == 'ecshop') {
require ROOT_PATH.'./data/config.php';
} else {
api_msg('db_api_no_match', $apptype);
}
parse_str(_authcode($code, 'DECODE', UC_KEY), $get);
if(get_magic_quotes_gpc()) {
$get = _stripslashes($get);
}
if(empty($get)) {
exit('Invalid Request');
}
$timestamp = time();
if($timestamp - $get['time'] > 3600) {
exit('Authracation has expiried');
}
$get['time'] = $timestamp;
class dbstuff {
var $querynum = 0;
var $link;
var $histories;
var $time;
var $tablepre;
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset, $pconnect = 0, $tablepre='', $time = 0) {
$this->time = $time;
$this->tablepre = $tablepre;
if($pconnect) {
if(!$this->link = mysql_pconnect($dbhost, $dbuser, $dbpw)) {
$this->halt('Can not connect to MySQL server');
}
} else {
if(!$this->link = mysql_connect($dbhost, $dbuser, $dbpw, 1)) {
$this->halt('Can not connect to MySQL server');
}
}
if($this->version() > '4.1') {
if($dbcharset) {
mysql_query("SET character_set_connection=".$dbcharset.", character_set_results=".$dbcharset.", character_set_client=binary", $this->link);
}
if($this->version() > '5.0.1') {
mysql_query("SET sql_mode=''", $this->link);
}
}
if($dbname) {
mysql_select_db($dbname, $this->link);
}
}
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return mysql_fetch_array($query, $result_type);
}
function result_first($sql) {
$query = $this->query($sql);
return $this->result($query, 0);
}
function fetch_first($sql) {
$query = $this->query($sql);
return $this->fetch_array($query);
}
function fetch_all($sql) {
$arr = array();
$query = $this->query($sql);
while($data = $this->fetch_array($query)) {
$arr[] = $data;
}
return $arr;
}
function cache_gc() {
$this->query("DELETE FROM {$this->tablepre}sqlcaches WHERE expiry<$this->time");
}
function query($sql, $type = '', $cachetime = FALSE) {
$func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
if(!($query = $func($sql, $this->link)) && $type != 'SILENT') {
$this->halt('MySQL Query Error', $sql);
}
$this->querynum++;
$this->histories[] = $sql;
return $query;
}
function affected_rows() {
return mysql_affected_rows($this->link);
}
function error() {
return (($this->link) ? mysql_error($this->link) : mysql_error());
}
function errno() {
return intval(($this->link) ? mysql_errno($this->link) : mysql_errno());
}
function result($query, $row) {
$query = @mysql_result($query, $row);
return $query;
}
function num_rows($query) {
$query = mysql_num_rows($query);
return $query;
}
function num_fields($query) {
return mysql_num_fields($query);
}
function free_result($query) {
return mysql_free_result($query);
}
function insert_id() {
return ($id = mysql_insert_id($this->link)) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
}
function fetch_row($query) {
$query = mysql_fetch_row($query);
return $query;
}
function fetch_fields($query) {
return mysql_fetch_field($query);
}
function version() {
return mysql_get_server_info($this->link);
}
function close() {
return mysql_close($this->link);
}
function halt($message = '', $sql = '') {
api_msg('run_sql_error', $message.'<br /><br />'.$sql.'<br /> '.mysql_error());
}
}
$db = new dbstuff();
$version = '';
if($apptype == 'discuz') {
define('BACKUP_DIR', ROOT_PATH.'forumdata/');
$tablepre = $tablepre;
if(empty($dbcharset)) {
$dbcharset = in_array(strtolower($charset), array('gbk', 'big5', 'utf-8')) ? str_replace('-', '', $charset) : '';
}
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $dbcharset, $pconnect, $tablepre);
define('IN_DISCUZ', true);
include ROOT_PATH.'discuz_version.php';
$version = DISCUZ_VERSION;
} elseif($apptype == 'uchome' || $apptype == 'supesite') {
define('BACKUP_DIR', ROOT_PATH.'./data/');
$tablepre = $_SC['tablepre'];
$dbcharset = $_SC['dbcharset'];
$db->connect($_SC['dbhost'], $_SC['dbuser'], $_SC['dbpw'], $_SC['dbname'], $dbcharset, $_SC['pconnect'], $tablepre);
} elseif($apptype == 'ucenter') {
define('BACKUP_DIR', ROOT_PATH.'./data/backup/');
$tablepre = UC_DBTABLEPRE;
$dbcharset = UC_DBCHARSET;
$db->connect(UC_DBHOST, UC_DBUSER, UC_DBPW, UC_DBNAME, $dbcharset, UC_DBCONNECT, $tablepre);
} elseif($apptype == 'ecmall') {
define('BACKUP_DIR', ROOT_PATH.'./data/backup/');
$tablepre = DB_PREFIX;
$dbcharset = strtolower(str_replace('-', '', strstr(LANG, '-')));
$cfg = parse_url(DB_CONFIG);
if(empty($cfg['pass'])) {
$cfg['pass'] = '';
} else {
$cfg['pass'] = urldecode($cfg['pass']);
}
$cfg['user'] = urldecode($cfg['user']);
$cfg['path'] = str_replace('/', '', $cfg['path']);
$db->connect($cfg['host'].':'.$cfg['port'], $cfg['user'], $cfg['pass'], $cfg['path'], $dbcharset, 0, $tablepre);
} elseif($apptype == 'supev') {
define('BACKUP_DIR', ROOT_PATH.'data/backup/');
$tablepre = $tablepre;
if(empty($dbcharset)) {
$dbcharset = in_array(strtolower($charset), array('gbk', 'big5', 'utf-8')) ? str_replace('-', '', $charset) : '';
}
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $dbcharset, $pconnect, $tablepre);
} elseif($apptype == 'ecshop') {
define('BACKUP_DIR', ROOT_PATH.'data/backup/');
$tablepre = $prefix;
$dbcharset = 'utf8';
$db->connect($db_host, $db_user, $db_pass, $db_name, $dbcharset, 0, $tablepre);
}
if($get['method'] == 'export') {
$db->query('SET SQL_QUOTE_SHOW_CREATE=0', 'SILENT');
$time = date("Y-m-d H:i:s", $timestamp);
$tables = array();
$tables = arraykeys2(fetchtablelist($tablepre), 'Name');
if($apptype == 'discuz') {
$query = $db->query("SELECT datatables FROM {$tablepre}plugins WHERE datatables<>''");
while($plugin = $db->fetch_array($query)) {
foreach(explode(',', $plugin['datatables']) as $table) {
if($table = trim($table)) {
$tables[] = $table;
}
}
}
}
$get['volume'] = isset($get['volume']) ? intval($get['volume']) : 0;
$get['volume'] = $get['volume'] + 1;
$version = $version ? $version : $apptype;
$idstring = '# Identify: '.base64_encode("$timestamp,$version,$apptype,multivol,$get[volume]")."\n";
if(!isset($get['sqlpath']) || empty($get['sqlpath'])) {
$get['sqlpath'] = 'backup_'.date('ymd', $timestamp).'_'.random(6);
if(!mkdir(BACKUP_DIR.'./'.$get['sqlpath'], 0777)) {
api_msg('mkdir_error', 'make dir error:'.BACKUP_DIR.'./'.$get['sqlpath']);
}
} elseif(!is_dir(BACKUP_DIR.'./'.$get['sqlpath'])) {
if(!mkdir(BACKUP_DIR.'./'.$get['sqlpath'], 0777)) {
api_msg('mkdir_error', 'make dir error:'.BACKUP_DIR.'./'.$get['sqlpath']);
}
}
if(!isset($get['backupfilename']) || empty($get['backupfilename'])) {
$get['backupfilename'] = date('ymd', $timestamp).'_'.random(6);
}
$sqldump = '';
$get['tableid'] = isset($get['tableid']) ? intval($get['tableid']) : 0;
$get['startfrom'] = isset($get['startfrom']) ? intval($get['startfrom']) : 0;
$complete = TRUE;
for(; $complete && $get['tableid'] < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $get['tableid']++) {
$sqldump .= sqldumptable($tables[$get['tableid']], strlen($sqldump));
if($complete) {
$get['startfrom'] = 0;
}
}
!$complete && $get['tableid']--;
$dumpfile = BACKUP_DIR.$get['sqlpath'].'/'.$get['backupfilename'].'-'.$get['volume'].'.sql';
if(trim($sqldump)) {
$sqldump = "$idstring".
"# <?exit();?>\n".
"# $apptype Multi-Volume Data Dump Vol.$get[volume]\n".
"# Time: $time\n".
"# Type: $apptype\n".
"# Table Prefix: $tablepre\n".
"# $dbcharset\n".
"# $apptype Home: http://www.comsenz.com\n".
"# Please visit our website for newest infomation about $apptype\n".
"# --------------------------------------------------------\n\n\n".
$sqldump;
@$fp = fopen($dumpfile, 'wb');
@flock($fp, 2);
if(@!fwrite($fp, $sqldump)) {
@fclose($fp);
api_msg('database_export_file_invalid', $dumpfile);
} else {
fclose($fp);
auto_next($get, $dumpfile);
}
} else {
@touch(ROOT_PATH.$get['sqlpath'].'/index.htm');
api_msg('explor_success', 'explor_success');
}
} elseif($get['method'] == 'import') {
if(!isset($get['dumpfile']) || empty($get['dumpfile'])) {
$get['dumpfile'] = get_dumpfile_by_path($get['sqlpath']);
$get['volume'] = 0;
}
$get['volume']++;
$next_dumpfile = preg_replace('/^(\d+)\_(\w+)\-(\d+)\.sql$/', '\\1_\\2-'.$get['volume'].'.sql', $get['dumpfile']);
if(!is_file(BACKUP_DIR.$get['sqlpath'].'/'.$get['dumpfile'])) {
if(is_file(BACKUP_DIR.$get['sqlpath'].'/'.$next_dumpfile)) {
api_msg('bak_file_lose', $get['dumpfile']);
} else {
api_msg('import_success', 'import_success');
}
}
$sqldump = file_get_contents(BACKUP_DIR.$get['sqlpath'].'/'.$get['dumpfile']);
$sqlquery = splitsql($sqldump);
unset($sqldump);
foreach($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset);
if($sql != '') {
$db->query($sql, 'SILENT');
if(($sqlerror = $db->error()) && $db->errno() != 1062) {
$db->halt('MySQL Query Error', $sql);
}
}
}
$cur_file = $get['dumpfile'];
$get['dumpfile'] = $next_dumpfile;
auto_next($get, BACKUP_DIR.$get['sqlpath'].'/'.$cur_file);
} elseif($get['method'] == 'ping') {
if($get['dir'] && is_dir(BACKUP_DIR.$get['dir'])) {
echo "1";exit;
} else {
echo "-1";exit;
}
} elseif($get['method'] == 'list') {
$str = "<root>\n";
$directory = dir(BACKUP_DIR);
while($entry = $directory->read()) {
$filename = BACKUP_DIR.$entry;
if(is_dir($filename) && preg_match('/backup_(\d+)_\w+$/', $filename, $match)) {
$str .= "\t<dir>\n";
$str .= "\t\t<dirname>$filename</dirname>\n";
$str .= "\t\t<dirdate>$match[1]</dirdate>\n";
$str .= "\t</dir>\n";
}
}
$directory->close();
$str .= "</root>";
echo $str;
exit;
} elseif($get['method'] == 'view') {
$sqlpath = trim($get['sqlpath']);
if(empty($sqlpath) || !is_dir(BACKUP_DIR.$sqlpath)) {
api_msg('dir_no_exists', $sqlpath);
}
$str = "<root>\n";
$directory = dir(BACKUP_DIR.$sqlpath);
while($entry = $directory->read()) {
$filename = BACKUP_DIR.$sqlpath.'/'.$entry;
if(is_file($filename) && preg_match('/\d+_\w+\-(\d+).sql$/', $filename, $match)) {
$str .= "\t<file>\n";
$str .= "\t\t<file_name>$match[0]</file_name>\n";
$str .= "\t\t<file_size>".filesize($filename)."</file_size>\n";
$str .= "\t\t<file_num>$match[1]</file_num>\n";
$str .= "\t\t<file_url>".str_replace(ROOT_PATH, 'http://'.$_SERVER['HTTP_HOST'].'/', $filename)."</file_url>\n";
$str .= "\t\t<last_modify>".filemtime($filename)."</last_modify>\n";
$str .= "\t</file>\n";
}
}
$directory->close();
$str .= "</root>";
echo $str;
exit;
} elseif($get['method'] == 'delete') {
$sqlpath = trim($get['sqlpath']);
if(empty($sqlpath) || !is_dir(BACKUP_DIR.$sqlpath)) {
api_msg('dir_no_exists', $sqlpath);
}
$directory = dir(BACKUP_DIR.$sqlpath);
while($entry = $directory->read()) {
$filename = BACKUP_DIR.$sqlpath.'/'.$entry;
if(is_file($filename) && preg_match('/\d+_\w+\-(\d+).sql$/', $filename) && !@unlink($filename)) {
api_msg('delete_dumpfile_error', $filename);
}
}
$directory->close();
@rmdir(BACKUP_DIR.$sqlpath);
api_msg('delete_sqlpath_success', 'delete_sqlpath_success');
}
function syntablestruct($sql, $version, $dbcharset) {
if(strpos(trim(substr($sql, 0, 18)), 'CREATE TABLE') === FALSE) {
return $sql;
}
$sqlversion = strpos($sql, 'ENGINE=') === FALSE ? FALSE : TRUE;
if($sqlversion === $version) {
return $sqlversion && $dbcharset ? preg_replace(array('/ character set \w+/i', '/ collate \w+/i', "/DEFAULT CHARSET=\w+/is"), array('', '', "DEFAULT CHARSET=$dbcharset"), $sql) : $sql;
}
if($version) {
return preg_replace(array('/TYPE=HEAP/i', '/TYPE=(\w+)/is'), array("ENGINE=MEMORY DEFAULT CHARSET=$dbcharset", "ENGINE=\\1 DEFAULT CHARSET=$dbcharset"), $sql);
} else {
return preg_replace(array('/character set \w+/i', '/collate \w+/i', '/ENGINE=MEMORY/i', '/\s*DEFAULT CHARSET=\w+/is', '/\s*COLLATE=\w+/is', '/ENGINE=(\w+)(.*)/is'), array('', '', 'ENGINE=HEAP', '', '', 'TYPE=\\1\\2'), $sql);
}
}
function splitsql($sql) {
$sql = str_replace("\r", "\n", $sql);
$ret = array();
$num = 0;
$queriesarray = explode(";\n", trim($sql));
unset($sql);
foreach($queriesarray as $query) {
$ret[$num] = isset($ret[$num]) ? $ret[$num] : '';
$queries = explode("\n", trim($query));
foreach($queries as $query) {
$ret[$num] .= isset($query[0]) && $query[0] == "#" ? NULL : $query;
}
$num++;
}
return($ret);
}
function get_dumpfile_by_path($path) {
if(empty($path) || !is_dir(BACKUP_DIR.$path)) {
api_msg('sqlpath_null_noexists', $path);
}
$directory = dir(BACKUP_DIR.$path);
while($entry = $directory->read()) {
$filename = BACKUP_DIR.$path.'/'.$entry;
if(is_file($filename)) {
if(preg_match('/^\d+\_\w+\-\d+\.sql$/', $entry)) {
$file_bakfile = preg_replace('/^(\d+)\_(\w+)\-(\d+)\.sql$/', '\\1_\\2-1.sql', $entry);
if(is_file(BACKUP_DIR.$path.'/'.$file_bakfile)) {
return $file_bakfile;
} else {
api_msg('sqlpath_nomatch_bakfile', $path);
}
}
}
}
$directory->close();
api_msg('sqlpath_nomatch_bakfile', $path);
}
function api_msg($code, $msg) {
$out = "<root>\n";
$out .= "\t<error errorCode=\"".constant(strtoupper($code))."\" errorMessage=\"$msg\" />\n";
$out .= "\t<fileinfo>\n";
$out .= "\t\t<file_num></file_num>\n";
$out .= "\t\t<file_size></file_size>\n";
$out .= "\t\t<file_name></file_name>\n";
$out .= "\t\t<file_url></file_url>\n";
$out .= "\t\t<last_modify></last_modify>\n";
$out .= "\t</fileinfo>\n";
$out .= "\t<nexturl></nexturl>\n";
$out .= "</root>";
echo $out;
exit;
}
function arraykeys2($array, $key2) {
$return = array();
foreach($array as $val) {
$return[] = $val[$key2];
}
return $return;
}
function auto_next($get, $sqlfile) {
$next_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?apptype='.$GLOBALS['apptype'].'&code='.urlencode(encode_arr($get));
$out = "<root>\n";
$out .= "\t<error errorCode=\"0\" errorMessage=\"ok\" />\n";
$out .= "\t<fileinfo>\n";
$out .= "\t\t<file_num>$get[volume]</file_num>\n";
$out .= "\t\t<file_size>".filesize($sqlfile)."</file_size>\n";
$out .= "\t\t<file_name>".basename($sqlfile)."</file_name>\n";
$out .= "\t\t<file_url>".str_replace(ROOT_PATH, 'http://'.$_SERVER['HTTP_HOST'].'/', $sqlfile)."</file_url>\n";
$out .= "\t\t<last_modify>".filemtime($sqlfile)."</last_modify>\n";
$out .= "\t</fileinfo>\n";
$out .= "\t<nexturl><![CDATA[$next_url]]></nexturl>\n";
$out .= "</root>";
echo $out;
exit;
}
function encode_arr($get) {
$tmp = '';
foreach($get as $key => $val) {
$tmp .= '&'.$key.'='.$val;
}
return _authcode($tmp, 'ENCODE', UC_KEY);
}
function sqldumptable($table, $currsize = 0) {
global $get, $db, $sizelimit, $startrow, $extendins, $sqlcompat, $sqlcharset, $dumpcharset, $usehex, $complete, $excepttables;
$offset = 300;
$tabledump = '';
$tablefields = array();
$query = $db->query("SHOW FULL COLUMNS FROM $table", 'SILENT');
if(strexists($table, 'adminsessions')) {
return ;
} elseif(!$query && $db->errno() == 1146) {
return;
} elseif(!$query) {
$usehex = FALSE;
} else {
while($fieldrow = $db->fetch_array($query)) {
$tablefields[] = $fieldrow;
}
}
if(!$get['startfrom']) {
$createtable = $db->query("SHOW CREATE TABLE $table", 'SILENT');
if(!$db->error()) {
$tabledump = "DROP TABLE IF EXISTS $table;\n";
} else {
return '';
}
$create = $db->fetch_row($createtable);
if(strpos($table, '.') !== FALSE) {
$tablename = substr($table, strpos($table, '.') + 1);
$create[1] = str_replace("CREATE TABLE $tablename", 'CREATE TABLE '.$table, $create[1]);
}
$tabledump .= $create[1];
$tablestatus = $db->fetch_first("SHOW TABLE STATUS LIKE '$table'");
$tabledump .= ($tablestatus['Auto_increment'] ? " AUTO_INCREMENT=$tablestatus[Auto_increment]" : '').";\n\n";
}
$tabledumped = 0;
$numrows = $offset;
$firstfield = $tablefields[0];
while($currsize + strlen($tabledump) + 500 < $sizelimit * 1000 && $numrows == $offset) {
if($firstfield['Extra'] == 'auto_increment') {
$selectsql = "SELECT * FROM $table WHERE $firstfield[Field] > $get[startfrom] LIMIT $offset";
} else {
$selectsql = "SELECT * FROM $table LIMIT $get[startfrom], $offset";
}
$tabledumped = 1;
$rows = $db->query($selectsql);
$numfields = $db->num_fields($rows);
$numrows = $db->num_rows($rows);
while($row = $db->fetch_row($rows)) {
$comma = $t = '';
for($i = 0; $i < $numfields; $i++) {
$t .= $comma.($usehex && !empty($row[$i]) && (strexists($tablefields[$i]['Type'], 'char') || strexists($tablefields[$i]['Type'], 'text')) ? '0x'.bin2hex($row[$i]) : '\''.mysql_escape_string($row[$i]).'\'');
$comma = ',';
}
if(strlen($t) + $currsize + strlen($tabledump) + 500 < $sizelimit * 1000) {
if($firstfield['Extra'] == 'auto_increment') {
$get['startfrom'] = $row[0];
} else {
$get['startfrom']++;
}
$tabledump .= "INSERT INTO $table VALUES ($t);\n";
} else {
$complete = FALSE;
break 2;
}
}
}
$tabledump .= "\n";
return $tabledump;
}
function random($length, $numeric = 0) {
PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
if($numeric) {
$hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
} else {
$hash = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
for($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
}
return $hash;
}
function fetchtablelist($tablepre = '') {
global $db;
$arr = explode('.', $tablepre);
$dbname = isset($arr[1]) && $arr[1] ? $arr[0] : '';
$tablepre = str_replace('_', '\_', $tablepre);
$sqladd = $dbname ? " FROM $dbname LIKE '$arr[1]%'" : "LIKE '$tablepre%'";
$tables = $table = array();
$query = $db->query("SHOW TABLE STATUS $sqladd");
while($table = $db->fetch_array($query)) {
$table['Name'] = ($dbname ? "$dbname." : '').$table['Name'];
$tables[] = $table;
}
return $tables;
}
function _stripslashes($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = _stripslashes($val);
}
} else {
$string = stripslashes($string);
}
return $string;
}
function _authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 4;
$key = md5($key ? $key : UC_KEY);
$keya = md5(substr($key, 0, 16));
$keyb = md5(substr($key, 16, 16));
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
$cryptkey = $keya.md5($keya.$keyc);
$key_length = strlen($cryptkey);
$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
$string_length = strlen($string);
$result = '';
$box = range(0, 255);
$rndkey = array();
for($i = 0; $i <= 255; $i++) {
$rndkey[$i] = ord($cryptkey[$i % $key_length]);
}
for($j = $i = 0; $i < 256; $i++) {
$j = ($j + $box[$i] + $rndkey[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for($a = $j = $i = 0; $i < $string_length; $i++) {
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
}
if($operation == 'DECODE') {
if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
return substr($result, 26);
} else {
return '';
}
} else {
return $keyc.str_replace('=', '', base64_encode($result));
}
}
function strexists($haystack, $needle) {
return !(strpos($haystack, $needle) === FALSE);
} | zyyhong | trunk/jiaju001/newbbs/bbs/api/dbbak.php | PHP | asf20 | 21,728 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: uchome.php 20555 2009-10-09 03:00:53Z liuqiang $
*/
@chdir('../');
require './include/common.inc.php';
if(!$ucappopen['UCHOME']) {
showmessage('uchome_not_installed');
}
if($action == 'getalbums' && $discuz_uid) {
$albums = @unserialize(dfopen("$uchomeurl/api/discuz.php?ac=album&uid=$discuz_uid"));
include_once language('misc');
if($albums && is_array($albums)) {
$str = '<select name="uch_albums" onchange="if(this.value) {var tmp=this.value.split(\'_\');ajaxget(\'api/uchome.php?action=getphotoes&photonum=\'+tmp[1]+\'&aid=\'+tmp[0], \'uch_photoes\');}"><option value="">'.$language['uch_selectalbum'].'</option>';
foreach($albums as $album) {
$str .= "<option value=\"$album[albumid]_$album[picnum]\">$album[albumname]</option>";
}
$str .= '</select>';
showmessage($str);
} else {
showmessage("$language[uch_noalbum]<a href=\"$uchomeurl/cp.php?ac=upload\" target=\"_blank\">$language[click_here]</a>$language[uch_createalbum]");
}
} elseif($action == 'getphotoes' && $discuz_uid && $aid) {
$page = max(1, intval($page));
$perpage = 8;
$start = ($page - 1) * $perpage;
$aid = intval($aid);
$photonum = intval($photonum);
$photoes = @unserialize(dfopen("$uchomeurl/api/discuz.php?ac=album&uid=$discuz_uid&start=$start&count=$photonum&perpage=$perpage&aid=$aid"));
if($photoes && is_array($photoes)) {
$i = 0;
$str = '<table cellspacing="2" cellpadding="2" class="imglist"><tr>';
foreach($photoes as $photo) {
if($i++ == $perpage) {
break;
}
$picurl = substr(strtolower($photo['bigpic']), 0, 7) == 'http://' ? '' : $uchomeurl.'/';
$str .= '<td valign="bottom" width="25%"><a href="javascript:;"><img src="'.$picurl.$photo['pic'].'" title="'.$photo['filename'].'" onclick="wysiwyg ? insertText(\'<img src='.$picurl.$photo[bigpic].' border=0 /> \', false) : insertText(\'[img]'.$picurl.$photo[bigpic].'[/img]\');" onload="thumbImg(this, 1)" _width="110" _height="110"></a></td>'.
($i % 4 == 0 && isset($photoes[$i]) ? '</tr><tr>' : '');
}
$str .= '</tr></table>'.multi($photonum, $perpage, $start / $perpage + 1, "api/uchome.php?action=getphotoes&aid=$aid&photonum=$photonum");
showmessage($str);
} else {
showmessage('NOPHOTO');
}
} | zyyhong | trunk/jiaju001/newbbs/bbs/api/uchome.php | PHP | asf20 | 2,378 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: misc.php 21333 2010-01-06 06:47:34Z cnteacher $
*/
define('NOROBOT', TRUE);
define('CURSCRIPT', 'misc');
require_once './include/common.inc.php';
require_once './include/post.func.php';
$feed = array();
if($action == 'maxpages') {
$pages = intval($pages);
if(empty($pages)) {
showmessage('undefined_action', NULL, 'HALTED');
} else {
showmessage('max_pages');
}
} elseif($action == 'paysucceed') {
showmessage('payonline_succeed', $url);
} elseif($action == 'nav') {
require_once DISCUZ_ROOT.'./include/forumselect.inc.php';
exit;
} elseif($action == 'customtopics') {
if(!submitcheck('keywordsubmit', 1)) {
if($_DCOOKIE['customkw']) {
$customkwlist = array();
foreach(@explode("\t", trim($_DCOOKIE['customkw'])) as $key => $keyword) {
$keyword = dhtmlspecialchars(trim(stripslashes($keyword)));
$customkwlist[$key]['keyword'] = $keyword;
$customkwlist[$key]['url'] = '<a href="topic.php?keyword='.rawurlencode($keyword).'" target="_blank">'.$keyword.'</a> ';
}
}
include template('customtopics');
} else {
if(!empty($delete) && is_array($delete)) {
$keywords = implode("\t", array_diff(explode("\t", $_DCOOKIE['customkw']), $delete));
} else {
$keywords = $_DCOOKIE['customkw'];
}
if($newkeyword = cutstr(dhtmlspecialchars(preg_replace("/[\s\|\t\,\'\<\>]/", '', $newkeyword)), 20)) {
if($_DCOOKIE['customkw']) {
if(!preg_match("/(^|\t)".preg_quote($newkeyword, '/')."($|\t)/i", $keywords)) {
if(count(explode("\t", $keywords)) >= $qihoo['maxtopics']) {
$keywords = substr($keywords, (strpos($keywords, "\t") + 1))."\t".$newkeyword;
} else {
$keywords .= "\t".$newkeyword;
}
}
} else {
$keywords = $newkeyword;
}
}
dsetcookie('customkw', stripslashes($keywords), 315360000);
showmessage('customtopics_updated', $indexname);
}
} elseif($action == 'attachcredit') {
if($formhash != FORMHASH) {
showmessage('undefined_action', NULL, 'HALTED');
}
$aid = intval($aid);
$attach = $db->fetch_first("SELECT tid, filename FROM {$tablepre}attachments WHERE aid='$aid'");
$thread = $db->fetch_first("SELECT fid FROM {$tablepre}threads WHERE tid='$attach[tid]' AND displayorder>='0'");
$forum = $db->fetch_first("SELECT getattachcredits FROM {$tablepre}forumfields WHERE fid='$thread[fid]'");
$getattachcredits = $forum['getattachcredits'] ? unserialize($forum['getattachcredits']) : $creditspolicy['getattach'];
checklowerlimit($getattachcredits, -1);
updatecredits($discuz_uid, $getattachcredits, -1);
$policymsg = $p = '';
foreach($getattachcredits as $id => $policy) {
$policymsg .= $p.($extcredits[$id]['img'] ? $extcredits[$id]['img'].' ' : '').$extcredits[$id]['title'].' '.$policy.' '.$extcredits[$id]['unit'];
$p = ', ';
}
$ck = substr(md5($aid.$timestamp.md5($authkey)), 0, 8);
$aidencode = aidencode($aid);
showmessage('attachment_credit', "attachment.php?aid=$aidencode&ck=$ck", '', 1);
} elseif($action == 'attachpay') {
$aid = intval($aid);
$aidencode = aidencode($aid);
if(!$aid) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif(!isset($extcredits[$creditstransextra[1]])) {
showmessage('credits_transaction_disabled');
} elseif(!$discuz_uid) {
showmessage('group_nopermission', NULL, 'NOPERM');
} else {
$attach = $db->fetch_first("SELECT a.tid, a.pid, a.uid, a.price, a.filename, af.description, a.readperm, m.username AS author FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid LEFT JOIN {$tablepre}members m ON a.uid=m.uid WHERE a.aid='$aid'");
if($attach['price'] <= 0) {
showmessage('undefined_action', NULL, 'HALTED');
}
}
if($attach['readperm'] && $attach['readperm'] > $readaccess) {
showmessage('attachment_forum_nopermission', NULL, 'NOPERM');
}
if(($balance = ${'extcredits'.$creditstransextra[1]} - $attach['price']) < ($minbalance = 0)) {
showmessage('credits_balance_insufficient');
}
$sidauth = rawurlencode(authcode($sid, 'ENCODE', $authkey));
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}attachpaymentlog WHERE aid='$aid' AND uid='$discuz_uid'")) {
showmessage('attachment_yetpay', "attachment.php?aid=$aidencode", '', 1);
}
$discuz_action = 81;
$attach['netprice'] = round($attach['price'] * (1 - $creditstax));
if(!submitcheck('paysubmit')) {
include template('attachpay');
} else {
$updateauthor = 1;
if($maxincperthread > 0) {
if(($db->result_first("SELECT SUM(netamount) FROM {$tablepre}attachpaymentlog WHERE aid='$aid'")) > $maxincperthread) {
$updateauthor = 0;
}
}
if($updateauthor) {
updatecredits($attach['uid'], array($creditstransextra[1] => $attach['netprice']));
}
updatecredits($discuz_uid, array($creditstransextra[1] => $attach['price']), -1);
$db->query("INSERT INTO {$tablepre}attachpaymentlog (uid, aid, authorid, dateline, amount, netamount)
VALUES ('$discuz_uid', '$aid', '$attach[uid]', '$timestamp', '$attach[price]', '$attach[netprice]')");
$aidencode = aidencode($aid);
showmessage('attachment_buy', "attachment.php?aid=$aidencode", '', 1);
}
} elseif($action == 'viewattachpayments') {
$discuz_action = 82;
$loglist = array();
$query = $db->query("SELECT a.*, m.username FROM {$tablepre}attachpaymentlog a
LEFT JOIN {$tablepre}members m USING (uid)
WHERE aid='$aid' ORDER BY dateline");
while($log = $db->fetch_array($query)) {
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('attachpay_view');
} elseif($action == 'getonlines') {
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}sessions", 0);
showmessage($num);
} elseif($action == 'swfupload') {
if($operation == 'config' && $discuz_uid) {
$swfhash = md5(substr(md5($_DCACHE['settings']['authkey']), 8).$discuz_uid);
include_once language('swfupload');
$imageexts = array('jpg','jpeg','gif','png','bmp');
if($attachextensions !== '') {
$attachextensions = str_replace(' ', '', $attachextensions);
$exts = explode(',', $attachextensions);
if($type == 'image') {
$exts = array_intersect($imageexts, $exts);
}
$attachextensions = '*.'.implode(',*.', $exts);
} else {
$attachextensions = $type == 'image' ? '*.'.implode(',*.', $imageexts) : '*.*';
}
$depict = $type == 'image' ? "Image File " : 'All Support Formats ';
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><parameter><allowsExtend><extend depict=\"$depict\">$attachextensions</extend></allowsExtend><language>$xmllang</language><config><userid>$discuz_uid</userid><hash>$swfhash</hash><maxupload>$maxattachsize</maxupload></config></parameter>";
} elseif($operation == 'upload') {
$uid = intval($_POST['uid']);
$aid = 0;
$isimage = 0;
$simple = !empty($simple) ? $simple : 0;
$groupid = intval($db->result_first("SELECT groupid FROM {$tablepre}members WHERE uid='$uid'"));
@include DISCUZ_ROOT.'./forumdata/cache/usergroup_'.$groupid.'.php';
$swfhash = md5(substr(md5($_DCACHE['settings']['authkey']), 8).$uid);
$statusid = -1;
if(!$_FILES['Filedata']['error'] && $_POST['hash'] == $swfhash) {
require_once './include/post.func.php';
$attachments = attach_upload('Filedata');
if($attachments) {
if(is_array($attachments)) {
$attach = $attachments[0];
$isimage = $attach['isimage'];
if(!$simple) {
require_once DISCUZ_ROOT.'include/chinese.class.php';
$c = new Chinese('utf8', $charset);
$attach['name'] = addslashes($c->Convert(urldecode($attach['name'])));
if($type != 'image' && $isimage) $isimage = -1;
} elseif($simple == 1 && $type != 'image' && $isimage) {
$isimage = -1;
} elseif($simple == 2 && $type == 'image' && !$isimage) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
echo "DISCUZUPLOAD|1|4|0|0|";
exit;
}
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote, width)
VALUES ('0', '0', '$timestamp', '0', '0', '$attach[name]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$isimage', '$uid', '$attach[thumb]', '$attach[remote]', '$attach[width]')");
$aid = $db->insert_id();
$statusid = 0;
$uploadtag = 'upload';
if(!$attachid) {
$uploadtag = 'swfupload';
}
write_statlog('', 'action='.$uploadtag, '', '', 'forumstat.php');
} else {
$statusid = $attachments;
}
} else {
$statusid = 9;
}
} else {
$statusid = 10;
}
if($simple == 1) {
echo "DISCUZUPLOAD|$statusid|$aid|$isimage";
} elseif($simple == 2) {
echo "DISCUZUPLOAD|".($type == 'image' ? '1' : '0')."|$statusid|$aid|$isimage|$attach[attachment]";
} else {
echo $aid;
}
}
exit;
} elseif($action == 'upload') {
$allowpostattach = $forum['allowpostattach'] != -1 && ($forum['allowpostattach'] == 1 || (!$forum['postattachperm'] && $allowpostattach) || ($forum['postattachperm'] && forumperm($forum['postattachperm'])));
$attachextensions = $forum['attachextensions'] ? $forum['attachextensions'] : $attachextensions;
if($attachextensions) {
$imgexts = explode(',', str_replace(' ', '', $attachextensions));
$imgexts = array_intersect(array('jpg','jpeg','gif','png','bmp'), $imgexts);
$imgexts = implode(', ', $imgexts);
} else {
$imgexts = 'jpg, jpeg, gif, png, bmp';
}
$allowpostimg = $allowpostattach && $imgexts;
if(!$allowpostimg) {
showmessage('undefined_action', NULL, 'HALTED');
}
include template('upload');
} elseif($action == 'imme_binding' && $discuz_uid) {
if(isemail($id)) {
$msn = $db->result_first("SELECT msn FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
$msn = explode("\t", $msn);
$id = dhtmlspecialchars(substr($id, 0, strpos($id, '@')));
$msn = "$msn[0]\t$id";
$db->query("UPDATE {$tablepre}memberfields SET msn='$msn' WHERE uid='$discuz_uid'");
showmessage('msn_binding_succeed', 'memcp.php');
} else {
if($result == 'Declined') {
dheader("Location: memcp.php");
} else {
showmessage('Binding Failed. Visit <a href="http://im.live.cn/imme/index.htm" target="_blank">MSN IMME</a> Q&A, please.');
}
}
} elseif($action == 'imme_cancelbinding' && $discuz_uid) {
$msn = $db->result_first("SELECT msn FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
$msn = explode("\t", $msn);
$db->query("UPDATE {$tablepre}memberfields SET msn='$msn[0]' WHERE uid='$discuz_uid'");
dheader("Location: http://settings.messenger.live.com/applications/websettings.aspx");
} else {
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
showmessage('forum_nopermission', NULL, 'NOPERM');
}
}
$thread = $db->fetch_first("SELECT * FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
showmessage('thread_nopermission', NULL, 'NOPERM');
}
if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
showmessage('forum_passwd', "forumdisplay.php?fid=$fid");
}
if(!$thread) {
showmessage('thread_nonexistence');
}
if($forum['type'] == 'forum') {
$navigation = "» <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a> » <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a> ";
$navtitle = strip_tags($forum['name']).' - '.$thread['subject'];
} elseif($forum['type'] == 'sub') {
$fup = $db->fetch_first("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$navigation = "» <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> » <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a> » <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a> ";
$navtitle = strip_tags($fup['name']).' - '.strip_tags($forum['name']).' - '.$thread['subject'];
}
}
if($action == 'votepoll' && submitcheck('pollsubmit', 1)) {
if(!$allowvote) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif(!empty($thread['closed'])) {
showmessage('thread_poll_closed', NULL, 'NOPERM');
} elseif(empty($pollanswers)) {
showmessage('thread_poll_invalid', NULL, 'NOPERM');
}
$pollarray = $db->fetch_first("SELECT maxchoices, expiration FROM {$tablepre}polls WHERE tid='$tid'");
if(!$pollarray) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif($pollarray['expiration'] && $pollarray['expiration'] < $timestamp) {
showmessage('poll_overdue', NULL, 'NOPERM');
} elseif($pollarray['maxchoices'] && $pollarray['maxchoices'] < count($pollanswers)) {
showmessage('poll_choose_most', NULL, 'NOPERM');
}
$voterids = $discuz_uid ? $discuz_uid : $onlineip;
$polloptionid = array();
$query = $db->query("SELECT polloptionid, voterids FROM {$tablepre}polloptions WHERE tid='$tid'");
while($pollarray = $db->fetch_array($query)) {
if(strexists("\t".$pollarray['voterids']."\t", "\t".$voterids."\t")) {
showmessage('thread_poll_voted', NULL, 'NOPERM');
}
$polloptionid[] = $pollarray['polloptionid'];
}
$polloptionids = '';
foreach($pollanswers as $key => $id) {
if(!in_array($id, $polloptionid)) {
showmessage('undefined_action', NULL, 'HALTED');
}
unset($polloptionid[$key]);
$polloptionids[] = $id;
}
$pollanswers = implode('\',\'', $polloptionids);
$db->query("UPDATE {$tablepre}polloptions SET votes=votes+1, voterids=CONCAT(voterids,'$voterids\t') WHERE polloptionid IN ('$pollanswers')", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SET lastpost='$timestamp' WHERE tid='$tid'", 'UNBUFFERED');
updatecredits($discuz_uid, $creditspolicy['votepoll']);
if($customaddfeed & 4) {
$feed['icon'] = 'poll';
$feed['title_template'] = 'feed_thread_votepoll_title';
$feed['title_data'] = array(
'subject' => "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$thread[subject]</a>",
'author' => "<a href=\"space.php?uid=$thread[authorid]\">$thread[author]</a>"
);
postfeed($feed);
}
$pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND first='1'");
if(!empty($inajax)) {
showmessage('thread_poll_succeed', "viewthread.php?tid=$tid&viewpid=$pid&inajax=1");
} else {
showmessage('thread_poll_succeed', "viewthread.php?tid=$tid");
}
} elseif($action == 'viewvote') {
require_once DISCUZ_ROOT.'./include/post.func.php';
$polloptionid = is_numeric($polloptionid) ? $polloptionid : '';
$overt = $db->result_first("SELECT overt FROM {$tablepre}polls WHERE tid='$tid'");
$polloptions = array();
$query = $db->query("SELECT polloptionid, polloption FROM {$tablepre}polloptions WHERE tid='$tid'");
while($options = $db->fetch_array($query)) {
if(empty($polloptionid)) {
$polloptionid = $options['polloptionid'];
}
$options['polloption'] = preg_replace("/\[url=(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/([^\[\"']+?)\](.+?)\[\/url\]/i",
"<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", $options['polloption']);
$polloptions[] = $options;
}
$arrvoterids = array();
if($overt || $adminid == 1) {
$voterids = '';
$voterids = $db->result_first("SELECT voterids FROM {$tablepre}polloptions WHERE polloptionid='$polloptionid'");
$arrvoterids = explode("\t", trim($voterids));
}
if(!empty($arrvoterids)) {
$arrvoterids = array_slice($arrvoterids, -100);
}
$voterlist = $voter = array();
if($voterids = implodeids($arrvoterids)) {
$query = $db->query("SELECT uid, username FROM {$tablepre}members WHERE uid IN ($voterids)");
while($voter = $db->fetch_array($query)) {
$voterlist[] = $voter;
}
}
include template('viewthread_poll_voters');
} elseif($action == 'rate' && $pid) {
if(!$raterange) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($modratelimit && $adminid == 3 && !$forum['ismoderator']) {
showmessage('thread_rate_moderator_invalid', NULL, 'HALTED');
}
$reasonpmcheck = $reasonpm == 2 || $reasonpm == 3 ? 'checked="checked" disabled' : '';
if(($reasonpm == 2 || $reasonpm == 3) || !empty($sendreasonpm)) {
$forumname = strip_tags($forum['name']);
$sendreasonpm = 1;
} else {
$sendreasonpm = 0;
}
foreach($raterange as $id => $rating) {
$maxratetoday[$id] = $rating['mrpd'];
}
$query = $db->query("SELECT extcredits, SUM(ABS(score)) AS todayrate FROM {$tablepre}ratelog
WHERE uid='$discuz_uid' AND dateline>=$timestamp-86400
GROUP BY extcredits");
while($rate = $db->fetch_array($query)) {
$maxratetoday[$rate['extcredits']] = $raterange[$rate['extcredits']]['mrpd'] - $rate['todayrate'];
}
$post = $db->fetch_first("SELECT * FROM {$tablepre}posts WHERE pid='$pid' AND invisible='0' AND authorid<>'0'");
if(!$post || $post['tid'] != $thread['tid'] || !$post['authorid']) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif(!$forum['ismoderator'] && $karmaratelimit && $timestamp - $post['dateline'] > $karmaratelimit * 3600) {
showmessage('thread_rate_timelimit', NULL, 'HALTED');
} elseif($post['authorid'] == $discuz_uid || $post['tid'] != $tid) {
showmessage('thread_rate_member_invalid', NULL, 'HALTED');
} elseif($post['anonymous']) {
showmessage('thread_rate_anonymous', NULL, 'HALTED');
} elseif($post['status'] & 1) {
showmessage('thread_rate_banned', NULL, 'HALTED');
}
$allowrate = TRUE;
if(!$dupkarmarate) {
$query = $db->query("SELECT pid FROM {$tablepre}ratelog WHERE uid='$discuz_uid' AND pid='$pid' LIMIT 1");
if($db->num_rows($query)) {
showmessage('thread_rate_duplicate', NULL, 'HALTED');
}
}
$discuz_action = 71;
$page = intval($page);
require_once DISCUZ_ROOT.'./include/misc.func.php';
if(!submitcheck('ratesubmit')) {
$referer = $boardurl.'viewthread.php?tid='.$tid.'&page='.$page.'#pid'.$pid;
$ratelist = array();
foreach($raterange as $id => $rating) {
if(isset($extcredits[$id])) {
$ratelist[$id] = '';
$rating['max'] = $rating['max'] < $maxratetoday[$id] ? $rating['max'] : $maxratetoday[$id];
$rating['min'] = -$rating['min'] < $maxratetoday[$id] ? $rating['min'] : -$maxratetoday[$id];
$offset = abs(ceil(($rating['max'] - $rating['min']) / 10));
if($rating['max'] > $rating['min']) {
for($vote = $rating['max']; $vote >= $rating['min']; $vote -= $offset) {
$ratelist[$id] .= $vote ? '<li>'.($vote > 0 ? '+'.$vote : $vote).'</li>' : '';
}
}
}
}
include template('rate');
} else {
checkreasonpm();
$rate = $ratetimes = 0;
$creditsarray = array();
foreach($raterange as $id => $rating) {
$score = intval(${'score'.$id});
if(isset($extcredits[$id]) && !empty($score)) {
if(abs($score) <= $maxratetoday[$id]) {
if($score > $rating['max'] || $score < $rating['min']) {
showmessage('thread_rate_range_invalid');
} else {
$creditsarray[$id] = $score;
$rate += $score;
$ratetimes += ceil(max(abs($rating['min']), abs($rating['max'])) / 5);
}
} else {
showmessage('thread_rate_ctrl');
}
}
}
if(!$creditsarray) {
showmessage('thread_rate_range_invalid', NULL, 'HALTED');
}
updatecredits($post['authorid'], $creditsarray);
$db->query("UPDATE {$tablepre}posts SET rate=rate+($rate), ratetimes=ratetimes+$ratetimes WHERE pid='$pid'");
if($post['first']) {
$threadrate = intval(@($post['rate'] + $rate) / abs($post['rate'] + $rate));
$db->query("UPDATE {$tablepre}threads SET rate='$threadrate' WHERE tid='$tid'");
$send_feed = false;
if(is_array($dzfeed_limit['thread_rate'])) foreach($dzfeed_limit['thread_rate'] as $val) {
if($post['rate'] < $val && ($post['rate'] + $rate) > $val) {
$send_feed = true;
$count = $val;
}
}
if($send_feed) {
$arg = $data = array();
$arg['type'] = 'thread_rate';
$arg['fid'] = $post['fid'];
$arg['typeid'] = $thread['typeid'];
$arg['sortid'] = $thread['sortid'];
$arg['uid'] = $thread['authorid'];
$arg['username'] = addslashes($thread['author']);
$data['title']['actor'] = $thread['authorid'] ? "<a href=\"space.php?uid={$thread[authorid]}\" target=\"_blank\">{$thread[author]}</a>" : $thread['author'];
$data['title']['forum'] = "<a href=\"forumdisplay.php?fid={$thread[fid]}\" target=\"_blank\">".$forum['name'].'</a>';
$data['title']['count'] = $count;
$data['title']['subject'] = "<a href=\"viewthread.php?tid={$thread[tid]}\" target=\"_blank\">{$thread[subject]}</a>";
add_feed($arg, $data);
}
} else {
$send_feed = false;
if(is_array($dzfeed_limit['post_rate'])) foreach($dzfeed_limit['post_rate'] as $val) {
if($post['rate'] < $val && ($post['rate'] + $rate) > $val) {
$send_feed = true;
$count = $val;
}
}
if($send_feed) {
$arg = $data = array();
$arg['type'] = 'post_rate';
$arg['fid'] = $post['fid'];
$arg['typeid'] = $thread['typeid'];
$arg['sortid'] = $thread['sortid'];
$arg['uid'] = $thread['authorid'];
$arg['username'] = addslashes($thread['author']);
$data['title']['actor'] = $thread['authorid'] ? "<a href=\"space.php?uid={$thread[authorid]}\" target=\"_blank\">{$thread[author]}</a>" : $thread['author'];
$data['title']['thread'] = "<a href=\"viewthread.php?tid={$thread[tid]}\" target=\"_blank\">{$thread[subject]}</a>";
$data['title']['count'] = $count;
add_feed($arg, $data);
}
}
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$sqlvalues = $comma = '';
$sqlreason = censor(trim($reason));
$sqlreason = cutstr(dhtmlspecialchars($sqlreason), 40);
foreach($creditsarray as $id => $addcredits) {
$sqlvalues .= "$comma('$pid', '$discuz_uid', '$discuz_user', '$id', '$timestamp', '$addcredits', '$sqlreason')";
$comma = ', ';
}
$db->query("INSERT INTO {$tablepre}ratelog (pid, uid, username, extcredits, dateline, score, reason)
VALUES $sqlvalues", 'UNBUFFERED');
include_once DISCUZ_ROOT.'./include/post.func.php';
$forum['threadcaches'] && @deletethreadcaches($tid);
$reason = dhtmlspecialchars(censor(trim($reason)));
if($sendreasonpm) {
$ratescore = $slash = '';
foreach($creditsarray as $id => $addcredits) {
$ratescore .= $slash.$extcredits[$id]['title'].' '.($addcredits > 0 ? '+'.$addcredits : $addcredits).' '.$extcredits[$id]['unit'];
$slash = ' / ';
}
sendreasonpm('post', 'rate_reason');
}
$logs = array();
foreach($creditsarray as $id => $addcredits) {
$logs[] = dhtmlspecialchars("$timestamp\t$discuz_userss\t$adminid\t$post[author]\t$id\t$addcredits\t$tid\t$thread[subject]\t$reason");
}
writelog('ratelog', $logs);
showmessage('thread_rate_succeed', dreferer());
}
} elseif($action == 'removerate' && $pid) {
if(!$forum['ismoderator'] || !$raterange) {
showmessage('undefined_action');
}
$reasonpmcheck = $reasonpm == 2 || $reasonpm == 3 ? 'checked="checked" disabled' : '';
if(($reasonpm == 2 || $reasonpm == 3) || !empty($sendreasonpm)) {
$forumname = strip_tags($forum['name']);
$sendreasonpm = 1;
} else {
$sendreasonpm = 0;
}
foreach($raterange as $id => $rating) {
$maxratetoday[$id] = $rating['mrpd'];
}
$post = $db->fetch_first("SELECT * FROM {$tablepre}posts WHERE pid='$pid' AND invisible='0' AND authorid<>'0'");
if(!$post || $post['tid'] != $thread['tid'] || !$post['authorid']) {
showmessage('undefined_action');
}
$discuz_action = 71;
require_once DISCUZ_ROOT.'./include/misc.func.php';
if(!submitcheck('ratesubmit')) {
$referer = $boardurl.'viewthread.php?tid='.$tid.'&page='.$page.'#pid'.$pid;
$ratelogs = array();
$query = $db->query("SELECT * FROM {$tablepre}ratelog WHERE pid='$pid' ORDER BY dateline");
while($ratelog = $db->fetch_array($query)) {
$ratelog['dbdateline'] = $ratelog['dateline'];
$ratelog['dateline'] = dgmdate("$dateformat $timeformat", $ratelog['dateline'] + $timeoffset * 3600);
$ratelog['scoreview'] = $ratelog['score'] > 0 ? '+'.$ratelog['score'] : $ratelog['score'];
$ratelogs[] = $ratelog;
}
include template('rate');
} else {
checkreasonpm();
if(!empty($logidarray)) {
if($sendreasonpm) {
$ratescore = $slash = '';
}
$query = $db->query("SELECT * FROM {$tablepre}ratelog WHERE pid='$pid'");
$rate = $ratetimes = 0;
$logs = array();
while($ratelog = $db->fetch_array($query)) {
if(in_array($ratelog['uid'].' '.$ratelog['extcredits'].' '.$ratelog['dateline'], $logidarray)) {
$rate += $ratelog['score'] = -$ratelog['score'];
$ratetimes += ceil(max(abs($rating['min']), abs($rating['max'])) / 5);
updatecredits($post['authorid'], array($ratelog['extcredits'] => $ratelog['score']));
$db->query("DELETE FROM {$tablepre}ratelog WHERE pid='$pid' AND uid='$ratelog[uid]' AND extcredits='$ratelog[extcredits]' AND dateline='$ratelog[dateline]'", 'UNBUFFERED');
$logs[] = dhtmlspecialchars("$timestamp\t$discuz_userss\t$adminid\t$ratelog[username]\t$ratelog[extcredits]\t$ratelog[score]\t$tid\t$thread[subject]\t$reason\tD");
if($sendreasonpm) {
$ratescore .= $slash.$extcredits[$ratelog['extcredits']]['title'].' '.($ratelog['score'] > 0 ? '+'.$ratelog['score'] : $ratelog['score']).' '.$extcredits[$ratelog['extcredits']]['unit'];
$slash = ' / ';
}
}
}
writelog('ratelog', $logs);
if($sendreasonpm) {
sendreasonpm('post', 'rate_removereason');
}
$db->query("UPDATE {$tablepre}posts SET rate=rate+($rate), ratetimes=ratetimes-$ratetimes WHERE pid='$pid'");
if($post['first']) {
$threadrate = @intval(@($post['rate'] + $rate) / abs($post['rate'] + $rate));
$db->query("UPDATE {$tablepre}threads SET rate='$threadrate' WHERE tid='$tid'");
}
}
showmessage('thread_rate_removesucceed', dreferer());
}
} elseif($action == 'viewratings' && $pid) {
$queryr = $db->query("SELECT * FROM {$tablepre}ratelog WHERE pid='$pid' ORDER BY dateline DESC");
$queryp = $db->query("SELECT p.* ".($bannedmessages ? ", m.groupid " : '').
" FROM {$tablepre}posts p ".
($bannedmessages ? "LEFT JOIN {$tablepre}members m ON m.uid=p.authorid" : '').
" WHERE p.pid='$pid' AND p.invisible='0'");
if(!($db->num_rows($queryr)) || !($db->num_rows($queryp))) {
showmessage('thread_rate_log_nonexistence');
}
$post = $db->fetch_array($queryp);
if($post['tid'] != $thread['tid']) {
showmessage('undefined_action', NULL, 'HALTED');
}
$loglist = $logcount = array();
while($log = $db->fetch_array($queryr)) {
$logcount[$log['extcredits']] += $log['score'];
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$log['score'] = $log['score'] > 0 ? '+'.$log['score'] : $log['score'];
$log['reason'] = dhtmlspecialchars($log['reason']);
$loglist[] = $log;
}
include template('rate_view');
} elseif($action == 'viewwarning' && $uid) {
if(!($warnuser = $db->result_first("SELECT username FROM {$tablepre}members WHERE uid='$uid'"))) {
showmessage('undefined_action', NULL, 'HALTED');
}
$query = $db->query("SELECT * FROM {$tablepre}warnings WHERE authorid='$uid'");
if(!($warnnum = $db->num_rows($query))) {
showmessage('thread_warning_nonexistence');
}
$warning = array();
while($warning = $db->fetch_array($query)) {
$warning['dateline'] = dgmdate("$dateformat $timeformat", $warning['dateline'] + $timeoffset * 3600);
$warning['reason'] = dhtmlspecialchars($warning['reason']);
$warnings[] = $warning;
}
$discuz_action = 73;
include template('warn_view');
} elseif($action == 'pay') {
if(!isset($extcredits[$creditstransextra[1]])) {
showmessage('credits_transaction_disabled');
} elseif($thread['price'] <= 0 || $thread['special'] <> 0) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif(!$discuz_uid) {
showmessage('group_nopermission', NULL, 'NOPERM');
}
if(($balance = ${'extcredits'.$creditstransextra[1]} - $thread['price']) < ($minbalance = 0)) {
showmessage('credits_balance_insufficient');
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}paymentlog WHERE tid='$tid' AND uid='$discuz_uid'")) {
showmessage('credits_buy_thread', 'viewthread.php?tid='.$tid);
}
$discuz_action = 81;
$thread['netprice'] = floor($thread['price'] * (1 - $creditstax));
if(!submitcheck('paysubmit')) {
include template('pay');
} else {
$updateauthor = true;
if($maxincperthread > 0) {
if(($db->result_first("SELECT SUM(netamount) FROM {$tablepre}paymentlog WHERE tid='$tid'")) > $maxincperthread) {
$updateauthor = false;
}
}
if($updateauthor) {
updatecredits($thread['authorid'], array($creditstransextra[1] => $thread['netprice']));
}
updatecredits($discuz_uid, array($creditstransextra[1] => $thread['price']), -1);
$db->query("INSERT INTO {$tablepre}paymentlog (uid, tid, authorid, dateline, amount, netamount)
VALUES ('$discuz_uid', '$tid', '$thread[authorid]', '$timestamp', '$thread[price]', '$thread[netprice]')");
showmessage('thread_pay_succeed', "viewthread.php?tid=$tid");
}
} elseif($action == 'viewpayments') {
$discuz_action = 82;
$loglist = array();
$query = $db->query("SELECT p.*, m.username FROM {$tablepre}paymentlog p
LEFT JOIN {$tablepre}members m USING (uid)
WHERE tid='$tid' ORDER BY dateline");
while($log = $db->fetch_array($query)) {
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('pay_view');
} elseif($action == 'report') {
if(!$reportpost) {
showmessage('thread_report_disabled');
}
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
if(!$thread || !is_numeric($pid)) {
showmessage('undefined_action', NULL, 'HALTED');
}
$discuz_action = 123;
$floodctrl = $floodctrl * 3;
if($timestamp - $lastpost < $floodctrl) {
showmessage('thread_report_flood_ctrl');
}
if($db->result_first("SELECT id FROM {$tablepre}reportlog WHERE pid='$pid' AND uid='$discuz_uid'")) {
showmessage('thread_report_existence');
}
if(!submitcheck('reportsubmit')) {
include template('reportpost');
exit;
} else {
$type = intval($type) ? 1 : 0;
$reason = cutstr(dhtmlspecialchars($reason), 40);
$db->query("INSERT INTO {$tablepre}reportlog (fid, pid, uid, username, type, reason, dateline)
VALUES ('$fid', '$pid', '$discuz_uid', '$discuz_user', '$type', '$reason', '$timestamp')");
$db->query("UPDATE {$tablepre}forums SET modworks='1' WHERE fid='$fid'");
$db->query("UPDATE {$tablepre}members SET lastpost='$timestamp' WHERE uid='$discuz_uid'");
showmessage('thread_report_succeed', "viewthread.php?tid=$tid");
}
} elseif($action == 'viewthreadmod' && $tid) {
include_once language('modactions');
$loglist = array();
$query = $db->query("SELECT * FROM {$tablepre}threadsmod WHERE tid='$tid' ORDER BY dateline DESC");
while($log = $db->fetch_array($query)) {
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$log['expiration'] = !empty($log['expiration']) ? gmdate("$dateformat", $log['expiration'] + $timeoffset * 3600) : '';
$log['status'] = empty($log['status']) ? 'style="text-decoration: line-through" disabled' : '';
if(!$modactioncode[$log['action']] && preg_match('/S(\d\d)/', $log['action'], $a) || $log['action'] == 'SPA') {
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_stamps.php';
if($log['action'] == 'SPA') {
$log['action'] = 'SPA'.$log['stamp'];
$stampid = $log['stamp'];
} else {
$stampid = intval($a[1]);
}
$modactioncode[$log['action']] = $modactioncode['SPA'].' '.$_DCACHE['stamps'][$stampid]['text'];
}
if($log['magicid']) {
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_magics.php';
$log['magicname'] = $_DCACHE['magics'][$log['magicid']]['name'];
}
$loglist[] = $log;
}
if(empty($loglist)) {
showmessage('threadmod_nonexistence');
}
include template('viewthread_mod');
} elseif($action == 'bestanswer' && $tid && $pid && submitcheck('bestanswersubmit')) {
$forward = 'viewthread.php?tid='.$tid;
$post = $db->fetch_first("SELECT authorid, first FROM {$tablepre}posts WHERE pid='$pid' and tid='$tid'");
if(!($thread['special'] == 3 && $post && ($forum['ismoderator'] || $thread['authorid'] == $discuz_uid) && $post['authorid'] != $thread['authorid'] && $post['first'] == 0 && $discuz_uid != $post['authorid'])) {
showmessage('reward_cant_operate');
} elseif($post['authorid'] == $thread['authorid']) {
showmessage('reward_cant_self');
} elseif($thread['price'] < 0) {
showmessage('reward_repeat_selection');
}
$thread['netprice'] = ceil($price * ( 1 + $creditstax) );
$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]+$thread[price] WHERE uid='$post[authorid]'");
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='$tid' and answererid='$post[authorid]'");
$db->query("UPDATE {$tablepre}rewardlog SET answererid='$post[authorid]' WHERE tid='$tid' and authorid='$thread[authorid]'");
$thread['price'] = '-'.$thread['price'];
$db->query("UPDATE {$tablepre}threads SET price='$thread[price]' WHERE tid='$tid'");
$db->query("UPDATE {$tablepre}posts SET dateline=$thread[dateline]+1 WHERE pid='$pid'");
$thread['dateline'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
if($discuz_uid != $thread['authorid']) {
sendnotice($thread['authorid'], 'reward_question', 'threads');
}
sendnotice($post['authorid'], 'reward_bestanswer', 'threads');
showmessage('reward_completion', $forward);
} elseif($action == 'activityapplies') {
if(!$discuz_uid) {
showmessage('undefined_action', NULL, 'HALTED');
}
if(submitcheck('activitysubmit')) {
$expiration = $db->result_first("SELECT expiration FROM {$tablepre}activities WHERE tid='$tid'");
if($expiration && $expiration < $timestamp) {
showmessage('activity_stop', NULL, 'NOPERM');
}
$query = $db->query("SELECT applyid FROM {$tablepre}activityapplies WHERE tid='$tid' and username='$discuz_user'");
if($db->num_rows($query)) {
showmessage('activity_repeat_apply', NULL, 'NOPERM');
}
$payvalue = intval($payvalue);
$payment = $payment ? $payvalue : -1;
$message = cutstr(dhtmlspecialchars($message), 200);
$contact = cutstr(dhtmlspecialchars($contact), 200);
$db->query("INSERT INTO {$tablepre}activityapplies (tid, username, uid, message, verified, dateline, payment, contact)
VALUES ('$tid', '$discuz_user', '$discuz_uid', '$message', '0', '$timestamp', '$payment', '$contact')");
if($customaddfeed & 4) {
$feed['icon'] = 'activity';
$feed['title_template'] = 'feed_reply_activity_title';
$feed['title_data'] = array(
'subject' => "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$thread[subject]</a>"
);
postfeed($feed);
}
showmessage('activity_completion', "viewthread.php?tid=$tid&viewpid=$pid");
}
} elseif($action == 'activityapplylist') {
$isactivitymaster = $thread['authorid'] == $discuz_uid || $alloweditactivity;
$activity = $db->fetch_first("SELECT * FROM {$tablepre}activities WHERE tid='$tid'");
if(!$activity || $thread['special'] != 4 || !$isactivitymaster) {
showmessage('undefined_action');
}
if(!submitcheck('applylistsubmit')) {
$sqlverified = $isactivitymaster ? '' : 'AND verified=1';
if(!empty($uid) && $isactivitymaster) {
$sqlverified .= " AND uid='$uid'";
}
$applylist = array();
$query = $db->query("SELECT applyid, username, uid, message, verified, dateline, payment, contact FROM {$tablepre}activityapplies WHERE tid='$tid' $sqlverified ORDER BY dateline DESC");
while($activityapplies = $db->fetch_array($query)) {
$activityapplies['dateline'] = dgmdate("$dateformat $timeformat", $activityapplies['dateline'] + $timeoffset * 3600);
$applylist[] = $activityapplies;
}
$activity['starttimefrom'] = dgmdate("$dateformat $timeformat", $activity['starttimefrom'] + $timeoffset * 3600);
$activity['starttimeto'] = $activity['starttimeto'] ? dgmdate("$dateformat $timeformat", $activity['starttimeto'] + $timeoffset * 3600) : 0;
$activity['expiration'] = $activity['expiration'] ? dgmdate("$dateformat $timeformat", $activity['expiration'] + $timeoffset * 3600) : 0;
$applynumbers = $db->result_first("SELECT COUNT(*) FROM {$tablepre}activityapplies WHERE tid='$tid' AND verified=1");
include template('activity_applylist');
} else {
if(empty($applyidarray)) {
showmessage('activity_choice_applicant', "viewthread.php?tid=$tid&do=viewapplylist");
} else {
$uidarray = array();
$ids = implode('\',\'', $applyidarray);
$query=$db->query("SELECT a.uid FROM {$tablepre}activityapplies a RIGHT JOIN {$tablepre}members m USING(uid) WHERE a.applyid IN ('$ids')");
while($uid = $db->fetch_array($query)) {
$uidarray[] = $uid['uid'];
}
$activity_subject = $thread['subject'];
if($operation == 'delete') {
$db->query("DELETE FROM {$tablepre}activityapplies WHERE applyid IN ('$ids')", 'UNBUFFERED');
sendnotice(implode(',', $uidarray), 'activity_delete', 'threads');
showmessage('activity_delete_completion', "viewthread.php?tid=$tid&do=viewapplylist");
} else {
$db->query("UPDATE {$tablepre}activityapplies SET verified=1 WHERE applyid IN ('$ids')", 'UNBUFFERED');
sendnotice(implode(',', $uidarray), 'activity_apply', 'threads');
showmessage('activity_auditing_completion', "viewthread.php?tid=$tid&do=viewapplylist");
}
}
}
} elseif($action == 'activityexport') {
$activity = $db->fetch_first("SELECT a.*, p.message FROM {$tablepre}activities a LEFT JOIN {$tablepre}posts p ON p.tid=a.tid AND p.first='1' WHERE a.tid='$tid'");
if(!$activity || $thread['special'] != 4 || $thread['authorid'] != $discuz_uid && !$alloweditactivity) {
showmessage('undefined_action');
}
$activity['starttimefrom'] = dgmdate("$dateformat $timeformat", $activity['starttimefrom'] + $timeoffset * 3600, 0);
$activity['starttimeto'] = $activity['starttimeto'] ? dgmdate("$dateformat $timeformat", $activity['starttimeto'] + $timeoffset * 3600, 0) : 0;
$activity['expiration'] = $activity['expiration'] ? dgmdate("$dateformat $timeformat", $activity['expiration'] + $timeoffset * 3600, 0) : 0;
$applynumbers = $db->result_first("SELECT COUNT(*) FROM {$tablepre}activityapplies WHERE tid='$tid' AND verified=1");
$applylist = array();
$query = $db->query("SELECT applyid, username, uid, message, verified, dateline, payment, contact FROM {$tablepre}activityapplies WHERE tid='$tid' ORDER BY dateline DESC");
while($apply = $db->fetch_array($query)) {
$apply['dateline'] = dgmdate("$dateformat $timeformat", $apply['dateline'] + $timeoffset *3600, 0);
$applylist[] = $apply;
}
$filename = "activity_{$tid}.csv";
ob_end_clean();
header('Content-Encoding: none');
header('Content-Type: '.('application/octet-stream'));
header('Content-Disposition: '.('attachment; ').'filename='.$filename);
header('Pragma: no-cache');
header('Expires: 0');
if(strtoupper($charset) == 'UTF-8') {
echo chr(0xEF).chr(0xBB).chr(0xBF);
}
include template('activity_export');
} elseif($action == 'tradeorder') {
$trades = array();
$query=$db->query("SELECT * FROM {$tablepre}trades WHERE tid='$tid' ORDER BY displayorder");
if($thread['authorid'] != $discuz_uid && !$allowedittrade) {
showmessage('undefined_action', NULL, 'HALTED');
}
if(!submitcheck('tradesubmit')) {
$stickcount = 0;$trades = $tradesstick = array();
while($trade = $db->fetch_array($query)) {
$stickcount = $trade['displayorder'] > 0 ? $stickcount + 1 : $stickcount;
$trade['displayorderview'] = $trade['displayorder'] < 0 ? 128 + $trade['displayorder'] : $trade['displayorder'];
if($trade['expiration']) {
$trade['expiration'] = ($trade['expiration'] - $timestamp) / 86400;
if($trade['expiration'] > 0) {
$trade['expirationhour'] = floor(($trade['expiration'] - floor($trade['expiration'])) * 24);
$trade['expiration'] = floor($trade['expiration']);
} else {
$trade['expiration'] = -1;
}
}
if($trade['displayorder'] < 0) {
$trades[] = $trade;
} else {
$tradesstick[] = $trade;
}
}
$trades = array_merge($tradesstick, $trades);
include template('trade_displayorder');
} else {
$count = 0;
while($trade = $db->fetch_array($query)) {
$displayordernew = abs(intval($displayorder[$trade['pid']]));
$displayordernew = $displayordernew > 128 ? 0 : $displayordernew;
if($stick[$trade['pid']]) {
$count++;
$displayordernew = $displayordernew == 0 ? 1 : $displayordernew;
}
if(!$stick[$trade['pid']] || $displayordernew > 0 && $tradestick < $count) {
$displayordernew = -1 * (128 - $displayordernew);
}
$db->query("UPDATE {$tablepre}trades SET displayorder='".$displayordernew."' WHERE tid='$tid' AND pid='$trade[pid]'");
}
showmessage('trade_displayorder_updated', "viewthread.php?tid=$tid");
}
} elseif($action == 'debatevote') {
if(!empty($thread['closed'])) {
showmessage('thread_poll_closed');
}
if(!$discuz_uid) {
showmessage('debate_poll_nopermission');
}
$isfirst = empty($pid) ? TRUE : FALSE;
$debate = $db->fetch_first("SELECT uid, endtime, affirmvoterids, negavoterids FROM {$tablepre}debates WHERE tid='$tid'");
if(empty($debate)) {
showmessage('debate_nofound');
}
$feed = array();
if($customaddfeed & 4) {
$feed['icon'] = 'debate';
$feed['title_template'] = 'feed_thread_debatevote_title';
$feed['title_data'] = array(
'subject' => "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$thread[subject]</a>",
'author' => "<a href=\"space.php?uid=$thread[authorid]\">$thread[author]</a>"
);
}
if($isfirst) {
$stand = intval($stand);
if($stand == 1 || $stand == 2) {
if(strpos("\t".$debate['affirmvoterids'], "\t$discuz_uid\t") !== FALSE || strpos("\t".$debate['negavoterids'], "\t$discuz_uid\t") !== FALSE) {
showmessage('debate_poll_voted');
} elseif($debate['uid'] == $discuz_uid) {
showmessage('debate_poll_myself');
} elseif($debate['endtime'] && $debate['endtime'] < $timestamp) {
showmessage('debate_poll_end');
}
}
if($stand == 1) {
$db->query("UPDATE {$tablepre}debates SET affirmvotes=affirmvotes+1 WHERE tid='$tid'");
$db->query("UPDATE {$tablepre}debates SET affirmvoterids=CONCAT(affirmvoterids, '$discuz_uid\t') WHERE tid='$tid'");
} elseif($stand == 2) {
$db->query("UPDATE {$tablepre}debates SET negavotes=negavotes+1 WHERE tid='$tid'");
$db->query("UPDATE {$tablepre}debates SET negavoterids=CONCAT(negavoterids, '$discuz_uid\t') WHERE tid='$tid'");
}
if($feed) {
postfeed($feed);
}
showmessage('debate_poll_succeed');
}
$debatepost = $db->fetch_first("SELECT stand, voterids, uid FROM {$tablepre}debateposts WHERE pid='$pid' AND tid='$tid'");
if(empty($debatepost)) {
showmessage('debate_nofound');
}
$debate = array_merge($debate, $debatepost);
unset($debatepost);
if($debate['uid'] == $discuz_uid) {
showmessage('debate_poll_myself', "viewthread.php?tid=$tid");
} elseif(strpos("\t".$debate['voterids'], "\t$discuz_uid\t") !== FALSE) {
showmessage('debate_poll_voted', "viewthread.php?tid=$tid");
} elseif($debate['endtime'] && $debate['endtime'] < $timestamp) {
showmessage('debate_poll_end', "viewthread.php?tid=$tid");
}
/*
if($isfirst) {
$sqladd = $debate['stand'] == 1 ? 'affirmvotes=affirmvotes+1' : ($debate['stand'] == 2 ? 'negavotes=negavotes+1' : '');
if($sqladd) {
$db->query("UPDATE {$tablepre}debates SET $sqladd WHERE tid='$tid'");
}
unset($sqladd);
}
*/
$db->query("UPDATE {$tablepre}debateposts SET voters=voters+1, voterids=CONCAT(voterids, '$discuz_uid\t') WHERE pid='$pid'");
if($feed) {
postfeed($feed);
}
showmessage('debate_poll_succeed', "viewthread.php?tid=$tid");
} elseif($action == 'debateumpire') {
$debate = $db->fetch_first("SELECT * FROM {$tablepre}debates WHERE tid='$tid'");
if(empty($debate)) {
showmessage('debate_nofound');
}elseif(!empty($thread['closed']) && $timestamp - $debate['endtime'] > 3600) {
showmessage('debate_umpire_edit_invalid');
} elseif($discuz_userss != $debate['umpire']) {
showmessage('debate_umpire_nopermission');
}
$debate = array_merge($debate, $thread);
if(!submitcheck('umpiresubmit')) {
$query = $db->query("SELECT SUM(dp.voters) as voters, dp.stand, m.uid, m.username FROM {$tablepre}debateposts dp
LEFT JOIN {$tablepre}members m ON m.uid=dp.uid
WHERE dp.tid='$tid' AND dp.stand<>0
GROUP BY m.uid
ORDER BY voters DESC
LIMIT 30");
$candidate = $candidates = array();
while($candidate = $db->fetch_array($query)) {
$candidate['username'] = dhtmlspecialchars($candidate['username']);
$candidates[$candidate['username']] = $candidate;
}
$winnerchecked = array($debate['winner'] => ' checked="checked"');
list($debate['bestdebater']) = preg_split("/\s/", $debate['bestdebater']);
include template('debate_umpire');
} else {
if(empty($bestdebater)) {
showmessage('debate_umpire_nofound_bestdebater');
} elseif(empty($winner)) {
showmessage('debate_umpire_nofound_winner');
} elseif(empty($umpirepoint)) {
showmessage('debate_umpire_nofound_point');
}
$bestdebateruid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$bestdebater' LIMIT 1");
if(!$bestdebateruid) {
showmessage('debate_umpire_bestdebater_invalid');
}
if(!$bestdebaterstand = $db->result_first("SELECT stand FROM {$tablepre}debateposts WHERE tid='$tid' AND uid='$bestdebateruid' AND stand>'0' AND uid<>'$debate[uid]' AND uid<>'$discuz_uid' LIMIT 1")) {
showmessage('debate_umpire_bestdebater_invalid');
}
$arr = $db->fetch_first("SELECT SUM(voters) as voters, COUNT(*) as replies FROM {$tablepre}debateposts WHERE tid='$tid' AND uid='$bestdebateruid'");
$bestdebatervoters = $arr['voters'];
$bestdebaterreplies = $arr['replies'];
$umpirepoint = dhtmlspecialchars($umpirepoint);
$bestdebater = dhtmlspecialchars($bestdebater);
$winner = intval($winner);
$db->query("UPDATE {$tablepre}threads SET closed='1' WHERE tid='$tid'");
$db->query("UPDATE {$tablepre}debates SET umpirepoint='$umpirepoint', winner='$winner', bestdebater='$bestdebater\t$bestdebateruid\t$bestdebaterstand\t$bestdebatervoters\t$bestdebaterreplies', endtime='$timestamp' WHERE tid='$tid'");
showmessage('debate_umpire_comment_succeed', 'viewthread.php?tid='.$tid);
}
} elseif($action == 'recommend') {
dsetcookie('discuz_recommend', '', -1, 0);
if(!$recommendthread['status'] || !$allowrecommend) {
showmessage('undefined_action', NULL, 'HALTED');
}
if($db->fetch_first("SELECT * FROM {$tablepre}memberrecommend WHERE recommenduid='$discuz_uid' AND tid='$tid'")) {
showmessage('recommend_duplicate');
}
$recommendcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}memberrecommend WHERE recommenduid='$discuz_uid' AND dateline>$timestamp-86400");
if($recommendthread['daycount'] && $recommendcount >= $recommendthread['daycount']) {
showmessage('recommend_outoftimes');
}
if($thread['authorid'] == $discuz_uid && !$recommendthread['ownthread']) {
showmessage('recommend_self_disallow');
}
$allowrecommend = intval($do == 'add' ? $allowrecommend : -$allowrecommend);
if($do == 'add') {
$heatadd = 'recommend_add=recommend_add+1';
} else {
$heatadd = 'recommend_sub=recommend_sub+1';
}
$db->query("UPDATE {$tablepre}threads SET heats=heats+'".(abs($allowrecommend) * $heatthread['recommend'])."', recommends=recommends+'$allowrecommend', $heatadd WHERE tid='$tid'");
$db->query("INSERT INTO {$tablepre}memberrecommend (tid, recommenduid, dateline) VALUES ('$tid', '$discuz_uid', '$timestamp')");
dsetcookie('discuz_recommend', 1, 43200, 0);
$allowrecommend = $allowrecommend > 0 ? '+'.$allowrecommend : $allowrecommend;
if($recommendthread['daycount']) {
$daycount = $recommendthread['daycount'] - $recommendcount;
showmessage('recommend_daycount_succed');
} else {
showmessage('recommend_succed');
}
} elseif($action == 'removeindexheats') {
if($adminid != 1) {
showmessage('undefined_action', NULL, 'HALTED');
}
$db->query("UPDATE {$tablepre}threads SET heats=0 WHERE tid='$tid'");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('heats');
dheader('Location: '.dreferer());
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/misc.php | PHP | asf20 | 49,623 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: medal.php 20267 2009-09-23 02:42:03Z monkey $
*/
define('CURSCRIPT', 'medal');
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
if(!$discuz_uid && $action) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
$medallist = $medallogs = array();
$tpp = 10;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
if(empty($action)) {
$query = $db->query("SELECT * FROM {$tablepre}medals WHERE available='1' ORDER BY displayorder LIMIT 0,100");
while($medal = $db->fetch_array($query)) {
$medal['permission'] = formulaperm($medal['permission'], 2);
$medallist[$medal['medalid']] = $medal;
}
$medaldata = $db->result_first("SELECT medals FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
$membermedal = $medaldata ? explode("\t", $medaldata) : array();
$medalcount = count($membermedal);
if(!empty($membermedal)) {
$medallog = array();
foreach($membermedal as $medalid) {
if($medalpos = strpos($medalid, '|')) {
$medalid = substr($medalid, 0, $medalpos);
}
$medallog['name'] = $_DCACHE['medals'][$medalid]['name'];
$medallog['image'] = $medallist[$medalid]['image'];
$medallogs[] = $medallog;
}
foreach($medallist as $medalid => $medal) {
if(in_array($medalid, $membermedal)) {
unset($medallist[$medalid]);
}
}
}
} elseif($action == 'apply' && submitcheck('medalsubmit')) {
$medalid = intval($medalid);
$formulamessage = $usermsg = $medalnew = '';
$medal = $db->fetch_first("SELECT * FROM {$tablepre}medals WHERE medalid='$medalid'");
if(!$medal['type']) {
showmessage('medal_apply_invalid');
}
$medaldetail = $db->fetch_first("SELECT medalid FROM {$tablepre}medallog WHERE uid='$discuz_uid' AND medalid='$medalid' AND type NOT IN('3', '4')");
if($medaldetail['medalid']) {
showmessage('medal_apply_existence', 'medal.php');
}
$medalpermission = $medal['permission'] ? unserialize($medal['permission']) : '';
if($medalpermission[0]) {
formulaperm($medal['permission'], 1);
if($formulamessage) {
showmessage('medal_permforum_nopermission', 'medal.php');
}
$usermedal = $db->fetch_first("SELECT medals FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
$medalnew = $usermedal['medals'] ? $usermedal['medals']."\t".$medal['medalid'] : $medal['medalid'];
$db->query("UPDATE {$tablepre}memberfields SET medals='$medalnew' WHERE uid='$discuz_uid'");
$db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('$discuz_uid', '$medalid', '1', '$timestamp', '$expiration', '0')");
showmessage('medal_get_succeed', 'medal.php');
} else {
$expiration = empty($medal['expiration'])? 0 : $timestamp + $medal['expiration'] * 86400;
$db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('$discuz_uid', '$medalid', '2', '$timestamp', '$expiration', '0')");
showmessage('medal_apply_succeed', 'medal.php');
}
} elseif($action == 'log') {
$medallognum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}medallog WHERE uid='$discuz_uid' AND type IN ('0', '1')");
$multipage = multi($medallognum, $tpp, $page, "medal.php?action=log");
$query = $db->query("SELECT me.*, m.image FROM {$tablepre}medallog me
LEFT JOIN {$tablepre}medals m USING (medalid)
WHERE me.uid='$discuz_uid' AND me.type IN ('0', '1') ORDER BY me.dateline DESC LIMIT $start_limit,$tpp");
while($medallog = $db->fetch_array($query)) {
$medallog['name'] = $_DCACHE['medals'][$medallog['medalid']]['name'];
$medallog['dateline'] = gmdate("$dateformat $timeformat", $medallog['dateline'] + $timeoffset * 3600);
$medallog['expiration'] = !empty($medallog['expiration']) ? gmdate("$dateformat $timeformat", $medallog['expiration'] + $timeoffset * 3600) : '';
$medallogs[] = $medallog;
}
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
include template('medal');
?> | zyyhong | trunk/jiaju001/newbbs/bbs/medal.php | PHP | asf20 | 4,142 |
/*
(C) 2001-2009 Comsenz Inc.
*/
/* common */
*{ word-wrap:break-word; }
body{ padding:5px 0; background:#FFF; text-align:center; }
body, td, input, textarea, select, button{ color:#666; font:12px Verdana, Tahoma, Arial, sans-serif; }
ul, dl, dd, p, h1, h2, h3, h4, h5, h6, form, fieldset { margin:0; padding:0; }
h1, h2, h3, h4, h5, h6{ font-size:12px; }
a{ color:#2366A8; text-decoration:none; }
a:hover { text-decoration:underline; }
a img{ border:none; }
em, cite, strong, th{ font-style:normal; font-weight:normal; }
table{ border-collapse:collapse; }
/* box */
.container{ overflow:hidden; margin:0 auto; width:700px; height:auto !important;text-align:left; border:1px solid #B5CFD9; }
.header{ height:194px; background:url(images/bg_repx.gif) repeat-x; }
.header h1{ text-indent:-9999px; width:270px; height:48px; background:url(images/bg_repno.gif) no-repeat 26px 22px; }
.header span { float: right; padding-right: 10px; }
.main{ padding:20px 20px 0; background:#F7FBFE url(images/bg_repx.gif) repeat-x 0 -194px; }
.main h3{ margin:10px auto; width:75%; color:#6CA1B4; font-weight:700; }
.desc{ margin:0 auto; width:537px; line-height:180%; clear:both; }
.desc ul{ margin-left:20px; }
.desc1{ margin:10px 0; width:100%; }
.desc1 ul{ margin-left:25px; }
.desc1 li{ margin:3px 0; }
.tb, .tb2{ margin:15px 0 15px 67px; }
.tb th{ padding:5px; color:#6CA1B4; font-weight:700; }
.tb td{ padding:3px 5px; }
.tb .w, .tb .nw, .tb .padleft{ padding-left:45px; }
.tb .pdleft1{ padding-left:67px; }
.tb2{}
.tb2 th, .tb2 td{ padding:3px 5px; }
.tbopt{ width:120px; }
.btnbox{ text-align:center; }
.btnbox input{ margin:0 2px; }
.btnbox textarea{ margin-bottom:10px; height:150px; }
.btn{ margin-top:10px; }
.footer{ line-height:40px; text-align:center; background:url(images/bg_footer.gif) repeat-x; font-size:11px; }
/* form */
.txt{ width:200px; }
/* step num */
.setup{ margin:46px 0 0 200px; padding-left:70px; }
.setup h2{ padding-top:0; *padding-top:6px; color:#6CA1B4; font-size:36px; }
.setup p{ margin-left:6px; color:#999; }
.step1{ background:url(images/stepnum.gif) no-repeat 0 8px; }
.step2{ background:url(images/stepnum.gif) no-repeat 0 -92px; }
.step3{ background:url(images/stepnum.gif) no-repeat 0 -192px; }
.step4{ background:url(images/stepnum.gif) no-repeat 0 -292px; }
/* step status */
.stepstat{ position:relative; bottom:-15px; left:80px; *width:593px; height:30px; }
.stepstatbg{ position:absolute; top:18px; z-index:90; width:535px; height:9px; overflow:hidden; background:#81C6F0 url(images/bg_stepstatus.gif) no-repeat; }
.stepstat ul{ position:absolute; top:3px; left:-2px; z-index:100; list-style:none; width:600px; white-space:nowrap; overflow:hidden; }
.stepstat li{ float:left; text-indent:-9999px; width:175px; height:30px; background:url(images/bg_repno.gif) no-repeat 0 -38px; }
.stepstat .current{ background:url(images/bg_repno.gif) no-repeat 0 -71px; }
.stepstat .unactivated{ background:url(images/bg_repno.gif) no-repeat 0 -103px; }
.stepstat .last{ width:20px; }
.stepstat1{ background-position:-750px 0; }
.stepstat2{ background-position:-570px 0; }
.stepstat3{ background-position:-390px 0; }
.stepstat4{ background-position:-210px 0; }
/* file status */
.w{ background:url(images/bg_repno.gif) no-repeat 45px -148px; }
.nw{ background:url(images/bg_repno.gif) no-repeat 45px -197px; }
/* space */
.marginbot{ margin-bottom:20px; }
.margintop{ margin-top:20px; }
.red{ color:red; }
.licenseblock{ margin-bottom:15px; padding:8px; height:280px; border:1px solid #EEE; background:#FFF; overflow:scroll; overflow-x:hidden; }
.license{}
.license h1{ padding-bottom:10px; font-size:14px; text-align:center; }
.license h3{ margin:0; color:#666; }
.license p{ line-height:150%; margin:10px 0; text-indent:25px; }
.license li{ line-height:150%; margin:5px 0; }
.title{ margin:5px 0 -15px 60px; }
#notice { border: 1px solid #B5CFD9; width: 100%; padding: 5px; height: 300px;overflow: hidden;text-align: left; } | zyyhong | trunk/jiaju001/newbbs/bbs/install/style.css | CSS | asf20 | 4,072 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: db.class.php 20664 2009-10-14 06:31:17Z zhaoxiongfei $
*/
if(!defined('IN_COMSENZ')) {
exit('Access Denied');
}
class dbstuff {
var $querynum = 0;
var $link;
var $histories;
var $time;
var $tablepre;
function connect($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset, $pconnect = 0, $tablepre='', $time = 0) {
$this->time = $time;
$this->tablepre = $tablepre;
if($pconnect) {
if(!$this->link = mysql_pconnect($dbhost, $dbuser, $dbpw)) {
$this->halt('Can not connect to MySQL server');
}
} else {
if(!$this->link = mysql_connect($dbhost, $dbuser, $dbpw, 1)) {
$this->halt('Can not connect to MySQL server');
}
}
if($this->version() > '4.1') {
if($dbcharset) {
mysql_query("SET character_set_connection=".$dbcharset.", character_set_results=".$dbcharset.", character_set_client=binary", $this->link);
}
if($this->version() > '5.0.1') {
mysql_query("SET sql_mode=''", $this->link);
}
}
if($dbname) {
mysql_select_db($dbname, $this->link);
}
}
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return mysql_fetch_array($query, $result_type);
}
function result_first($sql, &$data) {
$query = $this->query($sql);
$data = $this->result($query, 0);
}
function fetch_first($sql, &$arr) {
$query = $this->query($sql);
$arr = $this->fetch_array($query);
}
function fetch_all($sql, &$arr) {
$query = $this->query($sql);
while($data = $this->fetch_array($query)) {
$arr[] = $data;
}
}
function cache_gc() {
$this->query("DELETE FROM {$this->tablepre}sqlcaches WHERE expiry<$this->time");
}
function query($sql, $type = '', $cachetime = FALSE) {
$func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
if(!($query = $func($sql, $this->link)) && $type != 'SILENT') {
$this->halt('MySQL Query Error', $sql);
}
$this->querynum++;
$this->histories[] = $sql;
return $query;
}
function affected_rows() {
return mysql_affected_rows($this->link);
}
function error() {
return (($this->link) ? mysql_error($this->link) : mysql_error());
}
function errno() {
return intval(($this->link) ? mysql_errno($this->link) : mysql_errno());
}
function result($query, $row) {
$query = @mysql_result($query, $row);
return $query;
}
function num_rows($query) {
$query = mysql_num_rows($query);
return $query;
}
function num_fields($query) {
return mysql_num_fields($query);
}
function free_result($query) {
return mysql_free_result($query);
}
function insert_id() {
return ($id = mysql_insert_id($this->link)) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
}
function fetch_row($query) {
$query = mysql_fetch_row($query);
return $query;
}
function fetch_fields($query) {
return mysql_fetch_field($query);
}
function version() {
return mysql_get_server_info($this->link);
}
function close() {
return mysql_close($this->link);
}
function halt($message = '', $sql = '') {
show_error('run_sql_error', $message.'<br /><br />'.$sql.'<br /> '.mysql_error(), 0);
}
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/install/db.class.php | PHP | asf20 | 3,375 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: extvar.inc.php 21158 2009-11-18 00:52:28Z monkey $
*/
$attachdir = './attachments';
$attachurl = 'attachments';
$cron_pushthread_week = rand(1, 7);
$cron_pushthread_hour = rand(1, 8);
$extcredits = Array
(
1 => Array
(
'title' => $lang['init_credits_karma'],
'showinthread' => '',
'available' => 1
),
2 => Array
(
'title' => $lang['init_credits_money'],
'showinthread' => '',
'available' => 1
)
);
$extrasql = <<<EOT
UPDATE cdb_forumlinks SET name='$lang[init_link]', description='$lang[init_link_note]' WHERE id='1';
UPDATE cdb_forums SET name='$lang[init_default_forum]' WHERE fid='2';
UPDATE cdb_onlinelist SET title='$lang[init_group_1]' WHERE groupid='1';
UPDATE cdb_onlinelist SET title='$lang[init_group_2]' WHERE groupid='2';
UPDATE cdb_onlinelist SET title='$lang[init_group_3]' WHERE groupid='3';
UPDATE cdb_onlinelist SET title='$lang[init_group_0]' WHERE groupid='0';
UPDATE cdb_ranks SET ranktitle='$lang[init_rank_1]' WHERE rankid='1';
UPDATE cdb_ranks SET ranktitle='$lang[init_rank_2]' WHERE rankid='2';
UPDATE cdb_ranks SET ranktitle='$lang[init_rank_3]' WHERE rankid='3';
UPDATE cdb_ranks SET ranktitle='$lang[init_rank_4]' WHERE rankid='4';
UPDATE cdb_ranks SET ranktitle='$lang[init_rank_5]' WHERE rankid='5';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_1]' WHERE groupid='1';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_2]' WHERE groupid='2';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_3]' WHERE groupid='3';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_4]' WHERE groupid='4';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_5]' WHERE groupid='5';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_6]' WHERE groupid='6';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_7]' WHERE groupid='7';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_8]' WHERE groupid='8';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_9]' WHERE groupid='9';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_10]' WHERE groupid='10';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_11]' WHERE groupid='11';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_12]' WHERE groupid='12';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_13]' WHERE groupid='13';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_14]' WHERE groupid='14';
UPDATE cdb_usergroups SET grouptitle='$lang[init_group_15]' WHERE groupid='15';
UPDATE cdb_crons SET name='$lang[init_cron_1]' WHERE cronid='1';
UPDATE cdb_crons SET name='$lang[init_cron_2]' WHERE cronid='2';
UPDATE cdb_crons SET name='$lang[init_cron_3]' WHERE cronid='3';
UPDATE cdb_crons SET name='$lang[init_cron_4]' WHERE cronid='4';
UPDATE cdb_crons SET name='$lang[init_cron_5]' WHERE cronid='5';
UPDATE cdb_crons SET name='$lang[init_cron_6]' WHERE cronid='6';
UPDATE cdb_crons SET name='$lang[init_cron_7]' WHERE cronid='7';
UPDATE cdb_crons SET name='$lang[init_cron_8]' WHERE cronid='8';
UPDATE cdb_crons SET name='$lang[init_cron_9]' WHERE cronid='9';
UPDATE cdb_crons SET name='$lang[init_cron_10]' WHERE cronid='10';
UPDATE cdb_crons SET name='$lang[init_cron_11]', weekday='$cron_pushthread_week', hour='$cron_pushthread_week' WHERE cronid='11';
UPDATE cdb_settings SET value='$lang[init_dataformat]' WHERE variable='dateformat';
UPDATE cdb_settings SET value='$lang[init_modreasons]' WHERE variable='modreasons';
UPDATE cdb_settings SET value='$lang[init_threadsticky]' WHERE variable='threadsticky';
UPDATE cdb_settings SET value='$lang[init_qihoo_searchboxtxt]' WHERE variable='qihoo_searchboxtxt';
UPDATE cdb_styles SET name='$lang[init_default_style]' WHERE styleid='1';
UPDATE cdb_templates SET name='$lang[init_default_template]', copyright='$lang[init_default_template_copyright]' WHERE templateid='1';
EOT;
function upg_newbietask() {
global $db, $tablepre, $newbietask;
if($db->result($db->query("SELECT count(*) FROM `{$tablepre}tasks` WHERE newbietask=1"), 0)) {
return;
}
foreach($newbietask as $k => $sqlarray) {
$db->query("INSERT INTO `{$tablepre}tasks` (`newbietask`, `available`, `name`, `description`, `icon`, `applicants`, `achievers`, `tasklimits`, `applyperm`, `scriptname`, `starttime`, `endtime`, `period`, `reward`, `prize`, `bonus`, `displayorder`, `version`) VALUES ($sqlarray[task]);");
$currentid = $db->insert_id();
foreach($sqlarray['vars'] as $taskvars) {
$db->query("INSERT INTO `{$tablepre}taskvars` (`taskid`, `sort`, `name`, `description`, `variable`, `type`, `value`, `extra`) VALUES ($currentid, $taskvars);");
}
}
}
function upg_comsenz_stats() {
global $db, $tablepre;
static $is_run = false;
if($is_run) return;
if(getgpc('addfounder_contact','P')) {
$email = strip_tags(getgpc('email', 'P'));
$msn = strip_tags(getgpc('msn', 'P'));
$qq = strip_tags(getgpc('qq', 'P'));
if(!preg_match("/^[\d]+$/", $qq)) $qq = '';
if(strlen($email) < 6 || !preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email)) $email = '';
if(strlen($msn) < 6 || !preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $msn)) $msn = '';
$contact = serialize(array('qq' => $qq, 'msn' => $msn, 'email' => $email));
$db->query("REPLACE {$tablepre}settings (variable, value) VALUES ('founder_contact', '$contact')");
$is_run = ture;
echo '<script type="text/javascript">document.getElementById("laststep").disabled=false;document.getElementById("laststep").value = \''.lang('install_succeed').'\';</script><iframe src="../" style="display:none"></iframe>'."\r\n";
show_header();
echo '</div><div class="main" style="margin-top: -123px;"><ul style="line-height: 200%; margin-left: 30px;">';
echo '<li><a href="../">'.lang('install_succeed').'</a><br>';
echo '<script>setTimeout(function(){window.location=\'../\'}, 2000);</script>'.lang('auto_redirect').'</li>';
echo '</ul></div>';
show_footer();
} else {
show_header();
$contact = array();
$contact = unserialize($db->result($db->query("SELECT value FROM {$tablepre}settings WHERE variable='founder_contact'"),0));
$founder_contact = lang('founder_contact');
$founder_contact = str_replace(array("\n","\t"), array('<br>',' '), $founder_contact);
echo '</div><div class="main" style="margin-top: -123px;">';
echo $founder_contact;
echo '<form action="'.$url_forward.'" method="post" id="postform">';
echo "<br><table width=\"360\" cellspacing=\"1\" border=\"0\" align=\"center\">".
"<tr height=\"30\"><td align=\"right\" >QQ:</td><td> <input class=\"txt\" type=\"text\" value=\"$contact[qq]\" name=\"qq\" ></td></tr>
<tr height=\"30\"><td align=\"right\">MSN:</td><td> <input class=\"txt\" type=\"text\" value=\"$contact[msn]\" name=\"msn\" ></td></tr>
<tr height=\"30\"><td align=\"right\">E-mail:</td><td> <input class=\"txt\" type=\"text\" value=\"$contact[email]\" name=\"email\" ></td></tr>
<tr align=\"center\" height=\"30\"><td colspan=\"2\"><input type=\"submit\" style=\"padding: 2px;\" name=\"addfounder_contact\" value=\"".lang('install_submit')."\"></td></tr></table>";
echo '</form>';
getstatinfo();
echo '<p style="text-align:right"><input type="button" style="padding: 2px;" onclick="window.location=\'index.php?method=ext_info&skip=1\'" value="'.lang('skip_current').'" /></center></p>';
echo '</div>';
show_footer();
}
}
function getstatinfo() {
if($siteid && $key) {
return;
}
$version = '7.2';
$onlineip = '';
if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
$onlineip = getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
$onlineip = getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
$onlineip = getenv('REMOTE_ADDR');
} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
$onlineip = $_SERVER['REMOTE_ADDR'];
}
$funcurl = 'http://stat'.'.disc'.'uz.co'.'m/stat_ins.php';
$PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
$url = htmlspecialchars('http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api|archiver|wap)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))));
$url = substr($url, 0, -8);
$hash = md5("$url\$version{$onlineip}");
$q = "url=$url&version=$version&ip=$onlineip&time=".time()."&hash=$hash";
$q=rawurlencode(base64_encode($q));
dfopen($funcurl."?action=newinstall&q=$q");
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/install/extvar.inc.php | PHP | asf20 | 8,823 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: var.inc.php 21311 2009-11-26 01:35:43Z liulanbo $
*/
if(!defined('IN_COMSENZ')) {
exit('Access Denied');
}
define('SOFT_NAME', 'Discuz!');
define('SOFT_VERSION', '7.2');
define('SOFT_RELEASE', '20091126');
define('INSTALL_LANG', 'SC_UTF8');
define('DZUCFULL', false);
define('CONFIG', ROOT_PATH.'./config.inc.php');
$sqlfile = ROOT_PATH.'./install/discuz.sql';
$lockfile = ROOT_PATH.'./forumdata/install.lock';
include CONFIG;
//$charset = strtolower(str_replace('_', '', strstr(INSTALL_LANG, '_')));
//$charset = $charset == 'utf8' ? 'utf-8' : $charset;
define('CHARSET', $charset);
define('DBCHARSET', !$dbcharset && in_array(strtolower($charset), array('gbk', 'big5', 'utf-8')) ? str_replace('-', '', $charset) : $dbcharset);
define('ORIG_TABLEPRE', 'cdb_');
define('METHOD_UNDEFINED', 255);
define('ENV_CHECK_RIGHT', 0);
define('ERROR_CONFIG_VARS', 1);
define('SHORT_OPEN_TAG_INVALID', 2);
define('INSTALL_LOCKED', 3);
define('DATABASE_NONEXISTENCE', 4);
define('PHP_VERSION_TOO_LOW', 5);
define('MYSQL_VERSION_TOO_LOW', 6);
define('UC_URL_INVALID', 7);
define('UC_DNS_ERROR', 8);
define('UC_URL_UNREACHABLE', 9);
define('UC_VERSION_INCORRECT', 10);
define('UC_DBCHARSET_INCORRECT', 11);
define('UC_API_ADD_APP_ERROR', 12);
define('UC_ADMIN_INVALID', 13);
define('UC_DATA_INVALID', 14);
define('DBNAME_INVALID', 15);
define('DATABASE_ERRNO_2003', 16);
define('DATABASE_ERRNO_1044', 17);
define('DATABASE_ERRNO_1045', 18);
define('DATABASE_CONNECT_ERROR', 19);
define('TABLEPRE_INVALID', 20);
define('CONFIG_UNWRITEABLE', 21);
define('ADMIN_USERNAME_INVALID', 22);
define('ADMIN_EMAIL_INVALID', 25);
define('ADMIN_EXIST_PASSWORD_ERROR', 26);
define('ADMININFO_INVALID', 27);
define('LOCKFILE_NO_EXISTS', 28);
define('TABLEPRE_EXISTS', 29);
define('ERROR_UNKNOW_TYPE', 30);
define('ENV_CHECK_ERROR', 31);
define('UNDEFINE_FUNC', 32);
define('MISSING_PARAMETER', 33);
define('LOCK_FILE_NOT_TOUCH', 34);
$func_items = array('mysql_connect', 'fsockopen', 'gethostbyname', 'file_get_contents', 'xml_parser_create');
$env_items = array
(
'os' => array('c' => 'PHP_OS', 'r' => 'notset', 'b' => 'unix'),
'php' => array('c' => 'PHP_VERSION', 'r' => '4.0', 'b' => '5.0'),
'attachmentupload' => array('r' => 'notset', 'b' => '2M'),
'gdversion' => array('r' => '1.0', 'b' => '2.0'),
'diskspace' => array('r' => '10M', 'b' => 'notset'),
);
$dirfile_items = array
(
'config' => array('type' => 'file', 'path' => './config.inc.php'),
'attach' => array('type' => 'dir', 'path' => './attachments'),
'forumdata' => array('type' => 'dir', 'path' => './forumdata'),
'cache' => array('type' => 'dir', 'path' => './forumdata/cache'),
'ftemplates' => array('type' => 'dir', 'path' => './forumdata/templates'),
'threadcache' => array('type' => 'dir', 'path' => './forumdata/threadcaches'),
'logs' => array('type' => 'dir', 'path' => './forumdata/logs'),
'uccache' => array('type' => 'dir', 'path' => './uc_client/data/cache')
);
$form_app_reg_items = array
(
'ucenter' => array
(
'ucurl' => array('type' => 'text', 'required' => 1, 'reg' => '/^https?:\/\//', 'value' => array('type' => 'var', 'var' => 'ucapi')),
'ucip' => array('type' => 'text', 'required' => 0, 'reg' => '/^\d+\.\d+\.\d+\.\d+$/'),
'ucpw' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/')
),
'siteinfo' => array
(
'sitename' => array('type' => 'text', 'required' => 1, 'reg' => '/^.*$/', 'value' => array('type' => 'constant', 'var' => 'SOFT_NAME')),
'siteurl' => array('type' => 'text', 'required' => 1, 'reg' => '/^https?:\/\//', 'value' => array('type' => 'var', 'var' => 'default_appurl'))
)
);
$form_db_init_items = array
(
'dbinfo' => array
(
'dbhost' => array('type' => 'text', 'required' => 1, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'dbhost')),
'dbname' => array('type' => 'text', 'required' => 1, 'reg' => '/^.+$/', 'value' => array('type' => 'var', 'var' => 'dbname')),
'dbuser' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*$/', 'value' => array('type' => 'var', 'var' => 'dbuser')),
'dbpw' => array('type' => 'password', 'required' => 0, 'reg' => '/^.*$/', 'value' => array('type' => 'var', 'var' => 'dbpw')),
'tablepre' => array('type' => 'text', 'required' => 0, 'reg' => '/^.*+/', 'value' => array('type' => 'var', 'var' => 'tablepre')),
'adminemail' => array('type' => 'text', 'required' => 1, 'reg' => '/@/', 'value' => array('type' => 'var', 'var' => 'adminemail')),
),
'admininfo' => array
(
'username' => array('type' => 'text', 'required' => 1, 'reg' => '/^.*$/', 'value' => array('type' => 'constant', 'var' => 'admin')),
'password' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/'),
'password2' => array('type' => 'password', 'required' => 1, 'reg' => '/^.*$/'),
'email' => array('type' => 'text', 'required' => 1, 'reg' => '/@/', 'value' => array('type' => 'var', 'var' => 'adminemail')),
'testdata' => array('type' => 'checkbox', 'required' => 0, 'reg' => '/^1$/', 'value' => array('type' => 'constant', 'var' => '1')),
)
);
?> | zyyhong | trunk/jiaju001/newbbs/bbs/install/var.inc.php | PHP | asf20 | 5,282 |
<?php
define('UC_VERNAME', '中文版');
$lang = array(
'SC_GBK' => '简体中文版',
'TC_BIG5' => '繁体中文版',
'SC_UTF8' => '简体中文 UTF8 版',
'TC_UTF8' => '繁体中文 UTF8 版',
'EN_ISO' => 'ENGLISH ISO8859',
'EN_UTF8' => 'ENGLIST UTF-8',
'title_install' => SOFT_NAME.' 安装向导',
'agreement_yes' => '我同意',
'agreement_no' => '我不同意',
'notset' => '不限制',
'message_title' => '提示信息',
'error_message' => '错误信息',
'message_return' => '返回',
'return' => '返回',
'install_wizard' => '安装向导',
'config_nonexistence' => '配置文件不存在',
'nodir' => '目录不存在',
'short_open_tag_invalid' => '对不起,请将 php.ini 中的 short_open_tag 设置为 On,否则无法继续安装。',
'redirect' => '浏览器会自动跳转页面,无需人工干预。<br>除非当您的浏览器没有自动跳转时,请点击这里',
'auto_redirect' => '浏览器会自动跳转页面,无需人工干预',
'database_errno_2003' => '无法连接数据库,请检查数据库是否启动,数据库服务器地址是否正确',
'database_errno_1044' => '无法创建新的数据库,请检查数据库名称填写是否正确',
'database_errno_1045' => '无法连接数据库,请检查数据库用户名或者密码是否正确',
'database_errno_1064' => 'SQL 语法错误',
'dbpriv_createtable' => '没有CREATE TABLE权限,无法继续安装',
'dbpriv_insert' => '没有INSERT权限,无法继续安装',
'dbpriv_select' => '没有SELECT权限,无法继续安装',
'dbpriv_update' => '没有UPDATE权限,无法继续安装',
'dbpriv_delete' => '没有DELETE权限,无法继续安装',
'dbpriv_droptable' => '没有DROP TABLE权限,无法安装',
'db_not_null' => '数据库中已经安装过 UCenter, 继续安装会清空原有数据。',
'db_drop_table_confirm' => '继续安装会清空全部原有数据,您确定要继续吗?',
'writeable' => '可写',
'unwriteable' => '不可写',
'old_step' => '上一步',
'new_step' => '下一步',
'database_errno_2003' => '无法连接数据库,请检查数据库是否启动,数据库服务器地址是否正确',
'database_errno_1044' => '无法创建新的数据库,请检查数据库名称填写是否正确',
'database_errno_1045' => '无法连接数据库,请检查数据库用户名或者密码是否正确',
'database_connect_error' => '数据库连接错误',
'step_env_check_title' => '开始安装',
'step_env_check_desc' => '环境以及文件目录权限检查',
'step_db_init_title' => '安装数据库',
'step_db_init_desc' => '正在执行数据库安装',
'step1_file' => '目录文件',
'step1_need_status' => '所需状态',
'step1_status' => '当前状态',
'not_continue' => '请将以上红叉部分修正再试',
'tips_dbinfo' => '填写数据库信息',
'tips_dbinfo_comment' => '',
'tips_admininfo' => '填写管理员信息',
'step_ext_info_title' => '安装成功',
'step_ext_info_comment' => '点击进入登陆',
'ext_info_succ' => '安装成功',
'install_submit' => '提交',
'install_locked' => '安装锁定,已经安装过了,如果您确定要重新安装,请到服务器上删除<br /> '.str_replace(ROOT_PATH, '', $lockfile),
'error_quit_msg' => '您必须解决以上问题,安装才可以继续',
'step_app_reg_title' => '设置运行环境',
'step_app_reg_desc' => '检测服务器环境以及设置 UCenter',
'tips_ucenter' => '请填写 UCenter 相关信息',
'tips_ucenter_comment' => 'UCenter 是 Comsenz 公司产品的核心服务程序,Discuz! Board 的安装和运行依赖此程序。如果您已经安装了 UCenter,请填写以下信息。否则,请到 <a href="http://www.discuz.com/" target="blank">Comsenz 产品中心</a> 下载并且安装,然后再继续。',
'advice_mysql_connect' => '请检查 mysql 模块是否正确加载',
'advice_fsockopen' => '该函数需要 php.ini 中 allow_url_fopen 选项开启。请联系空间商,确定开启了此项功能',
'advice_gethostbyname' => '是否php配置中禁止了gethostbyname函数。请联系空间商,确定开启了此项功能',
'advice_file_get_contents' => '该函数需要 php.ini 中 allow_url_fopen 选项开启。请联系空间商,确定开启了此项功能',
'advice_xml_parser_create' => '该函数需要 PHP 支持 XML。请联系空间商,确定开启了此项功能',
'ucurl' => 'UCenter 的 URL',
'ucpw' => 'UCenter 创始人密码',
'ucip' => 'UCenter 的IP地址',
'ucenter_ucip_invalid' => '格式错误,请填写正确的 IP 地址',
'ucip_comment' => '绝大多数情况下您可以不填',
'tips_siteinfo' => '请填写站点信息',
'sitename' => '站点名称',
'siteurl' => '站点 URL',
'forceinstall' => '强制安装',
'dbinfo_forceinstall_invalid' => '当前数据库当中已经含有同样表前缀的数据表,您可以修改“表名前缀”来避免删除旧的数据,或者选择强制安装。强制安装会删除旧数据,且无法恢复',
'click_to_back' => '点击返回上一步',
'adminemail' => '系统信箱 Email',
'adminemail_comment' => '用于发送程序错误报告',
'dbhost_comment' => '数据库服务器地址, 一般为 localhost',
'tablepre_comment' => '同一数据库运行多个论坛时,请修改前缀',
'forceinstall_check_label' => '我要删除数据,强制安装 !!!',
'uc_url_empty' => '您没有填写 UCenter 的 URL,请返回填写',
'uc_url_invalid' => 'URL 格式错误',
'uc_url_unreachable' => 'UCenter 的 URL 地址可能填写错误,请检查',
'uc_ip_invalid' => '无法解析该域名,请填写站点的 IP',
'uc_admin_invalid' => 'UCenter 创始人密码错误,请重新填写',
'uc_data_invalid' => '通信失败,请检查 UCenter 的URL 地址是否正确 ',
'uc_dbcharset_incorrect' => 'UCenter 数据库字符集与当前应用字符集不一致',
'uc_api_add_app_error' => '向 UCenter 添加应用错误',
'uc_dns_error' => 'UCenter DNS解析错误,请返回填写一下 UCenter 的 IP地址',
'ucenter_ucurl_invalid' => 'UCenter 的URL为空,或者格式错误,请检查',
'ucenter_ucpw_invalid' => 'UCenter 的创始人密码为空,或者格式错误,请检查',
'siteinfo_siteurl_invalid' => '站点URL为空,或者格式错误,请检查',
'siteinfo_sitename_invalid' => '站点名称为空,或者格式错误,请检查',
'dbinfo_dbhost_invalid' => '数据库服务器为空,或者格式错误,请检查',
'dbinfo_dbname_invalid' => '数据库名为空,或者格式错误,请检查',
'dbinfo_dbuser_invalid' => '数据库用户名为空,或者格式错误,请检查',
'dbinfo_dbpw_invalid' => '数据库密码为空,或者格式错误,请检查',
'dbinfo_adminemail_invalid' => '系统邮箱为空,或者格式错误,请检查',
'dbinfo_tablepre_invalid' => '数据表前缀为空,或者格式错误,请检查',
'admininfo_username_invalid' => '管理员用户名为空,或者格式错误,请检查',
'admininfo_email_invalid' => '管理员Email为空,或者格式错误,请检查',
'admininfo_password_invalid' => '管理员密码为空,请填写',
'admininfo_password2_invalid' => '两次密码不一致,请检查',
'username' => '管理员账号',
'email' => '管理员 Email',
'password' => '管理员密码',
'password_comment' => '管理员密码不能为空',
'password2' => '重复密码',
'admininfo_invalid' => '管理员信息不完整,请检查管理员账号,密码,邮箱',
'dbname_invalid' => '数据库名为空,请填写数据库名称',
'tablepre_invalid' => '数据表前缀为空,或者格式错误,请检查',
'admin_username_invalid' => '非法用户名,用户名长度不应当超过 15 个英文字符,且不能包含特殊字符,一般是中文,字母或者数字',
'admin_password_invalid' => '密码和上面不一致,请重新输入',
'admin_email_invalid' => 'Email 地址错误,此邮件地址已经被使用或者格式无效,请更换为其他地址',
'admin_invalid' => '您的信息管理员信息没有填写完整,请仔细填写每个项目',
'admin_exist_password_error' => '该用户已经存在,如果您要设置此用户为论坛的管理员,请正确输入该用户的密码,或者请更换论坛管理员的名字',
'tagtemplates_subject' => '标题',
'tagtemplates_uid' => '用户 ID',
'tagtemplates_username' => '发帖者',
'tagtemplates_dateline' => '日期',
'tagtemplates_url' => '主题地址',
'uc_version_incorrect' => '您的 UCenter 服务端版本过低,请升级 UCenter 服务端到最新版本,并且升级,下载地址:http://www.comsenz.com/ 。',
'config_unwriteable' => '安装向导无法写入配置文件, 请设置 config.inc.php 程序属性为可写状态(777)',
'install_in_processed' => '正在安装...',
'install_succeed' => '安装成功,点击进入',
'install_founder_contact' => '进入下一步填写联系方式',
'init_credits_karma' => '威望',
'init_credits_money' => '金钱',
'init_group_0' => '会员',
'init_group_1' => '管理员',
'init_group_2' => '超级版主',
'init_group_3' => '版主',
'init_group_4' => '禁止发言',
'init_group_5' => '禁止访问',
'init_group_6' => '禁止 IP',
'init_group_7' => '游客',
'init_group_8' => '等待验证会员',
'init_group_9' => '乞丐',
'init_group_10' => '新手上路',
'init_group_11' => '注册会员',
'init_group_12' => '中级会员',
'init_group_13' => '高级会员',
'init_group_14' => '金牌会员',
'init_group_15' => '论坛元老',
'init_rank_1' => '新生入学',
'init_rank_2' => '小试牛刀',
'init_rank_3' => '实习记者',
'init_rank_4' => '自由撰稿人',
'init_rank_5' => '特聘作家',
'init_cron_1' => '清空今日发帖数',
'init_cron_2' => '清空本月在线时间',
'init_cron_3' => '每日数据清理',
'init_cron_4' => '生日统计与邮件祝福',
'init_cron_5' => '主题回复通知',
'init_cron_6' => '每日公告清理',
'init_cron_7' => '限时操作清理',
'init_cron_8' => '论坛推广清理',
'init_cron_9' => '每月主题清理',
'init_cron_10' => '每日 X-Space更新用户',
'init_cron_11' => '每周主题更新',
'init_bbcode_1' => '使内容横向滚动,这个效果类似 HTML 的 marquee 标签,注意:这个效果只在 Internet Explorer 浏览器下有效。',
'init_bbcode_2' => '嵌入 Flash 动画',
'init_bbcode_3' => '显示 QQ 在线状态,点这个图标可以和他(她)聊天',
'init_bbcode_4' => '上标',
'init_bbcode_5' => '下标',
'init_bbcode_6' => '嵌入 Windows media 音频',
'init_bbcode_7' => '嵌入 Windows media 音频或视频',
'init_qihoo_searchboxtxt' =>'输入关键词,快速搜索本论坛',
'init_threadsticky' =>'全局置顶,分类置顶,本版置顶',
'init_default_style' => '默认风格',
'init_default_forum' => '默认版块',
'init_default_template' => '默认模板套系',
'init_default_template_copyright' => '康盛创想(北京)科技有限公司',
'init_dataformat' => 'Y-n-j',
'init_modreasons' => '广告/SPAM\r\n恶意灌水\r\n违规内容\r\n文不对题\r\n重复发帖\r\n\r\n我很赞同\r\n精品文章\r\n原创内容',
'init_link' => 'Discuz! 官方论坛',
'init_link_note' => '提供最新 Discuz! 产品新闻、软件下载与技术交流',
'license' => '<div class="license"><h1>中文版授权协议 适用于中文用户</h1>
<p>版权所有 (c) 2001-2009,康盛创想(北京)科技有限公司保留所有权利。</p>
<p>感谢您选择 Discuz! 论坛产品。希望我们的努力能为您提供一个高效快速和强大的社区论坛解决方案。</p>
<p>Discuz! 英文全称为 Crossday Discuz! Board,中文全称为 Discuz! 论坛,以下简称 Discuz!。</p>
<p>康盛创想(北京)科技有限公司为 Discuz! 产品的开发商,依法独立拥有 Discuz! 产品著作权(中国国家版权局著作权登记号 2006SR11895)。康盛创想(北京)科技有限公司网址为 http://www.comsenz.com,Discuz! 官方网站网址为 http://www.discuz.com,Discuz! 官方讨论区网址为 http://www.discuz.net。</p>
<p>Discuz! 著作权已在中华人民共和国国家版权局注册,著作权受到法律和国际公约保护。使用者:无论个人或组织、盈利与否、用途如何(包括以学习和研究为目的),均需仔细阅读本协议,在理解、同意、并遵守本协议的全部条款后,方可开始使用 Discuz! 软件。</p>
<p>本授权协议适用且仅适用于 Discuz! 7.x.x 版本,康盛创想(北京)科技有限公司拥有对本授权协议的最终解释权。</p>
<h3>I. 协议许可的权利</h3>
<ol>
<li>您可以在完全遵守本最终用户授权协议的基础上,将本软件应用于非商业用途,而不必支付软件版权授权费用。</li>
<li>您可以在协议规定的约束和限制范围内修改 Discuz! 源代码(如果被提供的话)或界面风格以适应您的网站要求。</li>
<li>您拥有使用本软件构建的论坛中全部会员资料、文章及相关信息的所有权,并独立承担与文章内容的相关法律义务。</li>
<li>获得商业授权之后,您可以将本软件应用于商业用途,同时依据所购买的授权类型中确定的技术支持期限、技术支持方式和技术支持内容,自购买时刻起,在技术支持期限内拥有通过指定的方式获得指定范围内的技术支持服务。商业授权用户享有反映和提出意见的权力,相关意见将被作为首要考虑,但没有一定被采纳的承诺或保证。</li>
</ol>
<h3>II. 协议规定的约束和限制</h3>
<ol>
<li>未获商业授权之前,不得将本软件用于商业用途(包括但不限于企业网站、经营性网站、以营利为目或实现盈利的网站)。购买商业授权请登陆http://www.discuz.com参考相关说明,也可以致电8610-51657885了解详情。</li>
<li>不得对本软件或与之关联的商业授权进行出租、出售、抵押或发放子许可证。</li>
<li>无论如何,即无论用途如何、是否经过修改或美化、修改程度如何,只要使用 Discuz! 的整体或任何部分,未经书面许可,论坛页面页脚处的 Discuz! 名称和康盛创想(北京)科技有限公司下属网站(http://www.comsenz.com、http://www.discuz.com 或 http://www.discuz.net) 的链接都必须保留,而不能清除或修改。</li>
<li>禁止在 Discuz! 的整体或任何部分基础上以发展任何派生版本、修改版本或第三方版本用于重新分发。</li>
<li>如果您未能遵守本协议的条款,您的授权将被终止,所被许可的权利将被收回,并承担相应法律责任。</li>
</ol>
<h3>III. 有限担保和免责声明</h3>
<ol>
<li>本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。</li>
<li>用户出于自愿而使用本软件,您必须了解使用本软件的风险,在尚未购买产品技术服务之前,我们不承诺提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。</li>
<li>康盛创想(北京)科技有限公司不对使用本软件构建的论坛中的文章或信息承担责任。</li>
</ol>
<p>有关 Discuz! 最终用户授权协议、商业授权与技术服务的详细内容,均由 Discuz! 官方网站独家提供。康盛创想(北京)科技有限公司拥有在不事先通知的情况下,修改授权协议和服务价目表的权力,修改后的协议或价目表对自改变之日起的新授权用户生效。</p>
<p>电子文本形式的授权协议如同双方书面签署的协议一样,具有完全的和等同的法律效力。您一旦开始安装 Discuz!,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权力的同时,受到相关的约束和限制。协议许可范围以外的行为,将直接违反本授权协议并构成侵权,我们有权随时终止授权,责令停止损害,并保留追究相关责任的权力。</p></div>',
'uc_installed' => '您已经安装过 UCenter,如果需要重新安装,请删除 data/install.lock 文件',
'i_agree' => '我已仔细阅读,并同意上述条款中的所有内容',
'supportted' => '支持',
'unsupportted' => '不支持',
'max_size' => '支持/最大尺寸',
'project' => '项目',
'ucenter_required' => 'Discuz! 所需配置',
'ucenter_best' => 'Discuz! 最佳',
'curr_server' => '当前服务器',
'env_check' => '环境检查',
'os' => '操作系统',
'php' => 'PHP 版本',
'attachmentupload' => '附件上传',
'unlimit' => '不限制',
'version' => '版本',
'gdversion' => 'GD 库',
'allow' => '允许',
'unix' => '类Unix',
'diskspace' => '磁盘空间',
'priv_check' => '目录、文件权限检查',
'func_depend' => '函数依赖性检查',
'func_name' => '函数名称',
'check_result' => '检查结果',
'suggestion' => '建议',
'advice_mysql' => '请检查 mysql 模块是否正确加载',
'advice_fopen' => '该函数需要 php.ini 中 allow_url_fopen 选项开启。请联系空间商,确定开启了此项功能',
'advice_file_get_contents' => '该函数需要 php.ini 中 allow_url_fopen 选项开启。请联系空间商,确定开启了此项功能',
'advice_xml' => '该函数需要 PHP 支持 XML。请联系空间商,确定开启了此项功能',
'none' => '无',
'dbhost' => '数据库服务器',
'dbuser' => '数据库用户名',
'dbpw' => '数据库密码',
'dbname' => '数据库名',
'tablepre' => '数据表前缀',
'ucfounderpw' => '创始人密码',
'ucfounderpw2' => '重复创始人密码',
'init_log' => '初始化记录',
'clear_dir' => '清空目录',
'select_db' => '选择数据库',
'create_table' => '建立数据表',
'succeed' => '成功',
'testdata' => '安装测试数据',
'testdata_check_label' => '是',
'install_test_data' => '正在安装测试数据',
'method_undefined' => '未定义方法',
'database_nonexistence' => '数据库操作对象不存在',
'founder_contact' => '<h4>关于《康盛改善计划》的说明</h4>
为了不断改进产品质量,改善用户体验,Discuz!7.2《康盛改善计划》,该系统有利于我们分析用户在论坛的操作习惯,进而帮助我们在未来的版本中对产品进行改进,设计出更符合用户需求的新功能。
该系统不会收集站点敏感信息,不收集用户资料,不存在安全风险,并且经过实际测试不会影响论坛的运行效率。
您安装使用本版本表示您同意加入《康盛改善计划》,Discuz!运营部门会通过对站点的分析为您提供运营指导建议,我们将提示您如何根据站点运行情况开启论坛功能,如何进行合理的功能配置,以及提供其他的一些运营经验等。
为了方便我们和您沟通运营策略,请您留下常用的网络联系方式',
'skip_current' => '跳过本步',
);
$msglang = array(
'config_nonexistence' => '您的 config.inc.php 不存在, 无法继续安装, 请用 FTP 将该文件上传后再试。',
);
$optionlist = array (
8 => array (
'classid' => '1',
'displayorder' => '2',
'title' => '性别',
'identifier' => 'gender',
'type' => 'radio',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=男\r\n2=女",
),
),
16 => array (
'classid' => '2',
'displayorder' => '0',
'title' => '房屋类型',
'identifier' => 'property',
'type' => 'select',
'rules' => array (
'choices' => "1=写字楼\r\n2=公寓\r\n3=小区\r\n4=平房\r\n5=别墅\r\n6=地下室",
),
),
17 => array (
'classid' => '2',
'displayorder' => '0',
'title' => '座向',
'identifier' => 'face',
'type' => 'radio',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=南向\r\n2=北向\r\n3=西向\r\n4=东向",
),
),
18 => array (
'classid' => '2',
'displayorder' => '0',
'title' => '装修情况',
'identifier' => 'makes',
'type' => 'radio',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=无装修\r\n2=简单装修\r\n3=精装修",
),
),
19 => array (
'classid' => '2',
'displayorder' => '0',
'title' => '居室',
'identifier' => 'mode',
'type' => 'select',
'rules' => array (
'choices' => "1=独居\r\n2=两居室\r\n3=三居室\r\n4=四居室\r\n5=别墅",
),
),
23 => array (
'classid' => '2',
'displayorder' => '0',
'title' => '屋内设施',
'identifier' => 'equipment',
'type' => 'checkbox',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=水电\r\n2=宽带\r\n3=管道气\r\n4=有线电视\r\n5=电梯\r\n6=电话\r\n7=冰箱\r\n8=洗衣机\r\n9=热水器\r\n10=空调\r\n11=暖气\r\n12=微波炉\r\n13=油烟机\r\n14=饮水机",
),
),
25 => array (
'classid' => '2',
'displayorder' => '0',
'title' => '是否中介',
'identifier' => 'bool',
'type' => 'radio',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=是\r\n2=否",
),
),
27 => array (
'classid' => '3',
'displayorder' => '0',
'title' => '星座',
'identifier' => 'Horoscope',
'type' => 'select',
'rules' => array (
'choices' => "1=白羊座\r\n2=金牛座\r\n3=双子座\r\n4=巨蟹座\r\n5=狮子座\r\n6=处女座\r\n7=天秤座\r\n8=天蝎座\r\n9=射手座\r\n10=摩羯座\r\n11=水瓶座\r\n12=双鱼座",
),
),
30 => array (
'classid' => '3',
'displayorder' => '0',
'title' => '婚姻状况',
'identifier' => 'marrige',
'type' => 'radio',
'rules' => array (
'choices' => "1=已婚\r\n2=未婚",
),
),
31 => array (
'classid' => '3',
'displayorder' => '0',
'title' => '爱好',
'identifier' => 'hobby',
'type' => 'checkbox',
'rules' => array (
'choices' => "1=美食\r\n2=唱歌\r\n3=跳舞\r\n4=电影\r\n5=音乐\r\n6=戏剧\r\n7=聊天\r\n8=拍托\r\n9=电脑\r\n10=网络\r\n11=游戏\r\n12=绘画\r\n13=书法\r\n14=雕塑\r\n15=异性\r\n16=阅读\r\n17=运动\r\n18=旅游\r\n19=八卦\r\n20=购物\r\n21=赚钱\r\n22=汽车\r\n23=摄影",
),
),
32 => array (
'classid' => '3',
'displayorder' => '0',
'title' => '收入范围',
'identifier' => 'salary',
'type' => 'select',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=保密\r\n2=800元以上\r\n3=1500元以上\r\n4=2000元以上\r\n5=3000元以上\r\n6=5000元以上\r\n7=8000元以上",
),
),
34 => array (
'classid' => '1',
'displayorder' => '0',
'title' => '学历',
'identifier' => 'education',
'type' => 'radio',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=文盲\r\n2=小学\r\n3=初中\r\n4=高中\r\n5=中专\r\n6=大专\r\n7=本科\r\n8=研究生\r\n9=博士",
),
),
38 => array (
'classid' => '5',
'displayorder' => '0',
'title' => '席别',
'identifier' => 'seats',
'type' => 'select',
'rules' => array (
'choices' => "1=站票\r\n2=硬座\r\n3=软座\r\n4=硬卧\r\n5=软卧",
),
),
44 => array (
'classid' => '4',
'displayorder' => '0',
'title' => '是否应届',
'identifier' => 'recr_term',
'type' => 'radio',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=应届\r\n2=非应届",
),
),
48 => array (
'classid' => '4',
'displayorder' => '0',
'title' => '薪金',
'identifier' => 'recr_salary',
'type' => 'select',
'rules' => array (
'choices' => "1=面议\r\n2=1000以下\r\n3=1000~1500\r\n4=1500~2000\r\n5=2000~3000\r\n6=3000~4000\r\n7=4000~6000\r\n8=6000~8000\r\n9=8000以上",
),
),
50 => array (
'classid' => '4',
'displayorder' => '0',
'title' => '工作性质',
'identifier' => 'recr_work',
'type' => 'radio',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=全职\r\n2=兼职",
),
),
53 => array (
'classid' => '4',
'displayorder' => '0',
'title' => '性别要求',
'identifier' => 'recr_sex',
'type' => 'checkbox',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=男\r\n2=女",
),
),
62 => array (
'classid' => '5',
'displayorder' => '0',
'title' => '付款方式',
'identifier' => 'pay_type',
'type' => 'checkbox',
'rules' => array (
'required' => '0',
'unchangeable' => '0',
'choices' => "1=电汇\r\n2=支付宝\r\n3=现金\r\n4=其他",
),
),
);
$request_data = array (
'边栏模块_版块树形列表' =>
array (
'url' => 'function=module&module=forumtree.inc.php&settings=N%3B&jscharset=0&cachelife=864000',
'parameter' =>
array (
'module' => 'forumtree.inc.php',
'cachelife' => '864000',
'jscharset' => '0',
),
'comment' => '边栏版块树形列表模块',
'type' => '5',
),
'边栏模块_版主排行' =>
array (
'url' => 'function=module&module=modlist.inc.php&settings=N%3B&jscharset=0&cachelife=3600',
'parameter' =>
array (
'module' => 'modlist.inc.php',
'cachelife' => '3600',
'jscharset' => '0',
),
'comment' => '边栏版主排行模块',
'type' => '5',
),
'聚合模块_版块列表' =>
array (
'url' => 'function=module&module=rowcombine.inc.php&settings=a%3A1%3A%7Bs%3A4%3A%22data%22%3Bs%3A58%3A%22%B1%DF%C0%B8%C4%A3%BF%E9_%B0%E6%BF%E9%C5%C5%D0%D0%2C%B0%E6%BF%E9%C5%C5%D0%D0%0D%0A%B1%DF%C0%B8%C4%A3%BF%E9_%B0%E6%BF%E9%CA%F7%D0%CE%C1%D0%B1%ED%2C%B0%E6%BF%E9%C1%D0%B1%ED%22%3B%7D&jscharset=0&cachelife=864000',
'parameter' =>
array (
'module' => 'rowcombine.inc.php',
'cachelife' => '864000',
'settings' =>
array (
'data' => '边栏模块_版块排行,版块排行
边栏模块_版块树形列表,版块列表',
),
'jscharset' => '0',
),
'comment' => '热门版块、版块树形聚合模块',
'type' => '5',
),
'边栏模块_版块排行' =>
array (
'url' => 'function=forums&startrow=0&items=0&newwindow=1&orderby=posts&jscharset=0&cachelife=43200&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%B0%E6%BF%E9%C5%C5%D0%D0%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22textinfolist%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%3Cimg%20style%3D%5C%22vertical-align%3Amiddle%5C%22%20src%3D%5C%22images%2Fdefault%2Ftree_file.gif%5C%22%20%2F%3E%20%7Bforumname%7D%28%7Bposts%7D%29%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>版块排行</h4>
<ul class=\\"textinfolist\\">
[node]<li><img style=\\"vertical-align:middle\\" src=\\"images/default/tree_file.gif\\" /> {forumname}({posts})</li>[/node]
</ul>
</div>',
'cachelife' => '43200',
'startrow' => '0',
'items' => '0',
'newwindow' => 1,
'orderby' => 'posts',
'jscharset' => '0',
),
'comment' => '边栏版块排行模块',
'type' => '1',
),
'聚合模块_热门主题' =>
array (
'url' => 'function=module&module=rowcombine.inc.php&settings=a%3A2%3A%7Bs%3A5%3A%22title%22%3Bs%3A8%3A%22%C8%C8%C3%C5%D6%F7%CC%E2%22%3Bs%3A4%3A%22data%22%3Bs%3A79%3A%22%B1%DF%C0%B8%C4%A3%BF%E9_%C8%C8%C3%C5%D6%F7%CC%E2_%BD%F1%C8%D5%2C%C8%D5%0D%0A%B1%DF%C0%B8%C4%A3%BF%E9_%C8%C8%C3%C5%D6%F7%CC%E2_%B1%BE%D6%DC%2C%D6%DC%0D%0A%B1%DF%C0%B8%C4%A3%BF%E9_%C8%C8%C3%C5%D6%F7%CC%E2_%B1%BE%D4%C2%2C%D4%C2%22%3B%7D&jscharset=0&cachelife=1800',
'parameter' =>
array (
'module' => 'rowcombine.inc.php',
'cachelife' => '1800',
'settings' =>
array (
'title' => '热门主题',
'data' => '边栏模块_热门主题_今日,日
边栏模块_热门主题_本周,周
边栏模块_热门主题_本月,月',
),
'jscharset' => '0',
),
'comment' => '今日、本周、本月热门主题聚合模块',
'type' => '5',
),
'边栏模块_热门主题_本月' =>
array (
'url' => 'function=threads&sidestatus=0&maxlength=20&fnamelength=0&messagelength=&startrow=0&picpre=images%2Fcommon%2Fslisticon.gif&items=5&tag=&tids=&special=0&rewardstatus=&digest=0&stick=0&recommend=0&newwindow=1&threadtype=0&highlight=0&orderby=hourviews&hours=720&jscharset=0&cachelife=86400&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%B1%BE%D4%C2%C8%C8%C3%C5%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22textinfolist%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%7Bprefix%7D%7Bsubject%7D%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>本月热门</h4>
<ul class=\\"textinfolist\\">
[node]<li>{prefix}{subject}</li>[/node]
</ul>
</div>',
'cachelife' => '86400',
'sidestatus' => '0',
'startrow' => '0',
'items' => '5',
'maxlength' => '20',
'fnamelength' => '0',
'messagelength' => '',
'picpre' => 'images/common/slisticon.gif',
'tids' => '',
'keyword' => '',
'tag' => '',
'threadtype' => '0',
'highlight' => '0',
'recommend' => '0',
'newwindow' => 1,
'orderby' => 'hourviews',
'hours' => '720',
'jscharset' => '0',
),
'comment' => '边栏本月热门主题模块',
'type' => '0',
),
'聚合模块_会员排行' =>
array (
'url' => 'function=module&module=rowcombine.inc.php&settings=a%3A2%3A%7Bs%3A5%3A%22title%22%3Bs%3A8%3A%22%BB%E1%D4%B1%C5%C5%D0%D0%22%3Bs%3A4%3A%22data%22%3Bs%3A79%3A%22%B1%DF%C0%B8%C4%A3%BF%E9_%BB%E1%D4%B1%C5%C5%D0%D0_%BD%F1%C8%D5%2C%C8%D5%0D%0A%B1%DF%C0%B8%C4%A3%BF%E9_%BB%E1%D4%B1%C5%C5%D0%D0_%B1%BE%D6%DC%2C%D6%DC%0D%0A%B1%DF%C0%B8%C4%A3%BF%E9_%BB%E1%D4%B1%C5%C5%D0%D0_%B1%BE%D4%C2%2C%D4%C2%22%3B%7D&jscharset=0&cachelife=3600',
'parameter' =>
array (
'module' => 'rowcombine.inc.php',
'cachelife' => '3600',
'settings' =>
array (
'title' => '会员排行',
'data' => '边栏模块_会员排行_今日,日
边栏模块_会员排行_本周,周
边栏模块_会员排行_本月,月',
),
'jscharset' => '0',
),
'comment' => '今日、本周、本月会员排行聚合模块',
'type' => '5',
),
'边栏模块_推荐主题' =>
array (
'url' => 'function=threads&sidestatus=0&maxlength=20&fnamelength=0&messagelength=&startrow=0&picpre=images%2Fcommon%2Fslisticon.gif&items=5&tag=&tids=&special=0&rewardstatus=&digest=0&stick=0&recommend=1&newwindow=1&threadtype=0&highlight=0&orderby=lastpost&hours=48&jscharset=0&cachelife=3600&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%CD%C6%BC%F6%D6%F7%CC%E2%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22textinfolist%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%7Bprefix%7D%7Bsubject%7D%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>推荐主题</h4>
<ul class=\\"textinfolist\\">
[node]<li>{prefix}{subject}</li>[/node]
</ul>
</div>',
'cachelife' => '3600',
'sidestatus' => '0',
'startrow' => '0',
'items' => '5',
'maxlength' => '20',
'fnamelength' => '0',
'messagelength' => '',
'picpre' => 'images/common/slisticon.gif',
'tids' => '',
'keyword' => '',
'tag' => '',
'threadtype' => '0',
'highlight' => '0',
'recommend' => '1',
'newwindow' => 1,
'orderby' => 'lastpost',
'hours' => '48',
'jscharset' => '0',
),
'comment' => '边栏推荐主题模块',
'type' => '0',
),
'边栏模块_最新图片' =>
array (
'url' => 'function=images&sidestatus=0&isimage=1&threadmethod=1&maxwidth=140&maxheight=140&startrow=0&items=5&orderby=dateline&hours=0&digest=0&newwindow=1&jscharset=0&jstemplate=%3Cdiv%20%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%D7%EE%D0%C2%CD%BC%C6%AC%3C%2Fh4%3E%0D%0A%3Cscript%20type%3D%5C%22text%2Fjavascript%5C%22%3E%0D%0Avar%20slideSpeed%20%3D%202500%3B%0D%0Avar%20slideImgsize%20%3D%20%5B140%2C140%5D%3B%0D%0Avar%20slideTextBar%20%3D%200%3B%0D%0Avar%20slideBorderColor%20%3D%20%5C%27%23C8DCEC%5C%27%3B%0D%0Avar%20slideBgColor%20%3D%20%5C%27%23FFF%5C%27%3B%0D%0Avar%20slideImgs%20%3D%20new%20Array%28%29%3B%0D%0Avar%20slideImgLinks%20%3D%20new%20Array%28%29%3B%0D%0Avar%20slideImgTexts%20%3D%20new%20Array%28%29%3B%0D%0Avar%20slideSwitchBar%20%3D%201%3B%0D%0Avar%20slideSwitchColor%20%3D%20%5C%27black%5C%27%3B%0D%0Avar%20slideSwitchbgColor%20%3D%20%5C%27white%5C%27%3B%0D%0Avar%20slideSwitchHiColor%20%3D%20%5C%27%23C8DCEC%5C%27%3B%0D%0A%5Bnode%5D%0D%0AslideImgs%5B%7Border%7D%5D%20%3D%20%5C%22%7Bimgfile%7D%5C%22%3B%0D%0AslideImgLinks%5B%7Border%7D%5D%20%3D%20%5C%22%7Blink%7D%5C%22%3B%0D%0AslideImgTexts%5B%7Border%7D%5D%20%3D%20%5C%22%7Bsubject%7D%5C%22%3B%0D%0A%5B%2Fnode%5D%0D%0A%3C%2Fscript%3E%0D%0A%3Cscript%20language%3D%5C%22javascript%5C%22%20type%3D%5C%22text%2Fjavascript%5C%22%20src%3D%5C%22include%2Fjs%2Fslide.js%5C%22%3E%3C%2Fscript%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>最新图片</h4>
<script type=\\"text/javascript\\">
var slideSpeed = 2500;
var slideImgsize = [140,140];
var slideTextBar = 0;
var slideBorderColor = \\\'#C8DCEC\\\';
var slideBgColor = \\\'#FFF\\\';
var slideImgs = new Array();
var slideImgLinks = new Array();
var slideImgTexts = new Array();
var slideSwitchBar = 1;
var slideSwitchColor = \\\'black\\\';
var slideSwitchbgColor = \\\'white\\\';
var slideSwitchHiColor = \\\'#C8DCEC\\\';
[node]
slideImgs[{order}] = \\"{imgfile}\\";
slideImgLinks[{order}] = \\"{link}\\";
slideImgTexts[{order}] = \\"{subject}\\";
[/node]
</script>
<script language=\\"javascript\\" type=\\"text/javascript\\" src=\\"include/js/slide.js\\"></script>
</div>',
'cachelife' => '',
'sidestatus' => '0',
'startrow' => '0',
'items' => '5',
'isimage' => '1',
'maxwidth' => '140',
'maxheight' => '140',
'threadmethod' => '1',
'newwindow' => 1,
'orderby' => 'dateline',
'hours' => '',
'jscharset' => '0',
),
'comment' => '边栏最新图片展示模块',
'type' => '4',
),
'边栏模块_最新主题' =>
array (
'url' => 'function=threads&sidestatus=0&maxlength=20&fnamelength=0&messagelength=&startrow=0&picpre=images%2Fcommon%2Fslisticon.gif&items=5&tag=&tids=&special=0&rewardstatus=&digest=0&stick=0&recommend=0&newwindow=1&threadtype=0&highlight=0&orderby=dateline&hours=0&jscharset=0&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%D7%EE%D0%C2%D6%F7%CC%E2%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22textinfolist%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%7Bprefix%7D%7Bsubject%7D%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>最新主题</h4>
<ul class=\\"textinfolist\\">
[node]<li>{prefix}{subject}</li>[/node]
</ul>
</div>',
'cachelife' => '',
'sidestatus' => '0',
'startrow' => '0',
'items' => '5',
'maxlength' => '20',
'fnamelength' => '0',
'messagelength' => '',
'picpre' => 'images/common/slisticon.gif',
'tids' => '',
'keyword' => '',
'tag' => '',
'threadtype' => '0',
'highlight' => '0',
'recommend' => '0',
'newwindow' => 1,
'orderby' => 'dateline',
'hours' => '',
'jscharset' => '0',
),
'comment' => '边栏最新主题模块',
'type' => '0',
),
'边栏模块_活跃会员' =>
array (
'url' => 'function=memberrank&startrow=0&items=12&newwindow=1&extcredit=1&orderby=posts&hours=0&jscharset=0&cachelife=43200&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%BB%EE%D4%BE%BB%E1%D4%B1%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22avt_list%20s_clear%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%7Bavatarsmall%7D%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>活跃会员</h4>
<ul class=\\"avt_list s_clear\\">
[node]<li>{avatarsmall}</li>[/node]
</ul>
</div>',
'cachelife' => '43200',
'startrow' => '0',
'items' => '12',
'newwindow' => 1,
'extcredit' => '1',
'orderby' => 'posts',
'hours' => '',
'jscharset' => '0',
),
'comment' => '边栏活跃会员模块',
'type' => '2',
),
'边栏模块_热门主题_本版' =>
array (
'url' => 'function=threads&sidestatus=1&maxlength=20&fnamelength=0&messagelength=&startrow=0&picpre=images%2Fcommon%2Fslisticon.gif&items=5&tag=&tids=&special=0&rewardstatus=&digest=0&stick=0&recommend=0&newwindow=1&threadtype=0&highlight=0&orderby=replies&hours=0&jscharset=0&cachelife=1800&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%B1%BE%B0%E6%C8%C8%C3%C5%D6%F7%CC%E2%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22textinfolist%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%7Bprefix%7D%7Bsubject%7D%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>本版热门主题</h4>
<ul class=\\"textinfolist\\">
[node]<li>{prefix}{subject}</li>[/node]
</ul>
</div>',
'cachelife' => '1800',
'sidestatus' => '1',
'startrow' => '0',
'items' => '5',
'maxlength' => '20',
'fnamelength' => '0',
'messagelength' => '',
'picpre' => 'images/common/slisticon.gif',
'tids' => '',
'keyword' => '',
'tag' => '',
'threadtype' => '0',
'highlight' => '0',
'recommend' => '0',
'newwindow' => 1,
'orderby' => 'replies',
'hours' => '',
'jscharset' => '0',
),
'comment' => '边栏本版热门主题模块',
'type' => '0',
),
'边栏模块_热门主题_今日' =>
array (
'url' => 'function=threads&sidestatus=0&maxlength=20&fnamelength=0&messagelength=&startrow=0&picpre=images%2Fcommon%2Fslisticon.gif&items=5&tag=&tids=&special=0&rewardstatus=&digest=0&stick=0&recommend=0&newwindow=1&threadtype=0&highlight=0&orderby=hourviews&hours=24&jscharset=0&cachelife=1800&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%BD%F1%C8%D5%C8%C8%C3%C5%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22textinfolist%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%7Bprefix%7D%7Bsubject%7D%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>今日热门</h4>
<ul class=\\"textinfolist\\">
[node]<li>{prefix}{subject}</li>[/node]
</ul>
</div>',
'cachelife' => '1800',
'sidestatus' => '0',
'startrow' => '0',
'items' => '5',
'maxlength' => '20',
'fnamelength' => '0',
'messagelength' => '',
'picpre' => 'images/common/slisticon.gif',
'tids' => '',
'keyword' => '',
'tag' => '',
'threadtype' => '0',
'highlight' => '0',
'recommend' => '0',
'newwindow' => 1,
'orderby' => 'hourviews',
'hours' => '24',
'jscharset' => '0',
),
'comment' => '边栏今日热门主题模块',
'type' => '0',
),
'边栏模块_最新回复' =>
array (
'url' => 'function=threads&sidestatus=0&maxlength=20&fnamelength=0&messagelength=&startrow=0&picpre=images%2Fcommon%2Fslisticon.gif&items=5&tag=&tids=&special=0&rewardstatus=&digest=0&stick=0&recommend=0&newwindow=1&threadtype=0&highlight=0&orderby=lastpost&hours=0&jscharset=0&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%D7%EE%D0%C2%BB%D8%B8%B4%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22textinfolist%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%7Bprefix%7D%7Bsubject%7D%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>最新回复</h4>
<ul class=\\"textinfolist\\">
[node]<li>{prefix}{subject}</li>[/node]
</ul>
</div>',
'cachelife' => '',
'sidestatus' => '0',
'startrow' => '0',
'items' => '5',
'maxlength' => '20',
'fnamelength' => '0',
'messagelength' => '',
'picpre' => 'images/common/slisticon.gif',
'tids' => '',
'keyword' => '',
'tag' => '',
'threadtype' => '0',
'highlight' => '0',
'recommend' => '0',
'newwindow' => 1,
'orderby' => 'lastpost',
'hours' => '',
'jscharset' => '0',
),
'comment' => '边栏最新回复模块',
'type' => '0',
),
'边栏模块_最新图片_本版' =>
array (
'url' => 'function=images&sidestatus=1&isimage=1&threadmethod=1&maxwidth=140&maxheight=140&startrow=0&items=5&orderby=dateline&hours=0&digest=0&newwindow=1&jscharset=0&jstemplate=%3Cdiv%20%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%D7%EE%D0%C2%CD%BC%C6%AC%3C%2Fh4%3E%0D%0A%3Cscript%20type%3D%5C%22text%2Fjavascript%5C%22%3E%0D%0Avar%20slideSpeed%20%3D%202500%3B%0D%0Avar%20slideImgsize%20%3D%20%5B140%2C140%5D%3B%0D%0Avar%20slideTextBar%20%3D%200%3B%0D%0Avar%20slideBorderColor%20%3D%20%5C%27%23C8DCEC%5C%27%3B%0D%0Avar%20slideBgColor%20%3D%20%5C%27%23FFF%5C%27%3B%0D%0Avar%20slideImgs%20%3D%20new%20Array%28%29%3B%0D%0Avar%20slideImgLinks%20%3D%20new%20Array%28%29%3B%0D%0Avar%20slideImgTexts%20%3D%20new%20Array%28%29%3B%0D%0Avar%20slideSwitchBar%20%3D%201%3B%0D%0Avar%20slideSwitchColor%20%3D%20%5C%27black%5C%27%3B%0D%0Avar%20slideSwitchbgColor%20%3D%20%5C%27white%5C%27%3B%0D%0Avar%20slideSwitchHiColor%20%3D%20%5C%27%23C8DCEC%5C%27%3B%0D%0A%5Bnode%5D%0D%0AslideImgs%5B%7Border%7D%5D%20%3D%20%5C%22%7Bimgfile%7D%5C%22%3B%0D%0AslideImgLinks%5B%7Border%7D%5D%20%3D%20%5C%22%7Blink%7D%5C%22%3B%0D%0AslideImgTexts%5B%7Border%7D%5D%20%3D%20%5C%22%7Bsubject%7D%5C%22%3B%0D%0A%5B%2Fnode%5D%0D%0A%3C%2Fscript%3E%0D%0A%3Cscript%20language%3D%5C%22javascript%5C%22%20type%3D%5C%22text%2Fjavascript%5C%22%20src%3D%5C%22include%2Fjs%2Fslide.js%5C%22%3E%3C%2Fscript%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>最新图片</h4>
<script type=\\"text/javascript\\">
var slideSpeed = 2500;
var slideImgsize = [140,140];
var slideTextBar = 0;
var slideBorderColor = \\\'#C8DCEC\\\';
var slideBgColor = \\\'#FFF\\\';
var slideImgs = new Array();
var slideImgLinks = new Array();
var slideImgTexts = new Array();
var slideSwitchBar = 1;
var slideSwitchColor = \\\'black\\\';
var slideSwitchbgColor = \\\'white\\\';
var slideSwitchHiColor = \\\'#C8DCEC\\\';
[node]
slideImgs[{order}] = \\"{imgfile}\\";
slideImgLinks[{order}] = \\"{link}\\";
slideImgTexts[{order}] = \\"{subject}\\";
[/node]
</script>
<script language=\\"javascript\\" type=\\"text/javascript\\" src=\\"include/js/slide.js\\"></script>
</div>',
'cachelife' => '',
'sidestatus' => '1',
'startrow' => '0',
'items' => '5',
'isimage' => '1',
'maxwidth' => '140',
'maxheight' => '140',
'threadmethod' => '1',
'newwindow' => 1,
'orderby' => 'dateline',
'hours' => '',
'jscharset' => '0',
),
'comment' => '边栏本版最新图片展示模块',
'type' => '4',
),
'边栏模块_标签' =>
array (
'url' => 'function=module&module=tag.inc.php&settings=a%3A1%3A%7Bs%3A5%3A%22limit%22%3Bs%3A2%3A%2220%22%3B%7D&jscharset=0&cachelife=900',
'parameter' =>
array (
'module' => 'tag.inc.php',
'cachelife' => '900',
'settings' =>
array (
'limit' => '20',
),
'jscharset' => '0',
),
'comment' => '边栏标签模块',
'type' => '5',
),
'边栏模块_会员排行_本月' =>
array (
'url' => 'function=memberrank&startrow=0&items=5&newwindow=1&extcredit=1&orderby=hourposts&hours=720&jscharset=0&cachelife=86400&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%20s_clear%5C%22%3E%0D%0A%3Ch4%3E%B1%BE%D4%C2%C5%C5%D0%D0%3C%2Fh4%3E%0D%0A%5Bnode%5D%3Cdiv%20style%3D%5C%22clear%3Aboth%5C%22%3E%3Cdiv%20style%3D%5C%22float%3Aleft%3Bmargin%3A%200%2016px%205px%200%5C%22%3E%7Bavatarsmall%7D%3C%2Fdiv%3E%7Bmember%7D%3Cbr%20%2F%3E%B7%A2%CC%FB%20%7Bvalue%7D%20%C6%AA%3C%2Fdiv%3E%5B%2Fnode%5D%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>本月排行</h4>
[node]<div class=\\"s_clear\\" style=\\"margin-bottom: 5px;\\"><div style=\\"margin-right: 10px; float: left;\\">{avatarsmall}</div><p>{member}</p><p>发帖 {value} 篇</p></div>[/node]
</div>',
'cachelife' => '86400',
'startrow' => '0',
'items' => '5',
'newwindow' => 1,
'extcredit' => '1',
'orderby' => 'hourposts',
'hours' => '720',
'jscharset' => '0',
),
'comment' => '边栏会员本月发帖排行模块',
'type' => '2',
),
'边栏模块_会员排行_本周' =>
array (
'url' => 'function=memberrank&startrow=0&items=5&newwindow=1&extcredit=1&orderby=hourposts&hours=168&jscharset=0&cachelife=43200&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%20s_clear%5C%22%3E%0D%0A%3Ch4%3E%B1%BE%D6%DC%C5%C5%D0%D0%3C%2Fh4%3E%0D%0A%5Bnode%5D%3Cdiv%20style%3D%5C%22clear%3Aboth%5C%22%3E%3Cdiv%20style%3D%5C%22float%3Aleft%3Bmargin%3A%200%2016px%205px%200%5C%22%3E%7Bavatarsmall%7D%3C%2Fdiv%3E%7Bmember%7D%3Cbr%20%2F%3E%B7%A2%CC%FB%20%7Bvalue%7D%20%C6%AA%3C%2Fdiv%3E%5B%2Fnode%5D%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>本周排行</h4>
[node]<div class=\\"s_clear\\" style=\\"margin-bottom: 5px;\\"><div style=\\"margin-right: 10px; float: left;\\">{avatarsmall}</div><p>{member}</p><p>发帖 {value} 篇</p></div>[/node]
</div>',
'cachelife' => '43200',
'startrow' => '0',
'items' => '5',
'newwindow' => 1,
'extcredit' => '1',
'orderby' => 'hourposts',
'hours' => '168',
'jscharset' => '0',
),
'comment' => '边栏会员本周发帖排行模块',
'type' => '2',
),
'边栏方案_主题列表页默认' =>
array (
'url' => 'function=side&jscharset=&jstemplate=%5Bmodule%5D%B1%DF%C0%B8%C4%A3%BF%E9_%CE%D2%B5%C4%D6%FA%CA%D6%5B%2Fmodule%5D%3Chr%20class%3D%22shadowline%22%2F%3E%5Bmodule%5D%B1%DF%C0%B8%C4%A3%BF%E9_%C8%C8%C3%C5%D6%F7%CC%E2_%B1%BE%B0%E6%5B%2Fmodule%5D%3Chr%20class%3D%22shadowline%22%2F%3E%5Bmodule%5D%B1%DF%C0%B8%C4%A3%BF%E9_%B0%E6%BF%E9%C5%C5%D0%D0%5B%2Fmodule%5D',
'parameter' =>
array (
'selectmodule' =>
array (
1 => '边栏模块_我的助手',
2 => '边栏模块_热门主题_本版',
3 => '边栏模块_版块排行',
),
'cachelife' => 0,
'jstemplate' => '[module]边栏模块_我的助手[/module]<hr class="shadowline"/>[module]边栏模块_热门主题_本版[/module]<hr class="shadowline"/>[module]边栏模块_版块排行[/module]',
),
'comment' => NULL,
'type' => '-2',
),
'边栏方案_首页默认' =>
array (
'url' => 'function=side&jscharset=&jstemplate=%5Bmodule%5D%B1%DF%C0%B8%C4%A3%BF%E9_%CE%D2%B5%C4%D6%FA%CA%D6%5B%2Fmodule%5D%3Chr%20class%3D%22shadowline%22%2F%3E%5Bmodule%5D%BE%DB%BA%CF%C4%A3%BF%E9_%D0%C2%CC%FB%5B%2Fmodule%5D%3Chr%20class%3D%22shadowline%22%2F%3E%5Bmodule%5D%BE%DB%BA%CF%C4%A3%BF%E9_%C8%C8%C3%C5%D6%F7%CC%E2%5B%2Fmodule%5D%3Chr%20class%3D%22shadowline%22%2F%3E%5Bmodule%5D%B1%DF%C0%B8%C4%A3%BF%E9_%BB%EE%D4%BE%BB%E1%D4%B1%5B%2Fmodule%5D',
'parameter' =>
array (
'selectmodule' =>
array (
1 => '边栏模块_我的助手',
2 => '聚合模块_新帖',
3 => '聚合模块_热门主题',
4 => '边栏模块_活跃会员',
),
'cachelife' => 0,
'jstemplate' => '[module]边栏模块_我的助手[/module]<hr class="shadowline"/>[module]聚合模块_新帖[/module]<hr class="shadowline"/>[module]聚合模块_热门主题[/module]<hr class="shadowline"/>[module]边栏模块_活跃会员[/module]',
),
'comment' => NULL,
'type' => '-2',
),
'聚合模块_新帖' =>
array (
'url' => 'function=module&module=rowcombine.inc.php&settings=a%3A2%3A%7Bs%3A5%3A%22title%22%3Bs%3A8%3A%22%D7%EE%D0%C2%CC%FB%D7%D3%22%3Bs%3A4%3A%22data%22%3Bs%3A46%3A%22%B1%DF%C0%B8%C4%A3%BF%E9_%D7%EE%D0%C2%D6%F7%CC%E2%2C%D6%F7%CC%E2%0D%0A%B1%DF%C0%B8%C4%A3%BF%E9_%D7%EE%D0%C2%BB%D8%B8%B4%2C%BB%D8%B8%B4%22%3B%7D&jscharset=0',
'parameter' =>
array (
'module' => 'rowcombine.inc.php',
'cachelife' => '',
'settings' =>
array (
'title' => '最新帖子',
'data' => '边栏模块_最新主题,主题
边栏模块_最新回复,回复',
),
'jscharset' => '0',
),
'comment' => '最新主题、最新回复聚合模块',
'type' => '5',
),
'边栏模块_热门主题_本周' =>
array (
'url' => 'function=threads&sidestatus=0&maxlength=20&fnamelength=0&messagelength=&startrow=0&picpre=images%2Fcommon%2Fslisticon.gif&items=5&tag=&tids=&special=0&rewardstatus=&digest=0&stick=0&recommend=0&newwindow=1&threadtype=0&highlight=0&orderby=hourviews&hours=168&jscharset=0&cachelife=43200&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%5C%22%3E%0D%0A%3Ch4%3E%B1%BE%D6%DC%C8%C8%C3%C5%3C%2Fh4%3E%0D%0A%3Cul%20class%3D%5C%22textinfolist%5C%22%3E%0D%0A%5Bnode%5D%3Cli%3E%7Bprefix%7D%7Bsubject%7D%3C%2Fli%3E%5B%2Fnode%5D%0D%0A%3C%2Ful%3E%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>本周热门</h4>
<ul class=\\"textinfolist\\">
[node]<li>{prefix}{subject}</li>[/node]
</ul>
</div>',
'cachelife' => '43200',
'sidestatus' => '0',
'startrow' => '0',
'items' => '5',
'maxlength' => '20',
'fnamelength' => '0',
'messagelength' => '',
'picpre' => 'images/common/slisticon.gif',
'tids' => '',
'keyword' => '',
'tag' => '',
'threadtype' => '0',
'highlight' => '0',
'recommend' => '0',
'newwindow' => 1,
'orderby' => 'hourviews',
'hours' => '168',
'jscharset' => '0',
),
'comment' => '边栏本周热门主题模块',
'type' => '0',
),
'边栏模块_会员排行_今日' =>
array (
'url' => 'function=memberrank&startrow=0&items=5&newwindow=1&extcredit=1&orderby=hourposts&hours=24&jscharset=0&cachelife=3600&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%20s_clear%5C%22%3E%0D%0A%3Ch4%3E%BD%F1%C8%D5%C5%C5%D0%D0%3C%2Fh4%3E%0D%0A%5Bnode%5D%3Cdiv%20style%3D%5C%22clear%3Aboth%5C%22%3E%3Cdiv%20style%3D%5C%22float%3Aleft%3Bmargin%3A%200%2016px%205px%200%5C%22%3E%7Bavatarsmall%7D%3C%2Fdiv%3E%7Bmember%7D%3Cbr%20%2F%3E%B7%A2%CC%FB%20%7Bvalue%7D%20%C6%AA%3C%2Fdiv%3E%5B%2Fnode%5D%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox\\">
<h4>今日排行</h4>
[node]<div class=\\"s_clear\\" style=\\"margin-bottom: 5px;\\"><div style=\\"margin-right: 10px; float: left;\\">{avatarsmall}</div><p>{member}</p><p>发帖 {value} 篇</p></div>[/node]
</div>',
'cachelife' => '3600',
'startrow' => '0',
'items' => '5',
'newwindow' => 1,
'extcredit' => '1',
'orderby' => 'hourposts',
'hours' => '24',
'jscharset' => '0',
),
'comment' => '边栏会员今日发帖排行模块',
'type' => '2',
),
'边栏模块_论坛之星' =>
array (
'url' => 'function=memberrank&startrow=0&items=3&newwindow=1&extcredit=1&orderby=hourposts&hours=168&jscharset=0&cachelife=43200&jstemplate=%3Cdiv%20class%3D%5C%22sidebox%20s_clear%5C%22%3E%0D%0A%3Ch4%3E%B1%BE%D6%DC%D6%AE%D0%C7%3C%2Fh4%3E%0D%0A%5Bnode%5D%0D%0A%5Bshow%3D1%5D%3Cdiv%20style%3D%5C%22clear%3Aboth%5C%22%3E%3Cdiv%20style%3D%5C%22float%3Aleft%3B%20margin-right%3A%2016px%3B%5C%22%3E%7Bavatarsmall%7D%3C%2Fdiv%3E%5B%2Fshow%5D%7Bmember%7D%20%5Bshow%3D1%5D%3Cbr%20%2F%3E%B7%A2%CC%FB%20%7Bvalue%7D%20%C6%AA%3C%2Fdiv%3E%3Cdiv%20style%3D%5C%22clear%3Aboth%3Bmargin-top%3A2px%5C%22%20%2F%3E%3C%2Fdiv%3E%5B%2Fshow%5D%0D%0A%5B%2Fnode%5D%0D%0A%3C%2Fdiv%3E',
'parameter' =>
array (
'jstemplate' => '<div class=\\"sidebox s_clear\\">
<h4>本周之星</h4>
[node]
[show=1]<div style=\\"clear:both\\"><div style=\\"float:left; margin-right: 16px;\\">{avatarsmall}</div>[/show]{member} [show=1]<br />发帖 {value} 篇</div><div style=\\"clear:both;margin-top:2px\\" /></div>[/show]
[/node]
</div>',
'cachelife' => '43200',
'startrow' => '0',
'items' => '3',
'newwindow' => 1,
'extcredit' => '1',
'orderby' => 'hourposts',
'hours' => '168',
'jscharset' => '0',
),
'comment' => '边栏论坛之星模块',
'type' => '2',
),
'边栏模块_我的助手' =>
array (
'url' => 'function=module&module=assistant.inc.php&settings=N%3B&jscharset=0&cachelife=0',
'parameter' =>
array (
'module' => 'assistant.inc.php',
'cachelife' => '0',
'jscharset' => '0',
),
'comment' => '边栏我的助手模块',
'type' => '5',
),
'边栏模块_Google搜索' =>
array (
'url' => 'function=module&module=google.inc.php&settings=a%3A2%3A%7Bs%3A4%3A%22lang%22%3Bs%3A0%3A%22%22%3Bs%3A7%3A%22default%22%3Bs%3A1%3A%221%22%3B%7D&jscharset=0&cachelife=864000',
'parameter' =>
array (
'module' => 'google.inc.php',
'cachelife' => '864000',
'settings' =>
array (
'lang' => '',
'default' => '1',
),
'jscharset' => '0',
),
'comment' => '边栏 Google 搜索模块',
'type' => '5',
),
'UCHome_最新动态' =>
array (
'url' => 'function=module&module=feed.inc.php&settings=a%3A6%3A%7Bs%3A5%3A%22title%22%3Bs%3A8%3A%22%D7%EE%D0%C2%B6%AF%CC%AC%22%3Bs%3A4%3A%22uids%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22friend%22%3Bs%3A1%3A%220%22%3Bs%3A5%3A%22start%22%3Bs%3A1%3A%220%22%3Bs%3A5%3A%22limit%22%3Bs%3A2%3A%2210%22%3Bs%3A8%3A%22template%22%3Bs%3A54%3A%22%3Cdiv%20style%3D%5C%22padding-left%3A2px%5C%22%3E%7Btitle_template%7D%3C%2Fdiv%3E%22%3B%7D&jscharset=0&cachelife=0',
'parameter' =>
array (
'module' => 'feed.inc.php',
'cachelife' => '0',
'settings' =>
array (
'title' => '最新动态',
'uids' => '',
'friend' => '0',
'start' => '0',
'limit' => '10',
'template' => '<div style=\\"padding-left:2px\\">{title_template}</div>',
),
'jscharset' => '0',
),
'comment' => '获取UCHome的最新动态',
'type' => '5',
),
'UCHome_最新更新空间' =>
array (
'url' => 'function=module&module=space.inc.php&settings=a%3A17%3A%7Bs%3A5%3A%22title%22%3Bs%3A12%3A%22%D7%EE%D0%C2%B8%FC%D0%C2%BF%D5%BC%E4%22%3Bs%3A3%3A%22uid%22%3Bs%3A0%3A%22%22%3Bs%3A14%3A%22startfriendnum%22%3Bs%3A0%3A%22%22%3Bs%3A12%3A%22endfriendnum%22%3Bs%3A0%3A%22%22%3Bs%3A12%3A%22startviewnum%22%3Bs%3A0%3A%22%22%3Bs%3A10%3A%22endviewnum%22%3Bs%3A0%3A%22%22%3Bs%3A11%3A%22startcredit%22%3Bs%3A0%3A%22%22%3Bs%3A9%3A%22endcredit%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22avatar%22%3Bs%3A2%3A%22-1%22%3Bs%3A10%3A%22namestatus%22%3Bs%3A2%3A%22-1%22%3Bs%3A8%3A%22dateline%22%3Bs%3A1%3A%220%22%3Bs%3A10%3A%22updatetime%22%3Bs%3A1%3A%220%22%3Bs%3A5%3A%22order%22%3Bs%3A10%3A%22updatetime%22%3Bs%3A2%3A%22sc%22%3Bs%3A4%3A%22DESC%22%3Bs%3A5%3A%22start%22%3Bs%3A1%3A%220%22%3Bs%3A5%3A%22limit%22%3Bs%3A2%3A%2210%22%3Bs%3A8%3A%22template%22%3Bs%3A267%3A%22%3Ctable%3E%0D%0A%3Ctr%3E%0D%0A%3Ctd%20width%3D%5C%2250%5C%22%20rowspan%3D%5C%222%5C%22%3E%3Ca%20href%3D%5C%22%7Buserlink%7D%5C%22%20target%3D%5C%22_blank%5C%22%3E%3Cimg%20src%3D%5C%22%7Bphoto%7D%5C%22%20%2F%3E%3C%2Fa%3E%3C%2Ftd%3E%0D%0A%3Ctd%3E%3Ca%20href%3D%5C%22%7Buserlink%7D%5C%22%20%20target%3D%5C%22_blank%5C%22%20style%3D%5C%22text-decoration%3Anone%3B%5C%22%3E%7Busername%7D%3C%2Fa%3E%3C%2Ftd%3E%0D%0A%3C%2Ftr%3E%0D%0A%3Ctr%3E%3Ctd%3E%7Bupdatetime%7D%3C%2Ftd%3E%3C%2Ftr%3E%0D%0A%3C%2Ftable%3E%22%3B%7D&jscharset=0&cachelife=0',
'parameter' =>
array (
'module' => 'space.inc.php',
'cachelife' => '0',
'settings' =>
array (
'title' => '最新更新空间',
'uid' => '',
'startfriendnum' => '',
'endfriendnum' => '',
'startviewnum' => '',
'endviewnum' => '',
'startcredit' => '',
'endcredit' => '',
'avatar' => '-1',
'namestatus' => '-1',
'dateline' => '0',
'updatetime' => '0',
'order' => 'updatetime',
'sc' => 'DESC',
'start' => '0',
'limit' => '10',
'template' => '<table>
<tr>
<td width=\\"50\\" rowspan=\\"2\\"><a href=\\"{userlink}\\" target=\\"_blank\\"><img src=\\"{photo}\\" /></a></td>
<td><a href=\\"{userlink}\\" target=\\"_blank\\" style=\\"text-decoration:none;\\">{username}</a></td>
</tr>
<tr><td>{updatetime}</td></tr>
</table>',
),
'jscharset' => '0',
),
'comment' => '获取UCHome最新更新会员空间',
'type' => '5',
),
'UCHome_最新记录' =>
array (
'url' => 'function=module&module=doing.inc.php&settings=a%3A6%3A%7Bs%3A5%3A%22title%22%3Bs%3A8%3A%22%D7%EE%D0%C2%BC%C7%C2%BC%22%3Bs%3A3%3A%22uid%22%3Bs%3A0%3A%22%22%3Bs%3A4%3A%22mood%22%3Bs%3A1%3A%220%22%3Bs%3A5%3A%22start%22%3Bs%3A1%3A%220%22%3Bs%3A5%3A%22limit%22%3Bs%3A2%3A%2210%22%3Bs%3A8%3A%22template%22%3Bs%3A360%3A%22%0D%0A%3Cdiv%20style%3D%5C%22padding%3A0%200%205px%200%3B%5C%22%3E%0D%0A%3Ca%20href%3D%5C%22%7Buserlink%7D%5C%22%20target%3D%5C%22_blank%5C%22%3E%3Cimg%20src%3D%5C%22%7Bphoto%7D%5C%22%20width%3D%5C%2218%5C%22%20height%3D%5C%2218%5C%22%20align%3D%5C%22absmiddle%5C%22%3E%3C%2Fa%3E%20%3Ca%20href%3D%5C%22%7Buserlink%7D%5C%22%20%20target%3D%5C%22_blank%5C%22%3E%7Busername%7D%3C%2Fa%3E%A3%BA%0D%0A%3C%2Fdiv%3E%0D%0A%3Cdiv%20style%3D%5C%22padding%3A0%200%205px%2020px%3B%5C%22%3E%0D%0A%3Ca%20href%3D%5C%22%7Blink%7D%5C%22%20style%3D%5C%22color%3A%23333%3Btext-decoration%3Anone%3B%5C%22%20target%3D%5C%22_blank%5C%22%3E%7Bmessage%7D%3C%2Fa%3E%0D%0A%3C%2Fdiv%3E%22%3B%7D&jscharset=0&cachelife=0',
'parameter' =>
array (
'module' => 'doing.inc.php',
'cachelife' => '0',
'settings' =>
array (
'title' => '最新记录',
'uid' => '',
'mood' => '0',
'start' => '0',
'limit' => '10',
'template' => '
<div style=\\"padding:0 0 5px 0;\\">
<a href=\\"{userlink}\\" target=\\"_blank\\"><img src=\\"{photo}\\" width=\\"18\\" height=\\"18\\" align=\\"absmiddle\\"></a> <a href=\\"{userlink}\\" target=\\"_blank\\">{username}</a>:
</div>
<div style=\\"padding:0 0 5px 20px;\\">
<a href=\\"{link}\\" style=\\"color:#333;text-decoration:none;\\" target=\\"_blank\\">{message}</a>
</div>',
),
'jscharset' => '0',
),
'comment' => '获取UCHome的最新记录',
'type' => '5',
),
'UCHome_竞价排名' =>
array (
'url' => 'function=module&module=html.inc.php&settings=a%3A3%3A%7Bs%3A4%3A%22type%22%3Bs%3A1%3A%220%22%3Bs%3A4%3A%22code%22%3Bs%3A27%3A%22%3Cdiv%20id%3D%5C%22sidefeed%5C%22%3E%3C%2Fdiv%3E%22%3Bs%3A4%3A%22side%22%3Bs%3A1%3A%220%22%3B%7D&jscharset=0&cachelife=864000',
'parameter' =>
array (
'module' => 'html.inc.php',
'cachelife' => '864000',
'settings' =>
array (
'type' => '0',
'code' => '<div id=\\"sidefeed\\"></div>',
'side' => '0',
),
'jscharset' => '0',
),
'comment' => '获取UCHome的竞价排名信息',
'type' => '5',
),
);
$tasktypes = array(
'promotion' =>
array (
'name' => '论坛推广任务',
'version' => '1.0',
),
'gift' =>
array (
'name' => '红包类任务',
'version' => '1.0',
),
'avatar' =>
array (
'name' => '头像类任务',
'version' => '1.0',
)
);
$newbietask = array(
1 => array(
'name' => '回帖是一种美德',
'task' => "1, 0, '回帖是一种美德', '学习回帖,看帖回帖是一种美德,BS看帖不回帖的', '', 0, 0, 0, 'all', 'newbie_post_reply', 0, 0, 0, 'credit', '2', 10, -1, ''",
'vars' => array(
"'complete', '回复指定主题', '".addslashes('设置会员只有回复该主题才能完成任务,请填写主题的 tid(比如一个主题的地址是 http://localhost/viewthread.php?tid=8 那么该主题的 tid 就是 8),留空为不限制')."', 'threadid', 'text', '0', ''",
"'setting', '', '', 'entrance', 'text', 'viewthread', ''"
)
),
2 => array(
'name' => '我的第一次',
'task' => "1, 0, '我的第一次', '学会发主题帖,成为社区的焦点', '', 0, 0, 0, 'all', 'newbie_post_newthread', 0, 0, 0, 'credit', '2', 10, -1, ''",
'vars' => array(
"'complete', '在指定版块发表新主题', '".addslashes('设置会员必须在某个版块发表至少一篇新主题才能完成任务')."', 'forumid', 'text', '', ''",
"'setting', '', '', 'entrance', 'text', 'forumdisplay', ''"
)
),
3 => array(
'name' => '与众不同',
'task' => "1, 0, '与众不同', '修改个人资料,让你和别人与众不同', '', 0, 0, 0, 'all', 'newbie_modifyprofile', 0, 0, 0, 'credit', '2', 10, -1, ''",
'vars' => array(
"'complete', '完善个人资料', '".addslashes('申请任务后只要把自己的个人资料填写完整即可完成任务')."', '', '', '', ''",
"'setting', '', '', 'entrance', 'text', 'memcp', ''"
)
),
4 => array(
'name' => '我型我秀',
'task' => "1, 0, '我型我秀', '上传头像,让大家认识一个全新的你', '', 0, 0, 0, 'all', 'newbie_uploadavatar', 0, 0, 0, 'credit', '2', 10, -1, ''",
'vars' => array(
"'complete', '上传头像', '".addslashes('申请任务后只要成功上传头像即可完成任务')."', '', '', '', ''",
"'setting', '', '', 'entrance', 'text', 'memcp', ''"
)
),
5 => array(
'name' => '联络感情',
'task' => "1, 0, '联络感情', '给其他用户发个发短消息,大家联络一下感情', '', 0, 0, 0, 'all', 'newbie_sendpm', 0, 0, 0, 'credit', '2', 10, -1, ''",
'vars' => array(
"'complete', '给指定会员发送短消息', '".addslashes('只有给该会员成功发送短消息才能完成任务,请填写该会员的用户名')."', 'authorid', 'text', '', ''",
"'setting', '', '', 'entrance', 'text', 'space', ''"
)
),
6 => array(
'name' => '一个好汉三个帮',
'task' => "1, 0, '一个好汉三个帮', '出来混的,没几个好友怎么行,加个好友吧', '', 0, 0, 0, 'all', 'newbie_addbuddy', 0, 0, 0, 'credit', '2', 10, -1, ''",
'vars' => array(
"'complete', '将指定会员加为好友', '".addslashes('只有将该会员加为好友才能完成任务,请填写该会员的用户名')."', 'authorid', 'text', '', ''",
"'setting', '', '', 'entrance', 'text', 'space', ''"
)
),
7 => array(
'name' => '信息时代',
'task' => "1, 0, '信息时代', '信息时代最缺的什么?搜索', '', 0, 0, 0, 'all', 'newbie_search', 0, 0, 0, 'credit', '2', 10, -1, ''",
'vars' => array(
"'complete', '学会搜索', '".addslashes('申请任务后只要成功使用论坛搜索功能即可完成任务')."', '', '', '', ''",
"'setting', '', '', 'entrance', 'text', 'search', ''"
)
)
);
$testdatacontent = array();
$testdatacontent[0]['subject'] = '论坛运营秘籍 - Discuz! 7.2 新功能的妙用 ';
$testdatacontent[0]['message'] = <<<EOD
Discuz! 7.2 新推出的几个功能,都是围绕着提高论坛的互动性而设计的,好好利用这些新功能,对于提高论坛用户粘性,增强会员之间的互动性,大有脾益。下面我们来说说,如何根据论坛的实际情况,来合理的设置这些新功能。[p=30, 2, left]
[b][size=4]一、论坛动态和首页显示风格[/size][/b] [/p][p=30, 2, left]
[b]设计目标:[/b] [/p]
通过对论坛事件展示方式的优化,增强论坛信息的传递功能,提高论坛会员之间的沟通效率。[b]设置指导:[/b]
很多人喜欢 UCHome 中好友动态功能,Discuz! 将这一功能引入论坛系统,通过指定条件产生论坛动态消息,促进会员之间互动的产生。各项目的值应该根据当前论坛运营状况仔细斟酌而定。 例如:论坛日发帖量在100以上的,设置【主题回复数达到一定值发送动态】时可以如下设置 “10, 30, 80” ,这样当主题被回复了10次,30次,80次的时候都在论坛动态页产生一个动态消息。日发帖量在1000以上的论坛,就可以设置“30,100,200”。总结起来论坛小,活跃用户少,日发帖量不大,那么应该将各项目的阈值调低,这样让论坛动态更容易产生。相反,论坛大,活跃用户多,日发帖量很大,那么应该将各项目的阈值调高,避免论坛动态泛滥,影响用户体验。
[img]http://faq.comsenz.com/attachments/2009/10/26_200910091741481w8rg.thumb.jpg[/img]
论坛首页支持两种显示风格了:一种是传统的论坛版块列表的形式,这种形式历史悠久,被广大用户所熟悉,版块就像一本书的目录,用户可以根据版块来快速的确定自己感兴趣的话题在什么地方;第二种论坛首页形式就是7.2新推出的论坛动态,在这种形式下,论坛内的各种事件动态信息都汇集到论坛动态列表中,比如某人发的主题回复数超过1000了,某某的帖子被版主评为精华了等等。这种以事件为核心,动态信息为表现的形式,可以大大加强论坛用户之间的互动性,信息流动起来了,互动性就更容易产生,更能突出一个真实“社区”的感觉。
在这里特别提醒一下,刚开始运营不久的论坛,往往内容不够充实,人气不旺,也就产生不了高质量的论坛动态信息,因此短期内不宜设置首页风格为:论坛实时动态。
[img]http://faq.comsenz.com/attachments/2009/10/26_200910091742581Wdb4.png[/img][p=30, 2, left]
[b][size=4]二、基于主题热度和评价的主题推荐方式[/size][/b] [/p][p=30, 2, left]
[b]设计目标:[/b] [/p]
以前版本中的版主推荐或者被广泛采用的首页四格插件等功能都是为了达到同一个目的:让论坛的各种“热闹”或者精华信息被更多的用户更加容易的看到,促使他们参与其中。 但以前的方式由于对论坛的帖子没有一个统一标准的评价系统,因此不管采用那种信息提取方式,都会不够精准。因此 Discuz! 引入了主题热度的概念,让论坛用户广泛的参与到论坛内容的评价中来。让论坛热闹和精华信息的提取和展现变得更加准确,更加方便。
[b]设置指导:[/b]
【[url=http://faq.comsenz.com/viewnews-851]主题热度[/url]】会影响主题在主题列表显示时标题后图标的显示(如图),主题的热度根据回复数、评价值等参量根据一定算法计算得到。当热度值达到设定的显示级别如50,100,200 时,在主题列表中主题的标题后会显示对应级别的图标,来表示该主题的热门程度。站长应该根据站点当前运营情况来设定这些值,一般推荐的方案是保证主题列表中,热门主题和普通主题的比例在 1:7 左右。
[img]http://faq.comsenz.com/attachments/2009/10/26_200910091749011stPk.png[/img]
【[url=http://faq.comsenz.com/viewnews-851]主题评价[/url]】功能通过收集用户对主题的评价,来计算评价图标的显示级别,当达到设定的级别阈值时,在主题列表中显示主题标题后的对应级别的推荐图标。用户可以再后台设置主题评价的词语 例如加分操作和减分操作分别设置为“顶”“踩”或者“支持”“鄙视”等,发挥想象力,让用户更有兴趣参与到对主题的评价中来。
[img]http://faq.comsenz.com/attachments/2009/10/26_20091009174901250VL.png[/img]
【[url=http://faq.comsenz.com/viewnews-854]论坛热点[/url]】是根据主题热度来选取一部分热点主题展示在首页,由于选取的主题热度高,参与性强,加之显示在首页所以能好的促进论坛气氛的活跃。但是新站开启论坛热点的效果不会很好,因为新站主题少,人气少,提取出来的热点准确性就会大打折扣。等有一定人气基础,出来的热点才是真正的热点。一般推荐的方式是:左边放置图片展示,右边设置 10 至 14 个推荐主题。
[url=http://faq.comsenz.com/attachments/2009/10/26_200910091744121xhVg.png][img=644,186]http://faq.comsenz.com/attachments/2009/10/26_200910091744121xhVg.png[/img][/url]
【[url=http://faq.comsenz.com/viewnews-852]推荐主题[/url]】功能通过自动或手动方式从论坛数据中提取一些主题作为系统推荐的主题,这些主题一般为论坛里内容精彩、用户参与度高的话题。推荐主题的数量应设置合理,太多则让人眼花缭乱,太少则不美观。数据缓存时间也要设置得当,该值设置太大则数据长时间不更新,造成吸引力下降,设置太小频繁更新缓存又会增加服务器负担。根据设置推荐的主题可以显示在主题列表页,也可以显示在主题查看页(如图)。一般来讲和版块话题主旨符合程度高,帖子内容普适程度高的主题适合显示在主题列表页,帖子内容新颖,话题性强则更适合显示到主题查看页。
[img]http://faq.comsenz.com/attachments/2009/10/26_200910091759431vD2J.png[/img]
[url=http://faq.comsenz.com/attachments/2009/10/26_200910091759432UPgA.png][img=644,459]http://faq.comsenz.com/attachments/2009/10/26_200910091759432UPgA.png[/img][/url]
[p=30, 2, left]
[b][size=4]三、服务老用户不忘照顾新用户[/size][/b][/p]
[b]设计目标:[/b]
随着互联网的发展,论坛用户群体越来越广泛,很多人没有多少上网或电脑使用经验,他们成为论坛的用户后往往不知道自己能在论坛做些什么,通过新手任务功能,在向导的指引下,让这些用户很快的掌握论坛基本操作,不再对论坛感到陌生,尽快的参与到论坛的各种活动当中。
[b]设置指导:[/b]
建议站长在进行【[url=http://faq.comsenz.com/viewnews-853]新手任务[/url]】的设置时认真考虑任务奖励类型和具体的奖励量值。一般来讲,同时使用多种奖励形式(论坛已设定开启【道具】和【勋章】功能)更能激励新手们把所有新手任务做完。对积分的设置也要拉开层次,不要所有任务的奖励都奖励相同的积分量值。站长也可以修改任务描述,用更友好、更具吸引力的语言来描述任务,提高用户对完成任务的兴趣。下面是一些建议:
任务一的任务名可以写“学习回帖” ,奖励10个金钱 。任务二的任务名写成“开始我的第一次”,奖励一种道具。 任务三的任务名写成“与众不同”,奖励一枚勋章。
站长应该根据自己站点用户群特征来决定开启哪些新手任务项目,例如用户群主要为上网时间不长,对发帖回帖操作尚不熟悉的用户,那么就开启学习回帖,发表主题等比较初级的任务。如果用户群为已经有一定上网经验,对论坛常规的发帖回帖操作已经比较熟悉,那么就可以只开启修改个人资料,修改头像等比较高级的任务。
[color=#ff0000]备注: 文中的功能名以"【功能名称】" 形式标注 ,例如:【[/color][url=http://faq.comsenz.com/viewnews-853][color=#ff0000]新手任务[/color][/url][color=#ff0000]】 点击功能名称的链接,可以查看该功能的使用说明。[/color]
EOD;
$testdatacontent[1]['subject'] = 'Discuz! 7.2 新功能--站长推荐 ';
$testdatacontent[1]['message'] = <<<EOD
Discuz! 7.2 新增站长推荐功能,管理员可以设置一部分帖子为“站长推荐”,被设置为“站长推荐”的这些帖子就会在帖子内容页面右下角以浮动窗口的形式展示给浏览者,如果有多个主题被设置为“站长推荐”则随机轮流显示。
站长推荐可以理解为一个全局主题推荐,管理员可以将一些版块重要信息,比如通知、公告等设置为站长推荐,以保证更多的用户可以浏览到,或者还可以在此加入广告帖进行赢利,一个功能多种用法,各位站长可以根据自身情况设置和使用。
“站长推荐”在后台的设置位置为:Discuz! 7.2 后台 => 广告 => 站长推荐
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722051W2zR.gif[/img][p=30, 2, left]一、设置站长推荐[/p]
可以在此设置站长推荐区域标题,默认为“站长推荐”,您可以设置为您希望的标题:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722052Ji2X.gif[/img][p=30, 2, left]二、添加站长推荐[/p]
添加热点话题有三种方式:手动添加、添加主题、自动添加。[p=30, 2, left]1、手动添加[/p]
上图界面中点击“添加”,在弹出的下拉框中我们点击“手动添加”:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722053xvtI.gif[/img]
输入“推荐链接地址”、“推荐标题”、“推荐内容”和“附加图片”,然后“提交”即可手动添加一条站长推荐。
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722054Fae6.gif[/img]
上图界面中点击“提交”则该帖子成功被设置为“站长推荐”:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722055tNdh.gif[/img]
返回前台进入帖子内容页在右下角就可以看到我们刚才设置的该站长推荐:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722056CKUJ.gif[/img]
[b]2、添加主题[/b]
后台“站长推荐”点击“添加”,在弹出的下拉框中我们点击“添加主题”:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722057gPEE.gif[/img]
输入帖子地址后点击“获取帖子内容”则可以获取到该帖子的标题和帖子内容摘要:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722058BY2H.gif[/img]
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271722059Fwkt.gif[/img]
提交即可成功添加该主题为站长推荐信息。
[p=30, 2, left]3、自动添加[/p]
后台“站长推荐”点击“添加”,在弹出的下拉框中我们点击“自动添加”:
[img]http://faq.comsenz.com/attachments/2009/09/9_2009092717220510PAXX.gif[/img]
系统将自动推荐 10 个主题作为站长推荐候选,自动推荐的原则的获取站点所有版主的推荐主题,如果版主推荐主题不足 10 个则有几个自动推荐几个。
[img]http://faq.comsenz.com/attachments/2009/09/9_200909081525058gOVO.gif[/img]
管理员可以在此选择哪些推荐主题设置为站长推荐,选中推荐主题前面的多选框,“提交”即可。[p=30, 2, left]二、管理站长推荐[/p]
所有被设置为站长推荐和曾经设置为站长推荐的主题都会在此显示,管理员可以在此设置一些主题为站长推荐也可以取消其站长推荐的身份,还可以编辑这些主题,或者将这些主题删除出站长推荐。
[img]http://faq.comsenz.com/attachments/2009/09/9_2009092717220511ZOHp.gif[/img][p=30, 2, left]三、前台显示[/p]
我们来看看站长推荐在前台的显示效果,打开随便一篇帖子内容页,在右下角我们可以看到一个浮动窗口,这个就是站长推荐的显示界面:
[img]http://faq.comsenz.com/attachments/2009/09/9_2009092717220512QfsZ.gif[/img]
在该浮动窗口中点击帖子标题、内容摘要,或者右下角的“查看”链接都可以进入该帖子内容页查看详情。
看到这里相信大家已经清楚了该功能的实际用途和使用方法,那么,赶快体验吧!
EOD;
$testdatacontent[2]['subject'] = '论坛热点:在第一眼就留住用户 ';
$testdatacontent[2]['message'] = <<<EOD
让社区论坛在第一眼就留住用户,需要及时的把热点事件传递给用户,在第一时间把最受会员欢迎的主题资源展示出来,才能够最大限度的提高论坛的互动性,增加社区的黏着度。
Discuz! 7.2新增的论坛热点功能,能够很好的满足主题聚焦的应用需求。该功能可以将社区中最抢眼的主题合显示到论坛首页的头部,方便用户快速在论坛中浏览热点信息。论坛热点的设置和 Discuz! 的其它功能一操作非常简单,只需要以管理员身份到后台简单开启即可。
我们截图来看一下开启后的效果:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909110951061nyw4.gif[/img]
下面我们来说一下后台的开启方法:
进入 Discuz! 7.2 后台 => 界面 => 界面设置 => 首页设置:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271530271hxkL.gif[/img]
上图界面我们可以看到“论坛热点”开启选择,我们选择“是”来设置各项显示条件:
[img]http://faq.comsenz.com/attachments/2009/10/9_2009101616230316I1M.gif[/img]
论坛热点:是/否,设置是否显示全论坛的论坛热点主题。
论坛热点显示数量:设置论坛热点条目数,默认值 10 条。
论坛热点更新周期(秒):设置论坛热点在多长时间更新一次,默认值 900 。
论坛热点图片大小:设置首页论坛热点图片的大小,默认值 100*70 。
论坛热点内容截取文字长度:设置论坛热点内容的文字长度,默认值 200 个字。
如此设置后的效果如图开篇第一个图片所示,需要注意的是,这里设置的“论坛热点显示数量”为 10 仅指右侧不包含图片的热点主题,不包含左侧的带图片主题。
论坛热点的显示结构为:
左侧一列调用带图片的主题热度最高一条主题及其图片缩略图、主题内容摘要及其发布时间和作者;
右侧调用主题热度最高的 10 条不带图片的主题,按照主题热度从高到低排序,前面 2 条显示主题标题、作者及其内容摘要,后面的 8 条之显示主题标题。
到此论坛热点的开启和效果展示为大家讲解完毕了,怎么样,这个功能是不是很吸引你,还等什么,赶快安装最新版 Discuz! 7.2 或者将您的论坛升级到 Discuz! 7.2 来体验吧!
EOD;
$testdatacontent[3]['subject'] = 'Discuz! 7.2新特性--主题热度/评价';
$testdatacontent[3]['message'] = <<<EOD
Discuz!7.2 在对主题的操作上添加了新特性,即主题热度和主题评价。
主题热度,用户可以对主题进行回复、评价等操作,这些操作都会增加主题热度,当主题达到一定得热度时,会显示热度图标;
主题评价,用户可以对某主题评价,以表达自己的观点态度;当主题所得的评价指数达到后台设置的指数级别时,会显示评价图标;
这两项新特性都大大提高了用户浏览的效率,更是增加了热度高或评价高主题的浏览次数。
下面请看详细介绍:[p=30, 2, left][b]一、主题热度[/b][/p]
主题热度是 Discuz!7.2 新增的特性,站长可以在后台设置主题热度值及热度增加权重值。当某个主题达到站点设置的热度时,会在主题列表页标题右侧显示热度图标,大大提高热度主题的浏览次数。
1、后台设置
论坛后台 => 全局 => 论坛功能 => 主题热度,如下图:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909271400321aEXX.gif[/img]
回复增量权重:每次回复主题时,主题热度的增量,默认值为 5 。
评价增量权重:每次对主题进行评价操作时,主题热度的增量,默认为 3 。
热门主题显示级别:设置主题列表页主题热度的级别对应热度值。每个级别都有相应的热度图标,共有三个级别。级别热度值间用逗号分隔。留空为不显示热度图标。
设置完毕后,点击“提交”按钮完成设置。
设置完成后,到前台主题列表页刷新,达到热度值的主题前会显示主题热度图标:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909081603201rueN.gif][img=644,171]http://faq.comsenz.com/attachments/2009/09/15_200909081603201rueN.gif[/img][/url]
2、根据主题热度来排序浏览
用户可以根据主题热度来对主题列表排序浏览,打开主题列表页:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081603202zliR.gif[/img][p=30, 2, left][b]二、主题评价[/b][/p]
主题评价是 Discuz!7.2 新增的特性,后台有是否开启该功能的开关,并且站长可以在后台设置评价图标显示级别。
1、后台设置
论坛后台 => 全局 => 论坛功能 => 主题评价,如下图:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909271400351aw5h.gif[/img]
[img]http://faq.comsenz.com/attachments/2009/09/15_200909271400371JFAt.gif[/img]
[img]http://faq.comsenz.com/attachments/2009/09/15_200909271400401hrE4.gif[/img]
启用主题评价:选择“是”,打开主题评价功能。
加分操作文字:设置评价加分项的表达文字,建议设置的简单明了,而且不宜过长;默认每评价一次加 1 个评价积分。
减分操作文字:设置评价减分项的表达文字,建议设置的简单明了,而且不宜过长;默认每评价一次减 1 个评价积分。
默认显示数值:设置在帖子内容页默认显示的评价结果数值,用户点击可切换。
每 24 小时评价主体次数:设置用户每 24 小时可以评价多少篇主题,0 或留空为不限制。
是否允许评价自己的帖子:设置是否允许评价自己的主题,评价自己的主题无积分奖励。
评价图标显示级别:设置主题列表页评价图标每一级别对应的评价指数。建议为 3 个级别,每个级别的评价指数请用逗号分隔。
设置好,点击“提交”完成设置。
2、前台评价主题
在前台浏览主题内容时,您会看到如下图:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081605032M3vn.gif[/img]
当主题的评价指数达到后台设置的指数级别时,在主题列表页将会显示对应级别的评价图标:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909081605033D2LF.gif][img=644,201]http://faq.comsenz.com/attachments/2009/09/15_200909081605033D2LF.gif[/img][/url]
评价图标更直观地告诉该用户主题的评价,因此会大大增加评价高主题的浏览次数。
至此,主题热度和主题评价已经说明完毕,赶紧去体验下吧!
EOD;
$testdatacontent[4]['subject'] = 'Discuz! 7.2 新特性--推荐主题';
$testdatacontent[4]['message'] = <<<EOD
D
Discuz!7.2 版本完善了推荐主题功能:推荐主题时可以修改主题标题、并有选择性地推荐主题中的图片等,用户体验有了很大的提高。
下面请看详细介绍:[p=30, 2, left][b]一、后台开启推荐主题的权限[/b][/p]
论坛后台 => 版块 => 版块管理 => 编辑,即可看到下图所示:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081607261Sfhr.gif[/img]
选择推荐主题的方式及其他设置:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081607391e0B1.gif[/img]
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081607392ZKwm.gif[/img]
设置好后,点击“提交”完成推荐主题的后台设置。[p=30, 2, left][b]二、前台推荐主题[/b][/p]
有推荐权限的用户在前台可以推荐某个主题,如图:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909081607393hITH.gif][img=644,131]http://faq.comsenz.com/attachments/2009/09/15_200909081607393hITH.gif[/img][/url]
推荐主题设置:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081607394uMLw.gif[/img]
被推荐的主题,可以在帖子列表页顶部看到:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081607395MQ0W.gif[/img]
到此为止,推荐主题功能已经讲解完毕,赶紧去体验下吧!
EOD;
$testdatacontent[5]['subject'] = 'Discuz! 7.2 新特性--新手任务';
$testdatacontent[5]['message'] = <<<EOD
Discuz!7.2 在论坛任务方面有所改进,系统有针对性地自带了 7 个新手任务,无需站长添加。新注册用户将自动申请该任务,此功能可用于防止恶意注册及恶意灌水,或引导新手快速熟悉论坛。
下面请看详细介绍:[p=30, 2, left][b]一、后台启用[/b][/p]
系统自带的 7 个新手任务,在后台都有开关,您可以启用或关闭任务。
论坛后台 => 扩展 => 论坛任务,如下图:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909081610241JZg0.gif][img=644,436]http://faq.comsenz.com/attachments/2009/09/15_200909081610241JZg0.gif[/img][/url]
是否开启论坛任务:选择“是”开启论坛任务;如果选择“否”,那么下面的设置都是不起作用的。
可用:勾选表示该任务可用,用户注册后会自动申请该任务。如果不勾选,表示不可用,用户注册后,不会看到该任务。[p=30, 2, left][b]二、编辑新手任务[/b][/p]
您可以点击任务后的“编辑”来编辑该任务的一些信息,如图:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081610341n8AY.gif[/img]
编辑好点击“提交”完成编辑。[p=30, 2, left][b]三、新手前台执行任务[/b][/p]
用户注册后,登录前台,即可看到新手任务的提示,如图:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909081610343KZDL.gif[/img]
新手每完成一个任务,就会得到相应的奖励。
至此,新手任务已经讲解完毕,赶紧去体验下吧!
EOD;
$testdatacontent[6]['subject'] = '主题关注:让论坛帖子动起来';
$testdatacontent[6]['message'] = <<<EOD
用户在社区论坛中的核心应用是有效信息的获取。当用户在“逛”论坛的时候,发现了一个很感兴趣的话题往往需要一定的时间成本。如果用户翻到一个帖子,主题内容和里面的回复都很有意思,这时候用户肯定还想即时了解到帖子的发展情况。有了“主题关注”功能,可以很方便的实现主题信息的互动,只需要用户把这个值得关注的主题标记为关注状态,其他会员回复该主题时,用户就可以收到一个交互性的通知,只需要鼠标轻轻一点,就会看到所关注的主题中有哪些“志同道合”者的回复了。让论坛帖子内容互动起来,是不是会有不一样感觉呢?
“主题关注”不仅是社区论坛功能细节上的实现,更是在尊重网络社区用户阅读习惯的基础之上的设计理念创新。用户盲无目的的去浏览帖子内容很容易形成阅读疲劳,“主题关注”可以轻松的把用户关心的主题信息主动的展示给用户,让用户的有效信息获取更加精准高效。
下面介绍一下会员如何使用主题关注功能:[p=30, 2, left][b]一、关注主题[/b][/p]
要将一个主题设为被关注状态有以下三种方法:
1、发布新主题时
在发表主题的时候,点击“发表话题”按钮右侧的“更多选项”,然后在“发帖选项”里选中“关注主题”的复选框
[img]http://faq.comsenz.com/attachments/2009/10/42_2009102816100010TeM.gif[/img]
[img]http://faq.comsenz.com/attachments/2009/10/42_200910281610002EHJ8.gif[/img]
2、看贴时
点击主题内容下方的 “收藏”图标,在弹出的窗口中点击“关注此主题的最新回复”
[img]http://faq.comsenz.com/attachments/2009/10/42_200910281610003BVqH.gif[/img]
[p=30, 2, left][b]二、查看被关注的主题[/b][/p]
1、关注信息提示
当您所关注的主题有新的回复时,您将在页面顶部看到如下提示,您可以通过点击通知里的关注提示查看被关注主题的最新回复
[img]http://faq.comsenz.com/attachments/2009/10/42_200910281613191ND3i.gif[/img]
2、在“个人中心”的“我的关注”中查看关注列表。
在关注列表中,您可以选择查看正在关注的“有新回复的主题”或者“全部主题”
[img]http://faq.comsenz.com/attachments/2009/10/42_200910281615301xugz.gif[/img]
[img]http://faq.comsenz.com/attachments/2009/10/42_200910281618341SGvP.gif[/img][p=30, 2, left][b]三、取消关注主题[/b][/p]
1、在编辑帖子或回复帖子时,在高级模式下勾选“取消对此主题新回复的关注”复选框,这样此主题将不再处于被关注状态
[img]http://faq.comsenz.com/attachments/2009/10/42_200910281629011crqU.gif[/img]
2、在二(2)的关注列表中选择需要取消关注的主题并点击“提交”按钮,如此操作将使得选中主题不再处于被关注状态
[img]http://faq.comsenz.com/attachments/2009/10/42_200910281632171Yb4d.gif[/img]
此外,站点的管理员除了可以和普通会员一样使用主题关注功能外,还可以在系统设置中对会员的主题关注列表容量进行控制,具体操作如下:
系统设置 => 全局 => 用户权限 => 主题关注列表容量
[img]http://faq.comsenz.com/attachments/2009/10/42_200910281635481Z6XD.gif[/img]
EOD;
$testdatacontent[7]['subject'] = 'Discuz! 7.2 新特性--论坛动态';
$testdatacontent[7]['message'] = <<<EOD
Discuz! 7.2 增加了论坛动态实时浏览功能,用户除了浏览原来的版块列表界面外还可以切换到“论坛动态”里面查看论坛实时动态,此功能类似于 SNS 的动态查看功能,可以集中查看到所有好友的动态信息,而无需进入好友个人主页查看。
[img]http://faq.comsenz.com/attachments/2009/10/9_2009100915323019jA5.gif[/img]
站长可以在 Discuz! 7.2 后台设置论坛首页的默认显示风格,进入 Discuz! 7.2 系统设置 => 界面 => 界面设置 => 首页设置 => 首页显示风格:
[img]http://faq.comsenz.com/attachments/2009/10/9_200910091532302Z0N9.gif[/img]
经典版块列表:即论坛版块列表展示模式,也就是老版本的 Discuz! 的展示效果。
论坛实时动态:即 Discuz! 7.2 新增的动态实时查看功能,用户可以在此集中查看到所有好友的动态信息。
如果站长希望站点所有用户登录 Discuz! 后看到是其好友的动态信息,那么在这里就可以选择首页的默认显示风格为“论坛实时动态”,效果如下图所示:
[img]http://faq.comsenz.com/attachments/2009/10/9_200910091532303yDV1.gif[/img]
怎么样,是不是很方便?赶快安装全新的 Discuz! 7.2 或者升级您的论坛体验一下吧!
EOD;
$testdatacontent[8]['subject'] = 'Discuz! 7.2 新特性--提醒系统';
$testdatacontent[8]['message'] = <<<EOD
Discuz! 7.2 新增了提醒系统,提醒内容包括“全部”、“系统信息”、“好友信息”、“帖子信息”。上述这些信息主要有新信息则就会在导航的“提醒”那里出现新信息提示,如下图所示:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909291118351ebXv.gif[/img]
鼠标放到“提醒”上就可以看到收到的信息内容。
点击“提醒”即可进入提醒系统界面:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909291118352Km5p.gif[/img]
提醒系统首页是全部信息展示,分类浏览可以点击其他的信息类别进行浏览。
系统信息:包括管理操作提醒、道具赠送提醒、任务提醒、积分提醒等。
[img]http://faq.comsenz.com/attachments/2009/09/9_200909291118353g4uE.gif[/img]
好友信息:添加好友的提醒。
[img]http://faq.comsenz.com/attachments/2009/09/9_200909291118354wCOX.gif[/img]
帖子信息:主题关注相关提醒。
[img]http://faq.comsenz.com/attachments/2009/09/9_200909291118355XZp5.gif[/img]
Discuz! 7.2 提醒系统更加细化了各个操作带来的信息提醒,一目了然的分类,使用和浏览信息更加清晰明确。
EOD;
$testdatacontent[9]['subject'] = '帖子编辑器:轻轻松松发帖';
$testdatacontent[9]['message'] = <<<EOD
帖子主题的展示是社区论坛的核心功能。会员在发表或回复帖子时,用到的就多就是编辑器功能,很多站长苦恼于会员发帖时排版很乱而无法解决。一款专业编辑器不仅需发有人性化的界面,更需要能够帮助用户更好的对帖子内容进行编辑,让社区论坛主题的排版更加专业和多样化。
分析会员的使用习惯,Discuz! 7.2 的编辑器有了很大的改进,界面更友好,突出显示常用操作图标,并且新增了很多功能。
新增删除线和分割线标签,让您的帖子格式更加丰富多彩;插入图片可以设置宽高;音乐播放支持 mp3 wma ra rm ram midwav 等多种格式;视频播放支持 wmv rm rmvb flv swf avi asf mpg mpeg mov等多种格式;视频可以自动分析优酷、土豆、ku6三大主流视频网站的视频网址;附件上传、修改、删除等操作整合到编辑器中;附件上传机制改进,同时上传多个附件时如果有上传失败的,不影响已经成功上传的。
Discuz! 7.2 前台 => 发帖,即可进入全新的 Discuz! 7.2 编辑器:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271441261E3fW.gif[/img]
从上图界面可以看出,Discuz! 7.2 的编辑器有了很大的改观,突出显示目前社区比较常用的表情、图片、音乐、视频、Flash、代码、引用,界面更加友好。
下面介绍几个新增功能:[p=30, 2, left][b]1、新增删除线和分割线标签[/b][/p]
新增删除线和分割线标签,让您的帖子格式更加丰富多彩。
如下图所示我们为“节省天光”几个字添加“删除线”:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909071737197EwOi.gif[/img]
设置后的效果如下图所示:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909071737198xEI5.gif[/img]
同理添加分割线:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909071737199TrYW.gif[/img]
添加后的效果:
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371910v6WE.gif[/img][p=30, 2, left][b]2、插入图片可以设置宽高[/b][/p]
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371911dvfs.gif[/img][p=30, 2, left][b]3、音乐播放支持 mp3 wma ra rm ram mid wav 等多种格式[/b][/p]
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371912wMUt.gif[/img]
插入的音乐代码类似:
[audio]http://vfile.home.news.cn/music/public/vd06/200908/18/50/MUfs06200908181354375150fd99.mp3[/audio]
播放效果:
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371913aJ2z.gif[/img][p=30, 2, left][b]4、视频功能更强大[/b][/p]
视频播放支持 wmv rm rmvb flv swf avi asf mpg mpeg mov 等多种格式
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371914Ad5B.gif[/img]
插入的视频代码类似:
[media=wmv,400,300]http://w4180.s11.mydiscuz.com/Alizee_lais la bonita.wmv[/media]
发布后的效果:
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371915G371.gif[/img]
视频还可以自动分析优酷、土豆、ku6 三大主流视频网站的视频网址:
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371916vS5U.gif[/img]
插入的视频代码类似:
[media=swf,400,300]http://player.youku.com/player.php/sid/XMTA3OTE4NjIw/v.swf[/media]
发布后的效果:
[img]http://faq.comsenz.com/attachments/2009/09/9_20090907173719177BxG.gif[/img][p=30, 2, left][b]5、编辑器里上传附件[/b][/p]
附件上传、修改、删除等操作整合到编辑器中;附件上传机制改进,同时上传多个附件时如果有上传失败的,不影响已经成功上传的。
批量上传:
[img]http://faq.comsenz.com/attachments/2009/09/9_20090907173719182BAP.gif[/img]
普通上传:
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371919zovp.gif[/img]
附件列表:
[img]http://faq.comsenz.com/attachments/2009/09/9_2009090717371920TWNz.gif[/img]
到此 Discuz! 7.2 最新编辑器介绍完了,怎么样?是不是超酷炫!而且使用起来更加得心应手,那么还等什么,赶快体验吧!
论坛运营秘籍 - Discuz!7.2 新功能的妙用:[url=http://faq.comsenz.com/viewnews-869]http://faq.comsenz.com/viewnews-869[/url]
[p=30, 2, left][img]http://faq.comsenz.com/attachments/2009/09/9_200909071737196ENcW.gif[/img][/p]
EOD;
$testdatacontent[10]['subject'] = '转发视频:更易更强大';
$testdatacontent[10]['message'] = <<<EOD
Discuz! 7.2 在视频播放方面有了很大改进,不但支持播放 wmv rm rmvb flv swf avi asf mpgmpeg mov 等多种格式,还可以自动分析优酷、土豆、ku6三大主流视频网站的视频网址,而不需要再去找专门的转发引用地址,使得转发视频变得更容易更强大,下面为大家举例演示这三大主流视频网站的视频转发功能。
Discuz! 7.2 前台 => 发帖,即可进入全新 Discuz! 7.2 编辑器:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909271441261E3fW.gif[/img]
下面我们从优酷、土豆、ku6 三大主流视频网站分别找一个视频地址:
优酷:[url=http://v.youku.com/v_show/id_XOTMwODQ2NjQ=.html]http://v.youku.com/v_show/id_XOTMwODQ2NjQ=.html[/url]
土豆:[url=http://www.tudou.com/programs/view/4NgBn7J39bg/]http://www.tudou.com/programs/view/4NgBn7J39bg/[/url]
ku6 :[url=http://v.ku6.com/show/VrLuttrXQb1CIbkC.html]http://v.ku6.com/show/VrLuttrXQb1CIbkC.html[/url]
将上面三个地址分别插入视频,如图所示:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909111355583f0Ft.gif[/img]
插入后的代码如下图所示:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909111355584BDQP.gif[/img]
提交发布后的效果如下图所示:
[img]http://faq.comsenz.com/attachments/2009/09/9_200909111355585XszF.gif[/img]
从上面的演示可以看出来,Discuz! 7.2 发布优酷、土豆、ku6 三大主流视频网站的视频变得非常容易,无需再费力找论坛引用地址,直接输入视频的网址系统就会自动解析获取最终的播放地址,还等什么,快快来亲身体验一把吧!
EOD;
$testdatacontent[11]['subject'] = 'Discuz!7.2 新特性--Manyou应用的开启';
$testdatacontent[11]['message'] = <<<EOD
Discuz!7.2 较之前的版本,在后台添加了 Manyou 应用的开关。做为插件的形式,站长可以在后台开启或关闭该功能。开启该功能后,会员在论坛也可以看到 Manyou 应用的动态信息及大家都在玩什么应用游戏,同时还可以参与进来。
下面请看详细介绍:
[b]一、安装 Manyou 插件并开启[/b]
论坛后台 => 插件 => 论坛插件,如图:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909271430221otXN.gif][img=644,233]http://faq.comsenz.com/attachments/2009/09/15_200909271430221otXN.gif[/img][/url]
安装后,请启用该插件,如图:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909271432211ofuE.gif[/img][p=30, 2, left][b]二、开启 Manyou 应用[/b][/p]
论坛后台 => 插件 => Manyou:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909101753151btyX.gif][img=644,440]http://faq.comsenz.com/attachments/2009/09/15_200909101753151btyX.gif[/img][/url]
点击“设置”:
[url=http://faq.comsenz.com/attachments/2009/09/15_2009091017533510KUl.gif][img]http://faq.comsenz.com/attachments/2009/09/15_2009091017533510KUl.gif[/img][/url]
点击“MYOP 应用管理”:
[url=http://faq.comsenz.com/attachments/2009/09/15_20090910175335228pj.gif][img=644,228]http://faq.comsenz.com/attachments/2009/09/15_20090910175335228pj.gif[/img][/url]
点击“启用服务”:
[img]http://faq.comsenz.com/attachments/2009/09/15_200909101753353h7yn.gif[/img]
为站点开启具体的应用或游戏:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909101753354uW1y.gif][img=644,474]http://faq.comsenz.com/attachments/2009/09/15_200909101753354uW1y.gif[/img][/url]
设为默认应用:无论用户是否添加此应用,默认应用都会显示在所有用户的开始菜单里面。
关闭应用:用户不能添加处于关闭状态的应用,应用目录中也不会显示处于关闭状态的应用。
设为推荐应用:被设置为推荐的应用将显示在您网站应用目录的推荐栏目下。
为使大家能在论坛首页看到推荐的应用并方便地参与进来,请设置首页应用推荐条目数:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909101753355rwqi.gif][img]http://faq.comsenz.com/attachments/2009/09/15_200909101753355rwqi.gif[/img][/url][p=30, 2, left][b]三、前台查看[/b][/p]
1、前台查看 Manyou 动态
打开论坛首页,可以看到下图所示:
[url=http://faq.comsenz.com/attachments/2009/09/15_2009091017533561U7q.gif][img=644,244]http://faq.comsenz.com/attachments/2009/09/15_2009091017533561U7q.gif[/img][/url]
点击“应用动态”,即可查看 Manyou 应用的相关动态:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909101753357KO05.gif][img]http://faq.comsenz.com/attachments/2009/09/15_200909101753357KO05.gif[/img][/url]
点击“论坛版块”,可以在论坛首页下方看到推荐的 Manyou 应用:
[url=http://faq.comsenz.com/attachments/2009/09/15_200909101753358q9hK.gif][img=644,317]http://faq.comsenz.com/attachments/2009/09/15_200909101753358q9hK.gif[/img][/url]
到此,Manyou 应用功能已经讲解完毕,赶紧去体验一下吧!
EOD;
$testdatacontent[12]['subject'] = '7.2新增功能及功能强化';
$testdatacontent[12]['message'] = <<<EOD
[p=30, 2, left][b]功能新增:[/b][/p]
[p=16, 0, left]=================================================================[/p]
[p=16, 0, left]活动导出[/p]
[p=16, 0, left]增加附件的动态链接(attach://aid.ext),便于各方面引用[/p]
[p=16, 0, left]主题鉴定[/p]
[p=16, 0, left]抢楼贴[/p]
[p=16, 0, left]不受审核限制的 IP 列表[/p]
[p=16, 0, left]版块名称颜色[/p]
[p=16, 0, left]倒序帖--倒序显示回复[/p]
[p=16, 0, left]把主题在任意版块中置顶[/p]
[p=30, 2, left][b]增强优化:[/b][/p]
[p=16, 0, left]=================================================================[/p]
[p=16, 0, left]管理员不受任何搜索限制[/p]
[p=16, 0, left]权限表达式增强,增加注册 IP、注册时间、用户定制栏目的公式项目,可自定义权限表达式提示文字,增加可访问用户列表[/p]
[p=16, 0, left]数据调用增加主题评价的排序[/p]
[p=16, 0, left]管理中心用户管理增加马甲查找功能[/p]
[p=16, 0, left]回收站增加主题列表功能[/p]
[p=16, 0, left]买卖主题增加日志记录查看[/p]
[p=16, 0, left]个人资料页可自由查看他人的帖子[/p]
[p=16, 0, left]评分记录显示方式改进[/p]
[p=16, 0, left]主题列表分割带[/p]
[p=16, 0, left]分类信息加强[/p]
[p=16, 0, left]前台权限细化[/p]
[p=16, 0, left]搜索页高级搜索显示调整[/p]
[p=16, 0, left]添加新用户组时深度继承所选参照组权限[/p]
[p=16, 0, left]版主可以管理特殊用户组的用户[/p]
EOD;
?> | zyyhong | trunk/jiaju001/newbbs/bbs/install/lang.inc.php | PHP | asf20 | 105,849 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tag.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
define('CURSCRIPT', 'tag');
require_once './include/common.inc.php';
if(isset($action) && $action == 'relatetag') {
dheader('Expires: '.gmdate('D, d M Y H:i:s', $timestamp + 3600).' GMT');
!($rtid = intval($rtid)) && exit;
$extscript = '';
$threadtag = array();
$query = $db->query("SELECT tagname FROM {$tablepre}threadtags WHERE tid='$rtid'");
while($tags = $db->fetch_array($query)) {
$threadtag[] = $tags['tagname'];
}
if($threadtag) {
$requesttag = $threadtag[array_rand($threadtag)];
} else {
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_viewthread.php';
$requesttag = $db->result_first("SELECT tagname FROM {$tablepre}tags LIMIT ".rand(0, $_DCACHE['tags'][2] - 1).", 1", 0);
}
if(empty($requesttag)) {
exit;
}
include_once DISCUZ_ROOT.'./uc_client/client.php';
include_once template('relatetag');
$datalist = uc_tag_get($requesttag, $relatedtag['limit']);
$write = '';
if(is_array($datalist)) {
if(empty($datalist)) {
@include_once DISCUZ_ROOT.'./uc_client/data/cache/apps.php';
if(is_array($_CACHE['apps'])) {
foreach($_CACHE['apps'] as $app) {
if(array_key_exists($app['appid'], $relatedtag['limit'])) {
$datalist[$app['appid']] = array('data' => array(), 'type' => $app['type']);
}
}
}
}
$count = 0;
foreach($datalist as $appid => $data) {
$tagdata = '';
$template = $relatedtag['template'][$appid];
$datakey = $ext = array();
$type = $data['type'];
$data = $data['data'];
$i = 0;
foreach($data as $key => $value) {
if($appid == UC_APPID && $value['url'] == $boardurl.'viewthread.php?tid='.$rtid) {
continue;
}
if($type == 'SUPEV') {
$extmsg = '<img src="'.$value['thumb'].'" />';
} elseif(substr($type, 0, 6) == 'ECSHOP') {
$extmsg = '<img src="'.$value['image'].'" />';
} else {
$extmsg = '';
}
if(!$datakey) {
$tmp = array_keys($value);
foreach($tmp as $k => $v) {
$datakey[$k] = '{'.$v.'}';
}
}
if($extmsg) {
$ext[] = '<span id="app_'.$appid.'_'.$i.'"'.($i ? ' style="display: none"' : '').'>'.$extmsg.'</span>';
$tmp = '<li onmouseover="$(\'app_'.$appid.'_\' + last_app_'.$appid.').style.display = \'none\';last_app_'.$appid.' = \''.$i.'\';$(\'app_'.$appid.'_'.$i.'\').style.display = \'\'">'.$template['template'].'</li>';
} else {
$tmp = '<li>'.$template['template'].'</li>';
}
$tmp = str_replace($datakey, $value, $tmp);
$tagdata .= $tmp;
$i++;
}
$ext = implode('', $ext);
$tagdata = str_replace(array('\"', '\\\''), array('"', '\''), $tagdata);
if($data['type'] == 'SUPEV') {
$imgfield = 'thumb';
} elseif(substr($data['type'], 0, 6) == 'ECSHOP') {
$imgfield = 'image';
} else {
$imgfield = '';
}
$write .= tpl_relatetag($tagdata, $relatedtag['name'][$appid], $ext, $count);
if($ext) {
$extscript .= 'var last_app_'.$appid.' = \'0\';';
}
$count++;
if($count == 3) {
break;
}
}
}
$write = preg_replace("/\r\n|\n|\r/", '\n', tpl_relatetagwrap($write));
echo '$(\'relatedtags\').innerHTML = "'.addcslashes($write, '"').'";'.$extscript;
exit;
}
if(!$tagstatus) {
showmessage('undefined_action', NULL, 'HALTED');
}
if(!empty($name)) {
if(!preg_match('/^([\x7f-\xff_-]|\w|\s)+$/', $name) || strlen($name) > 20) {
showmessage('undefined_action', NULL, 'HALTED');
}
require_once DISCUZ_ROOT.'./include/misc.func.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_icons.php';
$tpp = $inajax ? 5 : $tpp;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$tag = $db->fetch_first("SELECT * FROM {$tablepre}tags WHERE tagname='$name'");
if($tag['closed']) {
showmessage('tag_closed');
}
$count = $db->result_first("SELECT count(*) FROM {$tablepre}threadtags WHERE tagname='$name'");
$query = $db->query("SELECT t.*,tt.tid as tagtid FROM {$tablepre}threadtags tt LEFT JOIN {$tablepre}threads t ON t.tid=tt.tid AND t.displayorder>='0' WHERE tt.tagname='$name' ORDER BY lastpost DESC LIMIT $start_limit, $tpp");
$cleantid = $threadlist = array();
while($tagthread = $db->fetch_array($query)) {
if($tagthread['tid']) {
$threadlist[] = procthread($tagthread);
} else {
$cleantid[] = $tagthread['tagtid'];
}
}
if($cleantid) {
$db->query("DELETE FROM {$tablepre}threadtags WHERE tagname='$name' AND tid IN (".implodeids($cleantid).")", 'UNBUFFERED');
$cleancount = count($cleantid);
if($count > $cleancount) {
$db->query("UPDATE {$tablepre}tags SET total=total-'$cleancount' WHERE tagname='$name'", 'UNBUFFERED');
} else {
$db->query("DELETE FROM {$tablepre}tags WHERE tagname='$name'", 'UNBUFFERED');
}
}
$tagnameenc = rawurlencode($name);
$navtitle = $name.' - ';
$multipage = multi($count, $tpp, $page, "tag.php?name=$tagnameenc");
include template('tag_threads');
} else {
$max = $db->result_first("SELECT total FROM {$tablepre}tags WHERE closed=0 ORDER BY total DESC LIMIT 1");
$viewthreadtags = intval($viewthreadtags);
$count = $db->result_first("SELECT count(*) FROM {$tablepre}tags WHERE closed=0");
$randlimit = mt_rand(0, $count <= $viewthreadtags ? 0 : $count - $viewthreadtags);
$query = $db->query("SELECT tagname,total FROM {$tablepre}tags WHERE closed=0 LIMIT $randlimit, $viewthreadtags");
$randtaglist = array();
while($tagrow = $db->fetch_array($query)) {
$tagrow['level'] = ceil($tagrow['total'] * 5 / $max);
$tagrow['tagnameenc'] = rawurlencode($tagrow['tagname']);
$randtaglist[] = $tagrow;
}
shuffle($randtaglist);
include template('tag');
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/tag.php | PHP | asf20 | 5,965 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: task.php 13890 2008-07-08 02:21:38Z liuqiang $
*/
define('CURSCRIPT', 'task');
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
if(!$taskon && $adminid != 1) {
showmessage('task_close');
}
$discuz_action = 180;
$id = intval($id);
if(empty($action)) {
$multipage = '';
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$tasklist = $endtaskids = $magics = $magicids = $medals = $medalids = $groups = $groupids = array();
switch($item) {
case 'doing':
$sql = "mt.status='0'";
break;
case 'done':
$sql = "mt.status='1'";
break;
case 'failed':
$sql = "mt.status='-1'";
break;
default:
$item = 'new';
$sql = "(mt.taskid IS NULL OR (ABS(mt.status)='1' AND t.period>0 AND $timestamp-mt.dateline>=t.period*3600))";
break;
}
$newbieadd = $item == 'done' || ($prompts['newbietask'] && $newbietaskid) ? '' : "AND t.newbietask!='1'";
if($prompts['newbietask'] && $newbietaskid) {
$taskrequired = $db->result_first("SELECT name FROM {$tablepre}tasks WHERE taskid='$newbietaskid'");
}
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}tasks t
LEFT JOIN {$tablepre}mytasks mt ON mt.taskid=t.taskid AND mt.uid='$discuz_uid'
WHERE $sql AND t.available='2' $newbieadd");
if($num) {
$updated = FALSE;
$multipage = multi($num, $tpp, $page, "task.php?item=$item");
$query = $db->query("SELECT t.*, mt.csc, mt.dateline FROM {$tablepre}tasks t
LEFT JOIN {$tablepre}mytasks mt ON mt.taskid=t.taskid AND mt.uid='$discuz_uid'
WHERE $sql AND t.available='2' $newbieadd ORDER BY displayorder, taskid DESC LIMIT $start_limit, $tpp");
while($task = $db->fetch_array($query)) {
if($task['reward'] == 'magic') {
$magicids[] = $task['prize'];
} elseif($task['reward'] == 'medal') {
$medalids[] = $task['prize'];
} elseif($task['reward'] == 'group') {
$groupids[] = $task['prize'];
}
if($task['available'] == '2' && ($task['starttime'] > $timestamp || ($task['endtime'] && $task['endtime'] <= $timestamp))) {
$endtaskids[] = $task['taskid'];
}
$csc = explode("\t", $task['csc']);
$task['csc'] = floatval($csc[0]);
$task['lastupdate'] = intval($csc[1]);
if(!$updated && $item == 'doing' && $task['csc'] < 100 && $timestamp - $task['lastupdate'] > 60) {
$updated = TRUE;
require_once DISCUZ_ROOT.'./include/tasks/'.$task['scriptname'].'.inc.php';
$task['applytime'] = $task['dateline'];
$result = task_csc($task);
if($result === TRUE) {
$task['csc'] = '100';
$db->query("UPDATE {$tablepre}mytasks SET csc='100' WHERE uid='$discuz_uid' AND taskid='$task[taskid]'");
} elseif($result === FALSE) {
$db->query("UPDATE {$tablepre}mytasks SET status='-1' WHERE uid='$discuz_uid' AND taskid='$task[taskid]'", 'UNBUFFERED');
} else {
$task['csc'] = floatval($result['csc']);
$db->query("UPDATE {$tablepre}mytasks SET csc='$task[csc]\t$timestamp' WHERE uid='$discuz_uid' AND taskid='$task[taskid]'", 'UNBUFFERED');
}
}
if(in_array($item, array('done', 'failed')) && $task['period']) {
$task['t'] = tasktimeformat($task['period'] * 3600 - $timestamp + $task['dateline']);
$task['allowapply'] = $timestamp - $task['dateline'] >= $task['period'] * 3600 ? 1 : 0;
}
if($task['newbietask'] == '1' && $task['taskid'] == $newbietaskid) {
$taskvars = array();
$query = $db->query("SELECT sort, name, description, variable, value FROM {$tablepre}taskvars WHERE taskid='$newbietaskid'");
while($taskvar = $db->fetch_array($query)) {
if(!$taskvar['variable'] || $taskvar['value']) {
if($taskvar['sort'] == 'complete') {
$taskvars['complete'][$taskvar['variable']] = $taskvar;
} elseif($taskvar['sort'] == 'setting') {
$taskvars['setting'][$taskvar['variable']] = $taskvar;
}
}
}
$task['entrance'] = $taskvars['setting']['entrance']['value'].'.php';
if(isset($taskvars['complete']['threadid'])) {
$task['entrance'] .= '?tid='.$taskvars['complete']['threadid']['value'];
} elseif(isset($taskvars['complete']['forumid'])) {
$task['entrance'] .= '?fid='.$taskvars['complete']['forumid']['value'];
} elseif(isset($taskvars['complete']['authorid'])) {
$task['entrance'] .= '?uid='.$taskvars['complete']['authorid']['value'];
}
}
$task['icon'] = $task['icon'] ? $task['icon'] : 'task.gif';
$task['icon'] = strtolower(substr($task['icon'], 0, 7)) == 'http://' ? $task['icon'] : "images/tasks/$task[icon]";
$task['dateline'] = $task['dateline'] ? dgmdate("$dateformat $timeformat", $task['dateline'] + $timeoffset * 3600) : '';
$tasklist[] = $task;
}
}
if($magicids) {
$query = $db->query("SELECT magicid, name FROM {$tablepre}magics WHERE magicid IN (".implodeids($magicids).")");
while($magic = $db->fetch_array($query)) {
$magics[$magic['magicid']] = $magic['name'];
}
}
if($medalids) {
$query = $db->query("SELECT medalid, name FROM {$tablepre}medals WHERE medalid IN (".implodeids($medalids).")");
while($medal = $db->fetch_array($query)) {
$medals[$medal['medalid']] = $medal['name'];
}
}
if($groupids) {
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE groupid IN (".implodeids($groupids).")");
while($group = $db->fetch_array($query)) {
$groups[$group['groupid']] = $group['grouptitle'];
}
}
if($item == 'doing' && ($prompts['task']['new'] != $num)) {
updateprompt('task', $discuz_uid, $num);
}
if($endtaskids) {
$db->query("UPDATE {$tablepre}tasks SET available='1' WHERE taskid IN (".implodeids($endtaskids).")", 'UNBUFFERED');
}
} elseif($action == 'view' && $id) {
if(!$task = $db->fetch_first("SELECT t.*, mt.status, mt.csc, mt.dateline, mt.dateline AS applytime FROM {$tablepre}tasks t LEFT JOIN {$tablepre}mytasks mt ON mt.uid='$discuz_uid' AND mt.taskid=t.taskid WHERE t.taskid='$id' AND t.available='2'")) {
showmessage('undefined_action');
}
if($task['reward'] == 'magic') {
$magic = $db->fetch_first("SELECT name, identifier FROM {$tablepre}magics WHERE magicid='$task[prize]'");
$magicname = $magic['name'];
$magic['identifier'] = strtolower($magic['identifier']);
} elseif($task['reward'] == 'medal') {
$medal = $db->fetch_first("SELECT name, image FROM {$tablepre}medals WHERE medalid='$task[prize]'");
$medalname = $medal['name'];
} elseif($task['reward'] == 'group') {
$grouptitle = $db->result_first("SELECT grouptitle FROM {$tablepre}usergroups WHERE groupid='$task[prize]'");
}
$task['icon'] = $task['icon'] ? $task['icon'] : 'task.gif';
$task['icon'] = strtolower(substr($task['icon'], 0, 7)) == 'http://' ? $task['icon'] : "images/tasks/$task[icon]";
$task['endtime'] = $task['endtime'] ? dgmdate("$dateformat $timeformat", $task['endtime'] + $timeoffset * 3600) : '';
$task['description'] = nl2br($task['description']);
$taskvars = array();
$query = $db->query("SELECT sort, name, description, variable, value FROM {$tablepre}taskvars WHERE taskid='$id'");
while($taskvar = $db->fetch_array($query)) {
if(!$taskvar['variable'] || $taskvar['value']) {
if(!$taskvar['variable']) {
$taskvar['value'] = $taskvar['description'];
} elseif($taskvar['variable'] == 'forumid') {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
} elseif($taskvar['variable'] == 'threadid') {
$subject = $db->result_first("SELECT subject FROM {$tablepre}threads WHERE tid='$taskvar[value]'");
$subject = $subject ? $subject : "TID $taskvar[value]";
} elseif($taskvar['variable'] == 'authorid') {
$author = $db->result_first("SELECT username FROM {$tablepre}members WHERE uid='$taskvar[value]'");
$author = $author ? $author : "TID $taskvar[value]";
}
if($taskvar['sort'] == 'apply') {
$taskvars['apply'][] = $taskvar;
} elseif($taskvar['sort'] == 'complete') {
$taskvars['complete'][$taskvar['variable']] = $taskvar;
} elseif($taskvar['sort'] == 'setting') {
$taskvars['setting'][$taskvar['variable']] = $taskvar;
}
}
}
$grouprequired = $comma = '';
$task['applyperm'] = $task['applyperm'] == 'all' ? '' : $task['applyperm'];
if(!in_array($task['applyperm'], array('', 'member', 'admin'))) {
$query = $db->query("SELECT grouptitle FROM {$tablepre}usergroups WHERE groupid IN (".str_replace("\t", ',', $task['applyperm']).")");
while($group = $db->fetch_array($query)) {
$grouprequired .= $comma.$group[grouptitle];
$comma = ', ';
}
}
if($task['relatedtaskid']) {
$taskrequired = $db->result_first("SELECT name FROM {$tablepre}tasks WHERE taskid='$task[relatedtaskid]'");
}
if($task['status'] == '-1') {
if($task['period']) {
$allowapply = $timestamp - $task['dateline'] >= $task['period'] * 3600 ? 3 : -7;
$task['t'] = tasktimeformat($task['period'] * 3600 - $timestamp + $task['dateline']);
} else {
$allowapply = -4;
}
} elseif($task['status'] == '0') {
$allowapply = -1;
if($task['newbietask'] == '1') {
$allowapply = -8;
$entrance = $taskvars['setting']['entrance']['value'].'.php';
if(isset($taskvars['complete']['threadid'])) {
$entrance .= '?tid='.$taskvars['complete']['threadid']['value'];
} elseif(isset($taskvars['complete']['forumid'])) {
$entrance .= '?fid='.$taskvars['complete']['forumid']['value'];
} elseif(isset($taskvars['complete']['authorid'])) {
$entrance .= '?uid='.$taskvars['complete']['authorid']['value'];
}
}
$csc = explode("\t", $task['csc']);
$task['csc'] = floatval($csc[0]);
$task['lastupdate'] = intval($csc[1]);
if($task['csc'] < 100 && $timestamp - $task['lastupdate'] > 60) {
require_once DISCUZ_ROOT.'./include/tasks/'.$task['scriptname'].'.inc.php';
$result = task_csc($task);
if($result === TRUE) {
$task['csc'] = '100';
$db->query("UPDATE {$tablepre}mytasks SET csc='100' WHERE uid='$discuz_uid' AND taskid='$id'");
} elseif($result === FALSE) {
$db->query("UPDATE {$tablepre}mytasks SET status='-1' WHERE uid='$discuz_uid' AND taskid='$id'", 'UNBUFFERED');
dheader("Location: task.php?action=view&id=$id");
} else {
$task['csc'] = floatval($result['csc']);
$db->query("UPDATE {$tablepre}mytasks SET csc='$task[csc]\t$timestamp' WHERE uid='$discuz_uid' AND taskid='$id'", 'UNBUFFERED');
}
}
} elseif($task['status'] == '1') {
if($task['period']) {
$allowapply = $timestamp - $task['dateline'] >= $task['period'] * 3600 ? 2 : -6;
$task['t'] = tasktimeformat($task['period'] * 3600 - $timestamp + $task['dateline']);
} else {
$allowapply = -5;
}
} else {
$allowapply = 1;
if($task['newbietask'] == '1' && $newbietaskid) {
$taskrequired = $db->result_first("SELECT name FROM {$tablepre}tasks WHERE taskid='$newbietaskid'");
}
}
if($allowapply > 0) {
if($task['applyperm'] && $task['applyperm'] != 'all' && !(($task['applyperm'] == 'member' && $adminid == '0') || ($task['applyperm'] == 'admin' && $adminid > '0') || forumperm($task['applyperm']))) {
$allowapply = -2;
} elseif($task['tasklimits'] && $task['achievers'] >= $task['tasklimits']) {
$allowapply = -3;
}
}
$task['dateline'] = dgmdate("$dateformat $timeformat", $task['dateline'] + $timeoffset * 3600);
if($inajax) {
include template('task_newbie_detail');
dexit();
}
} elseif($action == 'apply' && $id) {
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
if(!$task = $db->fetch_first("SELECT * FROM {$tablepre}tasks WHERE taskid='$id' AND available='2' AND newbietask!='1'")) {
showmessage('task_nonexistence', NULL, 'HALTED');
} elseif(($task['starttime'] && $task['starttime'] > $timestamp) || ($task['endtime'] && $task['endtime'] <= $timestamp)) {
showmessage('task_offline', NULL, 'HALTED');
} elseif($task['tasklimits'] && $task['achievers'] >= $task['tasklimits']) {
showmessage('task_full', NULL, 'HALTED');
}
if($task['relatedtaskid'] && !$db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND taskid='$task[relatedtaskid]' AND status='1'")) {
showmessage('task_relatedtask', 'task.php?action=view&id='.$task['relatedtaskid']);
} elseif($task['applyperm'] && $task['applyperm'] != 'all' && !(($task['applyperm'] == 'member' && $adminid == '0') || ($task['applyperm'] == 'admin' && $adminid > '0') || forumperm($task['applyperm']))) {
showmessage('task_grouplimit', 'task.php?item=new');
} else {
if(!$task['period'] && $db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND taskid='$id'")) {
showmessage('task_duplicate', 'task.php?item=new');
} elseif($task['period'] && $db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND taskid='$id' AND dateline>=$timestamp-$task[period]*3600")) {
showmessage('task_nextperiod', 'task.php?item=new');
}
}
require_once DISCUZ_ROOT.'./include/task.func.php';
task_apply($task);
showmessage('task_applied', "task.php?action=view&id=$id");
} elseif($action == 'draw' && $id) {
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
if(!$task = $db->fetch_first("SELECT t.*, mt.dateline AS applytime, mt.status FROM {$tablepre}tasks t, {$tablepre}mytasks mt WHERE mt.uid='$discuz_uid' AND mt.taskid=t.taskid AND t.taskid='$id' AND t.available='2'")) {
showmessage('task_nonexistence', NULL, 'HALTED');
} elseif($task['status'] != 0) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif($task['tasklimits'] && $task['achievers'] >= $task['tasklimits']) {
showmessage('task_up_to_limit', 'task.php');
}
require_once DISCUZ_ROOT.'./include/tasks/'.$task['scriptname'].'.inc.php';
$result = task_csc($task);
if($result === TRUE) {
if($task['reward']) {
require_once DISCUZ_ROOT.'./include/task.func.php';
$rewards = task_reward($task);
if($task['reward'] == 'magic') {
$magicname = $db->result_first("SELECT name FROM {$tablepre}magics WHERE magicid='$task[prize]'");
} elseif($task['reward'] == 'medal') {
$medalname = $db->result_first("SELECT name FROM {$tablepre}medals WHERE medalid='$task[prize]'");
} elseif($task['reward'] == 'group') {
$grouptitle = $db->result_first("SELECT grouptitle FROM {$tablepre}usergroups WHERE groupid='$task[prize]'");
}
sendnotice($discuz_uid, 'task_reward_'.$task['reward'], 'systempm');
}
task_sufprocess();
$db->query("UPDATE {$tablepre}mytasks SET status='1', csc='100', dateline='$timestamp' WHERE uid='$discuz_uid' AND taskid='$id'");
$db->query("UPDATE {$tablepre}tasks SET achievers=achievers+1 WHERE taskid='$id'", 'UNBUFFERED');
if(!$db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND status='0'")) {
updateprompt('task', $discuz_uid, 0);
}
if($inajax) {
taskmessage('100', $task['reward'] ? 'task_reward_'.$task['reward'] : 'task_completed');
} else {
showmessage('task_completed', 'task.php?item=done');
}
} elseif($result === FALSE) {
$db->query("UPDATE {$tablepre}mytasks SET status='-1' WHERE uid='$discuz_uid' AND taskid='$id'", 'UNBUFFERED');
$inajax ? taskmessage('-1', 'task_failed') : showmessage('task_failed', 'task.php?item=failed');
} else {
$result['t'] = tasktimeformat($result['remaintime']);
if($result['csc']) {
$db->query("UPDATE {$tablepre}mytasks SET csc='$result[csc]\t$timestamp' WHERE uid='$discuz_uid' AND taskid='$id'", 'UNBUFFERED');
$msg = $result['t'] ? 'task_doing_rt' : 'task_doing';
$inajax ? taskmessage($result['csc'], $msg) : showmessage($msg, "task.php?action=view&id=$id");
} else {
$msg = $result['t'] ? 'task_waiting_rt' : 'task_waiting';
$inajax ? taskmessage('0', $msg) : showmessage($msg, "task.php?action=view&id=$id");
}
}
} elseif($action == 'giveup' && $id && !empty($formhash)) {
if($formhash != FORMHASH) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif(!$task = $db->fetch_first("SELECT t.taskid, mt.status FROM {$tablepre}tasks t LEFT JOIN {$tablepre}mytasks mt ON mt.taskid=t.taskid AND mt.uid='$discuz_uid' WHERE t.taskid='$id' AND t.available='2' AND t.newbietask!='1'")) {
showmessage('task_nonexistence', NULL, 'HALTED');
} elseif($task['status'] != '0') {
showmessage('undefined_action');
}
$db->query("DELETE FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND taskid='$id'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}tasks SET applicants=applicants-1 WHERE taskid='$id'", 'UNBUFFERED');
if(!$db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND status='0'")) {
updateprompt('task', $discuz_uid, 0);
}
showmessage('task_giveup', "task.php?item=view&id=$id");
} elseif($action == 'parter' && $id) {
$query = $db->query("SELECT * FROM {$tablepre}mytasks WHERE taskid='$id' ORDER BY dateline DESC LIMIT 0, 8");
while($parter = $db->fetch_array($query)) {
$parter['avatar'] = discuz_uc_avatar($parter['uid'], 'small');
$csc = explode("\t", $parter['csc']);
$parter['csc'] = floatval($csc[0]);
$parterlist[] = $parter;
}
include template('task_parter');
dexit();
} elseif($action == 'newbie' && $prompts['newbietask'] && $newbietasks) {
$tpp = 8;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$num = count($newbietasks);
$multipage = multi($num, $tpp, $page, "task.php?action=newbie");
$ids = $doneids = $sortids = $thisids = array();
$sortids[] = $newbietaskid;
foreach($newbietasks as $id => $v) {
if($newbietaskid != $id) {
$ids[] = $id;
}
}
if($ids) {
$query = $db->query("SELECT taskid FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND taskid IN (".implodeids($ids).") AND status='1'");
while($mytask = $db->fetch_array($query)) {
$doneids[] = $mytask['taskid'];
}
}
foreach($ids as $id) {
if(!in_array($id, $doneids)) {
$sortids[] = $id;
}
}
$sortids = array_merge($sortids, $doneids);
for($i = $start_limit; $i < $tpp + $start_limit; $i++) {
if(!isset($sortids[$i])) {
break;
}
$thisids[] = $sortids[$i];
}
$doings = $num - count($doneids);
include template('task_newbie');
dexit();
} elseif($action == 'updatenewbietask' && $prompts['newbietask'] && $newbietaskid && $newbietasks[$newbietaskid]['scriptname'] == $scriptname) {
require_once DISCUZ_ROOT.'./include/task.func.php';
task_newbie_complete();
include template('task_newbie');
dexit();
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
include template('task');
function taskmessage($csc, $msg) {
extract($GLOBALS, EXTR_SKIP);
include_once language('messages');
include template('header_ajax');
eval("\$msg = \"$language[$msg]\";");
echo "$csc|$msg";
include template('footer_ajax');
exit;
}
function tasktimeformat($t) {
global $dlang;
if($t) {
$h = floor($t / 3600);
$m = floor(($t - $h * 3600) / 60);
$s = floor($t - $h * 3600 - $m * 60);
return ($h ? "$h{$dlang[date][4]}" : '').($m ? "$m{$dlang[date][6]}" : '').($h || !$s ? '' : "$s{$dlang[date][7]}");
}
return '';
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/task.php | PHP | asf20 | 19,476 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: login.func.php 20894 2009-10-29 02:06:08Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
function userlogin() {
global $db, $tablepre, $_DCACHE, $ucresult, $username, $password, $questionid, $answer, $loginfield;
require_once DISCUZ_ROOT.'./uc_client/client.php';
if($loginfield == 'uid') {
$isuid = 1;
} elseif($loginfield == 'email') {
$isuid = 2;
} else {
$isuid = 0;
}
$ucresult = uc_user_login($username, $password, $isuid, 1, $questionid, $answer);
list($tmp['uid'], $tmp['username'], $tmp['password'], $tmp['email'], $duplicate) = daddslashes($ucresult, 1);
$ucresult = $tmp;
if($ucresult['uid'] > 0) {
if($olduid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='".addslashes($ucresult['username'])."'")) {
require_once DISCUZ_ROOT.'./include/membermerge.func.php';
membermerge($olduid, $ucresult['uid']);
uc_user_merge_remove($ucresult['username']);
} else {
return 0;
}
}
if($ucresult['uid'] <= 0) {
return 0;
}
$member = $db->fetch_first("SELECT m.uid AS discuz_uid, m.username AS discuz_user, m.password AS discuz_pw, m.secques AS discuz_secques,
m.email, m.adminid, m.groupid, m.styleid, m.lastvisit, m.lastpost, u.allowinvisible
FROM {$tablepre}members m LEFT JOIN {$tablepre}usergroups u USING (groupid)
WHERE m.uid='$ucresult[uid]'");
if(!$member) {
return -1;
}
$member['discuz_userss'] = $member['discuz_user'];
$member['discuz_user'] = addslashes($member['discuz_user']);
foreach($member as $var => $value) {
$GLOBALS[$var] = $value;
}
if(addslashes($member['email']) != $ucresult['email']) {
$db->query("UPDATE {$tablepre}members SET email='$ucresult[email]' WHERE uid='$ucresult[uid]'");
}
if($questionid > 0 && empty($member['discuz_secques'])) {
$GLOBALS['discuz_secques'] = random(8);
$db->query("UPDATE {$tablepre}members SET secques='$GLOBALS[discuz_secques]' WHERE uid='$ucresult[uid]'");
}
$GLOBALS['styleid'] = $member['styleid'] ? $member['styleid'] : $_DCACHE['settings']['styleid'];
$cookietime = intval(isset($_POST['cookietime']) ? $_POST['cookietime'] : 0);
dsetcookie('cookietime', $cookietime, 86400);
dsetcookie('auth', authcode("$member[discuz_pw]\t$member[discuz_secques]\t$member[discuz_uid]", 'ENCODE'), $cookietime, 1, true);
dsetcookie('loginuser');
dsetcookie('activationauth');
dsetcookie('pmnum');
$GLOBALS['sessionexists'] = 0;
if($_DCACHE['settings']['frameon'] && $_DCOOKIE['frameon'] == 'yes') {
$GLOBALS['extrahead'] .= '<script>if(top != self) {parent.leftmenu.location.reload();}</script>';
}
return 1;
}
?>
| zyyhong | trunk/jiaju001/newbbs/bbs/include/login.func.php | PHP | asf20 | 2,804 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: search_trade.inc.php 17492 2008-12-31 01:39:40Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$orderby = in_array($orderby, array('dateline', 'price', 'expiration')) ? $orderby : 'dateline';
$ascdesc = isset($ascdesc) && $ascdesc == 'asc' ? 'asc' : 'desc';
if(!empty($searchid)) {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$index = $db->fetch_first("SELECT searchstring, keywords, threads, tids FROM {$tablepre}searchindex WHERE searchid='$searchid'");
if(!$index) {
showmessage('search_id_invalid');
}
$index['keywords'] = rawurlencode($index['keywords']);
$index['searchtype'] = preg_replace("/^([a-z]+)\|.*/", "\\1", $index['searchstring']);
$threadlist = $tradelist = array();
$query = $db->query("SELECT * FROM {$tablepre}trades WHERE pid IN ($index[tids]) ORDER BY $orderby $ascdesc LIMIT $start_limit, $tpp");
while($tradethread = $db->fetch_array($query)) {
$tradethread['lastupdate'] = dgmdate("$dateformat $timeformat", $tradethread['lastupdate'] + $timeoffset * 3600);
$tradethread['lastbuyer'] = rawurlencode($tradethread['lastbuyer']);
if($tradethread['expiration']) {
$tradethread['expiration'] = ($tradethread['expiration'] - $timestamp) / 86400;
if($tradethread['expiration'] > 0) {
$tradethread['expirationhour'] = floor(($tradethread['expiration'] - floor($tradethread['expiration'])) * 24);
$tradethread['expiration'] = floor($tradethread['expiration']);
} else {
$tradethread['expiration'] = -1;
}
}
$tradelist[] = $tradethread;
}
$multipage = multi($index['threads'], $tpp, $page, "search.php?searchid=$searchid".($orderby ? "&orderby=$orderby" : '')."&srchtype=trade&searchsubmit=yes");
$url_forward = 'search.php?'.$_SERVER['QUERY_STRING'];
include template('search_trade');
} else {
!($exempt & 2) && checklowerlimit($creditspolicy['search'], -1);
$srchtxt = isset($srchtxt) ? trim($srchtxt) : '';
$srchuname = isset($srchuname) ? trim($srchuname) : '';
$forumsarray = array();
if(!empty($srchfid)) {
foreach((is_array($srchfid) ? $srchfid : explode('_', $srchfid)) as $forum) {
if($forum = intval(trim($forum))) {
$forumsarray[] = $forum;
}
}
}
$fids = $comma = '';
foreach($_DCACHE['forums'] as $fid => $forum) {
if($forum['type'] != 'group' && (!$forum['viewperm'] && $readaccess) || ($forum['viewperm'] && forumperm($forum['viewperm']))) {
if(!$forumsarray || in_array($fid, $forumsarray)) {
$fids .= "$comma'$fid'";
$comma = ',';
}
}
}
$srchfilter = in_array($srchfilter, array('all', 'digest', 'top')) ? $srchfilter : 'all';
$searchstring = 'trade|'.addslashes($srchtxt).'|'.intval($srchtypeid).'|'.intval($srchuid).'|'.$srchuname.'|'.addslashes($fids).'|'.intval($srchfrom).'|'.intval($before).'|'.$srchfilter;
$searchindex = array('id' => 0, 'dateline' => '0');
$query = $db->query("SELECT searchid, dateline,
('$searchctrl'<>'0' AND ".(empty($discuz_uid) ? "useip='$onlineip'" : "uid='$discuz_uid'")." AND $timestamp-dateline<$searchctrl) AS flood,
(searchstring='$searchstring' AND expiration>'$timestamp') AS indexvalid
FROM {$tablepre}searchindex
WHERE ('$searchctrl'<>'0' AND ".(empty($discuz_uid) ? "useip='$onlineip'" : "uid='$discuz_uid'")." AND $timestamp-dateline<$searchctrl) OR (searchstring='$searchstring' AND expiration>'$timestamp')
ORDER BY flood");
while($index = $db->fetch_array($query)) {
if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
$searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
break;
} elseif($index['flood']) {
showmessage('search_ctrl', 'search.php');
}
}
if($searchindex['id']) {
$searchid = $searchindex['id'];
} else {
if(!$srchtxt && !$srchtypeid && !$srchuid && !$srchuname && !$srchfrom && !in_array($srchfilter, array('digest', 'top'))) {
showmessage('search_invalid', 'search.php');
} elseif(isset($srchfid) && $srchfid != 'all' && !(is_array($srchfid) && in_array('all', $srchfid)) && empty($forumsarray)) {
showmessage('search_forum_invalid', 'search.php');
} elseif(!$fids) {
showmessage('group_nopermission', NULL, 'NOPERM');
}
if($maxspm) {
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}searchindex WHERE dateline>'$timestamp'-60") >= $maxspm) {
showmessage('search_toomany', 'search.php');
}
}
$digestltd = $srchfilter == 'digest' ? "t.digest>'0' AND" : '';
$topltd = $srchfilter == 'top' ? "AND t.displayorder>'0'" : "AND t.displayorder>='0'";
if(!empty($srchfrom) && empty($srchtxt) && empty($srchtypeid) && empty($srchuid) && empty($srchuname)) {
$searchfrom = $before ? '<=' : '>=';
$searchfrom .= $timestamp - $srchfrom;
$sqlsrch = "FROM {$tablepre}trades tr INNER JOIN {$tablepre}threads t ON tr.tid=t.tid AND $digestltd t.fid IN ($fids) $topltd WHERE tr.dateline$searchfrom";
$expiration = $timestamp + $cachelife_time;
$keywords = '';
} else {
$sqlsrch = "FROM {$tablepre}trades tr INNER JOIN {$tablepre}threads t ON tr.tid=t.tid AND $digestltd t.fid IN ($fids) $topltd WHERE 1";
if($srchuname) {
$srchuid = $comma = '';
$srchuname = str_replace('*', '%', addcslashes($srchuname, '%_'));
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE username LIKE '".str_replace('_', '\_', $srchuname)."' LIMIT 50");
while($member = $db->fetch_array($query)) {
$srchuid .= "$comma'$member[uid]'";
$comma = ', ';
}
if(!$srchuid) {
$sqlsrch .= ' AND 0';
}
} elseif($srchuid) {
$srchuid = "'$srchuid'";
}
if($srchtypeid) {
$srchtypeid = intval($srchtypeid);
$sqlsrch .= " AND tr.typeid='$srchtypeid'";
}
if($srchtxt) {
if(preg_match("(AND|\+|&|\s)", $srchtxt) && !preg_match("(OR|\|)", $srchtxt)) {
$andor = ' AND ';
$sqltxtsrch = '1';
$srchtxt = preg_replace("/( AND |&| )/is", "+", $srchtxt);
} else {
$andor = ' OR ';
$sqltxtsrch = '0';
$srchtxt = preg_replace("/( OR |\|)/is", "+", $srchtxt);
}
$srchtxt = str_replace('*', '%', addcslashes($srchtxt, '%_'));
foreach(explode('+', $srchtxt) as $text) {
$text = trim($text);
if($text) {
$sqltxtsrch .= $andor;
$sqltxtsrch .= "tr.subject LIKE '%$text%'";
}
}
$sqlsrch .= " AND ($sqltxtsrch)";
}
if($srchuid) {
$sqlsrch .= " AND tr.sellerid IN ($srchuid)";
}
if(!empty($srchfrom)) {
$searchfrom = ($before ? '<=' : '>=').($timestamp - $srchfrom);
$sqlsrch .= " AND tr.dateline$searchfrom";
}
$keywords = str_replace('%', '+', $srchtxt).(trim($srchuname) ? '+'.str_replace('%', '+', $srchuname) : '');
$expiration = $timestamp + $cachelife_text;
}
$threads = $tids = 0;
$query = $db->query("SELECT tr.tid, tr.pid, t.closed $sqlsrch ORDER BY tr.pid DESC LIMIT $maxsearchresults");
while($post = $db->fetch_array($query)) {
if($thread['closed'] <= 1) {
$tids .= ','.$post['pid'];
$threads++;
}
}
$db->free_result($query);
$db->query("INSERT INTO {$tablepre}searchindex (keywords, searchstring, useip, uid, dateline, expiration, threads, tids)
VALUES ('$keywords', '$searchstring', '$onlineip', '$discuz_uid', '$timestamp', '$expiration', '$threads', '$tids')");
$searchid = $db->insert_id();
!($exempt & 2) && updatecredits($discuz_uid, $creditspolicy['search'], -1);
}
showmessage('search_redirect', "search.php?searchid=$searchid&srchtype=trade&orderby=$orderby&ascdesc=$ascdesc&searchsubmit=yes");
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/include/search_trade.inc.php | PHP | asf20 | 7,828 |
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: advertisements.inc.php 21075 2009-11-11 02:05:08Z liuqiang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$advarray = array();
if(!empty($_DCACHE['advs'])) {
$advs = CURSCRIPT == 'index' && !empty($gid) ? (array)$_DCACHE['advs']['cat'] : $_DCACHE['advs']['type'];
$advitems = $_DCACHE['advs']['items'];
if(in_array(CURSCRIPT, array('forumdisplay', 'viewthread')) && !empty($fid)) {
$thisgid = $forum['type'] == 'forum' ? $forum['fup'] : $_DCACHE['forums'][$forum['fup']]['fup'];
foreach($advs AS $type => $advitem) {
if($advitem = array_unique(array_merge((!empty($advitem['forum_'.$fid]) ? $advitem['forum_'.$fid] : array()), (!empty($advitem['forum_'.$thisgid]) ? $advitem['forum_'.$thisgid] : array()), (!empty($advitem['forum_all']) ? $advitem['forum_all'] : array())))) {
if(substr($type, 0, 6) == 'thread') {
$advarray[substr($type, 0, 7)][substr($type, 8, strlen($type))] = $advitem;
} else {
$advarray[$type] = $advitem;
}
}
}
$advs = $advarray;
}
if($globaladvs) {
foreach($globaladvs['type'] AS $key => $value) {
if(isset($advs[$key])) {
$advs[$key] = array_merge($advs[$key], $value);
} else {
$advs[$key] = $value;
}
}
$advitems = $advitems + $globaladvs['items'];
}
$advarray = $advs;
} else {
$advarray = $globaladvs['type'];
$advitems = $globaladvs['items'];
}
foreach($advarray as $advtype => $advcodes) {
if(substr($advtype, 0, 6) == 'thread') {
for($i = 1; $i <= $ppp; $i++) {
$adv_codes = @array_unique(array_merge((isset($advcodes[$i]) ? $advcodes[$i] : array()), (isset($advcodes[0]) ? $advcodes[0] : array())));
$advcount = count($adv_codes);
$advlist[$advtype][$i - 1] = $advitems[$advcount > 1 ? $adv_codes[mt_rand(0, $advcount -1)] : $adv_codes[0]];
}
} elseif($advtype == 'intercat') {
$advlist['intercat'] = $advcodes;
} else {
$advcodes = CURSCRIPT == 'index' && !empty($gid) ? $advcodes[$gid] : $advcodes;
$advcount = count($advcodes);
if($advtype == 'text') {
if($advcount > 5) {
$minfillpercent = 0;
for($cols = 5; $cols >= 3; $cols--) {
if(($remainder = $advcount % $cols) == 0) {
$advcols = $cols;
break;
} elseif($remainder / $cols > $minfillpercent) {
$minfillpercent = $remainder / $cols;
$advcols = $cols;
}
}
} else {
$advcols = $advcount;
}
$advlist[$advtype] = '';
for($i = 0; $i < $advcols * ceil($advcount / $advcols); $i++) {
$advlist[$advtype] .= (($i + 1) % $advcols == 1 || $advcols == 1 ? '<tr>' : '').
'<td width="'.intval(100 / $advcols).'%">'.(isset($advcodes[$i]) ? $advitems[$advcodes[$i]] : ' ').'</td>'.
(($i + 1) % $advcols == 0 ? "</tr>\n" : '');
}
} else {
$advlist[$advtype] = $advitems[$advcount > 1 ? $advcodes[mt_rand(0, $advcount - 1)] : $advcodes[0]];
}
}
}
unset($_DCACHE['advs'], $advs, $advarray);
if(empty($advlist['intercat'])) {
unset($advitems);
}
?> | zyyhong | trunk/jiaju001/newbbs/bbs/include/advertisements.inc.php | PHP | asf20 | 3,449 |