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: task.func.php 21053 2009-11-09 10:29:02Z wangjinbo $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_apply($task = array()) { global $db, $tablepre, $discuz_uid, $discuz_user, $timestamp; if(!isset($task['newbie'])) { require_once DISCUZ_ROOT.'./include/tasks/'.$task['scriptname'].'.inc.php'; task_condition(); } $db->query("REPLACE INTO {$tablepre}mytasks (uid, username, taskid, csc, dateline) VALUES ('$discuz_uid', '$discuz_user', '$task[taskid]', '0\t$timestamp', '$timestamp')"); $db->query("UPDATE {$tablepre}tasks SET applicants=applicants+1 WHERE taskid='$task[taskid]'", 'UNBUFFERED'); updateprompt('task', $discuz_uid, $db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND status='0'")); if(!isset($task['newbie'])) { task_preprocess($task); } } function task_reward($task = array()) { switch($task['reward']) { case 'credit': return task_reward_credit($task['prize'], $task['bonus']); break; case 'magic': return task_reward_magic($task['prize'], $task['bonus']); break; case 'medal': return task_reward_medal($task['prize'], $task['bonus']); break; case 'invite': return task_reward_invite($task['bonus'], $task['prize']); break; case 'group': return task_reward_group($task['prize'], $task['bonus']); break; } } function task_reward_credit($extcreditid, $credits) { global $db, $tablepre, $discuz_uid, $timestamp; $creditsarray[$extcreditid] = $credits; updatecredits($discuz_uid, $creditsarray); $db->query("INSERT INTO {$tablepre}creditslog (uid, fromto, sendcredits, receivecredits, send, receive, dateline, operation) VALUES ('$discuz_uid', 'TASK REWARD', '$extcreditid', '$extcreditid', '0', '$credits', '$timestamp', 'RCV')"); } function task_reward_magic($magicid, $num) { global $db, $tablepre, $discuz_uid; if($db->result_first("SELECT COUNT(*) FROM {$tablepre}membermagics WHERE magicid='$magicid' AND uid='$discuz_uid'")) { $db->query("UPDATE {$tablepre}membermagics SET num=num+'$num' WHERE magicid='$magicid' AND uid='$discuz_uid'", 'UNBUFFERED'); } else { $db->query("INSERT INTO {$tablepre}membermagics (uid, magicid, num) VALUES ('$discuz_uid', '$magicid', '$num')"); } } function task_reward_medal($medalid, $day) { global $db, $tablepre, $discuz_uid, $timestamp; $medals = $db->result_first("SELECT medals FROM {$tablepre}memberfields WHERE uid='$discuz_uid'"); $medalsnew = $medals ? $medals."\t".$medalid : $medalid; $db->query("UPDATE {$tablepre}memberfields SET medals='$medalsnew' WHERE uid='$discuz_uid'", 'UNBUFFERED'); $db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('$discuz_uid', '$medalid', '0', '$timestamp', '".($day ? $timestamp + $day * 86400 : '')."', '1')"); } function task_reward_invite($day, $num) { global $db, $tablepre, $discuz_uid, $timestamp, $onlineip; $expiration = $timestamp + $day * 86400; $invitecodes = ''; $comma = '<br />'; for($i = 1; $i <= $num; $i++) { $invitecode = substr(md5($discuz_uid.$timestamp.random(6)), 0, 10).random(6); $db->query("INSERT INTO {$tablepre}invites (uid, dateline, expiration, inviteip, invitecode) VALUES ('$discuz_uid', '$timestamp', '$expiration', '$onlineip', '$invitecode')", 'UNBUFFERED'); $invitecodes .= $comma.'<b>'.$invitecode.'</b>'; } return $invitecodes; } function task_reward_group($gid, $day = 0) { global $db, $tablepre, $discuz_uid, $timestamp; $exists = FALSE; if($extgroupids) { $extgroupids = explode("\t", $extgroupids); if(in_array($gid, $extgroupids)) { $exists = TRUE; } else { $extgroupids[] = $gid; } $extgroupids = implode("\t", $extgroupids); } else { $extgroupids = $gid; } $db->query("UPDATE {$tablepre}members SET extgroupids='$extgroupids' WHERE uid='$discuz_uid'", 'UNBUFFERED'); if($day) { $groupterms = $db->result_first("SELECT groupterms FROM {$tablepre}memberfields WHERE uid='$discuz_uid'"); $groupterms = $groupterms ? unserialize($groupterms) : array(); $groupterms['ext'][$gid] = $exists && $groupterms['ext'][$gid] ? max($groupterms['ext'][$gid], $timestamp + $day * 86400) : $timestamp + $day * 86400; $db->query("UPDATE {$tablepre}memberfields SET groupterms='".addslashes(serialize($groupterms))."' WHERE uid='$discuz_uid'", 'UNBUFFERED'); } } function task_newbie_complete() { global $db, $tablepre, $discuz_uid, $timestamp, $task, $newbietasks, $newbietaskid, $currenttaskcsc, $nextnewbietaskid, $magicname, $medalname, $grouptitle, $rewards; require_once DISCUZ_ROOT.'./include/tasks/newbie_'.$newbietasks[$newbietaskid]['scriptname'].'.inc.php'; $task = $db->fetch_first("SELECT * FROM {$tablepre}tasks WHERE taskid='$newbietaskid' AND available='2'"); $currenttaskcsc = 0; if(task_csc($task) === TRUE) { $currenttaskcsc = 100; if($task['reward']) { $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'); } $db->query("UPDATE {$tablepre}mytasks SET status='1', csc='100', dateline='$timestamp' WHERE uid='$discuz_uid' AND taskid='$newbietaskid'"); $db->query("UPDATE {$tablepre}tasks SET achievers=achievers+1 WHERE taskid='$newbietaskid'", 'UNBUFFERED'); $nextnewbietaskid = intval($db->result_first("SELECT t.taskid FROM {$tablepre}tasks t LEFT JOIN {$tablepre}mytasks mt ON mt.taskid=t.taskid AND mt.uid='$discuz_uid' WHERE mt.taskid IS NULL AND t.available='2' AND t.newbietask='1' ORDER BY t.newbietask DESC LIMIT 1")); if($nextnewbietaskid) { $nexttask = $db->fetch_first("SELECT * FROM {$tablepre}tasks WHERE taskid='$nextnewbietaskid' AND available='2'"); $nexttask['newbie'] = 1; task_apply($nexttask); $db->query("UPDATE {$tablepre}members SET newbietaskid='$nextnewbietaskid' WHERE uid='$discuz_uid'", 'UNBUFFERED'); } else { $db->query("UPDATE {$tablepre}members SET prompt=prompt^8, newbietaskid='0' WHERE uid='$discuz_uid'", 'UNBUFFERED'); } $taskmsg = $newbietasks['task'][$newbietaskid]['scriptname']; if(!$nextnewbietaskid) { $taskmsg .= '_complete'; } write_statlog('', 'action=newbie&from='.$taskmsg, '', '', 'task.php'); } } function task_newfunction_autoapply() { global $db, $tablepre, $discuz_uid; $query = $db->query("SELECT * FROM {$tablepre}tasks WHERE newbietask='2' AND available='2'"); $tprompt = FALSE; while($t = $db->fetch_array($query)) { $t['newbie'] = 1; if(!$db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND taskid='$t[taskid]'")) { task_apply($t); $tprompt = TRUE; } } $tprompt && updateprompt('task', $discuz_uid, $db->result_first("SELECT COUNT(*) FROM {$tablepre}mytasks WHERE uid='$discuz_uid' AND status='0'")); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/task.func.php
PHP
asf20
7,419
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: template.func.php 19936 2009-09-15 06:22:00Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function parse_template($tplfile, $templateid, $tpldir) { global $language, $subtemplates, $timestamp; $nest = 6; $basefile = $file = basename($tplfile, '.htm'); $file == 'header' && CURSCRIPT && $file = 'header_'.CURSCRIPT; $objfile = DISCUZ_ROOT.'./forumdata/templates/'.STYLEID.'_'.$templateid.'_'.$file.'.tpl.php'; if(!@$fp = fopen($tplfile, 'r')) { dexit("Current template file './$tpldir/$file.htm' not found or have no access!"); } elseif($language['discuz_lang'] != 'templates' && !include language('templates', $templateid, $tpldir)) { dexit("<br />Current template pack do not have a necessary language file 'templates.lang.php' or have syntax error!"); } $template = @fread($fp, filesize($tplfile)); fclose($fp); $var_regexp = "((\\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(\[[a-zA-Z0-9_\-\.\"\'\[\]\$\x7f-\xff]+\])*)"; $const_regexp = "([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)"; $headerexists = preg_match("/{(sub)?template\s+header\}/", $template) || $basefile == 'header_ajax'; $subtemplates = array(); for($i = 1; $i <= 3; $i++) { if(strexists($template, '{subtemplate')) { $template = preg_replace("/[\n\r\t]*\{subtemplate\s+([a-z0-9_:]+)\}[\n\r\t]*/ies", "stripvtemplate('\\1', 1)", $template); } } $template = preg_replace("/[\n\r\t]*\{csstemplate\}[\n\r\t]*/ies", "loadcsstemplate('\\1')", $template); $template = preg_replace("/([\n\r]+)\t+/s", "\\1", $template); $template = preg_replace("/\<\!\-\-\{(.+?)\}\-\-\>/s", "{\\1}", $template); $template = preg_replace("/\{lang\s+(.+?)\}/ies", "languagevar('\\1')", $template); $template = preg_replace("/\{faq\s+(.+?)\}/ies", "faqvar('\\1')", $template); $template = str_replace("{LF}", "<?=\"\\n\"?>", $template); $template = preg_replace("/\{(\\\$[a-zA-Z0-9_\[\]\'\"\$\.\x7f-\xff]+)\}/s", "<?=\\1?>", $template); $template = preg_replace("/$var_regexp/es", "addquote('<?=\\1?>')", $template); $template = preg_replace("/\<\?\=\<\?\=$var_regexp\?\>\?\>/es", "addquote('<?=\\1?>')", $template); $headeradd = $headerexists ? "hookscriptoutput('$basefile');" : ''; if(!empty($subtemplates)) { $headeradd .= "\n0\n"; foreach ($subtemplates as $fname) { $headeradd .= "|| checktplrefresh('$tplfile', '$fname', $timestamp, '$templateid', '$tpldir')\n"; } $headeradd .= ';'; } $template = "<? if(!defined('IN_DISCUZ')) exit('Access Denied'); {$headeradd}?>\n$template"; $template = preg_replace("/[\n\r\t]*\{template\s+([a-z0-9_:]+)\}[\n\r\t]*/ies", "stripvtemplate('\\1', 0)", $template); $template = preg_replace("/[\n\r\t]*\{template\s+(.+?)\}[\n\r\t]*/ies", "stripvtemplate('\\1', 0)", $template); $template = preg_replace("/[\n\r\t]*\{eval\s+(.+?)\}[\n\r\t]*/ies", "stripvtags('<? \\1 ?>','')", $template); $template = preg_replace("/[\n\r\t]*\{echo\s+(.+?)\}[\n\r\t]*/ies", "stripvtags('<? echo \\1; ?>','')", $template); $template = preg_replace("/([\n\r\t]*)\{elseif\s+(.+?)\}([\n\r\t]*)/ies", "stripvtags('\\1<? } elseif(\\2) { ?>\\3','')", $template); $template = preg_replace("/([\n\r\t]*)\{else\}([\n\r\t]*)/is", "\\1<? } else { ?>\\2", $template); for($i = 0; $i < $nest; $i++) { $template = preg_replace("/[\n\r\t]*\{loop\s+(\S+)\s+(\S+)\}[\n\r]*(.+?)[\n\r]*\{\/loop\}[\n\r\t]*/ies", "stripvtags('<? if(is_array(\\1)) { foreach(\\1 as \\2) { ?>','\\3<? } } ?>')", $template); $template = preg_replace("/[\n\r\t]*\{loop\s+(\S+)\s+(\S+)\s+(\S+)\}[\n\r\t]*(.+?)[\n\r\t]*\{\/loop\}[\n\r\t]*/ies", "stripvtags('<? if(is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\\4<? } } ?>')", $template); $template = preg_replace("/([\n\r\t]*)\{if\s+(.+?)\}([\n\r]*)(.+?)([\n\r]*)\{\/if\}([\n\r\t]*)/ies", "stripvtags('\\1<? if(\\2) { ?>\\3','\\4\\5<? } ?>\\6')", $template); } $template = preg_replace("/\{$const_regexp\}/s", "<?=\\1?>", $template); $template = preg_replace("/ \?\>[\n\r]*\<\? /s", " ", $template); if(!@$fp = fopen($objfile, 'w')) { dexit("Directory './forumdata/templates/' not found or have no access!"); } $template = preg_replace("/\"(http)?[\w\.\/:]+\?[^\"]+?&[^\"]+?\"/e", "transamp('\\0')", $template); $template = preg_replace("/\<script[^\>]*?src=\"(.+?)\"(.*?)\>\s*\<\/script\>/ise", "stripscriptamp('\\1', '\\2')", $template); $template = preg_replace("/[\n\r\t]*\{block\s+([a-zA-Z0-9_]+)\}(.+?)\{\/block\}/ies", "stripblock('\\1', '\\2')", $template); flock($fp, 2); fwrite($fp, $template); fclose($fp); } function stripvtemplate($tpl, $sub) { $vars = explode(':', $tpl); $templateid = 0; $tpldir = ''; if(count($vars) == 2) { list($templateid, $tpl) = $vars; $tpldir = './plugins/'.$templateid.'/templates'; } if($sub) { return loadsubtemplate($tpl, $templateid, $tpldir); } else { return stripvtags("<? include template('$tpl', '$templateid', '$tpldir'); ?>", ''); } } function loadsubtemplate($file, $templateid = 0, $tpldir = '') { global $subtemplates; $tpldir = $tpldir ? $tpldir : TPLDIR; $templateid = $templateid ? $templateid : TEMPLATEID; $tplfile = DISCUZ_ROOT.'./'.$tpldir.'/'.$file.'.htm'; if($templateid != 1 && !file_exists($tplfile)) { $tplfile = DISCUZ_ROOT.'./templates/default/'.$file.'.htm'; } $content = @implode('', file($tplfile)); $subtemplates[] = $tplfile; return $content; } function loadcsstemplate() { global $csscurscripts; $scriptcss = '<link rel="stylesheet" type="text/css" href="forumdata/cache/style_{STYLEID}_common.css?{VERHASH}" />'; $content = $csscurscripts = ''; $content = @implode('', file(DISCUZ_ROOT.'./forumdata/cache/style_'.STYLEID.'_script.css')); $content = preg_replace("/([\n\r\t]*)\[CURSCRIPT\s+=\s+(.+?)\]([\n\r]*)(.*?)([\n\r]*)\[\/CURSCRIPT\]([\n\r\t]*)/ies", "cssvtags('\\2','\\4')", $content); if($csscurscripts) { $csscurscripts = preg_replace(array('/\s*([,;:\{\}])\s*/', '/[\t\n\r]/', '/\/\*.+?\*\//'), array('\\1', '',''), $csscurscripts); if(@$fp = fopen(DISCUZ_ROOT.'./forumdata/cache/scriptstyle_'.STYLEID.'_'.CURSCRIPT.'.css', 'w')) { fwrite($fp, $csscurscripts); fclose($fp); } else { exit('Can not write to cache files, please check directory ./forumdata/ and ./forumdata/cache/ .'); } $scriptcss .='<link rel="stylesheet" type="text/css" href="forumdata/cache/scriptstyle_{STYLEID}_{CURSCRIPT}.css?{VERHASH}" />'; } $content = str_replace('[SCRIPTCSS]', $scriptcss, $content); return $content; } function cssvtags($curscript, $content) { global $csscurscripts; $csscurscripts .= in_array(CURSCRIPT, explode(',', $curscript)) ? $content : ''; } function transamp($str) { $str = str_replace('&', '&amp;', $str); $str = str_replace('&amp;amp;', '&amp;', $str); $str = str_replace('\"', '"', $str); return $str; } function addquote($var) { return str_replace("\\\"", "\"", preg_replace("/\[([a-zA-Z0-9_\-\.\x7f-\xff]+)\]/s", "['\\1']", $var)); } function languagevar($var) { global $templatelang; if(isset($GLOBALS['language'][$var])) { return $GLOBALS['language'][$var]; } else { $vars = explode(':', $var); if(count($vars) != 2) { return "!$var!"; } if(in_array($vars[0], $GLOBALS['templatelangs']) && empty($templatelang[$vars[0]])) { @include_once DISCUZ_ROOT.'./forumdata/plugins/'.$vars[0].'.lang.php'; } if(!isset($templatelang[$vars[0]][$vars[1]])) { return "!$var!"; } else { return $templatelang[$vars[0]][$vars[1]]; } } } function faqvar($var) { global $_DCACHE; include_once DISCUZ_ROOT.'./forumdata/cache/cache_faqs.php'; if(isset($_DCACHE['faqs'][$var])) { return '<a href="faq.php?action=faq&id='.$_DCACHE['faqs'][$var]['fpid'].'&messageid='.$_DCACHE['faqs'][$var]['id'].'" target="_blank">'.$_DCACHE['faqs'][$var]['keyword'].'</a>'; } else { return "!$var!"; } } function stripvtags($expr, $statement) { $expr = str_replace("\\\"", "\"", preg_replace("/\<\?\=(\\\$.+?)\?\>/s", "\\1", $expr)); $statement = str_replace("\\\"", "\"", $statement); return $expr.$statement; } function stripscriptamp($s, $extra) { $extra = str_replace('\\"', '"', $extra); $s = str_replace('&amp;', '&', $s); return "<script src=\"$s\" type=\"text/javascript\"$extra></script>"; } function stripblock($var, $s) { $s = str_replace('\\"', '"', $s); $s = preg_replace("/<\?=\\\$(.+?)\?>/", "{\$\\1}", $s); preg_match_all("/<\?=(.+?)\?>/e", $s, $constary); $constadd = ''; $constary[1] = array_unique($constary[1]); foreach($constary[1] as $const) { $constadd .= '$__'.$const.' = '.$const.';'; } $s = preg_replace("/<\?=(.+?)\?>/", "{\$__\\1}", $s); $s = str_replace('?>', "\n\$$var .= <<<EOF\n", $s); $s = str_replace('<?', "\nEOF;\n", $s); return "<?\n$constadd\$$var = <<<EOF\n".$s."\nEOF;\n?>"; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/template.func.php
PHP
asf20
9,027
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: forum.func.php 20900 2009-10-29 02:49:38Z tiger $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function checkautoclose() { global $timestamp, $forum, $thread; if(!$forum['ismoderator'] && $forum['autoclose']) { $closedby = $forum['autoclose'] > 0 ? 'dateline' : 'lastpost'; $forum['autoclose'] = abs($forum['autoclose']); if($timestamp - $thread[$closedby] > $forum['autoclose'] * 86400) { return 'post_thread_closed_by_'.$closedby; } } return FALSE; } function forum(&$forum) { global $_DCOOKIE, $timestamp, $timeformat, $dateformat, $discuz_uid, $groupid, $lastvisit, $moddisplay, $timeoffset, $hideprivate, $onlinehold; if(!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || !empty($forum['allowview']) || (isset($forum['users']) && strstr($forum['users'], "\t$discuz_uid\t"))) { $forum['permission'] = 2; } elseif(!$hideprivate) { $forum['permission'] = 1; } else { return FALSE; } if($forum['icon']) { if(strstr($forum['icon'], ',')) { $flash = explode(",", $forum['icon']); $forum['icon'] = "<a href=\"forumdisplay.php?fid=$forum[fid]\"><embed style=\"float:left; margin-right: 10px\" src=\"".trim($flash[0])."\" width=\"".trim($flash[1])."\" height=\"".trim($flash[2])."\" type=\"application/x-shockwave-flash\" align=\"left\"></embed></a>"; } else { $forum['icon'] = "<a href=\"forumdisplay.php?fid=$forum[fid]\"><img style=\"float:left; margin-right: 10px\" src=\"$forum[icon]\" align=\"left\" alt=\"\" border=\"0\" /></a>"; } } $lastpost = array('tid' => 0, 'dateline' => 0, 'subject' => '', 'author' => ''); list($lastpost['tid'], $lastpost['subject'], $lastpost['dateline'], $lastpost['author']) = is_array($forum['lastpost']) ? $forum['lastpost'] : explode("\t", $forum['lastpost']); $forum['folder'] = (isset($_DCOOKIE['fid'.$forum['fid']]) && $_DCOOKIE['fid'.$forum['fid']] > $lastvisit ? $_DCOOKIE['fid'.$forum['fid']] : $lastvisit) < $lastpost['dateline'] ? ' class="new"' : ''; if($lastpost['tid']) { $lastpost['dateline'] = dgmdate("$dateformat $timeformat", $lastpost['dateline'] + $timeoffset * 3600); $lastpost['authorusername'] = $lastpost['author']; if($lastpost['author']) { $lastpost['author'] = '<a href="space.php?username='.rawurlencode($lastpost['author']).'">'.$lastpost['author'].'</a>'; } $forum['lastpost'] = $lastpost; } else { $forum['lastpost'] = $lastpost['authorusername'] = ''; } $forum['moderators'] = moddisplay($forum['moderators'], $moddisplay, !empty($forum['inheritedmod'])); if(isset($forum['subforums'])) { $forum['subforums'] = implode(', ', $forum['subforums']); } return TRUE; } function forumselect($groupselectable = FALSE, $tableformat = 0, $selectedfid = 0, $showhide = FALSE) { global $_DCACHE, $discuz_uid, $groupid, $fid, $gid, $indexname, $db, $tablepre; if(!isset($_DCACHE['forums'])) { require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; } $forumcache = &$_DCACHE['forums']; $forumlist = $tableformat ? '<dl><dd><ul>' : '<optgroup label="&nbsp;">'; foreach($forumcache as $forum) { if((!$forum['status'] || $forum['status'] == 2) && !$showhide) { continue; } if($forum['type'] == 'group') { if($tableformat) { $forumlist .= '</ul></dd></dl><dl><dt><a href="'.$indexname.'?gid='.$forum['fid'].'">'.$forum['name'].'</a></dt><dd><ul>'; } else { $forumlist .= $groupselectable ? '<option value="'.$forum['fid'].'" class="bold">--'.$forum['name'].'</option>' : '</optgroup><optgroup label="--'.$forum['name'].'">'; } $visible[$forum['fid']] = true; } elseif($forum['type'] == 'forum' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$discuz_uid\t"))) { if($tableformat) { $forumlist .= '<li'.($fid == $forum['fid'] ? ' class="current"' : '').'><a href="forumdisplay.php?fid='.$forum['fid'].'">'.$forum['name'].'</a></li>'; } else { $forumlist .= '<option value="'.$forum['fid'].'"'.($selectedfid && $selectedfid == $forum['fid'] ? ' selected' : '').'>'.$forum['name'].'</option>'; } $visible[$forum['fid']] = true; } elseif($forum['type'] == 'sub' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$discuz_uid\t"))) { if($tableformat) { $forumlist .= '<li class="sub'.($fid == $forum['fid'] ? ' current' : '').'"><a href="forumdisplay.php?fid='.$forum['fid'].'">'.$forum['name'].'</a></li>'; } else { $forumlist .= '<option value="'.$forum['fid'].'"'.($selectedfid && $selectedfid == $forum['fid'] ? ' selected' : '').'>&nbsp; &nbsp; &nbsp; '.$forum['name'].'</option>'; } } } $forumlist .= $tableformat ? '</ul></dd></dl>' : '</optgroup>'; $forumlist = str_replace($tableformat ? '<dl><dd><ul></ul></dd></dl>' : '<optgroup label="&nbsp;"></optgroup>', '', $forumlist); return $forumlist; } function visitedforums() { global $_DCACHE, $_DCOOKIE, $forum, $sid; $count = 0; $visitedforums = ''; $fidarray = array($forum['fid']); foreach(explode('D', $_DCOOKIE['visitedfid']) as $fid) { if(isset($_DCACHE['forums'][$fid]) && !in_array($fid, $fidarray)) { $fidarray[] = $fid; if($fid != $forum['fid']) { $visitedforums .= '<li><a href="forumdisplay.php?fid='.$fid.'&amp;sid='.$sid.'">'.$_DCACHE['forums'][$fid]['name'].'</a></li>'; if(++$count >= $GLOBALS['visitedforums']) { break; } } } } if(($visitedfid = implode('D', $fidarray)) != $_DCOOKIE['visitedfid']) { dsetcookie('visitedfid', $visitedfid, 2592000); } return $visitedforums; } function moddisplay($moderators, $type, $inherit = 0) { if($type == 'selectbox') { if($moderators) { $modlist = ''; foreach(explode("\t", $moderators) as $moderator) { $modlist .= '<li><a href="space.php?username='.rawurlencode($moderator).'">'.($inherit ? '<strong>'.$moderator.'</strong>' : $moderator).'</a></li>'; } } else { $modlist = ''; } return $modlist; } else { if($moderators) { $modlist = $comma = ''; foreach(explode("\t", $moderators) as $moderator) { $modlist .= $comma.'<a class="notabs" href="space.php?username='.rawurlencode($moderator).'">'.($inherit ? '<strong>'.$moderator.'</strong>' : $moderator).'</a>'; $comma = ', '; } } else { $modlist = ''; } return $modlist; } } function getcacheinfo($tid) { global $timestamp, $cachethreadlife, $cachethreaddir; $tid = intval($tid); $cachethreaddir2 = DISCUZ_ROOT.'./'.$cachethreaddir; $cache = array('filemtime' => 0, 'filename' => ''); $tidmd5 = substr(md5($tid), 3); $fulldir = $cachethreaddir2.'/'.$tidmd5[0].'/'.$tidmd5[1].'/'.$tidmd5[2].'/'; $cache['filename'] = $fulldir.$tid.'.htm'; if(file_exists($cache['filename'])) { $cache['filemtime'] = filemtime($cache['filename']); } else { if(!is_dir($fulldir)) { for($i=0; $i<3; $i++) { $cachethreaddir2 .= '/'.$tidmd5{$i}; if(!is_dir($cachethreaddir2)) { @mkdir($cachethreaddir2, 0777); @touch($cachethreaddir2.'/index.htm'); } } } } return $cache; } function recommendupdate($fid, &$modrecommend, $force = '', $position = 0) { global $db, $tablepre, $timestamp, $_DCACHE; $recommendlist = $recommendimagelist = $modedtids = array(); $num = $modrecommend['num'] ? intval($modrecommend['num']) : 10; $imagenum = $modrecommend['imagenum'] = $modrecommend['imagenum'] ? intval($modrecommend['imagenum']) : 5; $imgw = $modrecommend['imagewidth'] = $modrecommend['imagewidth'] ? intval($modrecommend['imagewidth']) : 200; $imgh = $modrecommend['imageheight'] = $modrecommend['imageheight'] ? intval($modrecommend['imageheight']) : 150; if($modrecommend['sort'] && ($timestamp - $modrecommend['updatetime'] > $modrecommend['cachelife'] || $force)) { $query = $db->query("SELECT tid, moderatorid, aid FROM {$tablepre}forumrecommend WHERE fid='$fid'"); while($row = $db->fetch_array($query)) { if($row['aid'] && $modrecommend['sort'] == 2 || $modrecommend['sort'] == 1) { @unlink(DISCUZ_ROOT.'./forumdata/imagecaches/'.intval($row['aid']).'_'.$imgw.'_'.$imgh.'.jpg'); } if($modrecommend['sort'] == 2 && $row['moderatorid']) { $modedtids[] = $row['tid']; } } $db->query("DELETE FROM {$tablepre}forumrecommend WHERE fid='$fid'".($modrecommend['sort'] == 2 ? " AND moderatorid='0'" : '')); $orderby = 'dateline'; $conditions = $modrecommend['dateline'] ? 'AND dateline>'.($timestamp - $modrecommend['dateline'] * 3600) : ''; switch($modrecommend['orderby']) { case '': case '1':$orderby = 'lastpost';break; case '2':$orderby = 'views';break; case '3':$orderby = 'replies';break; case '4':$orderby = 'digest';break; case '5':$orderby = 'recommends';$conditions .= " AND recommends>'0'";break; case '6':$orderby = 'heats';break; } $add = $comma = $i = ''; $addthread = $addimg = $recommendlist = $recommendimagelist = $tids = array(); $query = $db->query("SELECT fid, tid, author, authorid, subject, highlight FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' $conditions ORDER BY $orderby DESC LIMIT 0, $num"); while($thread = $db->fetch_array($query)) { $recommendlist[$thread['tid']] = $thread; $tids[] = $thread['tid']; if(!$modedtids || !in_array($thread['tid'], $modedtids)) { $addthread[$thread['tid']] = "'$thread[fid]', '$thread[tid]', '1', '$i', '".addslashes($thread['subject'])."', '".addslashes($thread['author'])."', '$thread[authorid]', '0', '0', '$thread[highlight]'"; $i++; } } if($tids) { $query = $db->query("SELECT p.fid, p.tid, a.aid FROM {$tablepre}posts p INNER JOIN {$tablepre}attachments a ON a.pid=p.pid AND a.isimage IN ('1', '-1') AND a.width>='$imgw' WHERE p.tid IN (".implodeids($tids).") AND p.first='1'"); while($attachment = $db->fetch_array($query)) { if(isset($recommendimagelist[$attachment['tid']])) { continue; } $key = authcode($attachment['aid']."\t".$imgw."\t".$imgh, 'ENCODE', $_DCACHE['settings']['authkey']); $recommendlist[$attachment['tid']]['filename'] = 'image.php?aid='.$attachment['aid'].'&size='.$imgw.'x'.$imgh.'&key='.rawurlencode($key); $recommendimagelist[$attachment['tid']] = $recommendlist[$attachment['tid']]; $addimg[$attachment['tid']] = ",'$attachment[aid]', '".addslashes($recommendlist[$attachment['tid']]['filename'])."', '1'"; if(count($recommendimagelist) == $imagenum) { break; } } } foreach($addthread as $tid => $row) { $add .= $comma.'('.$row.(!isset($addimg[$tid]) ? ",'0','','0'" : $addimg[$tid]).')'; $comma = ', '; } unset($recommendimagelist); if($add) { $db->query("REPLACE INTO {$tablepre}forumrecommend (fid, tid, position, displayorder, subject, author, authorid, moderatorid, expiration, highlight, aid, filename, typeid) VALUES $add"); $modrecommend['updatetime'] = $timestamp; $modrecommendnew = addslashes(serialize($modrecommend)); $db->query("UPDATE {$tablepre}forumfields SET modrecommend='$modrecommendnew' WHERE fid='$fid'"); } } $recommendlists = $recommendlist = array(); $position = $position ? "AND position IN ('0','$position')" : ''; $query = $db->query("SELECT * FROM {$tablepre}forumrecommend WHERE fid='$fid' $position ORDER BY displayorder"); while($recommend = $db->fetch_array($query)) { if(($recommend['expiration'] && $recommend['expiration'] > $timestamp) || !$recommend['expiration']) { $recommendlist[] = $recommend; if($recommend['typeid'] && count($recommendimagelist) <= $imagenum) { $recommendimagelist[] = $recommend; } } if(count($recommendlist) == $num) { break; } } if($recommendlist) { $colorarray = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282'); foreach($recommendlist as $thread) { if($thread['highlight']) { $string = sprintf('%02d', $thread['highlight']); $stylestr = sprintf('%03b', $string[0]); $thread['highlight'] = ' style="'; $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : ''; $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : ''; $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : ''; $thread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : ''; $thread['highlight'] .= '"'; } else { $thread['highlight'] = ''; } $recommendlists[$thread['tid']]['author'] = $thread['author']; $recommendlists[$thread['tid']]['authorid'] = $thread['authorid']; $recommendlists[$thread['tid']]['subject'] = $modrecommend['maxlength'] ? cutstr($thread['subject'], $modrecommend['maxlength']) : $thread['subject']; $recommendlists[$thread['tid']]['subjectstyles'] = $thread['highlight']; } } if($recommendimagelist && $recommendlist) { $recommendlists['images'] = $recommendimagelist; } return $recommendlists; } function showstars($num) { global $starthreshold; $alt = 'alt="Rank: '.$num.'"'; if(empty($starthreshold)) { for($i = 0; $i < $num; $i++) { echo '<img src="'.IMGDIR.'/star_level1.gif" '.$alt.' />'; } } else { for($i = 3; $i > 0; $i--) { $numlevel = intval($num / pow($starthreshold, ($i - 1))); $num = ($num % pow($starthreshold, ($i - 1))); for($j = 0; $j < $numlevel; $j++) { echo '<img src="'.IMGDIR.'/star_level'.$i.'.gif" '.$alt.' />'; } } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/forum.func.php
PHP
asf20
13,816
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: viewthread_debate.inc.php 21214 2009-11-20 07:17:05Z liulanbo $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $debate = $thread; $debate = $sdb->fetch_first("SELECT * FROM {$tablepre}debates WHERE tid='$tid'"); $debate['dbendtime'] = $debate['endtime']; if($debate['dbendtime']) { $debate['endtime'] = gmdate("$dateformat $timeformat", $debate['dbendtime'] + $timeoffset * 3600); } if($debate['dbendtime'] > $timestamp) { $debate['remaintime'] = remaintime($debate['dbendtime'] - $timestamp); } $debate['starttime'] = dgmdate("$dateformat $timeformat", $debate['starttime'] + $timeoffset * 3600); $debate['affirmpoint'] = discuzcode($debate['affirmpoint'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0); $debate['negapoint'] = discuzcode($debate['negapoint'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0); if($debate['affirmvotes'] || $debate['negavotes']) { if($debate['affirmvotes'] && $debate['affirmvotes'] > $debate['negavotes']) { $debate['affirmvoteswidth'] = 100; $debate['negavoteswidth'] = intval($debate['negavotes'] / $debate['affirmvotes'] * 100); } elseif($debate['negavotes'] && $debate['negavotes'] > $debate['affirmvotes']) { $debate['negavoteswidth'] = 100; $debate['affirmvoteswidth'] = intval($debate['affirmvotes'] / $debate['negavotes'] * 100); } else { $debate['affirmvoteswidth'] = $debate['negavoteswidth'] = 100; } } else { $debate['negavoteswidth'] = $debate['affirmvoteswidth'] = 0; } if($debate['umpirepoint']) { $debate['umpirepoint'] = discuzcode($debate['umpirepoint'], 0, 0, 0, 1, 1, 1, 0, 0, 0, 0); } $debate['umpireurl'] = rawurlencode($debate['umpire']); list($debate['bestdebater'], $debate['bestdebateruid'], $debate['bestdebaterstand'], $debate['bestdebatervoters'], $debate['bestdebaterreplies']) = explode("\t", $debate['bestdebater']); $debate['bestdebaterurl'] = rawurlencode($debate['bestdebater']); $query = $sdb->query("SELECT author, authorid FROM {$tablepre}posts p LEFT JOIN {$tablepre}debateposts dp ON p.pid=dp.pid WHERE p.tid='$tid' AND p.invisible='0' AND dp.stand='1' GROUP BY dp.uid ORDER BY p.dateline DESC LIMIT 5"); while($affirmavatar = $sdb->fetch_array($query)) { $debate['affirmavatars'] .= '<a title="'.$affirmavatar['author'].'" target="_blank" href="space.php?uid='.$affirmavatar['authorid'].'">'.discuz_uc_avatar($affirmavatar['authorid'], 'small').'</a>'; } $query = $sdb->query("SELECT author, authorid FROM {$tablepre}posts p LEFT JOIN {$tablepre}debateposts dp ON p.pid=dp.pid WHERE p.tid='$tid' AND p.invisible='0' AND dp.stand='2' GROUP BY dp.uid ORDER BY p.dateline DESC LIMIT 5"); while($negaavatar = $sdb->fetch_array($query)) { $debate['negaavatars'] .= '<a title="'.$negaavatar['author'].'" target="_blank" href="space.php?uid='.$negaavatar['authorid'].'">'.discuz_uc_avatar($negaavatar['authorid'], 'small').'</a>'; } if($fastpost && $allowpostreply && $thread['closed'] == 0) { $firststand = $sdb->result_first("SELECT stand FROM {$tablepre}debateposts WHERE tid='$tid' AND uid='$discuz_uid' AND stand<>'0' ORDER BY dateline LIMIT 1"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/viewthread_debate.inc.php
PHP
asf20
3,196
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: viewthread_reward.inc.php 16854 2008-11-24 14:15:05Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $bapid = 0; $rewardprice = abs($thread['price']); $bestpost = array(); if($thread['price'] < 0 && $page == 1) { foreach($postlist as $key => $post) { if(!$post['first']) { $bapid = $key; break; } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/viewthread_reward.inc.php
PHP
asf20
475
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: slide.js 20766 2009-10-19 03:22:19Z monkey $ */ /* var slideSpeed = 2500; var slideImgsize = [140,140]; var slideBorderColor = '#C8DCEC'; var slideBgColor = '#FFF'; var slideImgs = new Array(); var slideImgLinks = new Array(); var slideImgTexts = new Array(); var slideSwitchColor = 'black'; var slideSwitchbgColor = 'white'; var slideSwitchHiColor = '#C8DCEC'; */ if(isUndefined(sliderun)) { var sliderun = 1; function slide() { var s = new Object(); s.slideId = Math.random(); s.slideSpeed = slideSpeed; s.size = slideImgsize; s.imgs = slideImgs; s.imgLoad = new Array(); s.imgnum = slideImgs.length; s.imgLinks = slideImgLinks; s.imgTexts = slideImgTexts; s.slideBorderColor = slideBorderColor; s.slideBgColor = slideBgColor; s.slideSwitchColor = slideSwitchColor; s.slideSwitchbgColor = slideSwitchbgColor; s.slideSwitchHiColor = slideSwitchHiColor; s.currentImg = 0; s.prevImg = 0; s.imgLoaded = 0; s.st = null; s.loadImage = function () { if(!s.imgnum) { return; } s.size[0] = parseInt(s.size[0]); s.size[1] = parseInt(s.size[1]); document.write('<div class="slideouter" id="outer_'+s.slideId+'" style="cursor:pointer;position:absolute;width:'+(s.size[0]-1)+'px;height:'+(s.size[1]-1)+'px;border:1px solid '+s.slideBorderColor+'"></div>'); document.write('<table cellspacing="0" cellpadding="0" style="cursor:pointer;width:'+s.size[0]+'px;height:'+s.size[1]+'px;table-layout:fixed;overflow:hidden;background:'+s.slideBgColor+';text-align:center"><tr><td valign="middle" style="padding:0" id="slide_'+s.slideId+'">'); document.write((typeof IMGDIR == 'undefined' ? '' : '<img src="'+IMGDIR+'/loading.gif" />') + '<br /><span id="percent_'+s.slideId+'">0%</span></td></tr></table>'); document.write('<div id="switch_'+s.slideId+'" style="position:absolute;margin-left:1px;margin-top:-18px"></div>'); $('outer_' + s.slideId).onclick = s.imageLink; for(i = 1;i < s.imgnum;i++) { switchdiv = document.createElement('div'); switchdiv.id = 'switch_' + i + '_' + s.slideId; switchdiv.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=70)'; switchdiv.style.opacity = 0.7; switchdiv.style.styleFloat = 'left'; switchdiv.style.cssFloat = 'left'; switchdiv.style.cursor = 'pointer'; switchdiv.style.width = '17px'; switchdiv.style.height = '17px'; switchdiv.style.overflow = 'hidden'; switchdiv.style.fontWeight = 'bold'; switchdiv.style.textAlign = 'center'; switchdiv.style.fontSize = '9px'; switchdiv.style.color = s.slideSwitchColor; switchdiv.style.borderRight = '1px solid ' + s.slideBorderColor; switchdiv.style.borderTop = '1px solid ' + s.slideBorderColor; switchdiv.style.backgroundColor = s.slideSwitchbgColor; switchdiv.className = 'slideswitch'; switchdiv.i = i; switchdiv.onclick = function () { s.switchImage(this); }; switchdiv.innerHTML = i; $('switch_'+s.slideId).appendChild(switchdiv); s.imgLoad[i] = new Image(); s.imgLoad[i].src = s.imgs[i]; s.imgLoad[i].onerror = function () { s.imgLoaded++; }; } s.loadCheck(); }; s.imageLink = function () { window.open(s.imgLinks[s.currentImg]); }; s.switchImage = function (obj) { s.showImage(obj.i); s.interval(); }; s.loadCheck = function () { for(i = 1;i < s.imgnum;i++) { if(s.imgLoad[i].complete && !s.imgLoad[i].status) { s.imgLoaded++; s.imgLoad[i].status = 1; if(s.imgLoad[i].width > s.size[0] || s.imgLoad[i].height > s.size[1]) { zr = s.imgLoad[i].width / s.imgLoad[i].height; if(zr > 1) { s.imgLoad[i].height = s.size[1]; s.imgLoad[i].width = s.size[1] * zr; } else { s.imgLoad[i].width = s.size[0]; s.imgLoad[i].height = s.size[0] / zr; if(s.imgLoad[i].height > s.size[1]) { s.imgLoad[i].height = s.size[1]; s.imgLoad[i].width = s.size[1] * zr; } } } } } if(s.imgLoaded < s.imgnum - 1) { $('percent_' + s.slideId).innerHTML = (parseInt(s.imgLoad.length / s.imgnum * 100)) + '%'; setTimeout(function () { s.loadCheck(); }, 100); } else { for(i = 1;i < s.imgnum;i++) { s.imgLoad[i].onclick = s.imageLink; s.imgLoad[i].title = s.imgTexts[i]; } s.showImage(); s.interval(); } }; s.interval = function () { clearInterval(s.st); s.st = setInterval(function () { s.showImage(); }, s.slideSpeed); }; s.showImage = function (i) { if(!i) { s.currentImg++; s.currentImg = s.currentImg < s.imgnum ? s.currentImg : 1; } else { s.currentImg = i; } if(s.prevImg) { $('switch_' + s.prevImg + '_' + s.slideId).style.backgroundColor = s.slideSwitchbgColor; } $('switch_' + s.currentImg + '_' + s.slideId).style.backgroundColor = s.slideSwitchHiColor; $('slide_' + s.slideId).innerHTML = ''; $('slide_' + s.slideId).appendChild(s.imgLoad[s.currentImg]); s.prevImg = s.currentImg; }; s.loadImage(); } } slide();
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/slide.js
JavaScript
asf20
5,276
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: common.js 20980 2009-11-05 02:06:19Z monkey $ */ var BROWSER = {}; var USERAGENT = navigator.userAgent.toLowerCase(); BROWSER.ie = window.ActiveXObject && USERAGENT.indexOf('msie') != -1 && USERAGENT.substr(USERAGENT.indexOf('msie') + 5, 3); BROWSER.firefox = document.getBoxObjectFor && USERAGENT.indexOf('firefox') != -1 && USERAGENT.substr(USERAGENT.indexOf('firefox') + 8, 3); BROWSER.chrome = window.MessageEvent && !document.getBoxObjectFor && USERAGENT.indexOf('chrome') != -1 && USERAGENT.substr(USERAGENT.indexOf('chrome') + 7, 10); BROWSER.opera = window.opera && opera.version(); BROWSER.safari = window.openDatabase && USERAGENT.indexOf('safari') != -1 && USERAGENT.substr(USERAGENT.indexOf('safari') + 7, 8); BROWSER.other = !BROWSER.ie && !BROWSER.firefox && !BROWSER.chrome && !BROWSER.opera && !BROWSER.safari; BROWSER.firefox = BROWSER.chrome ? 1 : BROWSER.firefox; var DISCUZCODE = []; DISCUZCODE['num'] = '-1'; DISCUZCODE['html'] = []; var CSSLOADED = []; var JSMENU = []; JSMENU['active'] = []; JSMENU['timer'] = []; JSMENU['drag'] = []; JSMENU['layer'] = 0; JSMENU['zIndex'] = {'win':200,'menu':300,'prompt':400,'dialog':500}; JSMENU['float'] = ''; var AJAX = []; AJAX['debug'] = 0; AJAX['url'] = []; AJAX['stack'] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; var clipboardswfdata = ''; var CURRENTSTYPE = null; var discuz_uid = isUndefined(discuz_uid) ? 0 : discuz_uid; var creditnotice = isUndefined(creditnotice) ? '' : creditnotice; var cookiedomain = isUndefined(cookiedomain) ? '' : cookiedomain; var cookiepath = isUndefined(cookiepath) ? '' : cookiepath; if(BROWSER.firefox && window.HTMLElement) { HTMLElement.prototype.__defineSetter__('outerHTML', function(sHTML) { var r = this.ownerDocument.createRange(); r.setStartBefore(this); var df = r.createContextualFragment(sHTML); this.parentNode.replaceChild(df,this); return sHTML; }); HTMLElement.prototype.__defineGetter__('outerHTML', function() { var attr; var attrs = this.attributes; var str = '<' + this.tagName.toLowerCase(); for(var i = 0;i < attrs.length;i++){ attr = attrs[i]; if(attr.specified) str += ' ' + attr.name + '="' + attr.value + '"'; } if(!this.canHaveChildren) { return str + '>'; } return str + '>' + this.innerHTML + '</' + this.tagName.toLowerCase() + '>'; }); HTMLElement.prototype.__defineGetter__('canHaveChildren', function() { switch(this.tagName.toLowerCase()) { case 'area':case 'base':case 'basefont':case 'col':case 'frame':case 'hr':case 'img':case 'br':case 'input':case 'isindex':case 'link':case 'meta':case 'param': return false; } return true; }); HTMLElement.prototype.click = function(){ var evt = this.ownerDocument.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null); this.dispatchEvent(evt); }; } function $(id) { return document.getElementById(id); } function display(id) { $(id).style.display = $(id).style.display == '' ? 'none' : ''; } function isUndefined(variable) { return typeof variable == 'undefined' ? true : false; } function in_array(needle, haystack) { if(typeof needle == 'string' || typeof needle == 'number') { for(var i in haystack) { if(haystack[i] == needle) { return true; } } } return false; } function trim(str) { return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, ''); } function strlen(str) { return (BROWSER.ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length; } function mb_strlen(str) { var len = 0; for(var i = 0; i < str.length; i++) { len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1; } return len; } function mb_cutstr(str, maxlen, dot) { var len = 0; var ret = ''; var dot = !dot ? '...' : ''; maxlen = maxlen - dot.length; for(var i = 0; i < str.length; i++) { len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1; if(len > maxlen) { ret += dot; break; } ret += str.substr(i, 1); } return ret; } function checkall(form, prefix, checkall) { var checkall = checkall ? checkall : 'chkall'; count = 0; for(var i = 0; i < form.elements.length; i++) { var e = form.elements[i]; if(e.name && e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) { e.checked = form.elements[checkall].checked; if(e.checked) { count++; } } } return count; } function doane(event) { e = event ? event : window.event; if(!e) return; if(BROWSER.ie) { e.returnValue = false; e.cancelBubble = true; } else if(e) { e.stopPropagation(); e.preventDefault(); } } function _attachEvent(obj, evt, func, eventobj) { eventobj = !eventobj ? obj : eventobj; if(obj.addEventListener) { obj.addEventListener(evt, func, false); } else if(eventobj.attachEvent) { obj.attachEvent('on' + evt, func); } } function _detachEvent(obj, evt, func, eventobj) { eventobj = !eventobj ? obj : eventobj; if(obj.removeEventListener) { obj.removeEventListener(evt, func, false); } else if(eventobj.detachEvent) { obj.detachEvent('on' + evt, func); } } function setcookie(cookieName, cookieValue, seconds, path, domain, secure) { var expires = new Date(); expires.setTime(expires.getTime() + seconds * 1000); domain = !domain ? cookiedomain : domain; path = !path ? cookiepath : path; document.cookie = escape(cookieName) + '=' + escape(cookieValue) + (expires ? '; expires=' + expires.toGMTString() : '') + (path ? '; path=' + path : '/') + (domain ? '; domain=' + domain : '') + (secure ? '; secure' : ''); } function getcookie(name) { var cookie_start = document.cookie.indexOf(name); var cookie_end = document.cookie.indexOf(";", cookie_start); return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length))); } function thumbImg(obj, method) { if(!obj) { return; } obj.onload = null; file = obj.src; zw = obj.offsetWidth; zh = obj.offsetHeight; if(zw < 2) { if(!obj.id) { obj.id = 'img_' + Math.random(); } setTimeout("thumbImg($('" + obj.id + "'), " + method + ")", 100); return; } zr = zw / zh; method = !method ? 0 : 1; if(method) { fixw = obj.getAttribute('_width'); fixh = obj.getAttribute('_height'); if(zw > fixw) { zw = fixw; zh = zw / zr; } if(zh > fixh) { zh = fixh; zw = zh * zr; } } else { var widthary = imagemaxwidth.split('%'); if(widthary.length > 1) { fixw = $('wrap').clientWidth - 200; if(widthary[0]) { fixw = fixw * widthary[0] / 100; } else if(widthary[1]) { fixw = fixw < widthary[1] ? fixw : widthary[1]; } } else { fixw = widthary[0]; } if(zw > fixw) { zw = fixw; zh = zw / zr; obj.style.cursor = 'pointer'; if(!obj.onclick) { obj.onclick = function() { zoom(obj, obj.src); }; } } } obj.width = zw; obj.height = zh; } function imgzoom() {} function attachimg() {} function setCopy(text, msg){ if(BROWSER.ie) { clipboardData.setData('Text', text); if(msg) { showDialog(msg, 'notice'); } } else { var msg = '<div style="text-decoration:underline;">点此复制到剪贴板</div>' + AC_FL_RunContent('id', 'clipboardswf', 'name', 'clipboardswf', 'devicefont', 'false', 'width', '120', 'height', '40', 'src', 'images/common/clipboard.swf', 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent', 'style' , 'margin-top:-20px'); showDialog(msg, 'info'); text = text.replace(/[\xA0]/g, ' '); clipboardswfdata = text; } } function getClipboardData() { window.document.clipboardswf.SetVariable('str', clipboardswfdata); } function saveData(ignoreempty) { var ignoreempty = isUndefined(ignoreempty) ? 0 : ignoreempty; var obj = $('postform') && (($('fwin_newthread') && $('fwin_newthread').style.display == '') || ($('fwin_reply') && $('fwin_reply').style.display == '')) ? $('postform') : ($('fastpostform') ? $('fastpostform') : $('postform')); if(!obj) return; var data = subject = message = ''; for(var i = 0; i < obj.elements.length; i++) { var el = obj.elements[i]; if(el.name != '' && (el.tagName == 'TEXTAREA' || el.tagName == 'INPUT' && (el.type == 'text' || el.type == 'checkbox' || el.type == 'radio')) && el.name.substr(0, 6) != 'attach') { var elvalue = el.value; if(el.name == 'subject') { subject = trim(elvalue); } else if(el.name == 'message') { if(typeof wysiwyg != 'undefined' && wysiwyg == 1) { elvalue = html2bbcode(editdoc.body.innerHTML); } message = trim(elvalue); } if((el.type == 'checkbox' || el.type == 'radio') && !el.checked) { continue; } if(trim(elvalue)) { data += el.name + String.fromCharCode(9) + el.tagName + String.fromCharCode(9) + el.type + String.fromCharCode(9) + elvalue + String.fromCharCode(9, 9); } } } if(!subject && !message && !ignoreempty) { return; } if(BROWSER.ie){ with(document.documentElement) { setAttribute("value", data); save('Discuz'); } } else if(window.sessionStorage){ sessionStorage.setItem('Discuz', data); } } function switchAdvanceMode(url) { var obj = $('postform') && (($('fwin_newthread') && $('fwin_newthread').style.display == '') || ($('fwin_reply') && $('fwin_reply').style.display == '')) ? $('postform') : $('fastpostform'); if(obj && obj.message.value != '') { saveData(); url += '&cedit=yes'; } location.href = url; return false; } function updatestring(str1, str2, clear) { str2 = '_' + str2 + '_'; return clear ? str1.replace(str2, '') : (str1.indexOf(str2) == -1 ? str1 + str2 : str1); } function toggle_collapse(objname, noimg, complex, lang) { var obj = $(objname); if(obj) { obj.style.display = obj.style.display == '' ? 'none' : ''; var collapsed = getcookie('discuz_collapse'); collapsed = updatestring(collapsed, objname, !obj.style.display); setcookie('discuz_collapse', collapsed, (collapsed ? 2592000 : -2592000)); } if(!noimg) { var img = $(objname + '_img'); if(img.tagName != 'IMG') { if(img.className.indexOf('_yes') == -1) { img.className = img.className.replace(/_no/, '_yes'); if(lang) { img.innerHTML = lang[0]; } } else { img.className = img.className.replace(/_yes/, '_no'); if(lang) { img.innerHTML = lang[1]; } } } else { img.src = img.src.indexOf('_yes.gif') == -1 ? img.src.replace(/_no\.gif/, '_yes\.gif') : img.src.replace(/_yes\.gif/, '_no\.gif'); } img.blur(); } if(complex) { var objc = $(objname + '_c'); if(objc) { objc.className = objc.className == 'c_header' ? 'c_header closenode' : 'c_header'; } } } function sidebar_collapse(lang) { if(lang[0]) { toggle_collapse('sidebar', null, null, lang); $('wrap').className = $('wrap').className == 'wrap with_side s_clear' ? 'wrap s_clear' : 'wrap with_side s_clear'; } else { var collapsed = getcookie('discuz_collapse'); collapsed = updatestring(collapsed, 'sidebar', 1); setcookie('discuz_collapse', collapsed, (collapsed ? 2592000 : -2592000)); location.reload(); } } function loadcss(cssname) { if(!CSSLOADED[cssname]) { css = document.createElement('link'); css.type = 'text/css'; css.rel = 'stylesheet'; css.href = 'forumdata/cache/style_' + STYLEID + '_' + cssname + '.css?' + VERHASH; var headNode = document.getElementsByTagName("head")[0]; headNode.appendChild(css); CSSLOADED[cssname] = 1; } } function showMenu(v) { var ctrlid = isUndefined(v['ctrlid']) ? v : v['ctrlid']; var showid = isUndefined(v['showid']) ? ctrlid : v['showid']; var menuid = isUndefined(v['menuid']) ? showid + '_menu' : v['menuid']; var ctrlObj = $(ctrlid); var menuObj = $(menuid); if(!menuObj) return; var mtype = isUndefined(v['mtype']) ? 'menu' : v['mtype']; var evt = isUndefined(v['evt']) ? 'mouseover' : v['evt']; var pos = isUndefined(v['pos']) ? '43' : v['pos']; var layer = isUndefined(v['layer']) ? 1 : v['layer']; var duration = isUndefined(v['duration']) ? 2 : v['duration']; var timeout = isUndefined(v['timeout']) ? 250 : v['timeout']; var maxh = isUndefined(v['maxh']) ? 500 : v['maxh']; var cache = isUndefined(v['cache']) ? 1 : v['cache']; var drag = isUndefined(v['drag']) ? '' : v['drag']; var dragobj = drag && $(drag) ? $(drag) : menuObj; var fade = isUndefined(v['fade']) ? 0 : v['fade']; var cover = isUndefined(v['cover']) ? 0 : v['cover']; var zindex = isUndefined(v['zindex']) ? JSMENU['zIndex']['menu'] : v['zindex']; if(typeof JSMENU['active'][layer] == 'undefined') { JSMENU['active'][layer] = []; } if(evt == 'click' && in_array(menuid, JSMENU['active'][layer]) && mtype != 'win') { hideMenu(menuid, mtype); return; } if(mtype == 'menu') { hideMenu(layer, mtype); } if(ctrlObj) { if(!ctrlObj.initialized) { ctrlObj.initialized = true; ctrlObj.unselectable = true; ctrlObj.outfunc = typeof ctrlObj.onmouseout == 'function' ? ctrlObj.onmouseout : null; ctrlObj.onmouseout = function() { if(this.outfunc) this.outfunc(); if(duration < 3 && !JSMENU['timer'][menuid]) JSMENU['timer'][menuid] = setTimeout('hideMenu(\'' + menuid + '\', \'' + mtype + '\')', timeout); }; ctrlObj.overfunc = typeof ctrlObj.onmouseover == 'function' ? ctrlObj.onmouseover : null; ctrlObj.onmouseover = function(e) { doane(e); if(this.overfunc) this.overfunc(); if(evt == 'click') { clearTimeout(JSMENU['timer'][menuid]); JSMENU['timer'][menuid] = null; } else { for(var i in JSMENU['timer']) { if(JSMENU['timer'][i]) { clearTimeout(JSMENU['timer'][i]); JSMENU['timer'][i] = null; } } } }; } } var dragMenu = function(menuObj, e, op) { e = e ? e : window.event; if(op == 1) { if(in_array(BROWSER.ie ? e.srcElement.tagName : e.target.tagName, ['TEXTAREA', 'INPUT', 'BUTTON', 'SELECT'])) { return; } JSMENU['drag'] = [e.clientX, e.clientY]; JSMENU['drag'][2] = parseInt(menuObj.style.left); JSMENU['drag'][3] = parseInt(menuObj.style.top); document.onmousemove = function(e) {try{dragMenu(menuObj, e, 2);}catch(err){}}; document.onmouseup = function(e) {try{dragMenu(menuObj, e, 3);}catch(err){}}; doane(e); } else if(op == 2 && JSMENU['drag'][0]) { var menudragnow = [e.clientX, e.clientY]; menuObj.style.left = (JSMENU['drag'][2] + menudragnow[0] - JSMENU['drag'][0]) + 'px'; menuObj.style.top = (JSMENU['drag'][3] + menudragnow[1] - JSMENU['drag'][1]) + 'px'; doane(e); } else if(op == 3) { JSMENU['drag'] = []; document.onmousemove = null; document.onmouseup = null; } }; if(!menuObj.initialized) { menuObj.initialized = true; menuObj.ctrlkey = ctrlid; menuObj.mtype = mtype; menuObj.layer = layer; menuObj.cover = cover; if(ctrlObj && ctrlObj.getAttribute('fwin')) {menuObj.scrolly = true;} menuObj.style.position = 'absolute'; menuObj.style.zIndex = zindex + layer; menuObj.onclick = function(e) { if(!e || BROWSER.ie) { window.event.cancelBubble = true; return window.event; } else { e.stopPropagation(); return e; } }; if(duration < 3) { if(duration > 1) { menuObj.onmouseover = function() { clearTimeout(JSMENU['timer'][menuid]); JSMENU['timer'][menuid] = null; }; } if(duration != 1) { menuObj.onmouseout = function() { JSMENU['timer'][menuid] = setTimeout('hideMenu(\'' + menuid + '\', \'' + mtype + '\')', timeout); }; } } if(drag) { dragobj.style.cursor = 'move'; dragobj.onmousedown = function(event) {try{dragMenu(menuObj, event, 1);}catch(e){}}; } if(cover) { var coverObj = document.createElement('div'); coverObj.id = menuid + '_cover'; coverObj.style.position = 'absolute'; coverObj.style.zIndex = menuObj.style.zIndex - 1; coverObj.style.left = coverObj.style.top = '0px'; coverObj.style.width = '100%'; coverObj.style.height = document.body.scrollHeight + 'px'; coverObj.style.backgroundColor = '#000'; coverObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50)'; coverObj.style.opacity = 0.5; $('append_parent').appendChild(coverObj); } } menuObj.style.display = ''; if(cover) $(menuid + '_cover').style.display = ''; if(fade) { var O = 0; var fadeIn = function(O) { if(O == 100) { clearTimeout(fadeInTimer); return; } menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + O + ')'; menuObj.style.opacity = O / 100; O += 10; var fadeInTimer = setTimeout(function () { fadeIn(O); }, 50); }; fadeIn(O); menuObj.fade = true; } else { menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)'; menuObj.style.opacity = 1; menuObj.fade = false; } setMenuPosition(showid, menuid, pos); if(maxh && menuObj.scrollHeight > maxh) { menuObj.style.height = maxh + 'px'; if(BROWSER.opera) { menuObj.style.overflow = 'auto'; } else { menuObj.style.overflowY = 'auto'; } } if(!duration) { setTimeout('hideMenu(\'' + menuid + '\', \'' + mtype + '\')', timeout); } if(!in_array(menuid, JSMENU['active'][layer])) JSMENU['active'][layer].push(menuid); menuObj.cache = cache; if(layer > JSMENU['layer']) { JSMENU['layer'] = layer; } } function setMenuPosition(showid, menuid, pos) { var showObj = $(showid); var menuObj = menuid ? $(menuid) : $(showid + '_menu'); if(isUndefined(pos)) pos = '43'; var basePoint = parseInt(pos.substr(0, 1)); var direction = parseInt(pos.substr(1, 1)); var sxy = sx = sy = sw = sh = ml = mt = mw = mcw = mh = mch = bpl = bpt = 0; if(!menuObj || (basePoint > 0 && !showObj)) return; if(showObj) { sxy = fetchOffset(showObj); sx = sxy['left']; sy = sxy['top']; sw = showObj.offsetWidth; sh = showObj.offsetHeight; } mw = menuObj.offsetWidth; mcw = menuObj.clientWidth; mh = menuObj.offsetHeight; mch = menuObj.clientHeight; switch(basePoint) { case 1: bpl = sx; bpt = sy; break; case 2: bpl = sx + sw; bpt = sy; break; case 3: bpl = sx + sw; bpt = sy + sh; break; case 4: bpl = sx; bpt = sy + sh; break; } switch(direction) { case 0: menuObj.style.left = (document.body.clientWidth - menuObj.clientWidth) / 2 + 'px'; mt = (document.documentElement.clientHeight - menuObj.clientHeight) / 2; break; case 1: ml = bpl - mw; mt = bpt - mh; break; case 2: ml = bpl; mt = bpt - mh; break; case 3: ml = bpl; mt = bpt; break; case 4: ml = bpl - mw; mt = bpt; break; } if(in_array(direction, [1, 4]) && ml < 0) { ml = bpl; if(in_array(basePoint, [1, 4])) ml += sw; } else if(ml + mw > document.documentElement.scrollLeft + document.body.clientWidth && sx >= mw) { ml = bpl - mw; if(in_array(basePoint, [2, 3])) ml -= sw; } if(in_array(direction, [1, 2]) && mt < 0) { mt = bpt; if(in_array(basePoint, [1, 2])) mt += sh; } else if(mt + mh > document.documentElement.scrollTop + document.documentElement.clientHeight && sy >= mh) { mt = bpt - mh; if(in_array(basePoint, [3, 4])) mt -= sh; } if(pos == '210') { ml += 69 - sw / 2; mt -= 5; if(showObj.tagName == 'TEXTAREA') { ml -= sw / 2; mt += sh / 2; } } if(direction == 0 || menuObj.scrolly) { if(BROWSER.ie && BROWSER.ie < 7) { if(direction == 0) mt += Math.max(document.documentElement.scrollTop, document.body.scrollTop); } else { if(menuObj.scrolly) mt -= Math.max(document.documentElement.scrollTop, document.body.scrollTop); menuObj.style.position = 'fixed'; } } if(ml) menuObj.style.left = ml + 'px'; if(mt) menuObj.style.top = mt + 'px'; if(direction == 0 && BROWSER.ie && !document.documentElement.clientHeight) { menuObj.style.position = 'absolute'; menuObj.style.top = (document.body.clientHeight - menuObj.clientHeight) / 2 + 'px'; } if(menuObj.style.clip && !BROWSER.opera) { menuObj.style.clip = 'rect(auto, auto, auto, auto)'; } } function fetchOffset(obj) { var left_offset = 0, top_offset = 0; if(obj.getBoundingClientRect){ var rect = obj.getBoundingClientRect(); var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop); var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft); if(document.documentElement.dir == 'rtl') { scrollLeft = scrollLeft + document.documentElement.clientWidth - document.documentElement.scrollWidth; } left_offset = rect.left + scrollLeft - document.documentElement.clientLeft; top_offset = rect.top + scrollTop - document.documentElement.clientTop; } if(left_offset <= 0 || top_offset <= 0) { left_offset = obj.offsetLeft; top_offset = obj.offsetTop; while((obj = obj.offsetParent) != null) { left_offset += obj.offsetLeft; top_offset += obj.offsetTop; } } return { 'left' : left_offset, 'top' : top_offset }; } function hideMenu(attr, mtype) { attr = isUndefined(attr) ? '' : attr; mtype = isUndefined(mtype) ? 'menu' : mtype; if(attr == '') { for(var i = 1; i <= JSMENU['layer']; i++) { hideMenu(i, mtype); } return; } else if(typeof attr == 'number') { for(var j in JSMENU['active'][attr]) { hideMenu(JSMENU['active'][attr][j], mtype); } return; } else if(typeof attr == 'string') { var menuObj = $(attr); if(!menuObj || (mtype && menuObj.mtype != mtype)) return; clearTimeout(JSMENU['timer'][attr]); var hide = function() { if(menuObj.cache) { menuObj.style.display = 'none'; if(menuObj.cover) $(attr + '_cover').style.display = 'none'; } else { menuObj.parentNode.removeChild(menuObj); if(menuObj.cover) $(attr + '_cover').parentNode.removeChild($(attr + '_cover')); } var tmp = []; for(var k in JSMENU['active'][menuObj.layer]) { if(attr != JSMENU['active'][menuObj.layer][k]) tmp.push(JSMENU['active'][menuObj.layer][k]); } JSMENU['active'][menuObj.layer] = tmp; }; if(menuObj.fade) { var O = 100; var fadeOut = function(O) { if(O == 0) { clearTimeout(fadeOutTimer); hide(); return; } menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + O + ')'; menuObj.style.opacity = O / 100; O -= 10; var fadeOutTimer = setTimeout(function () { fadeOut(O); }, 50); }; fadeOut(O); } else { hide(); } } } function showPrompt(ctrlid, evt, msg, timeout, negligible) { var menuid = ctrlid ? ctrlid + '_pmenu' : 'ntcwin'; var duration = timeout ? 0 : 3; if(!$(menuid)) { var div = document.createElement('div'); div.id = menuid; div.className = ctrlid ? 'promptmenu up' : 'ntcwin'; div.style.display = 'none'; $('append_parent').appendChild(div); if(ctrlid) { msg = '<div id="' + ctrlid + '_prompt" class="promptcontent"><ul><li>' + msg + '</li></ul></div>'; } else { msg = negligible ? msg : '<span style="font-style: normal;">' + msg + '</span>'; msg = '<table cellspacing="0" cellpadding="0" class="popupcredit"><tr><td class="pc_l">&nbsp;</td><td class="pc_c"><div class="pc_inner">' + msg + (negligible ? '<a class="pc_btn" href="javascript:;" onclick="display(\'ntcwin\');setcookie(\'discuz_creditnoticedisable\', 1, 31536000);" title="不要再提示我"><img src="' + IMGDIR + '/popupcredit_btn.gif" alt="不要再提示我" /></a>' : '') + '</td><td class="pc_r">&nbsp;</td></tr></table>'; } div.innerHTML = msg; } if(ctrlid) { if($(ctrlid).evt !== false) { var prompting = function() { showMenu({'mtype':'prompt','ctrlid':ctrlid,'evt':evt,'menuid':menuid,'pos':'210'}); }; if(evt == 'click') { $(ctrlid).onclick = prompting; } else { $(ctrlid).onmouseover = prompting; } } showMenu({'mtype':'prompt','ctrlid':ctrlid,'evt':evt,'menuid':menuid,'pos':'210','duration':duration,'timeout':timeout,'fade':1,'zindex':JSMENU['zIndex']['prompt']}); $(ctrlid).unselectable = false; } else { showMenu({'mtype':'prompt','pos':'00','menuid':menuid,'duration':duration,'timeout':timeout,'fade':1,'zindex':JSMENU['zIndex']['prompt']}); } } function showCreditPrompt() { var notice = getcookie('discuz_creditnotice').split('D'); if(notice.length < 2 || notice[9] != discuz_uid || getcookie('discuz_creditnoticedisable')) { return; } var creditnames = creditnotice.split(','); var creditinfo = []; var s = ''; var e; for(var i in creditnames) { e = creditnames[i].split('|'); creditinfo[e[0]] = [e[1], e[2]]; } for(i = 1; i <= 8; i++) { if(notice[i] != 0 && creditinfo[i]) { s += '<span>' + creditinfo[i][0] + (notice[i] > 0 ? '<em>+' : '<em class="desc">') + notice[i] + '</em>' + creditinfo[i][1] + '</span>'; } } s && showPrompt(null, null, s, 2000, 1); setcookie('discuz_creditnotice', '', -2592000); } function showDialog(msg, mode, t, func, cover) { cover = isUndefined(cover) ? (mode == 'info' ? 0 : 1) : cover; mode = in_array(mode, ['confirm', 'notice', 'info']) ? mode : 'alert'; var menuid = 'fwin_dialog'; var menuObj = $(menuid); if(menuObj) hideMenu('fwin_dialog', 'dialog'); menuObj = document.createElement('div'); menuObj.style.display = 'none'; menuObj.className = 'fwinmask'; menuObj.id = menuid; $('append_parent').appendChild(menuObj); var s = '<table cellpadding="0" cellspacing="0" class="fwin"><tr><td class="t_l"></td><td class="t_c"></td><td class="t_r"></td></tr><tr><td class="m_l"></td><td class="m_c"><div class="fcontent' + (mode == 'info' ? '' : ' alert_win') + '"><h3 class="float_ctrl"><em>'; s += t ? t : '提示信息'; s += '</em><span><a href="javascript:;" class="float_close" onclick="hideMenu(\'' + menuid + '\', \'dialog\')" title="关闭">关闭</a></span></h3>'; if(mode == 'info') { s += msg ? msg : ''; } else { s += '<hr class="shadowline" />'; s += '<div class="postbox"><div class="' + (mode == 'alert' ? 'alert_error' : 'alert_info') + '"><p>' + msg + '</p></div>'; s += '<div class="alert_btn"><input type="button" id="fwin_dialog_submit" value="&nbsp;确定&nbsp;" />'; s += mode == 'confirm' ? '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" onclick="hideMenu(\'' + menuid + '\', \'dialog\')" value="&nbsp;取消&nbsp;" />' : ''; s += '</div></div>'; } s += '</div></td><td class="m_r"></td></tr><tr><td class="b_l"></td><td class="b_c"></td><td class="b_r"></td></tr></table>'; menuObj.innerHTML = s; if($('fwin_dialog_submit')) $('fwin_dialog_submit').onclick = function() { if(typeof func == 'function') func(); else eval(func); hideMenu(menuid, 'dialog') }; showMenu({'mtype':'dialog','menuid':menuid,'duration':3,'pos':'00','zindex':JSMENU['zIndex']['dialog'],'cache':0,'cover':cover}); } function showWindow(k, url, mode, cache) { mode = isUndefined(mode) ? 'get' : mode; cache = isUndefined(cache) ? 1 : cache; var menuid = 'fwin_' + k; var menuObj = $(menuid); if(disallowfloat && disallowfloat.indexOf(k) != -1) { if(BROWSER.ie) url += (url.indexOf('?') != -1 ? '&' : '?') + 'referer=' + escape(location.href); location.href = url; return; } var fetchContent = function() { if(mode == 'get') { menuObj.url = url; url += (url.search(/\?/) > 0 ? '&' : '?') + 'infloat=yes&handlekey=' + k; ajaxget(url, 'fwin_content_' + k, null, '', '', function() {initMenu();show();}); } else if(mode == 'post') { menuObj.act = $(url).action; ajaxpost(url, 'fwin_content_' + k, '', '', '', function() {initMenu();show();}); } showDialog('', 'info', '<img src="' + IMGDIR + '/loading.gif"> 加载中...'); }; var initMenu = function() { var objs = menuObj.getElementsByTagName('*'); for(var i = 0; i < objs.length; i++) { if(objs[i].id) { objs[i].setAttribute('fwin', k); } if(objs[i].className == 'float_ctrl') { if(!objs[i].id) objs[i].id = 'fctrl_' + k; drag = objs[i].id; } } }; var show = function() { hideMenu('fwin_dialog', 'dialog'); showMenu({'mtype':'win','menuid':menuid,'duration':3,'pos':'00','zindex':JSMENU['zIndex']['win'],'drag':typeof drag == 'undefined' ? '' : drag,'cache':cache}); }; if(!menuObj) { menuObj = document.createElement('div'); menuObj.id = menuid; menuObj.className = 'fwinmask'; menuObj.style.display = 'none'; $('append_parent').appendChild(menuObj); menuObj.innerHTML = '<table cellpadding="0" cellspacing="0" class="fwin"><tr><td class="t_l"></td><td class="t_c"></td><td class="t_r"></td></tr><tr><td class="m_l"></td><td class="m_c" id="fwin_content_' + k + '">' + '</td><td class="m_r"></td></tr><tr><td class="b_l"></td><td class="b_c"></td><td class="b_r"></td></tr></table>'; fetchContent(); } else if((mode == 'get' && url != menuObj.url) || (mode == 'post' && $(url).action != menuObj.act)) { fetchContent(); } else { show(); } doane(); } function hideWindow(k) { hideMenu('fwin_' + k, 'win'); hideMenu(); hideMenu('', 'prompt'); } function Ajax(recvType, waitId) { for(var stackId = 0; stackId < AJAX['stack'].length && AJAX['stack'][stackId] != 0; stackId++); AJAX['stack'][stackId] = 1; var aj = new Object(); aj.loading = '加载中...'; aj.recvType = recvType ? recvType : 'XML'; aj.waitId = waitId ? $(waitId) : null; aj.resultHandle = null; aj.sendString = ''; aj.targetUrl = ''; aj.stackId = 0; aj.stackId = stackId; aj.setLoading = function(loading) { if(typeof loading !== 'undefined' && loading !== null) aj.loading = loading; }; aj.setRecvType = function(recvtype) { aj.recvType = recvtype; }; aj.setWaitId = function(waitid) { aj.waitId = typeof waitid == 'object' ? waitid : $(waitid); }; aj.createXMLHttpRequest = function() { var request = false; if(window.XMLHttpRequest) { request = new XMLHttpRequest(); if(request.overrideMimeType) { request.overrideMimeType('text/xml'); } } else if(window.ActiveXObject) { var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP']; for(var i=0; i<versions.length; i++) { try { request = new ActiveXObject(versions[i]); if(request) { return request; } } catch(e) {} } } return request; }; aj.XMLHttpRequest = aj.createXMLHttpRequest(); aj.showLoading = function() { if(aj.waitId && (aj.XMLHttpRequest.readyState != 4 || aj.XMLHttpRequest.status != 200)) { aj.waitId.style.display = ''; aj.waitId.innerHTML = '<span><img src="' + IMGDIR + '/loading.gif"> ' + aj.loading + '</span>'; } }; aj.processHandle = function() { if(aj.XMLHttpRequest.readyState == 4 && aj.XMLHttpRequest.status == 200) { for(k in AJAX['url']) { if(AJAX['url'][k] == aj.targetUrl) { AJAX['url'][k] = null; } } if(aj.waitId) { aj.waitId.style.display = 'none'; } if(aj.recvType == 'HTML') { aj.resultHandle(aj.XMLHttpRequest.responseText, aj); } else if(aj.recvType == 'XML') { if(aj.XMLHttpRequest.responseXML.lastChild) { aj.resultHandle(aj.XMLHttpRequest.responseXML.lastChild.firstChild.nodeValue, aj); } else { if(AJAX['debug']) { var error = mb_cutstr(aj.XMLHttpRequest.responseText.replace(/\r?\n/g, '\\n').replace(/"/g, '\\\"'), 200); aj.resultHandle('<root>ajaxerror<script type="text/javascript" reload="1">showDialog(\'Ajax Error: \\n' + error + '\');</script></root>', aj); } } } AJAX['stack'][aj.stackId] = 0; } }; aj.get = function(targetUrl, resultHandle) { setTimeout(function(){aj.showLoading()}, 250); if(in_array(targetUrl, AJAX['url'])) { return false; } else { AJAX['url'].push(targetUrl); } aj.targetUrl = targetUrl; aj.XMLHttpRequest.onreadystatechange = aj.processHandle; aj.resultHandle = resultHandle; var attackevasive = isUndefined(attackevasive) ? 0 : attackevasive; var delay = attackevasive & 1 ? (aj.stackId + 1) * 1001 : 100; if(window.XMLHttpRequest) { setTimeout(function(){ aj.XMLHttpRequest.open('GET', aj.targetUrl); aj.XMLHttpRequest.send(null);}, delay); } else { setTimeout(function(){ aj.XMLHttpRequest.open("GET", targetUrl, true); aj.XMLHttpRequest.send();}, delay); } }; aj.post = function(targetUrl, sendString, resultHandle) { setTimeout(function(){aj.showLoading()}, 250); if(in_array(targetUrl, AJAX['url'])) { return false; } else { AJAX['url'].push(targetUrl); } aj.targetUrl = targetUrl; aj.sendString = sendString; aj.XMLHttpRequest.onreadystatechange = aj.processHandle; aj.resultHandle = resultHandle; aj.XMLHttpRequest.open('POST', targetUrl); aj.XMLHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); aj.XMLHttpRequest.send(aj.sendString); }; return aj; } function newfunction(func){ var args = []; for(var i=1; i<arguments.length; i++) args.push(arguments[i]); return function(event){ doane(event); window[func].apply(window, args); return false; } } function evalscript(s) { if(s.indexOf('<script') == -1) return s; var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig; var arr = []; while(arr = p.exec(s)) { var p1 = /<script[^\>]*?src=\"([^\>]*?)\"[^\>]*?(reload=\"1\")?(?:charset=\"([\w\-]+?)\")?><\/script>/i; var arr1 = []; arr1 = p1.exec(arr[0]); if(arr1) { appendscript(arr1[1], '', arr1[2], arr1[3]); } else { p1 = /<script(.*?)>([^\x00]+?)<\/script>/i; arr1 = p1.exec(arr[0]); appendscript('', arr1[2], arr1[1].indexOf('reload=') != -1); } } return s; } function appendscript(src, text, reload, charset) { var id = hash(src + text); var evalscripts = []; if(!reload && in_array(id, evalscripts)) return; if(reload && $(id)) { $(id).parentNode.removeChild($(id)); } evalscripts.push(id); var scriptNode = document.createElement("script"); scriptNode.type = "text/javascript"; scriptNode.id = id; scriptNode.charset = charset ? charset : (BROWSER.firefox ? document.characterSet : document.charset); try { if(src) { scriptNode.src = src; } else if(text){ scriptNode.text = text; } $('append_parent').appendChild(scriptNode); } catch(e) {} } function stripscript(s) { return s.replace(/<script.*?>.*?<\/script>/ig, ''); } function ajaxupdateevents(obj, tagName) { tagName = tagName ? tagName : 'A'; var objs = obj.getElementsByTagName(tagName); for(k in objs) { var o = objs[k]; ajaxupdateevent(o); } } function ajaxupdateevent(o) { if(typeof o == 'object' && o.getAttribute) { if(o.getAttribute('ajaxtarget')) { if(!o.id) o.id = Math.random(); var ajaxevent = o.getAttribute('ajaxevent') ? o.getAttribute('ajaxevent') : 'click'; var ajaxurl = o.getAttribute('ajaxurl') ? o.getAttribute('ajaxurl') : o.href; _attachEvent(o, ajaxevent, newfunction('ajaxget', ajaxurl, o.getAttribute('ajaxtarget'), o.getAttribute('ajaxwaitid'), o.getAttribute('ajaxloading'), o.getAttribute('ajaxdisplay'))); if(o.getAttribute('ajaxfunc')) { o.getAttribute('ajaxfunc').match(/(\w+)\((.+?)\)/); _attachEvent(o, ajaxevent, newfunction(RegExp.$1, RegExp.$2)); } } } } /* *@ url: 需求请求的 url *@ id : 显示的 id *@ waitid: 等待的 id,默认为显示的 id,如果 waitid 为空字符串,则不显示 loading..., 如果为 null,则在 showid 区域显示 *@ linkid: 是哪个链接触发的该 ajax 请求,该对象的属性(如 ajaxdisplay)保存了一些 ajax 请求过程需要的数据。 */ function ajaxget(url, showid, waitid, loading, display, recall) { waitid = typeof waitid == 'undefined' || waitid === null ? showid : waitid; var x = new Ajax(); x.setLoading(loading); x.setWaitId(waitid); x.display = typeof display == 'undefined' || display == null ? '' : display; x.showId = $(showid); if(x.showId) x.showId.orgdisplay = typeof x.showId.orgdisplay === 'undefined' ? x.showId.style.display : x.showId.orgdisplay; if(url.substr(strlen(url) - 1) == '#') { url = url.substr(0, strlen(url) - 1); x.autogoto = 1; } var url = url + '&inajax=1&ajaxtarget=' + showid; x.get(url, function(s, x) { var evaled = false; if(s.indexOf('ajaxerror') != -1) { evalscript(s); evaled = true; } if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) { if(x.showId) { x.showId.style.display = x.showId.orgdisplay; x.showId.style.display = x.display; x.showId.orgdisplay = x.showId.style.display; ajaxinnerhtml(x.showId, s); ajaxupdateevents(x.showId); if(x.autogoto) scroll(0, x.showId.offsetTop); } } ajaxerror = null; if(typeof recall == 'function') { recall(); } else { eval(recall); } if(!evaled) evalscript(s); }); } function ajaxpost(formid, showid, waitid, showidclass, submitbtn, recall) { var waitid = typeof waitid == 'undefined' || waitid === null ? showid : (waitid !== '' ? waitid : ''); var showidclass = !showidclass ? '' : showidclass; var ajaxframeid = 'ajaxframe'; var ajaxframe = $(ajaxframeid); var formtarget = $(formid).target; var handleResult = function() { var s = ''; var evaled = false; showloading('none'); try { if(BROWSER.ie) { s = $(ajaxframeid).contentWindow.document.XMLDocument.text; } else { s = $(ajaxframeid).contentWindow.document.documentElement.firstChild.nodeValue; } } catch(e) { if(AJAX['debug']) { var error = mb_cutstr($(ajaxframeid).contentWindow.document.body.innerText.replace(/\r?\n/g, '\\n').replace(/"/g, '\\\"'), 200); s = '<root>ajaxerror<script type="text/javascript" reload="1">showDialog(\'Ajax Error: \\n' + error + '\');</script></root>'; } } if(s != '' && s.indexOf('ajaxerror') != -1) { evalscript(s); evaled = true; } if(showidclass) { $(showid).className = showidclass; if(submitbtn) { submitbtn.disabled = false; } } if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) { ajaxinnerhtml($(showid), s); } ajaxerror = null; if($(formid)) $(formid).target = formtarget; if(typeof recall == 'function') { recall(); } else { eval(recall); } if(!evaled) evalscript(s); ajaxframe.loading = 0; $('append_parent').removeChild(ajaxframe); }; if(!ajaxframe) { if (BROWSER.ie) { ajaxframe = document.createElement('<iframe name="' + ajaxframeid + '" id="' + ajaxframeid + '"></iframe>'); } else { ajaxframe = document.createElement('iframe'); ajaxframe.name = ajaxframeid; ajaxframe.id = ajaxframeid; } ajaxframe.style.display = 'none'; ajaxframe.loading = 1; $('append_parent').appendChild(ajaxframe); } else if(ajaxframe.loading) { return false; } _attachEvent(ajaxframe, 'load', handleResult); showloading(); $(formid).target = ajaxframeid; $(formid).action += '&inajax=1'; $(formid).submit(); return false; } function ajaxmenu(ctrlObj, timeout, cache, duration, pos, recall) { var ctrlid = ctrlObj.id; if(!ctrlid) { ctrlid = ctrlObj.id = 'ajaxid_' + Math.random(); } var menuid = ctrlid + '_menu'; var menu = $(menuid); if(isUndefined(timeout)) timeout = 3000; if(isUndefined(cache)) cache = 1; if(isUndefined(pos)) pos = '43'; if(isUndefined(duration)) duration = timeout > 0 ? 0 : 3; var func = function() { showMenu({'ctrlid':ctrlid,'duration':duration,'timeout':timeout,'pos':pos,'cache':cache,'layer':2}); if(typeof recall == 'function') { recall(); } else { eval(recall); } }; if(menu) { if(menu.style.display == '') { hideMenu(menuid); } else { func(); } } else { menu = document.createElement('div'); menu.id = menuid; menu.style.display = 'none'; menu.className = 'popupmenu_popup'; menu.innerHTML = '<div class="popupmenu_option" id="' + menuid + '_content"></div>'; $('append_parent').appendChild(menu); ajaxget(!isUndefined(ctrlObj.href) ? ctrlObj.href : ctrlObj.attributes['href'].value, menuid + '_content', 'ajaxwaitid', '', '', func); } } function hash(string, length) { var length = length ? length : 32; var start = 0; var i = 0; var result = ''; filllen = length - string.length % length; for(i = 0; i < filllen; i++){ string += "0"; } while(start < string.length) { result = stringxor(result, string.substr(start, length)); start += length; } return result; } function stringxor(s1, s2) { var s = ''; var hash = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; var max = Math.max(s1.length, s2.length); for(var i=0; i<max; i++) { var k = s1.charCodeAt(i) ^ s2.charCodeAt(i); s += hash.charAt(k % 52); } return s; } function showloading(display, waiting) { var display = display ? display : 'block'; var waiting = waiting ? waiting : '页面加载中...'; $('ajaxwaitid').innerHTML = waiting; $('ajaxwaitid').style.display = display; } function ajaxinnerhtml(showid, s) { if(showid.tagName != 'TBODY') { showid.innerHTML = s; } else { while(showid.firstChild) { showid.firstChild.parentNode.removeChild(showid.firstChild); } var div1 = document.createElement('DIV'); div1.id = showid.id+'_div'; div1.innerHTML = '<table><tbody id="'+showid.id+'_tbody">'+s+'</tbody></table>'; $('append_parent').appendChild(div1); var trs = div1.getElementsByTagName('TR'); var l = trs.length; for(var i=0; i<l; i++) { showid.appendChild(trs[0]); } var inputs = div1.getElementsByTagName('INPUT'); var l = inputs.length; for(var i=0; i<l; i++) { showid.appendChild(inputs[0]); } div1.parentNode.removeChild(div1); } } function AC_GetArgs(args, classid, mimeType) { var ret = new Object(); ret.embedAttrs = new Object(); ret.params = new Object(); ret.objAttrs = new Object(); for (var i = 0; i < args.length; i = i + 2){ var currArg = args[i].toLowerCase(); switch (currArg){ case "classid":break; case "pluginspage":ret.embedAttrs[args[i]] = 'http://www.macromedia.com/go/getflashplayer';break; case "src":ret.embedAttrs[args[i]] = args[i+1];ret.params["movie"] = args[i+1];break; case "codebase":ret.objAttrs[args[i]] = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0';break; case "onafterupdate":case "onbeforeupdate":case "onblur":case "oncellchange":case "onclick":case "ondblclick":case "ondrag":case "ondragend": case "ondragenter":case "ondragleave":case "ondragover":case "ondrop":case "onfinish":case "onfocus":case "onhelp":case "onmousedown": case "onmouseup":case "onmouseover":case "onmousemove":case "onmouseout":case "onkeypress":case "onkeydown":case "onkeyup":case "onload": case "onlosecapture":case "onpropertychange":case "onreadystatechange":case "onrowsdelete":case "onrowenter":case "onrowexit":case "onrowsinserted":case "onstart": case "onscroll":case "onbeforeeditfocus":case "onactivate":case "onbeforedeactivate":case "ondeactivate":case "type": case "id":ret.objAttrs[args[i]] = args[i+1];break; case "width":case "height":case "align":case "vspace": case "hspace":case "class":case "title":case "accesskey":case "name": case "tabindex":ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];break; default:ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1]; } } ret.objAttrs["classid"] = classid; if(mimeType) { ret.embedAttrs["type"] = mimeType; } return ret; } function AC_DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { var versionStr = -1; if(navigator.plugins != null && navigator.plugins.length > 0 && (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"])) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if(versionRevision == "") { versionRevision = descArray[4]; } if(versionRevision[0] == "d") { versionRevision = versionRevision.substring(1); } else if(versionRevision[0] == "r") { versionRevision = versionRevision.substring(1); if(versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); } } versionStr = versionMajor + "." + versionMinor + "." + versionRevision; } else if(BROWSER.ie && !BROWSER.opera) { try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); versionStr = axo.GetVariable("$version"); } catch (e) {} } if(versionStr == -1 ) { return false; } else if(versionStr != 0) { if(BROWSER.ie && !BROWSER.opera) { tempArray = versionStr.split(" "); tempString = tempArray[1]; versionArray = tempString.split(","); } else { versionArray = versionStr.split("."); } var versionMajor = versionArray[0]; var versionMinor = versionArray[1]; var versionRevision = versionArray[2]; return versionMajor > parseFloat(reqMajorVer) || (versionMajor == parseFloat(reqMajorVer)) && (versionMinor > parseFloat(reqMinorVer) || versionMinor == parseFloat(reqMinorVer) && versionRevision >= parseFloat(reqRevision)); } } function AC_FL_RunContent() { var str = ''; if(AC_DetectFlashVer(9,0,124)) { var ret = AC_GetArgs(arguments, "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash"); if(BROWSER.ie && !BROWSER.opera) { str += '<object '; for (var i in ret.objAttrs) { str += i + '="' + ret.objAttrs[i] + '" '; } str += '>'; for (var i in ret.params) { str += '<param name="' + i + '" value="' + ret.params[i] + '" /> '; } str += '</object>'; } else { str += '<embed '; for (var i in ret.embedAttrs) { str += i + '="' + ret.embedAttrs[i] + '" '; } str += '></embed>'; } } else { str = '此内容需要 Adobe Flash Player 9.0.124 或更高版本<br /><a href="http://www.adobe.com/go/getflashplayer/" target="_blank"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="下载 Flash Player" /></a>'; } return str; } function simulateSelect(selectId) { var selectObj = $(selectId); var defaultopt = defaultv = ''; var menuObj = document.createElement('div'); var ul = document.createElement('ul'); var handleKeyDown = function(e) { e = BROWSER.ie ? event : e; if(e.keyCode == 40 || e.keyCode == 38) doane(e); }; for(var i = 0; i < selectObj.options.length; i++) { var li = document.createElement('li'); li.innerHTML = selectObj.options[i].innerHTML; li.k_id = i; li.k_value = selectObj.options[i].value; if(selectObj.options[i].selected) { defaultopt = selectObj.options[i].innerHTML; defaultv = selectObj.options[i].value; li.className = 'current'; selectObj.setAttribute('selecti', i); } li.onclick = function() { if($(selectId + '_ctrl').innerHTML != this.innerHTML) { var lis = menuObj.getElementsByTagName('li'); lis[$(selectId).getAttribute('selecti')].className = ''; this.className = 'current'; $(selectId + '_ctrl').innerHTML = this.innerHTML; $(selectId).setAttribute('selecti', this.k_id); $(selectId).options.length = 0; $(selectId).options[0] = new Option('', this.k_value); eval(selectObj.getAttribute('change')); } hideMenu(menuObj.id); return false; }; ul.appendChild(li); } selectObj.options.length = 0; selectObj.options[0]= new Option('', defaultv); selectObj.style.display = 'none'; selectObj.outerHTML += '<a href="javascript:;" hidefocus="true" id="' + selectId + '_ctrl" tabindex="1">' + defaultopt + '</a>'; menuObj.id = selectId + '_ctrl_menu'; menuObj.className = 'select_menu'; menuObj.style.display = 'none'; menuObj.appendChild(ul); $('append_parent').appendChild(menuObj); $(selectId + '_ctrl').onclick = function(e) { $(selectId + '_ctrl_menu').style.width = (BROWSER.ie ? Math.max($(selectId + '_ctrl').clientWidth, parseInt($(selectId + '_ctrl').currentStyle.width)) : $(selectId + '_ctrl').clientWidth) + 'px'; showMenu({'ctrlid':(selectId == 'loginfield' ? 'account' : selectId + '_ctrl'),'menuid':selectId + '_ctrl_menu','evt':'click','pos':'13'}); doane(e); }; $(selectId + '_ctrl').onfocus = menuObj.onfocus = function() { _attachEvent(document.body, 'keydown', handleKeyDown); }; $(selectId + '_ctrl').onblur = menuObj.onblur = function() { _detachEvent(document.body, 'keydown', handleKeyDown); }; $(selectId + '_ctrl').onkeyup = function(e) { e = e ? e : window.event; value = e.keyCode; if(value == 40 || value == 38) { if(menuObj.style.display == 'none') { $(selectId + '_ctrl').click(); } else { lis = menuObj.getElementsByTagName('li'); selecti = selectObj.getAttribute('selecti'); lis[selecti].className = ''; if(value == 40) { selecti = parseInt(selecti) + 1; } else if(value == 38) { selecti = parseInt(selecti) - 1; } if(selecti < 0) { selecti = lis.length - 1 } else if(selecti > lis.length - 1) { selecti = 0; } lis[selecti].className = 'current'; selectObj.setAttribute('selecti', selecti); lis[selecti].parentNode.scrollTop = lis[selecti].offsetTop; } } else if(value == 13) { var lis = menuObj.getElementsByTagName('li'); lis[selectObj.getAttribute('selecti')].click(); } else if(value == 27) { hideMenu(menuObj.id); } }; } function detectCapsLock(e, obj) { var valueCapsLock = e.keyCode ? e.keyCode : e.which; var valueShift = e.shiftKey ? e.shiftKey : (valueCapsLock == 16 ? true : false); this.clearDetect = function () { obj.className = 'txt'; }; obj.className = (valueCapsLock >= 65 && valueCapsLock <= 90 && !valueShift || valueCapsLock >= 97 && valueCapsLock <= 122 && valueShift) ? 'capslock txt' : 'txt'; if(BROWSER.ie) { event.srcElement.onblur = this.clearDetect; } else { e.target.onblur = this.clearDetect; } } function switchTab(prefix, current, total) { for(i = 1; i <= total;i++) { $(prefix + '_' + i).className = ''; $(prefix + '_c_' + i).style.display = 'none'; } $(prefix + '_' + current).className = 'current'; $(prefix + '_c_' + current).style.display = ''; } function keyPageScroll(e, prev, next, url, page) { e = e ? e : window.event; var tagname = BROWSER.ie ? e.srcElement.tagName : e.target.tagName; if(tagname == 'INPUT' || tagname == 'TEXTAREA') return; actualCode = e.keyCode ? e.keyCode : e.charCode; if(next && actualCode == 39) { window.location = url + '&page=' + (page + 1); } if(prev && actualCode == 37) { window.location = url + '&page=' + (page - 1); } } function showselect(obj, inpid, t, rettype) { if(!obj.id) { var t = !t ? 0 : t; var rettype = !rettype ? 0 : rettype; obj.id = 'calendarexp_' + Math.random(); div = document.createElement('div'); div.id = obj.id + '_menu'; div.style.display = 'none'; div.className = 'showselect_menu'; $('append_parent').appendChild(div); s = ''; if(!t) { s += showselect_row(inpid, '一天', 1, 0, rettype); s += showselect_row(inpid, '一周', 7, 0, rettype); s += showselect_row(inpid, '一个月', 30, 0, rettype); s += showselect_row(inpid, '三个月', 90, 0, rettype); s += showselect_row(inpid, '自定义', -2); } else { if($(t)) { var lis = $(t).getElementsByTagName('LI'); for(i = 0;i < lis.length;i++) { s += '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = this.innerHTML">' + lis[i].innerHTML + '</a><br />'; } s += showselect_row(inpid, '自定义', -1); } else { s += '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = \'0\'">永久</a><br />'; s += showselect_row(inpid, '7 天', 7, 1, rettype); s += showselect_row(inpid, '14 天', 14, 1, rettype); s += showselect_row(inpid, '一个月', 30, 1, rettype); s += showselect_row(inpid, '三个月', 90, 1, rettype); s += showselect_row(inpid, '半年', 182, 1, rettype); s += showselect_row(inpid, '一年', 365, 1, rettype); s += showselect_row(inpid, '自定义', -1); } } $(div.id).innerHTML = s; } showMenu({'ctrlid':obj.id,'evt':'click'}); if(BROWSER.ie && BROWSER.ie < 7) { doane(event); } } function showselect_row(inpid, s, v, notime, rettype) { if(v >= 0) { if(!rettype) { var notime = !notime ? 0 : 1; t = today.getTime(); t += 86400000 * v; d = new Date(); d.setTime(t); return '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = \'' + d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + (!notime ? ' ' + d.getHours() + ':' + d.getMinutes() : '') + '\'">' + s + '</a><br />'; } else { return '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = \'' + v + '\'">' + s + '</a><br />'; } } else if(v == -1) { return '<a href="javascript:;" onclick="$(\'' + inpid + '\').focus()">' + s + '</a><br />'; } else if(v == -2) { return '<a href="javascript:;" onclick="$(\'' + inpid + '\').onclick()">' + s + '</a><br />'; } } function showColorBox(ctrlid, layer, k) { if(!$(ctrlid + '_menu')) { var menu = document.createElement('div'); menu.id = ctrlid + '_menu'; menu.className = 'popupmenu_popup colorbox'; menu.unselectable = true; menu.style.display = 'none'; var coloroptions = ['Black', 'Sienna', 'DarkOliveGreen', 'DarkGreen', 'DarkSlateBlue', 'Navy', 'Indigo', 'DarkSlateGray', 'DarkRed', 'DarkOrange', 'Olive', 'Green', 'Teal', 'Blue', 'SlateGray', 'DimGray', 'Red', 'SandyBrown', 'YellowGreen','SeaGreen', 'MediumTurquoise','RoyalBlue', 'Purple', 'Gray', 'Magenta', 'Orange', 'Yellow', 'Lime', 'Cyan', 'DeepSkyBlue', 'DarkOrchid', 'Silver', 'Pink', 'Wheat', 'LemonChiffon', 'PaleGreen', 'PaleTurquoise', 'LightBlue', 'Plum', 'White']; var str = ''; for(var i = 0; i < 40; i++) { str += '<input type="button" style="background-color: ' + coloroptions[i] + '" onclick="' + (typeof wysiwyg == 'undefined' ? 'seditor_insertunit(\'' + k + '\', \'[color=' + coloroptions[i] + ']\', \'[/color]\')' : (ctrlid == editorid + '_cmd_table_param_4' ? '$(\'' + ctrlid + '\').value=\'' + coloroptions[i] + '\';hideMenu(2)' : 'discuzcode(\'forecolor\', \'' + coloroptions[i] + '\')')) + '" title="' + coloroptions[i] + '" />' + (i < 39 && (i + 1) % 8 == 0 ? '<br />' : ''); } menu.innerHTML = str; $('append_parent').appendChild(menu); } showMenu({'ctrlid':ctrlid,'evt':'click','layer':layer}); } function announcement() { var ann = new Object(); ann.anndelay = 3000;ann.annst = 0;ann.annstop = 0;ann.annrowcount = 0;ann.anncount = 0;ann.annlis = $('annbody').getElementsByTagName("LI");ann.annrows = new Array(); ann.announcementScroll = function () { if(this.annstop) { this.annst = setTimeout(function () { ann.announcementScroll(); }, this.anndelay);return; } if(!this.annst) { var lasttop = -1; for(i = 0;i < this.annlis.length;i++) { if(lasttop != this.annlis[i].offsetTop) { if(lasttop == -1) lasttop = 0; this.annrows[this.annrowcount] = this.annlis[i].offsetTop - lasttop;this.annrowcount++; } lasttop = this.annlis[i].offsetTop; } if(this.annrows.length == 1) { $('ann').onmouseover = $('ann').onmouseout = null; } else { this.annrows[this.annrowcount] = this.annrows[1]; $('annbodylis').innerHTML += $('annbodylis').innerHTML; this.annst = setTimeout(function () { ann.announcementScroll(); }, this.anndelay); $('ann').onmouseover = function () { ann.annstop = 1; }; $('ann').onmouseout = function () { ann.annstop = 0; }; } this.annrowcount = 1; return; } if(this.annrowcount >= this.annrows.length) { $('annbody').scrollTop = 0; this.annrowcount = 1; this.annst = setTimeout(function () { ann.announcementScroll(); }, this.anndelay); } else { this.anncount = 0; this.announcementScrollnext(this.annrows[this.annrowcount]); } }; ann.announcementScrollnext = function (time) { $('annbody').scrollTop++; this.anncount++; if(this.anncount != time) { this.annst = setTimeout(function () { ann.announcementScrollnext(time); }, 10); } else { this.annrowcount++; this.annst = setTimeout(function () { ann.announcementScroll(); }, this.anndelay); } }; ann.announcementScroll(); } function removeindexheats() { return confirm('您确认要把此主题从热点主题中移除么?'); } function smilies_show(id, smcols, seditorkey) { if(seditorkey && !$(seditorkey + 'smilies_menu')) { var div = document.createElement("div"); div.id = seditorkey + 'smilies_menu'; div.style.display = 'none'; div.className = 'smilieslist'; $('append_parent').appendChild(div); var div = document.createElement("div"); div.id = id; div.style.overflow = 'hidden'; $(seditorkey + 'smilies_menu').appendChild(div); } if(typeof smilies_type == 'undefined') { var scriptNode = document.createElement("script"); scriptNode.type = "text/javascript"; scriptNode.charset = charset ? charset : (BROWSER.firefox ? document.characterSet : document.charset); scriptNode.src = 'forumdata/cache/smilies_var.js?' + VERHASH; $('append_parent').appendChild(scriptNode); if(BROWSER.ie) { scriptNode.onreadystatechange = function() { smilies_onload(id, smcols, seditorkey); }; } else { scriptNode.onload = function() { smilies_onload(id, smcols, seditorkey); }; } } else { smilies_onload(id, smcols, seditorkey); } } function smilies_onload(id, smcols, seditorkey) { seditorkey = !seditorkey ? '' : seditorkey; smile = getcookie('smile').split('D'); if(typeof smilies_type == 'object') { if(smile[0] && smilies_array[smile[0]]) { CURRENTSTYPE = smile[0]; } else { for(i in smilies_array) { CURRENTSTYPE = i; break; } } smiliestype = '<div class="smiliesgroup"><ul>'; for(i in smilies_type) { if(smilies_type[i][0]) { smiliestype += '<li><a href="javascript:;" hidefocus="true" ' + (CURRENTSTYPE == i ? 'class="current"' : '') + ' id="'+seditorkey+'stype_'+i+'" onclick="smilies_switch(\'' + id + '\', \'' + smcols + '\', '+i+', 1, \'' + seditorkey + '\');if(CURRENTSTYPE) {$(\''+seditorkey+'stype_\'+CURRENTSTYPE).className=\'\';}this.className=\'current\';CURRENTSTYPE='+i+';doane(event);">'+smilies_type[i][0]+'</a></li>'; } } smiliestype += '</ul></div>'; $(id).innerHTML = smiliestype + '<div id="' + id + '_data"></div><div class="smilieslist_page" id="' + id + '_page"></div>'; smilies_switch(id, smcols, CURRENTSTYPE, smile[1], seditorkey); } } function smilies_switch(id, smcols, type, page, seditorkey) { page = page ? page : 1; if(!smilies_array[type] || !smilies_array[type][page]) return; setcookie('smile', type + 'D' + page, 31536000); smiliesdata = '<table id="' + id + '_table" cellpadding="0" cellspacing="0"><tr>'; j = k = 0; img = []; for(i in smilies_array[type][page]) { if(j >= smcols) { smiliesdata += '<tr>'; j = 0; } s = smilies_array[type][page][i]; smilieimg = 'images/smilies/' + smilies_type[type][1] + '/' + s[2]; img[k] = new Image(); img[k].src = smilieimg; smiliesdata += s && s[0] ? '<td onmouseover="smilies_preview(\'' + seditorkey + '\', \'' + id + '\', this, ' + s[5] + ')" onclick="' + (typeof wysiwyg != 'undefined' ? 'insertSmiley(' + s[0] + ')': 'seditor_insertunit(\'' + seditorkey + '\', \'' + s[1].replace(/'/, '\\\'') + '\')') + '" id="' + seditorkey + 'smilie_' + s[0] + '_td"><img id="smilie_' + s[0] + '" width="' + s[3] +'" height="' + s[4] +'" src="' + smilieimg + '" alt="' + s[1] + '" />' : '<td>'; j++;k++; } smiliesdata += '</table>'; smiliespage = ''; if(smilies_array[type].length > 2) { prevpage = ((prevpage = parseInt(page) - 1) < 1) ? smilies_array[type].length - 1 : prevpage; nextpage = ((nextpage = parseInt(page) + 1) == smilies_array[type].length) ? 1 : nextpage; smiliespage = '<div class="pags_act"><a href="javascript:;" onclick="smilies_switch(\'' + id + '\', \'' + smcols + '\', ' + type + ', ' + prevpage + ', \'' + seditorkey + '\');doane(event);">上页</a>' + '<a href="javascript:;" onclick="smilies_switch(\'' + id + '\', \'' + smcols + '\', ' + type + ', ' + nextpage + ', \'' + seditorkey + '\');doane(event);">下页</a></div>' + page + '/' + (smilies_array[type].length - 1); } $(id + '_data').innerHTML = smiliesdata; $(id + '_page').innerHTML = smiliespage; } function smilies_preview(seditorkey, id, obj, w) { var menu = $('smilies_preview'); if(!menu) { menu = document.createElement('div'); menu.id = 'smilies_preview'; menu.className = 'smilies_preview'; menu.style.display = 'none'; $('append_parent').appendChild(menu); } menu.innerHTML = '<img width="' + w + '" src="' + obj.childNodes[0].src + '" />'; mpos = fetchOffset($(id + '_data')); spos = fetchOffset(obj); pos = spos['left'] >= mpos['left'] + $(id + '_data').offsetWidth / 2 ? '13' : '24'; showMenu({'ctrlid':obj.id,'showid':id + '_data','menuid':menu.id,'pos':pos,'layer':3}); } function seditor_ctlent(event, script) { if(event.ctrlKey && event.keyCode == 13 || event.altKey && event.keyCode == 83) { eval(script); } } function seditor_insertunit(key, text, textend, moveend) { $(key + 'message').focus(); textend = isUndefined(textend) ? '' : textend; moveend = isUndefined(textend) ? 0 : moveend; startlen = strlen(text); endlen = strlen(textend); if(!isUndefined($(key + 'message').selectionStart)) { var opn = $(key + 'message').selectionStart + 0; if(textend != '') { text = text + $(key + 'message').value.substring($(key + 'message').selectionStart, $(key + 'message').selectionEnd) + textend; } $(key + 'message').value = $(key + 'message').value.substr(0, $(key + 'message').selectionStart) + text + $(key + 'message').value.substr($(key + 'message').selectionEnd); if(!moveend) { $(key + 'message').selectionStart = opn + strlen(text) - endlen; $(key + 'message').selectionEnd = opn + strlen(text) - endlen; } } 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'); if(!moveend) { sel.moveStart('character', -endlen); sel.moveEnd('character', -endlen); } sel.select(); } else { $(key + 'message').value += text; } hideMenu(2); if(BROWSER.ie) { doane(); } } function parseurl(str, mode, parsecode) { if(isUndefined(parsecode)) parsecode = true; if(parsecode) str= str.replace(/\s*\[code\]([\s\S]+?)\[\/code\]\s*/ig, function($1, $2) {return codetag($2);}); str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(jpg|gif|png|bmp))/ig, mode == 'html' ? '$1<img src="$2" border="0">' : '$1[img]$2[/img]'); str = str.replace(/([^>=\]"'\/@]|^)((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast):\/\/))([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]'); str = str.replace(/([^\w>=\]"'\/@]|^)((www\.)([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]'); str = str.replace(/([^\w->=\]:"'\.\/]|^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1<a href="mailto:$2">$2</a>' : '$1[email]$2[/email]'); if(parsecode) { for(var i = 0; i <= DISCUZCODE['num']; i++) { str = str.replace("[\tDISCUZ_CODE_" + i + "\t]", DISCUZCODE['html'][i]); } } return str; } function codetag(text) { DISCUZCODE['num']++; if(typeof wysiwyg != 'undefined' && wysiwyg) text = text.replace(/<br[^\>]*>/ig, '\n').replace(/<(\/|)[A-Za-z].*?>/ig, ''); DISCUZCODE['html'][DISCUZCODE['num']] = '[code]' + text + '[/code]'; return '[\tDISCUZ_CODE_' + DISCUZCODE['num'] + '\t]'; } function pmchecknew() { ajaxget('pm.php?checknewpm=' + Math.random(), 'myprompt_check', 'ajaxwaitid'); } function showimmestatus(imme) { var lang = {'Online':'MSN 在线','Busy':'MSN 忙碌','Away':'MSN 离开','Offline':'MSN 脱机'}; $('imme_status_' + imme.id.substr(0, imme.id.indexOf('@'))).innerHTML = lang[imme.statusText]; } if(typeof IN_ADMINCP == 'undefined') { if(discuz_uid && !getcookie('checkpm')) { _attachEvent(window, 'load', pmchecknew, document); } if(creditnotice != '' && getcookie('discuz_creditnotice') && !getcookie('discuz_creditnoticedisable')) { _attachEvent(window, 'load', showCreditPrompt, document); } } if(BROWSER.ie) { document.documentElement.addBehavior("#default#userdata"); }
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/common.js
JavaScript
asf20
66,495
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: tree.js 19838 2009-09-11 06:36:37Z monkey $ */ var icon = new Object(); icon.root = IMGDIR + '/tree_root.gif'; icon.folder = IMGDIR + '/tree_folder.gif'; icon.folderOpen = IMGDIR + '/tree_folderopen.gif'; icon.file = IMGDIR + '/tree_file.gif'; icon.empty = IMGDIR + '/tree_empty.gif'; icon.line = IMGDIR + '/tree_line.gif'; icon.lineMiddle = IMGDIR + '/tree_linemiddle.gif'; icon.lineBottom = IMGDIR + '/tree_linebottom.gif'; icon.plus = IMGDIR + '/tree_plus.gif'; icon.plusMiddle = IMGDIR + '/tree_plusmiddle.gif'; icon.plusBottom = IMGDIR + '/tree_plusbottom.gif'; icon.minus = IMGDIR + '/tree_minus.gif'; icon.minusMiddle = IMGDIR + '/tree_minusmiddle.gif'; icon.minusBottom = IMGDIR + '/tree_minusbottom.gif'; function treeNode(id, pid, name, url, target, open) { var obj = new Object(); obj.id = id; obj.pid = pid; obj.name = name; obj.url = url; obj.target = target; obj.open = open; obj._isOpen = open; obj._lastChildId = 0; obj._pid = 0; return obj; } function dzTree(treeName) { this.nodes = new Array(); this.openIds = getcookie('discuz_leftmenu_openids'); this.pushNodes = new Array(); this.addNode = function(id, pid, name, url, target, open) { var theNode = new treeNode(id, pid, name, url, target, open); this.pushNodes.push(id); if(!this.nodes[pid]) { this.nodes[pid] = new Array(); } this.nodes[pid]._lastChildId = id; for(k in this.nodes) { if(this.openIds && this.openIds.indexOf('_' + theNode.id) != -1) { theNode._isOpen = true; } if(this.nodes[k].pid == id) { theNode._lastChildId = this.nodes[k].id; } } this.nodes[id] = theNode; }; this.show = function() { var s = '<div class="tree">'; s += this.createTree(this.nodes[0]); s += '</div>'; document.write(s); }; this.createTree = function(node, padding) { padding = padding ? padding : ''; if(node.id == 0){ var icon1 = ''; } else { var icon1 = '<img src="' + this.getIcon1(node) + '" onclick="' + treeName + '.switchDisplay(\'' + node.id + '\')" id="icon1_' + node.id + '" style="cursor: pointer;">'; } var icon2 = '<img src="' + this.getIcon2(node) + '" onclick="' + treeName + '.switchDisplay(\'' + node.id + '\')" id="icon2_' + node.id + '" style="cursor: pointer;">'; var s = '<div class="node" id="node_' + node.id + '">' + padding + icon1 + icon2 + this.getName(node) + '</div>'; s += '<div class="nodes" id="nodes_' + node.id + '" style="display:' + (node._isOpen ? '' : 'none') + '">'; for(k in this.pushNodes) { var id = this.pushNodes[k]; var theNode = this.nodes[id]; if(theNode.pid == node.id) { if(node.id == 0){ var thePadding = ''; } else { var thePadding = padding + (node.id == this.nodes[node.pid]._lastChildId ? '<img src="' + icon.empty + '">' : '<img src="' + icon.line + '">'); } if(!theNode._lastChildId) { var icon1 = '<img src="' + this.getIcon1(theNode) + '"' + ' id="icon1_' + theNode.id + '">'; var icon2 = '<img src="' + this.getIcon2(theNode) + '" id="icon2_' + theNode.id + '">'; s += '<div class="node" id="node_' + theNode.id + '">' + thePadding + icon1 + icon2 + this.getName(theNode) + '</div>'; } else { s += this.createTree(theNode, thePadding); } } } s += '</div>'; return s; }; this.getIcon1 = function(theNode) { var parentNode = this.nodes[theNode.pid]; var src = ''; if(theNode._lastChildId) { if(theNode._isOpen) { if(theNode.id == 0) { return icon.minus; } if(theNode.id == parentNode._lastChildId) { src = icon.minusBottom; } else { src = icon.minusMiddle; } } else { if(theNode.id == 0) { return icon.plus; } if(theNode.id == parentNode._lastChildId) { src = icon.plusBottom; } else { src = icon.plusMiddle; } } } else { if(theNode.id == parentNode._lastChildId) { src = icon.lineBottom; } else { src = icon.lineMiddle; } } return src; }; this.getIcon2 = function(theNode) { var src = ''; if(theNode.id == 0 ) { return icon.root; } if(theNode._lastChildId) { if(theNode._isOpen) { src = icon.folderOpen; } else { src = icon.folder; } } else { src = icon.file; } return src; }; this.getName = function(theNode) { if(theNode.url) { return '<a href="'+theNode.url+'" target="' + theNode.target + '"> '+theNode.name+'</a>'; } else { return theNode.name; } }; this.switchDisplay = function(nodeId) { eval('var theTree = ' + treeName); var theNode = theTree.nodes[nodeId]; if($('nodes_' + nodeId).style.display == 'none') { theTree.openIds = updatestring(theTree.openIds, nodeId); setcookie('discuz_leftmenu_openids', theTree.openIds, 8640000000); theNode._isOpen = true; $('nodes_' + nodeId).style.display = ''; $('icon1_' + nodeId).src = theTree.getIcon1(theNode); $('icon2_' + nodeId).src = theTree.getIcon2(theNode); } else { theTree.openIds = updatestring(theTree.openIds, nodeId, true); setcookie('discuz_leftmenu_openids', theTree.openIds, 8640000000); theNode._isOpen = false; $('nodes_' + nodeId).style.display = 'none'; $('icon1_' + nodeId).src = theTree.getIcon1(theNode); $('icon2_' + nodeId).src = theTree.getIcon2(theNode); } }; }
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/tree.js
JavaScript
asf20
5,535
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: calendar.js 19565 2009-09-06 02:28:41Z liuqiang $ */ var controlid = null; var currdate = null; var startdate = null; var enddate = null; var yy = null; var mm = null; var hh = null; var ii = null; var currday = null; var addtime = false; var today = new Date(); var lastcheckedyear = false; var lastcheckedmonth = false; function loadcalendar() { s = ''; s += '<div id="calendar" style="display:none; position:absolute; z-index:100000;" onclick="doane(event)">'; s += '<div style="width: 210px;"><table cellspacing="0" cellpadding="0" width="100%" style="text-align: center;">'; s += '<tr align="center" id="calendar_week"><td><a href="###" onclick="refreshcalendar(yy, mm-1)" title="上一月">《</a></td><td colspan="5" style="text-align: center"><a href="###" onclick="showdiv(\'year\');doane(event)" class="dropmenu" title="点击选择年份" id="year"></a>&nbsp; - &nbsp;<a id="month" class="dropmenu" title="点击选择月份" href="###" onclick="showdiv(\'month\');doane(event)"></a></td><td><A href="###" onclick="refreshcalendar(yy, mm+1)" title="下一月">》</A></td></tr>'; s += '<tr id="calendar_header"><td>日</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td></tr>'; for(var i = 0; i < 6; i++) { s += '<tr>'; for(var j = 1; j <= 7; j++) s += "<td id=d" + (i * 7 + j) + " height=\"19\">0</td>"; s += "</tr>"; } s += '<tr id="hourminute"><td colspan="7" align="center"><input type="text" size="2" value="" id="hour" class="txt" onKeyUp=\'this.value=this.value > 23 ? 23 : zerofill(this.value);controlid.value=controlid.value.replace(/\\d+(\:\\d+)/ig, this.value+"$1")\'> 点 <input type="text" size="2" value="" id="minute" class="txt" onKeyUp=\'this.value=this.value > 59 ? 59 : zerofill(this.value);controlid.value=controlid.value.replace(/(\\d+\:)\\d+/ig, "$1"+this.value)\'> 分</td></tr>'; s += '</table></div></div>'; s += '<div id="calendar_year" onclick="doane(event)" style="display: none;z-index:100001;"><div class="col">'; for(var k = 2020; k >= 1931; k--) { s += k != 2020 && k % 10 == 0 ? '</div><div class="col">' : ''; s += '<a href="###" onclick="refreshcalendar(' + k + ', mm);$(\'calendar_year\').style.display=\'none\'"><span' + (today.getFullYear() == k ? ' class="calendar_today"' : '') + ' id="calendar_year_' + k + '">' + k + '</span></a><br />'; } s += '</div></div>'; s += '<div id="calendar_month" onclick="doane(event)" style="display: none;z-index:100001;">'; for(var k = 1; k <= 12; k++) { s += '<a href="###" onclick="refreshcalendar(yy, ' + (k - 1) + ');$(\'calendar_month\').style.display=\'none\'"><span' + (today.getMonth()+1 == k ? ' class="calendar_today"' : '') + ' id="calendar_month_' + k + '">' + k + ( k < 10 ? '&nbsp;' : '') + ' 月</span></a><br />'; } s += '</div>'; if(BROWSER.ie && BROWSER.ie < 7) { s += '<iframe id="calendariframe" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>'; s += '<iframe id="calendariframe_year" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>'; s += '<iframe id="calendariframe_month" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>'; } var div = document.createElement('div'); div.innerHTML = s; $('append_parent').appendChild(div); document.onclick = function(event) { $('calendar').style.display = 'none'; $('calendar_year').style.display = 'none'; $('calendar_month').style.display = 'none'; if(BROWSER.ie && BROWSER.ie < 7) { $('calendariframe').style.display = 'none'; $('calendariframe_year').style.display = 'none'; $('calendariframe_month').style.display = 'none'; } }; $('calendar').onclick = function(event) { doane(event); $('calendar_year').style.display = 'none'; $('calendar_month').style.display = 'none'; if(BROWSER.ie && BROWSER.ie < 7) { $('calendariframe_year').style.display = 'none'; $('calendariframe_month').style.display = 'none'; } }; } function parsedate(s) { /(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec(s); var m1 = (RegExp.$1 && RegExp.$1 > 1899 && RegExp.$1 < 2101) ? parseFloat(RegExp.$1) : today.getFullYear(); var m2 = (RegExp.$2 && (RegExp.$2 > 0 && RegExp.$2 < 13)) ? parseFloat(RegExp.$2) : today.getMonth() + 1; var m3 = (RegExp.$3 && (RegExp.$3 > 0 && RegExp.$3 < 32)) ? parseFloat(RegExp.$3) : today.getDate(); var m4 = (RegExp.$4 && (RegExp.$4 > -1 && RegExp.$4 < 24)) ? parseFloat(RegExp.$4) : 0; var m5 = (RegExp.$5 && (RegExp.$5 > -1 && RegExp.$5 < 60)) ? parseFloat(RegExp.$5) : 0; /(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec("0000-00-00 00\:00"); return new Date(m1, m2 - 1, m3, m4, m5); } function settime(d) { $('calendar').style.display = 'none'; $('calendar_month').style.display = 'none'; if(BROWSER.ie && BROWSER.ie < 7) { $('calendariframe').style.display = 'none'; } controlid.value = yy + "-" + zerofill(mm + 1) + "-" + zerofill(d) + (addtime ? ' ' + zerofill($('hour').value) + ':' + zerofill($('minute').value) : ''); } function showcalendar(event, controlid1, addtime1, startdate1, enddate1) { controlid = controlid1; addtime = addtime1; startdate = startdate1 ? parsedate(startdate1) : false; enddate = enddate1 ? parsedate(enddate1) : false; currday = controlid.value ? parsedate(controlid.value) : today; hh = currday.getHours(); ii = currday.getMinutes(); var p = fetchOffset(controlid); $('calendar').style.display = 'block'; $('calendar').style.left = p['left']+'px'; $('calendar').style.top = (p['top'] + 20)+'px'; doane(event); refreshcalendar(currday.getFullYear(), currday.getMonth()); if(lastcheckedyear != false) { $('calendar_year_' + lastcheckedyear).className = 'calendar_default'; $('calendar_year_' + today.getFullYear()).className = 'calendar_today'; } if(lastcheckedmonth != false) { $('calendar_month_' + lastcheckedmonth).className = 'calendar_default'; $('calendar_month_' + (today.getMonth() + 1)).className = 'calendar_today'; } $('calendar_year_' + currday.getFullYear()).className = 'calendar_checked'; $('calendar_month_' + (currday.getMonth() + 1)).className = 'calendar_checked'; $('hourminute').style.display = addtime ? '' : 'none'; lastcheckedyear = currday.getFullYear(); lastcheckedmonth = currday.getMonth() + 1; if(BROWSER.ie && BROWSER.ie < 7) { $('calendariframe').style.top = $('calendar').style.top; $('calendariframe').style.left = $('calendar').style.left; $('calendariframe').style.width = $('calendar').offsetWidth; $('calendariframe').style.height = $('calendar').offsetHeight; $('calendariframe').style.display = 'block'; } } function refreshcalendar(y, m) { var x = new Date(y, m, 1); var mv = x.getDay(); var d = x.getDate(); var dd = null; yy = x.getFullYear(); mm = x.getMonth(); $("year").innerHTML = yy; $("month").innerHTML = mm + 1 > 9 ? (mm + 1) : '0' + (mm + 1); for(var i = 1; i <= mv; i++) { dd = $("d" + i); dd.innerHTML = "&nbsp;"; dd.className = ""; } while(x.getMonth() == mm) { dd = $("d" + (d + mv)); dd.innerHTML = '<a href="###" onclick="settime(' + d + ');return false">' + d + '</a>'; if(x.getTime() < today.getTime() || (enddate && x.getTime() > enddate.getTime()) || (startdate && x.getTime() < startdate.getTime())) { dd.className = 'calendar_expire'; } else { dd.className = 'calendar_default'; } if(x.getFullYear() == today.getFullYear() && x.getMonth() == today.getMonth() && x.getDate() == today.getDate()) { dd.className = 'calendar_today'; dd.firstChild.title = '今天'; } if(x.getFullYear() == currday.getFullYear() && x.getMonth() == currday.getMonth() && x.getDate() == currday.getDate()) { dd.className = 'calendar_checked'; } x.setDate(++d); } while(d + mv <= 42) { dd = $("d" + (d + mv)); dd.innerHTML = "&nbsp;"; d++; } if(addtime) { $('hour').value = zerofill(hh); $('minute').value = zerofill(ii); } } function showdiv(id) { var p = fetchOffset($(id)); $('calendar_' + id).style.left = p['left']+'px'; $('calendar_' + id).style.top = (p['top'] + 16)+'px'; $('calendar_' + id).style.display = 'block'; if(BROWSER.ie && BROWSER.ie < 7) { $('calendariframe_' + id).style.top = $('calendar_' + id).style.top; $('calendariframe_' + id).style.left = $('calendar_' + id).style.left; $('calendariframe_' + id).style.width = $('calendar_' + id).offsetWidth; $('calendariframe_' + id ).style.height = $('calendar_' + id).offsetHeight; $('calendariframe_' + id).style.display = 'block'; } } function zerofill(s) { var s = parseFloat(s.toString().replace(/(^[\s0]+)|(\s+$)/g, '')); s = isNaN(s) ? 0 : s; return (s < 10 ? '0' : '') + s.toString(); } loadcss('calendar'); loadcalendar();
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/calendar.js
JavaScript
asf20
9,130
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: post.js 21297 2009-11-25 09:40:15Z monkey $ */ var postSubmited = false; var AID = 1; var UPLOADSTATUS = -1; var UPLOADFAILED = UPLOADCOMPLETE = AUTOPOST = 0; var CURRENTATTACH = '0'; var FAILEDATTACHS = ''; var UPLOADWINRECALL = null; var STATUSMSG = {'-1' : '内部服务器错误', '0' : '上传成功', '1' : '不支持此类扩展名', '2' : '附件大小为 0', '3' : '附件大小超限', '4' : '不支持此类扩展名', '5' : '附件大小超限', '6' : '附件总大小超限', '7' : '图片附件不合法', '8' : '附件文件无法保存', '9' : '没有合法的文件被上传', '10' : '非法操作'}; function checkFocus() { var obj = wysiwyg ? editwin : textobj; if(!obj.hasfocus) { obj.focus(); } } function ctlent(event) { if(postSubmited == false && (event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83) && $('postsubmit')) { if(in_array($('postsubmit').name, ['topicsubmit', 'replysubmit', 'editsubmit']) && !validate($('postform'))) { doane(event); return; } postSubmited = true; $('postsubmit').disabled = true; $('postform').submit(); } if(event.keyCode == 9) { doane(event); } } function checklength(theform) { var message = wysiwyg ? html2bbcode(getEditorContents()) : (!theform.parseurloff.checked ? parseurl(theform.message.value) : theform.message.value); showDialog('当前长度: ' + mb_strlen(message) + ' 字节,' + (postmaxchars != 0 ? '系统限制: ' + postminchars + ' 到 ' + postmaxchars + ' 字节。' : ''), 'notice', '字数检查'); } if(!tradepost) { var tradepost = 0; } function validate(theform) { var message = trim(wysiwyg ? html2bbcode(getEditorContents()) : (!theform.parseurloff.checked ? parseurl(theform.message.value) : theform.message.value)); if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && theform.subject.value == "") || !sortid && !special && message == "") { showDialog('请完成标题或内容栏。'); return false; } else if(mb_strlen(theform.subject.value) > 80) { showDialog('您的标题超过 80 个字符的限制。'); return false; } if(tradepost) { if(theform.item_name.value == '') { showDialog('对不起,请输入商品名称。'); return false; } else if(theform.item_price.value == '') { showDialog('对不起,请输入商品现价。'); return false; } else if(!parseInt(theform.item_price.value)) { showDialog('对不起,商品现价必须为有效数字。'); return false; } else if(theform.item_costprice.value != '' && !parseInt(theform.item_costprice.value)) { showDialog('对不起,商品原价必须为有效数字。'); return false; } else if(theform.item_number.value != '0' && !parseInt(theform.item_number.value)) { showDialog('对不起,商品数量必须为数字。'); theform.item_number.focus(); return false; } } if(in_array($('postsubmit').name, ['topicsubmit', 'editsubmit'])) { if(theform.typeid && (theform.typeid.options && theform.typeid.options[theform.typeid.selectedIndex].value == 0) && typerequired) { showDialog('请选择主题对应的分类。'); return false; } if(special == 3 && isfirstpost) { if(theform.rewardprice.value == "") { showDialog('对不起,请输入悬赏积分。'); return false; } } else if(special == 4 && isfirstpost) { if(theform.activityclass.value == "") { showDialog('对不起,请输入活动所属类别。'); return false; } else if($('starttimefrom_0').value == "" && $('starttimefrom_1').value == "") { showDialog('对不起,请输入活动开始时间。'); return false; } else if(theform.activityplace.value == "") { showDialog('对不起,请输入活动地点。'); return false; } } } if(isfirstpost && sortid && typeof checkallsort == 'function') { if(!checkallsort()) return false; } if(!disablepostctrl && !sortid && !special && ((postminchars != 0 && mb_strlen(message) < postminchars) || (postmaxchars != 0 && mb_strlen(message) > postmaxchars))) { showDialog('您的帖子长度不符合要求。\n\n当前长度: ' + mb_strlen(message) + ' 字节\n系统限制: ' + postminchars + ' 到 ' + postmaxchars + ' 字节'); return false; } if(UPLOADSTATUS == 0) { if(!confirm('您有等待上传的附件,确认不上传这些附件吗?')) { return false; } } else if(UPLOADSTATUS == 1) { showDialog('您有正在上传的附件,请稍候,上传完成后帖子将会自动发表...', 'notice'); AUTOPOST = 1; return false; } if($(editorid + '_attachlist')) { $('postbox').appendChild($(editorid + '_attachlist')); $(editorid + '_attachlist').style.display = 'none'; } if($(editorid + '_imgattachlist')) { $('postbox').appendChild($(editorid + '_imgattachlist')); $(editorid + '_imgattachlist').style.display = 'none'; } hideMenu(); theform.message.value = message; if($('postsubmit').name == 'editsubmit') { return true; } else if(in_array($('postsubmit').name, ['topicsubmit', 'replysubmit'])) { seccheck(theform, seccodecheck, secqaacheck); return false; } } function seccheck(theform, seccodecheck, secqaacheck) { if(seccodecheck || secqaacheck) { var url = 'ajax.php?inajax=1&action='; if(seccodecheck) { var x = new Ajax(); x.get(url + 'checkseccode&seccodeverify=' + (BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent($('seccodeverify').value) : $('seccodeverify').value), function(s) { if(s.substr(0, 7) != 'succeed') { showDialog(s); $('seccodeverify').focus(); } else if(secqaacheck) { checksecqaa(url, theform); } else { postsubmit(theform); } }); } else if(secqaacheck) { checksecqaa(url, theform); } } else { postsubmit(theform); } } function checksecqaa(url, theform) { var x = new Ajax(); var secanswer = $('secanswer').value; secanswer = BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent(secanswer) : secanswer; x.get(url + 'checksecanswer&secanswer=' + secanswer, function(s) { if(s.substr(0, 7) != 'succeed') { showDialog(s); $('secanswer').focus(); } else { postsubmit(theform); } }); } function postsubmit(theform) { theform.replysubmit ? theform.replysubmit.disabled = true : (theform.editsubmit ? theform.editsubmit.disabled = true : theform.topicsubmit.disabled = true); theform.submit(); } function loadData(quiet) { var data = ''; if(BROWSER.ie){ with(document.documentElement) { load('Discuz'); data = getAttribute("value"); } } else if(window.sessionStorage){ data = sessionStorage.getItem('Discuz'); } if(in_array((data = trim(data)), ['', 'null', 'false', null, false])) { if(!quiet) { showDialog('没有可以恢复的数据!'); } return; } if(!quiet && !confirm('此操作将覆盖当前帖子内容,确定要恢复数据吗?')) { return; } var data = data.split(/\x09\x09/); for(var i = 0; i < $('postform').elements.length; i++) { var el = $('postform').elements[i]; if(el.name != '' && (el.tagName == 'TEXTAREA' || el.tagName == 'INPUT' && (el.type == 'text' || el.type == 'checkbox' || el.type == 'radio'))) { for(var j = 0; j < data.length; j++) { var ele = data[j].split(/\x09/); if(ele[0] == el.name) { elvalue = !isUndefined(ele[3]) ? ele[3] : ''; if(ele[1] == 'INPUT') { if(ele[2] == 'text') { el.value = elvalue; } else if((ele[2] == 'checkbox' || ele[2] == 'radio') && ele[3] == el.value) { el.checked = true; evalevent(el); } } else if(ele[1] == 'TEXTAREA') { if(ele[0] == 'message') { if(!wysiwyg) { textobj.value = elvalue; } else { editdoc.body.innerHTML = bbcode2html(elvalue); } } else { el.value = elvalue; } } break } } } } } function evalevent(obj) { var script = obj.parentNode.innerHTML; var re = /onclick="(.+?)["|>]/ig; var matches = re.exec(script); if(matches != null) { matches[1] = matches[1].replace(/this\./ig, 'obj.'); eval(matches[1]); } } function setCaretAtEnd() { if(wysiwyg) { editdoc.body.innerHTML += ''; } else { editdoc.value += ''; } } function relatekw(subject, message, recall) { if(isUndefined(recall)) recall = ''; if(isUndefined(subject) || subject == -1) subject = $('subject').value; if(isUndefined(message) || message == -1) message = getEditorContents(); subject = (BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent(subject) : subject); message = (BROWSER.ie && document.charset == 'utf-8' ? encodeURIComponent(message) : message); message = message.replace(/&/ig, '', message).substr(0, 500); ajaxget('relatekw.php?subjectenc=' + subject + '&messageenc=' + message, 'tagselect', '', '', '', recall); } function switchicon(iconid, obj) { $('iconid').value = iconid; $('icon_img').src = obj.src; hideMenu(); } var editbox = editwin = editdoc = editcss = null; var cursor = -1; var stack = []; var initialized = false; function newEditor(mode, initialtext) { wysiwyg = parseInt(mode); if(!(BROWSER.ie || BROWSER.firefox || (BROWSER.opera >= 9))) { allowswitcheditor = wysiwyg = 0; } if(!BROWSER.ie) { $(editorid + '_cmd_paste').parentNode.style.display = 'none'; } if(!allowswitcheditor) { $(editorid + '_switcher').style.display = 'none'; } $(editorid + '_cmd_table').disabled = wysiwyg ? false : true; $(editorid + '_cmd_table').className = wysiwyg ? '' : 'tblbtn_disabled'; if(wysiwyg) { if($(editorid + '_iframe')) { editbox = $(editorid + '_iframe'); } else { var iframe = document.createElement('iframe'); editbox = textobj.parentNode.appendChild(iframe); editbox.id = editorid + '_iframe'; } editwin = editbox.contentWindow; editdoc = editwin.document; writeEditorContents(isUndefined(initialtext) ? textobj.value : initialtext); } else { editbox = editwin = editdoc = textobj; if(!isUndefined(initialtext)) { writeEditorContents(initialtext); } addSnapshot(textobj.value); } setEditorEvents(); initEditor(); } function initEditor() { var buttons = $(editorid + '_controls').getElementsByTagName('a'); for(var i = 0; i < buttons.length; i++) { if(buttons[i].id.indexOf(editorid + '_cmd_') != -1) { buttons[i].href = 'javascript:;'; buttons[i].onclick = function(e) {discuzcode(this.id.substr(this.id.lastIndexOf('_cmd_') + 5));try{ajaxget('forumstat.php?action='+this.id);} catch(e) {}}; } } setUnselectable($(editorid + '_controls')); textobj.onkeydown = function(e) {ctlent(e ? e : event)}; } function setUnselectable(obj) { if(BROWSER.ie && BROWSER.ie > 4 && typeof obj.tagName != 'undefined') { if(obj.hasChildNodes()) { for(var i = 0; i < obj.childNodes.length; i++) { setUnselectable(obj.childNodes[i]); } } if(obj.tagName != 'INPUT') { obj.unselectable = 'on'; } } } function writeEditorContents(text) { if(wysiwyg) { if(text == '' && (BROWSER.firefox || BROWSER.opera)) { text = '<br />'; } if(initialized && !(BROWSER.firefox && BROWSER.firefox >= 3 || BROWSER.opera)) { editdoc.body.innerHTML = text; } else { editdoc.designMode = 'on'; editdoc = editwin.document; editdoc.open('text/html', 'replace'); editdoc.write(text); editdoc.close(); editdoc.body.contentEditable = true; initialized = true; } } else { textobj.value = text; } setEditorStyle(); } function getEditorContents() { return wysiwyg ? editdoc.body.innerHTML : editdoc.value; } function setEditorStyle() { if(wysiwyg) { textobj.style.display = 'none'; editbox.style.display = ''; editbox.className = textobj.className; var headNode = editdoc.getElementsByTagName("head")[0]; if(!headNode) { headNode = editdoc.getElementsByTagName("body")[0]; } if(!headNode.getElementsByTagName('link').length) { editcss = editdoc.createElement('link'); editcss.type = 'text/css'; editcss.rel = 'stylesheet'; editcss.href = editorcss; headNode.appendChild(editcss); } if(BROWSER.firefox || BROWSER.opera) { editbox.style.border = '0px'; } else if(BROWSER.ie) { editdoc.body.style.border = '0px'; editdoc.body.addBehavior('#default#userData'); } editbox.style.width = textobj.style.width; editbox.style.height = textobj.style.height; editdoc.firstChild.style.background = 'none'; editdoc.body.style.backgroundColor = TABLEBG; editdoc.body.style.textAlign = 'left'; if(BROWSER.ie) { try{$('subject').focus();} catch(e) {editwin.focus();} } } else { var iframe = textobj.parentNode.getElementsByTagName('iframe')[0]; if(iframe) { textobj.style.display = ''; textobj.style.width = iframe.style.width; textobj.style.height = iframe.style.height; iframe.style.display = 'none'; } if(BROWSER.ie) { try{$('subject').focus();} catch(e) {textobj.focus();} } } } function setEditorEvents() { var floatPic = function(e) { var obj = BROWSER.ie ? e.srcElement : e.target; var tag = obj.tagName.toLowerCase(); var menuid = obj.id + '_menu'; var menu = $(menuid); if(JSMENU['float']) $(JSMENU['float']).style.display = 'none'; if(tag != 'img') return; if(!obj.id) obj.id = editorid + '_f_' + tag + '_' + Math.random(); if(!menu) { menu = document.createElement('div'); menu.id = menuid; menu.style.position = 'absolute'; menu.style.zIndex = '999'; menu.className = 'popupmenu_popup popupfix simple_menu'; menu.style.width = '80px'; menu.innerHTML = '<div class="popupmenu_option" unselectable="on"><ul unselectable="on"><li id="' + menuid + '_left" unselectable="on">图片居左混排</li><li id="' + menuid + '_right" unselectable="on">图片居右混排</li></ul></div>'; $('append_parent').appendChild(menu); $(menuid + '_left').onclick = function(e) {discuzcode('floatleft', obj.id);menu.style.display='none';doane(e)}; $(menuid + '_right').onclick = function(e) {discuzcode('floatright', obj.id);menu.style.display='none';doane(e)}; } var pos = fetchOffset($(editorid + '_iframe')); menu.style.left = pos['left'] + e.clientX + 'px'; menu.style.top = pos['top'] + e.clientY + 'px'; menu.style.display = ''; JSMENU['float'] = menuid; doane(e); }; if(wysiwyg) { if(BROWSER.firefox || BROWSER.opera) { editwin.addEventListener('keydown', function(e) {ctlent(e);}, true); editwin.addEventListener('mouseup', floatPic, true); } else if(editdoc.attachEvent) { editdoc.body.attachEvent('onkeydown', ctlent); editdoc.body.attachEvent('onmouseup', floatPic); } } editwin.onfocus = function(e) {this.hasfocus = true;}; editwin.onblur = function(e) {this.hasfocus = false;}; } function wrapTags(tagname, useoption, selection) { if(isUndefined(selection)) { var selection = getSel(); if(selection === false) { selection = ''; } else { selection += ''; } } if(useoption !== false) { var opentag = '[' + tagname + '=' + useoption + ']'; } else { var opentag = '[' + tagname + ']'; } var closetag = '[/' + tagname + ']'; var text = opentag + selection + closetag; insertText(text, strlen(opentag), strlen(closetag), in_array(tagname, ['code', 'quote', 'free', 'hide']) ? true : false); } function applyFormat(cmd, dialog, argument) { if(wysiwyg) { editdoc.execCommand(cmd, (isUndefined(dialog) ? false : dialog), (isUndefined(argument) ? true : argument)); return; } switch(cmd) { case 'paste': if(BROWSER.ie) { var str = clipboardData.getData("TEXT"); insertText(str, str.length, 0); } break; case 'bold': case 'italic': case 'underline': case 'strikethrough': wrapTags(cmd.substr(0, 1), false); break; case 'inserthorizontalrule': insertText('[hr]', 4, 0); break; case 'justifyleft': case 'justifycenter': case 'justifyright': wrapTags('align', cmd.substr(7)); break; case 'fontname': wrapTags('font', argument); break; case 'fontsize': wrapTags('size', argument); break; case 'forecolor': wrapTags('color', argument); break; } } function getCaret() { if(wysiwyg) { var obj = editdoc.body; var s = document.selection.createRange(); s.setEndPoint('StartToStart', obj.createTextRange()); var matches1 = s.htmlText.match(/<\/p>/ig); var matches2 = s.htmlText.match(/<br[^\>]*>/ig); var fix = (matches1 ? matches1.length - 1 : 0) + (matches2 ? matches2.length : 0); var pos = s.text.replace(/\r?\n/g, ' ').length; if(matches3 = s.htmlText.match(/<img[^\>]*>/ig)) pos += matches3.length; if(matches4 = s.htmlText.match(/<\/tr|table>/ig)) pos += matches4.length; return [pos, fix]; } else { var sel = getSel(); return [sel === false ? 0 : sel.length, 0]; } } function setCaret(pos) { var obj = wysiwyg ? editdoc.body : editbox; var r = obj.createTextRange(); r.moveStart('character', pos); r.collapse(true); r.select(); } function isEmail(email) { return email.length > 6 && /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/.test(email); } function insertAttachTag(aid) { var txt = '[attach]' + aid + '[/attach]'; if(wysiwyg) { insertText(txt, false); } else { insertText(txt, strlen(txt), 0); } } function insertAttachimgTag(aid) { if(wysiwyg) { insertText('<img src="' + $('image_' + aid).src + '" border="0" aid="attachimg_' + aid + '" width="' + $('image_' + aid).width + '" alt="" />', false); } else { var txt = '[attachimg]' + aid + '[/attachimg]'; insertText(txt, strlen(txt), 0); } } function insertSmiley(smilieid) { checkFocus(); var src = $('smilie_' + smilieid).src; var code = $('smilie_' + smilieid).alt; if(wysiwyg && allowsmilies && (!$('smileyoff') || $('smileyoff').checked == false)) { if(BROWSER.firefox) { applyFormat('InsertImage', false, src); var smilies = editdoc.body.getElementsByTagName('img'); for(var i = 0; i < smilies.length; i++) { if(smilies[i].src == src && smilies[i].getAttribute('smilieid') < 1) { smilies[i].setAttribute('smilieid', smilieid); smilies[i].setAttribute('border', "0"); } } } else { insertText('<img src="' + src + '" border="0" smilieid="' + smilieid + '" alt="" /> ', false); } } else { code += ' '; insertText(code, strlen(code), 0); } hideMenu(); } function discuzcode(cmd, arg) { if(cmd != 'redo') { addSnapshot(getEditorContents()); } checkFocus(); if(in_array(cmd, ['simple', 'paragraph', 'list', 'smilies', 'createlink', 'quote', 'code', 'free', 'hide', 'audio', 'video', 'flash', 'attach', 'image']) || cmd == 'table' && wysiwyg || in_array(cmd, ['fontname', 'fontsize', 'forecolor']) && !arg) { showEditorMenu(cmd); return; } else if(cmd.substr(0, 6) == 'custom') { showEditorMenu(cmd.substr(8), cmd.substr(6, 1)); return; } else if(wysiwyg && cmd == 'inserthorizontalrule') { insertText('<hr class="solidline" />', 24); } else if(cmd == 'autotypeset') { autoTypeset(); return; } else if(!wysiwyg && cmd == 'removeformat') { var simplestrip = new Array('b', 'i', 'u'); var complexstrip = new Array('font', 'color', 'size'); var str = getSel(); if(str === false) { return; } for(var tag in simplestrip) { str = stripSimple(simplestrip[tag], str); } for(var tag in complexstrip) { str = stripComplex(complexstrip[tag], str); } insertText(str); } else if(!wysiwyg && cmd == 'undo') { addSnapshot(getEditorContents()); moveCursor(-1); if((str = getSnapshot()) !== false) { editdoc.value = str; } } else if(!wysiwyg && cmd == 'redo') { moveCursor(1); if((str = getSnapshot()) !== false) { editdoc.value = str; } } else if(!wysiwyg && in_array(cmd, ['insertorderedlist', 'insertunorderedlist'])) { var listtype = cmd == 'insertorderedlist' ? '1' : ''; var opentag = '[list' + (listtype ? ('=' + listtype) : '') + ']\n'; var closetag = '[/list]'; if(txt = getSel()) { var regex = new RegExp('([\r\n]+|^[\r\n]*)(?!\\[\\*\\]|\\[\\/?list)(?=[^\r\n])', 'gi'); txt = opentag + trim(txt).replace(regex, '$1[*]') + '\n' + closetag; insertText(txt, strlen(txt), 0); } else { insertText(opentag + closetag, opentag.length, closetag.length); while(listvalue = prompt('输入一个列表项目.\r\n留空或者点击取消完成此列表.', '')) { if(BROWSER.opera > 8) { listvalue = '\n' + '[*]' + listvalue; insertText(listvalue, strlen(listvalue) + 1, 0); } else { listvalue = '[*]' + listvalue + '\n'; insertText(listvalue, strlen(listvalue), 0); } } } } else if(!wysiwyg && cmd == 'unlink') { var sel = getSel(); sel = stripSimple('url', sel); sel = stripComplex('url', sel); insertText(sel); } else if(cmd == 'floatleft' || cmd == 'floatright') { if(wysiwyg) { if(selection = getSel()) { var span = editdoc.getElementById(arg).parentNode; if(span.tagName == 'SPAN') { if(typeof span.style.styleFloat != 'undefined') span.style.styleFloat = cmd.substr(5); else span.style.cssFloat = cmd.substr(5); return; } else { var ret = insertText('<br style="clear: both"><span style="float: ' + cmd.substr(5) + '">' + selection + '</span>', true); } } } } else if(cmd == 'loaddata') { loadData(); } else if(cmd == 'savedata') { saveData(); } else if(cmd == 'checklength') { checklength($('postform')); } else if(cmd == 'clearcontent') { clearContent(); } else { try { var ret = applyFormat(cmd, false, (isUndefined(arg) ? true : arg)); } catch(e) { var ret = false; } } if(cmd != 'undo') { addSnapshot(getEditorContents()); } if(in_array(cmd, ['bold', 'italic', 'underline', 'strikethrough', 'inserthorizontalrule', 'fontname', 'fontsize', 'forecolor', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', 'floatleft', 'floatright', 'removeformat', 'unlink', 'undo', 'redo'])) { hideMenu(); } return ret; } function showEditorMenu(tag, params) { var sel, selection; var str = ''; var ctrlid = editorid + (params ? '_cmd_custom' + params + '_' : '_cmd_') + tag; var opentag = '[' + tag + ']'; var closetag = '[/' + tag + ']'; var menu = $(ctrlid + '_menu'); var pos = [0, 0]; if(BROWSER.ie) { sel = wysiwyg ? editdoc.selection.createRange() : document.selection.createRange(); pos = getCaret(); } selection = sel ? (wysiwyg ? sel.htmlText : sel.text) : getSel(); if(menu) { if(menu.style.display == '') { hideMenu(ctrlid + '_menu', 'menu'); return; } showMenu({'ctrlid':ctrlid,'evt':'click','duration':in_array(tag, ['simple', 'fontname', 'fontsize', 'paragraph', 'list', 'smilies']) ? 2 : 3,'drag':in_array(tag, ['attach', 'image']) ? ctrlid + '_ctrl' : 1}); } else { switch(tag) { case 'createlink': str = '请输入链接的地址:<br /><input type="text" id="' + ctrlid + '_param_1" style="width: 98%" value="" class="txt" />'+ (selection ? '' : '<br />请输入链接的文字:<br /><input type="text" id="' + ctrlid + '_param_2" style="width: 98%" value="" class="txt" />'); break; case 'forecolor': showColorBox(ctrlid, 1); return; case 'code': case 'quote': case 'hide': case 'free': if(selection) { return insertText((opentag + selection + closetag), strlen(opentag), strlen(closetag), true, sel); } var lang = {'quote' : '请输入要插入的引用', 'code' : '请输入要插入的代码', 'hide' : '请输入要插入的隐藏内容', 'free' : '请输入要插入的免费信息'}; str += lang[tag] + ':<br /><textarea id="' + ctrlid + '_param_1" style="width: 98%" cols="50" rows="5" class="txtarea"></textarea>' + (tag == 'hide' ? '<br /><input type="radio" name="' + ctrlid + '_radio" id="' + ctrlid + '_radio_1" class="txt" checked="checked" />只有当浏览者回复本帖时才显示<br /><input type="radio" name="' + ctrlid + '_radio" id="' + ctrlid + '_radio_2" class="txt" />只有当浏览者积分高于 <input type="text" size="3" id="' + ctrlid + '_param_2" class="txt" /> 时才显示' : ''); break; case 'table': str = '表格行数: <input type="text" id="' + ctrlid + '_param_1" size="2" value="2" class="txt" /> &nbsp; 表格列数: <input type="text" id="' + ctrlid + '_param_2" size="2" value="2" class="txt" /><br />表格宽度: <input type="text" id="' + ctrlid + '_param_3" size="2" value="" class="txt" /> &nbsp; 背景颜色: <input type="text" id="' + ctrlid + '_param_4" size="2" class="txt" onclick="showColorBox(this.id, 2)" />'; break; case 'audio': str = '请输入音乐文件地址:<br /><input type="text" id="' + ctrlid + '_param_1" class="txt" value="" style="width: 245px;" />'; break; case 'video': str = '请输入视频地址:<br /><input type="text" value="" id="' + ctrlid + '_param_1" style="width: 245px;" class="txt" /><br />宽: <input id="' + ctrlid + '_param_2" size="5" value="400" class="txt" /> &nbsp; 高: <input id="' + ctrlid + '_param_3" size="5" value="300" class="txt" />'; break; case 'flash': str = '请输入 Flash 文件地址:<br /><input type="text" id="' + ctrlid + '_param_1" class="txt" value="" style="width: 245px;" />'; break; default: var haveSel = selection == null || selection == false || in_array(trim(selection), ['', 'null', 'undefined', 'false']) ? 0 : 1; if(params == 1 && haveSel) { return insertText((opentag + selection + closetag), strlen(opentag), strlen(closetag), true, sel); } var promptlang = custombbcodes[tag]['prompt'].split("\t"); for(var i = 1; i <= params; i++) { if(i != params || !haveSel) { str += (promptlang[i - 1] ? promptlang[i - 1] : '请输入第 ' + i + ' 个参数:') + '<br /><input type="text" id="' + ctrlid + '_param_' + i + '" style="width: 98%" value="" class="txt" />' + (i < params ? '<br />' : ''); } } break; } var menu = document.createElement('div'); menu.id = ctrlid + '_menu'; menu.style.display = 'none'; menu.className = 'popupmenu_popup popupfix'; menu.style.width = (tag == 'table' ? 192 : 250) + 'px'; $(editorid + '_controls').appendChild(menu); menu.innerHTML = '<div class="popupmenu_option">' + str + '<br /><center><input type="button" id="' + ctrlid + '_submit" value="提交" /> &nbsp; <input type="button" onClick="hideMenu()" value="取消" /></center></div>'; showMenu({'ctrlid':ctrlid,'evt':'click','duration':3,'cache':0,'drag':1}); } try{$(ctrlid + '_param_1').focus()}catch(e){}; var objs = menu.getElementsByTagName('*'); for(var i = 0; i < objs.length; i++) { _attachEvent(objs[i], 'keydown', function(e) { e = e ? e : event; obj = BROWSER.ie ? event.srcElement : e.target; if((obj.type == 'text' && e.keyCode == 13) || (obj.type == 'textarea' && e.ctrlKey && e.keyCode == 13)) { if($(ctrlid + '_submit') && tag != 'image') $(ctrlid + '_submit').click(); doane(e); } else if(e.keyCode == 27) { hideMenu(); doane(e); } }); } if($(ctrlid + '_submit')) $(ctrlid + '_submit').onclick = function() { checkFocus(); if(BROWSER.ie) { setCaret(pos[0]); } switch(tag) { case 'createlink': var href = $(ctrlid + '_param_1').value; href = (isEmail(href) ? 'mailto:' : '') + href; if(href != '') { var v = selection ? selection : ($(ctrlid + '_param_2').value ? $(ctrlid + '_param_2').value : href); str = wysiwyg ? ('<a href="' + href + '">' + v + '</a>') : '[url=' + href + ']' + v + '[/url]'; if(wysiwyg) insertText(str, str.length - v.length, 0, (selection ? true : false), sel); else insertText(str, str.length - v.length - 6, 6, (selection ? true : false), sel); } break; case 'code': case 'quote': case 'hide': case 'free': if(tag == 'hide' && $(ctrlid + '_radio_2').checked) { var mincredits = parseInt($(ctrlid + '_param_2').value); opentag = mincredits > 0 ? '[hide=' + mincredits + ']' : '[hide]'; } str = selection ? selection : $(ctrlid + '_param_1').value; if(wysiwyg) { if(tag == 'code') { str = preg_replace(['<', '>'], ['&lt;', '&gt;'], str); } str = str.replace(/\r?\n/g, '<br />'); } str = opentag + str + closetag; insertText(str, strlen(opentag), strlen(closetag), false, sel); break; case 'table': var rows = $(ctrlid + '_param_1').value; var columns = $(ctrlid + '_param_2').value; var width = $(ctrlid + '_param_3').value; var bgcolor = $(ctrlid + '_param_4').value; rows = /^[-\+]?\d+$/.test(rows) && rows > 0 && rows <= 30 ? rows : 2; columns = /^[-\+]?\d+$/.test(columns) && columns > 0 && columns <= 30 ? columns : 2; width = width.substr(width.length - 1, width.length) == '%' ? (width.substr(0, width.length - 1) <= 98 ? width : '98%') : (width <= 560 ? width : '98%'); bgcolor = /[\(\)%,#\w]+/.test(bgcolor) ? bgcolor : ''; str = '<table cellspacing="0" cellpadding="0" width="' + (width ? width : '50%') + '" class="t_table"' + (bgcolor ? ' bgcolor="' + bgcolor + '"' : '') + '>'; for (var row = 0; row < rows; row++) { str += '<tr>\n'; for (col = 0; col < columns; col++) { str += '<td>&nbsp;</td>\n'; } str += '</tr>\n'; } str += '</table>\n'; insertText(str, str.length - pos[1], 0, false, sel); break; case 'audio': case 'flash': insertText(opentag + $(ctrlid + '_param_1').value + closetag, opentag.length, closetag.length, false, sel); break; case 'video': var mediaUrl = $(ctrlid + '_param_1').value; var ext = mediaUrl.lastIndexOf('.') == -1 ? '' : mediaUrl.substr(mediaUrl.lastIndexOf('.') + 1, mb_strlen(mediaUrl)).toLowerCase(); ext = in_array(ext, ['mp3', 'wma', 'ra', 'rm', 'ram', 'mid', 'asx', 'wmv', 'avi', 'mpg', 'mpeg', 'rmvb', 'asf', 'mov', 'flv', 'swf']) ? ext : 'x'; if(ext == 'x') { if(/^mms:\/\//.test(mediaUrl)) { ext = 'mms'; } else if(/^(rtsp|pnm):\/\//.test(mediaUrl)) { ext = 'rtsp'; } } var str = '[media=' + ext + ',' + $(ctrlid + '_param_2').value + ',' + $(ctrlid + '_param_3').value + ']' + mediaUrl + '[/media]'; insertText(str, str.length - pos[1], 0, false, sel); break; case 'image': var width = parseInt($(ctrlid + '_param_2').value); var height = parseInt($(ctrlid + '_param_3').value); width = width > 0 && width <= 1024 ? width : 0; height = height && height <= 768 > 0 ? height : 0; var src = $(ctrlid + '_param_1').value; var style = ''; if(wysiwyg) { style += width ? ' width=' + width : ''; style += height ? ' height=' + height : ''; var str = '<img src=' + src + style + ' border=0 /> '; insertText(str, str.length - pos[1], 0, false, sel); } else { style += width || height ? '=' + width + ',' + height : ''; insertText('[img' + style + ']' + src + '[/img]', 0, 0, false, sel); } $(ctrlid + '_param_1').value = ''; default: var first = $(ctrlid + '_param_1').value; if($(ctrlid + '_param_2')) var second = $(ctrlid + '_param_2').value; if($(ctrlid + '_param_3')) var third = $(ctrlid + '_param_3').value; if((params == 1 && first) || (params == 2 && first && (haveSel || second)) || (params == 3 && first && second && (haveSel || third))) { if(params == 1) { str = first; } else if(params == 2) { str = haveSel ? selection : second; opentag = '[' + tag + '=' + first + ']'; } else { str = haveSel ? selection : third; opentag = '[' + tag + '=' + first + ',' + second + ']'; } insertText((opentag + str + closetag), strlen(opentag), strlen(closetag), true, sel); } break; } hideMenu(); }; } function autoTypeset() { var sel; if(BROWSER.ie) { sel = wysiwyg ? editdoc.selection.createRange() : document.selection.createRange(); } var selection = sel ? (wysiwyg ? sel.htmlText.replace(/<\/?p>/ig, '<br />') : sel.text) : getSel(); selection = wysiwyg ? selection.replace(/<br[^\>]*>/ig, "\n") : selection.replace(/\r?\n/g, "\n"); selection = trim(selection); selection = wysiwyg ? selection.replace(/\n+/g, '</p><p style="line-height: 30px; text-indent: 2em;">') : selection.replace(/\n/g, '[/p][p=30, 2, left]'); opentag = wysiwyg ? '<p style="line-height: 30px; text-indent: 2em;">' : '[p=30, 2, left]'; var s = opentag + selection + (wysiwyg ? '</p>' : '[/p]'); insertText(s, strlen(opentag), 4, false, sel); hideMenu(); } function getSel() { if(wysiwyg) { if(BROWSER.firefox || BROWSER.opera) { selection = editwin.getSelection(); checkFocus(); range = selection ? selection.getRangeAt(0) : editdoc.createRange(); return readNodes(range.cloneContents(), false); } else { var range = editdoc.selection.createRange(); if(range.htmlText && range.text) { return range.htmlText; } else { var htmltext = ''; for(var i = 0; i < range.length; i++) { htmltext += range.item(i).outerHTML; } return htmltext; } } } else { if(!isUndefined(editdoc.selectionStart)) { return editdoc.value.substr(editdoc.selectionStart, editdoc.selectionEnd - editdoc.selectionStart); } else if(document.selection && document.selection.createRange) { return document.selection.createRange().text; } else if(window.getSelection) { return window.getSelection() + ''; } else { return false; } } } function insertText(text, movestart, moveend, select, sel) { if(wysiwyg) { if(BROWSER.firefox || BROWSER.opera) { applyFormat('removeformat'); var fragment = editdoc.createDocumentFragment(); var holder = editdoc.createElement('span'); holder.innerHTML = text; while(holder.firstChild) { fragment.appendChild(holder.firstChild); } insertNodeAtSelection(fragment); } else { checkFocus(); if(!isUndefined(editdoc.selection) && editdoc.selection.type != 'Text' && editdoc.selection.type != 'None') { movestart = false; editdoc.selection.clear(); } if(isUndefined(sel)) { sel = editdoc.selection.createRange(); } sel.pasteHTML(text); if(text.indexOf('\n') == -1) { if(!isUndefined(movestart)) { sel.moveStart('character', -strlen(text) + movestart); sel.moveEnd('character', -moveend); } else if(movestart != false) { sel.moveStart('character', -strlen(text)); } if(!isUndefined(select) && select) { sel.select(); } } } } else { checkFocus(); if(!isUndefined(editdoc.selectionStart)) { var opn = editdoc.selectionStart + 0; editdoc.value = editdoc.value.substr(0, editdoc.selectionStart) + text + editdoc.value.substr(editdoc.selectionEnd); if(!isUndefined(movestart)) { editdoc.selectionStart = opn + movestart; editdoc.selectionEnd = opn + strlen(text) - moveend; } else if(movestart !== false) { editdoc.selectionStart = opn; editdoc.selectionEnd = opn + strlen(text); } } else if(document.selection && document.selection.createRange) { if(isUndefined(sel)) { sel = document.selection.createRange(); } sel.text = text.replace(/\r?\n/g, '\r\n'); if(!isUndefined(movestart)) { sel.moveStart('character', -strlen(text) +movestart); sel.moveEnd('character', -moveend); } else if(movestart !== false) { sel.moveStart('character', -strlen(text)); } sel.select(); } else { editdoc.value += text; } } } function stripSimple(tag, str, iterations) { var opentag = '[' + tag + ']'; var closetag = '[/' + tag + ']'; if(isUndefined(iterations)) { iterations = -1; } while((startindex = stripos(str, opentag)) !== false && iterations != 0) { iterations --; if((stopindex = stripos(str, closetag)) !== false) { var text = str.substr(startindex + opentag.length, stopindex - startindex - opentag.length); str = str.substr(0, startindex) + text + str.substr(stopindex + closetag.length); } else { break; } } return str; } function stripComplex(tag, str, iterations) { var opentag = '[' + tag + '='; var closetag = '[/' + tag + ']'; if(isUndefined(iterations)) { iterations = -1; } while((startindex = stripos(str, opentag)) !== false && iterations != 0) { iterations --; if((stopindex = stripos(str, closetag)) !== false) { var openend = stripos(str, ']', startindex); if(openend !== false && openend > startindex && openend < stopindex) { var text = str.substr(openend + 1, stopindex - openend - 1); str = str.substr(0, startindex) + text + str.substr(stopindex + closetag.length); } else { break; } } else { break; } } return str; } function stripos(haystack, needle, offset) { if(isUndefined(offset)) { offset = 0; } var index = haystack.toLowerCase().indexOf(needle.toLowerCase(), offset); return (index == -1 ? false : index); } function switchEditor(mode) { if(mode == wysiwyg || !allowswitcheditor) { return; } if(!mode) { var controlbar = $(editorid + '_controls'); var controls = []; var buttons = controlbar.getElementsByTagName('a'); var buttonslength = buttons.length; for(var i = 0; i < buttonslength; i++) { if(buttons[i].id) { controls[controls.length] = buttons[i].id; } } var controlslength = controls.length; for(var i = 0; i < controlslength; i++) { var control = $(controls[i]); if(control.id.indexOf(editorid + '_cmd_') != -1) { control.className = control.id.indexOf(editorid + '_cmd_custom') == -1 ? '' : 'plugeditor'; control.state = false; control.mode = 'normal'; } else if(control.id.indexOf(editorid + '_popup_') != -1) { control.state = false; } } } cursor = -1; stack = []; var parsedtext = getEditorContents(); parsedtext = mode ? bbcode2html(parsedtext) : html2bbcode(parsedtext); wysiwyg = mode; $(editorid + '_mode').value = mode; newEditor(mode, parsedtext); setEditorStyle(); editwin.focus(); setCaretAtEnd(); } function insertNodeAtSelection(text) { checkFocus(); var sel = editwin.getSelection(); var range = sel ? sel.getRangeAt(0) : editdoc.createRange(); sel.removeAllRanges(); range.deleteContents(); var node = range.startContainer; var pos = range.startOffset; switch(node.nodeType) { case Node.ELEMENT_NODE: if(text.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { selNode = text.firstChild; } else { selNode = text; } node.insertBefore(text, node.childNodes[pos]); add_range(selNode); break; case Node.TEXT_NODE: if(text.nodeType == Node.TEXT_NODE) { var text_length = pos + text.length; node.insertData(pos, text.data); range = editdoc.createRange(); range.setEnd(node, text_length); range.setStart(node, text_length); sel.addRange(range); } else { node = node.splitText(pos); var selNode; if(text.nodeType == Node.DOCUMENT_FRAGMENT_NODE) { selNode = text.firstChild; } else { selNode = text; } node.parentNode.insertBefore(text, node); add_range(selNode); } break; } } function add_range(node) { checkFocus(); var sel = editwin.getSelection(); var range = editdoc.createRange(); range.selectNodeContents(node); sel.removeAllRanges(); sel.addRange(range); } function readNodes(root, toptag) { var html = ""; var moz_check = /_moz/i; switch(root.nodeType) { case Node.ELEMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: var closed; if(toptag) { closed = !root.hasChildNodes(); html = '<' + root.tagName.toLowerCase(); var attr = root.attributes; for(var i = 0; i < attr.length; ++i) { var a = attr.item(i); if(!a.specified || a.name.match(moz_check) || a.value.match(moz_check)) { continue; } html += " " + a.name.toLowerCase() + '="' + a.value + '"'; } html += closed ? " />" : ">"; } for(var i = root.firstChild; i; i = i.nextSibling) { html += readNodes(i, true); } if(toptag && !closed) { html += "</" + root.tagName.toLowerCase() + ">"; } break; case Node.TEXT_NODE: html = htmlspecialchars(root.data); break; } return html; } function moveCursor(increment) { var test = cursor + increment; if(test >= 0 && stack[test] != null && !isUndefined(stack[test])) { cursor += increment; } } function addSnapshot(str) { if(stack[cursor] == str) { return; } else { cursor++; stack[cursor] = str; if(!isUndefined(stack[cursor + 1])) { stack[cursor + 1] = null; } } } function getSnapshot() { if(!isUndefined(stack[cursor]) && stack[cursor] != null) { return stack[cursor]; } else { return false; } } function clearContent() { if(wysiwyg) { editdoc.body.innerHTML = BROWSER.firefox ? '<br />' : ''; } else { textobj.value = ''; } } function uploadNextAttach() { var str = $('attachframe').contentWindow.document.body.innerHTML; if(str == '') return; var arr = str.split('|'); var att = CURRENTATTACH.split('|'); uploadAttach(parseInt(att[0]), arr[0] == 'DISCUZUPLOAD' ? parseInt(arr[1]) : -1, att[1]); } function uploadAttach(curId, statusid, prefix) { prefix = isUndefined(prefix) ? '' : prefix; var nextId = 0; for(var i = 0; i < AID - 1; i++) { if($(prefix + 'attachform_' + i)) { nextId = i; if(curId == 0) { break; } else { if(i > curId) { break; } } } } if(nextId == 0) { return; } CURRENTATTACH = nextId + '|' + prefix; if(curId > 0) { if(statusid == 0) { UPLOADCOMPLETE++; } else { FAILEDATTACHS += '<br />' + mb_cutstr($(prefix + 'attachnew_' + curId).value.substr($(prefix + 'attachnew_' + curId).value.replace(/\\/g, '/').lastIndexOf('/') + 1), 25) + ': ' + STATUSMSG[statusid]; UPLOADFAILED++; } $(prefix + 'cpdel_' + curId).innerHTML = '<img src="' + IMGDIR + '/check_' + (statusid == 0 ? 'right' : 'error') + '.gif" alt="' + STATUSMSG[statusid] + '" />'; if(nextId == curId || in_array(statusid, [6, 8])) { if(prefix == 'img') updateImageList(); else updateAttachList(); if(UPLOADFAILED > 0) { showDialog('附件上传完成!成功 ' + UPLOADCOMPLETE + ' 个,失败 ' + UPLOADFAILED + ' 个:' + FAILEDATTACHS); FAILEDATTACHS = ''; } UPLOADSTATUS = 2; for(var i = 0; i < AID - 1; i++) { if($(prefix + 'attachform_' + i)) { reAddAttach(prefix, i) } } $(prefix + 'uploadbtn').style.display = ''; $(prefix + 'uploading').style.display = 'none'; if(AUTOPOST) { hideMenu(); validate($('postform')); } else if(UPLOADFAILED == 0 && ((prefix == 'img' && $(editorid + '_cmd_image_menu').style.display == 'none') || (prefix == '' && $(editorid + '_cmd_attach_menu').style.display == 'none'))) { showDialog('附件上传完成!', 'notice'); } UPLOADFAILED = UPLOADCOMPLETE = 0; CURRENTATTACH = '0'; FAILEDATTACHS = ''; return; } } else { $(prefix + 'uploadbtn').style.display = 'none'; $(prefix + 'uploading').style.display = ''; } $(prefix + 'cpdel_' + nextId).innerHTML = '<img src="' + IMGDIR + '/loading.gif" alt="上传中..." />'; UPLOADSTATUS = 1; $(prefix + 'attachform_' + nextId).submit(); } function addAttach(prefix) { var id = AID; var tags, newnode, i; prefix = isUndefined(prefix) ? '' : prefix; newnode = $(prefix + 'attachbtnhidden').firstChild.cloneNode(true); tags = newnode.getElementsByTagName('input'); for(i in tags) { if(tags[i].name == 'Filedata') { tags[i].id = prefix + 'attachnew_' + id; tags[i].onchange = function() {insertAttach(prefix, id)}; tags[i].unselectable = 'on'; } else if(tags[i].name == 'attachid') { tags[i].value = id; } } tags = newnode.getElementsByTagName('form'); tags[0].name = tags[0].id = prefix + 'attachform_' + id; $(prefix + 'attachbtn').appendChild(newnode); newnode = $(prefix + 'attachbodyhidden').firstChild.cloneNode(true); tags = newnode.getElementsByTagName('input'); for(i in tags) { if(tags[i].name == prefix + 'localid[]') { tags[i].value = id; } } tags = newnode.getElementsByTagName('span'); for(i in tags) { if(tags[i].id == prefix + 'localfile[]') { tags[i].id = prefix + 'localfile_' + id; } else if(tags[i].id == prefix + 'cpdel[]') { tags[i].id = prefix + 'cpdel_' + id; } else if(tags[i].id == prefix + 'localno[]') { tags[i].id = prefix + 'localno_' + id; } else if(tags[i].id == prefix + 'deschidden[]') { tags[i].id = prefix + 'deschidden_' + id; } } AID++; newnode.style.display = 'none'; $(prefix + 'attachbody').appendChild(newnode); } function insertAttach(prefix, id) { var localimgpreview = ''; var path = $(prefix + 'attachnew_' + id).value; var extpos = path.lastIndexOf('.'); var ext = extpos == -1 ? '' : path.substr(extpos + 1, path.length).toLowerCase(); var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig"); var localfile = $(prefix + 'attachnew_' + id).value.substr($(prefix + 'attachnew_' + id).value.replace(/\\/g, '/').lastIndexOf('/') + 1); var filename = mb_cutstr(localfile, 30); if(path == '') { return; } if(extensions != '' && (re.exec(extensions) == null || ext == '')) { reAddAttach(prefix, id); showDialog('对不起,不支持上传此类扩展名的附件。'); return; } if(prefix == 'img' && imgexts.indexOf(ext) == -1) { reAddAttach(prefix, id); showDialog('请选择图片文件(' + imgexts + ')'); return; } $(prefix + 'cpdel_' + id).innerHTML = '<a href="###" class="deloption" onclick="reAddAttach(\'' + prefix + '\', ' + id + ')">删除</a>'; $(prefix + 'localfile_' + id).innerHTML = '<span>' + filename + '</span>'; $(prefix + 'attachnew_' + id).style.display = 'none'; $(prefix + 'deschidden_' + id).style.display = ''; $(prefix + 'deschidden_' + id).title = localfile; $(prefix + 'localno_' + id).parentNode.parentNode.style.display = ''; addAttach(prefix); UPLOADSTATUS = 0; } function reAddAttach(prefix, id) { $(prefix + 'attachbody').removeChild($(prefix + 'localno_' + id).parentNode.parentNode); $(prefix + 'attachbtn').removeChild($(prefix + 'attachnew_' + id).parentNode.parentNode); $(prefix + 'attachbody').innerHTML == '' && addAttach(prefix); $('localimgpreview_' + id) ? document.body.removeChild($('localimgpreview_' + id)) : null; } function delAttach(id, type) { appendAttachDel(id); $('attach_' + id).style.display = 'none'; ATTACHNUM['attach' + (type ? 'un' : '') + 'used']--; updateattachnum('attach'); } function delImgAttach(id, type) { appendAttachDel(id); $('image_td_' + id).className = 'imgdeleted'; $('image_' + id).onclick = null; $('image_desc_' + id).disabled = true; ATTACHNUM['image' + (type ? 'un' : '') + 'used']--; updateattachnum('image'); } function appendAttachDel(id) { var input = document.createElement('input'); input.name = 'attachdel[]'; input.value = id; input.type = 'hidden'; $('postbox').appendChild(input); } function updateAttach(aid) { objupdate = $('attachupdate'+aid); obj = $('attach' + aid); if(!objupdate.innerHTML) { obj.style.display = 'none'; objupdate.innerHTML = '<input type="file" name="attachupdate[paid' + aid + ']"><a href="javascript:;" onclick="updateAttach(' + aid + ')">取消</a>'; } else { obj.style.display = ''; objupdate.innerHTML = ''; } } function updateattachnum(type) { ATTACHNUM[type + 'used'] = ATTACHNUM[type + 'used'] >= 0 ? ATTACHNUM[type + 'used'] : 0; ATTACHNUM[type + 'unused'] = ATTACHNUM[type + 'unused'] >= 0 ? ATTACHNUM[type + 'unused'] : 0; var num = ATTACHNUM[type + 'used'] + ATTACHNUM[type + 'unused']; if(num) { $(editorid + '_cmd_' + type).title = '包含 ' + num + (type == 'image' ? ' 个图片附件' : ' 个附件'); $(editorid + '_cmd_' + type + '_notice').style.display = ''; } else { $(editorid + '_cmd_' + type).title = type == 'image' ? '图片' : '附件'; $(editorid + '_cmd_' + type + '_notice').style.display = 'none'; } } function swfHandler(action, type) { if(type == 'image') { updateImageList(action); } else { updateAttachList(action); } } function updateAttachList(action) { if(action != 2) ajaxget('ajax.php?action=attachlist&posttime=' + $('posttime').value, 'attachlist'); if(action != 1) switchAttachbutton('attachlist');$('attach_tblheader').style.display = $('attach_notice').style.display = ''; } function updateImageList(action) { if(action != 2) ajaxget('ajax.php?action=imagelist&pid=' + pid + '&posttime=' + $('posttime').value, 'imgattachlist'); if(action != 1) switchImagebutton('imgattachlist');$('imgattach_notice').style.display = ''; } function switchButton(btn, btns) { if(!$(editorid + '_btn_' + btn) || !$(editorid + '_' + btn)) { return; } $(editorid + '_btn_' + btn).style.display = ''; $(editorid + '_' + btn).style.display = ''; $(editorid + '_btn_' + btn).className = 'current'; for(i = 0;i < btns.length;i++) { if(btns[i] != btn) { if(!$(editorid + '_' + btns[i]) || !$(editorid + '_btn_' + btns[i])) { continue; } $(editorid + '_' + btns[i]).style.display = 'none'; $(editorid + '_btn_' + btns[i]).className = ''; } } } function uploadWindowstart() { $('uploadwindowing').style.visibility = 'visible'; $('uploadsubmit').disabled = true; } function uploadWindowload() { $('uploadwindowing').style.visibility = 'hidden'; $('uploadsubmit').disabled = false; var str = $('uploadattachframe').contentWindow.document.body.innerHTML; if(str == '') return; var arr = str.split('|'); if(arr[0] == 'DISCUZUPLOAD' && arr[2] == 0) { UPLOADWINRECALL(arr[3], arr[5]); hideWindow('upload'); } else { showDialog('上传失败:' + STATUSMSG[arr[2]]); } } function uploadWindow(recall, type) { var type = isUndefined(type) ? 'image' : type; UPLOADWINRECALL = recall; showWindow('upload', 'misc.php?action=upload&fid=' + fid + '&type=' + type, 'get', 0, 1, 0); } function updatetradeattach(aid, url, attachurl) { $('tradeaid').value = aid; $('tradeattach_image').innerHTML = '<img src="' + attachurl + '/' + url + '" class="goodsimg" />'; }
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/post.js
JavaScript
asf20
51,214
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: viewthread.js 21279 2009-11-24 09:59:28Z monkey $ */ var replyreload = ''; function attachimgshow(pid) { aimgs = aimgcount[pid]; aimgcomplete = 0; loadingcount = 0; for(i = 0;i < aimgs.length;i++) { obj = $('aimg_' + aimgs[i]); if(!obj) { aimgcomplete++; continue; } if(!obj.status) { obj.status = 1; obj.src = obj.getAttribute('file'); loadingcount++; } else if(obj.status == 1) { if(obj.complete) { obj.status = 2; } else { loadingcount++; } } else if(obj.status == 2) { aimgcomplete++; if(obj.getAttribute('thumbImg')) { thumbImg(obj); } } if(loadingcount >= 10) { break; } } if(aimgcomplete < aimgs.length) { setTimeout("attachimgshow('" + pid + "')", 100); } } function attachimginfo(obj, infoobj, show, event) { objinfo = fetchOffset(obj); if(show) { $(infoobj).style.left = objinfo['left'] + 'px'; $(infoobj).style.top = obj.offsetHeight < 40 ? (objinfo['top'] + obj.offsetHeight) + 'px' : objinfo['top'] + 'px'; $(infoobj).style.display = ''; } else { if(BROWSER.ie) { $(infoobj).style.display = 'none'; return; } else { var mousex = document.body.scrollLeft + event.clientX; var mousey = document.documentElement.scrollTop + event.clientY; if(mousex < objinfo['left'] || mousex > objinfo['left'] + objinfo['width'] || mousey < objinfo['top'] || mousey > objinfo['top'] + objinfo['height']) { $(infoobj).style.display = 'none'; } } } } function copycode(obj) { setCopy(BROWSER.ie ? obj.innerText.replace(/\r\n\r\n/g, '\r\n') : obj.textContent, '代码已复制到剪贴板'); } function signature(obj) { if(obj.style.maxHeightIE != '') { var height = (obj.scrollHeight > parseInt(obj.style.maxHeightIE)) ? obj.style.maxHeightIE : obj.scrollHeight + 'px'; if(obj.innerHTML.indexOf('<IMG ') == -1) { obj.style.maxHeightIE = ''; } return height; } } function tagshow(event) { var obj = BROWSER.ie ? event.srcElement : event.target; ajaxmenu(obj, 0, 1, 2); } var zoomclick = 0, zoomstatus = 1; function zoom(obj, zimg) { if(!zoomstatus) { window.open(zimg, '', ''); return; } if(!obj.id) obj.id = 'img_' + Math.random(); var menuid = obj.id + '_zmenu'; var menu = $(menuid); var imgid = menuid + '_img'; var zoomid = menuid + '_zimg'; var maxh = (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight) - 70; zimg = zimg ? zimg : obj.src; if(!menu) { menu = document.createElement('div'); menu.id = menuid; var objpos = fetchOffset(obj); menu.innerHTML = '<div onclick="$(\'append_parent\').removeChild($(\'' + obj.id + '_zmenu\'))" style="filter:alpha(opacity=50);opacity:0.5;background:#FFF;position:absolute;width:' + obj.clientWidth + 'px;height:' + obj.clientHeight + 'px;left:' + objpos['left'] + 'px;top:' + objpos['top'] + 'px"><table width="100%" height="100%"><tr><td valign="middle" align="center"><img src="' + IMGDIR + '/loading.gif" /></td></tr></table></div>' + '<div style="position:absolute;top:-100000px;display:none"><img id="' + imgid + '" src="' + zimg + '"></div>'; $('append_parent').appendChild(menu); $(imgid).onload = function() { $(imgid).parentNode.style.display = ''; var imgw = $(imgid).width; var imgh = $(imgid).height; var r = imgw / imgh; var w = document.body.clientWidth * 0.95; w = imgw > w ? w : imgw; var h = w / r; if(h > maxh) { h = maxh; w = h * r; } $('append_parent').removeChild(menu); menu = document.createElement('div'); menu.id = menuid; menu.style.overflow = 'visible'; menu.style.width = (w < 300 ? 300 : w) + 20 + 'px'; menu.style.height = h + 50 + 'px'; menu.innerHTML = '<div class="zoominner"><p id="' + menuid + '_ctrl"><span class="right"><a href="' + zimg + '" class="imglink" target="_blank" title="在新窗口打开">在新窗口打开</a><a href="javascipt:;" id="' + menuid + '_adjust" class="imgadjust" title="实际大小">实际大小</a><a href="javascript:;" onclick="hideMenu()" class="imgclose" title="关闭">关闭</a></span>鼠标滚轮缩放图片</p><div align="center" onmousedown="zoomclick=1" onmousemove="zoomclick=2" onmouseup="if(zoomclick==1) hideMenu()"><img id="' + zoomid + '" src="' + zimg + '" width="' + w + '" height="' + h + '" w="' + imgw + '" h="' + imgh + '"></div></div>'; $('append_parent').appendChild(menu); $(menuid + '_adjust').onclick = function(e) {adjust(e, 1)}; if(BROWSER.ie){ menu.onmousewheel = adjust; } else { menu.addEventListener('DOMMouseScroll', adjust, false); } showMenu({'menuid':menuid,'duration':3,'pos':'00','cover':1,'drag':menuid,'maxh':maxh+70}); }; } else { showMenu({'menuid':menuid,'duration':3,'pos':'00','cover':1,'drag':menuid,'maxh':menu.clientHeight}); } if(BROWSER.ie) doane(event); var adjust = function(e, a) { var imgw = $(zoomid).getAttribute('w'); var imgh = $(zoomid).getAttribute('h'); var imgwstep = imgw / 10; var imghstep = imgh / 10; if(!a) { if(!e) e = window.event; if(e.altKey || e.shiftKey || e.ctrlKey) return; if(e.wheelDelta <= 0 || e.detail > 0) { if($(zoomid).width - imgwstep <= 200 || $(zoomid).height - imghstep <= 200) { doane(e);return; } $(zoomid).width -= imgwstep; $(zoomid).height -= imghstep; } else { if($(zoomid).width + imgwstep >= imgw) { doane(e);return; } $(zoomid).width += imgwstep; $(zoomid).height += imghstep; } } else { $(zoomid).width = imgw; $(zoomid).height = imgh; } menu.style.width = (parseInt($(zoomid).width < 300 ? 300 : parseInt($(zoomid).width)) + 20) + 'px'; menu.style.height = (parseInt($(zoomid).height) + 50) + 'px'; setMenuPosition('', menuid, '00'); doane(e); }; } function parsetag(pid) { if(!$('postmessage_'+pid) || $('postmessage_'+pid).innerHTML.match(/<script[^\>]*?>/i)) { return; } var havetag = false; var tagfindarray = new Array(); var str = $('postmessage_'+pid).innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3, $4) { for(i in tagarray) { if(tagarray[i] && $3.indexOf(tagarray[i]) != -1) { havetag = true; $3 = $3.replace(tagarray[i], '<h_ ' + i + '>'); tmp = $3.replace(/&[a-z]*?<h_ \d+>[a-z]*?;/ig, ''); if(tmp != $3) { $3 = tmp; } else { tagfindarray[i] = tagarray[i]; tagarray[i] = ''; } } } return $2 + $3; }); if(havetag) { $('postmessage_'+pid).innerHTML = str.replace(/<h_ (\d+)>/ig, function($1, $2) { return '<span href=\"tag.php?name=' + tagencarray[$2] + '\" onclick=\"tagshow(event)\" class=\"t_tag\">' + tagfindarray[$2] + '</span>'; }); } } function setanswer(pid){ if(confirm('您确认要把该回复选为“最佳答案”吗?')){ if(BROWSER.ie) { doane(event); } $('modactions').action='misc.php?action=bestanswer&tid=' + tid + '&pid=' + pid + '&bestanswersubmit=yes'; $('modactions').submit(); } } var authort; function showauthor(ctrlObj, menuid) { authort = setTimeout(function () { showMenu({'menuid':menuid}); if($(menuid + '_ma').innerHTML == '') $(menuid + '_ma').innerHTML = ctrlObj.innerHTML; }, 500); if(!ctrlObj.onmouseout) { ctrlObj.onmouseout = function() { clearTimeout(authort); } } } function fastpostvalidate(theform) { s = ''; if(theform.message.value == '' && theform.subject.value == '') { s = '请完成标题或内容栏。'; theform.message.focus(); } else if(mb_strlen(theform.subject.value) > 80) { s = '您的标题超过 80 个字符的限制。'; theform.subject.focus(); } if(!disablepostctrl && ((postminchars != 0 && mb_strlen(theform.message.value) < postminchars) || (postmaxchars != 0 && mb_strlen(theform.message.value) > postmaxchars))) { s = '您的帖子长度不符合要求。\n\n当前长度: ' + mb_strlen(theform.message.value) + ' ' + '字节\n系统限制: ' + postminchars + ' 到 ' + postmaxchars + ' 字节'; } if(s) { $('fastpostreturn').className = 'onerror'; $('fastpostreturn').innerHTML = s; $('fastpostsubmit').disabled = false; return false; } $('fastpostsubmit').disabled = true; theform.message.value = parseurl(theform.message.value); ajaxpost('fastpostform', 'fastpostreturn', 'fastpostreturn', 'onerror', $('fastpostsubmit')); return false; } function fastpostappendreply() { setcookie('discuz_fastpostrefresh', $('fastpostrefresh').checked ? 1 : 0, 2592000); if($('fastpostrefresh').checked) { location.href = 'redirect.php?tid='+tid+'&goto=lastpost&from=fastpost&random=' + Math.random() + '#lastpost'; return; } newpos = fetchOffset($('post_new')); document.documentElement.scrollTop = newpos['top']; $('post_new').style.display = ''; $('post_new').id = ''; div = document.createElement('div'); div.id = 'post_new'; div.style.display = 'none'; div.className = 'viewthread_table'; $('postlistreply').appendChild(div); $('fastpostsubmit').disabled = false; $('fastpostmessage').value = ''; if($('secanswer3')) { $('checksecanswer3').innerHTML = '<img src="images/common/none.gif" width="17" height="17">'; $('secanswer3').value = ''; secclick3['secanswer3'] = 0; } if($('seccodeverify3')) { $('checkseccodeverify3').innerHTML = '<img src="images/common/none.gif" width="17" height="17">'; $('seccodeverify3').value = ''; secclick3['seccodeverify3'] = 0; } showCreditPrompt(); } function submithandle_fastpost(locationhref) { var pid = locationhref.lastIndexOf('#pid'); if(pid != -1) { pid = locationhref.substr(pid + 4); ajaxget('viewthread.php?tid=' + tid + '&viewpid=' + pid, 'post_new', 'ajaxwaitid', '', null, 'fastpostappendreply()'); if(replyreload) { var reloadpids = replyreload.split(','); for(i = 1;i < reloadpids.length;i++) { ajaxget('viewthread.php?tid=' + tid + '&viewpid=' + reloadpids[i], 'post_' + reloadpids[i]); } } $('fastpostreturn').className = ''; } else { $('post_new').style.display = $('fastpostmessage').value = $('fastpostreturn').className = ''; $('fastpostreturn').innerHTML = '本版回帖需要审核,您的帖子将在通过审核后显示'; } } function messagehandle_fastpost() { $('fastpostsubmit').disabled = false; } function recommendupdate(n) { if(getcookie('discuz_recommend')) { var objv = n > 0 ? $('recommendv_add') : $('recommendv_subtract'); objv.innerHTML = parseInt(objv.innerHTML) + 1; $('recommendv').innerHTML = parseInt($('recommendv').innerHTML) + n; setcookie('discuz_recommend', '', -2592000); } } function switchrecommendv() { display('recommendv'); display('recommendav'); } function appendreply() { newpos = fetchOffset($('post_new')); document.documentElement.scrollTop = newpos['top']; $('post_new').style.display = ''; $('post_new').id = ''; div = document.createElement('div'); div.id = 'post_new'; div.style.display = 'none'; div.className = ''; $('postlistreply').appendChild(div); $('postform').replysubmit.disabled = false; showCreditPrompt(); } function creditconfirm(v) { return confirm('下载需要消耗' + v + ',您是否要下载?'); }
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/viewthread.js
JavaScript
asf20
11,482
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: bbcode.js 21030 2009-11-09 00:37:07Z monkey $ */ var re; function addslashes(str) { return preg_replace(['\\\\', '\\\'', '\\\/', '\\\(', '\\\)', '\\\[', '\\\]', '\\\{', '\\\}', '\\\^', '\\\$', '\\\?', '\\\.', '\\\*', '\\\+', '\\\|'], ['\\\\', '\\\'', '\\/', '\\(', '\\)', '\\[', '\\]', '\\{', '\\}', '\\^', '\\$', '\\?', '\\.', '\\*', '\\+', '\\|'], str); } function atag(aoptions, text) { if(trim(text) == '') { return ''; } href = getoptionvalue('href', aoptions); if(href.substr(0, 11) == 'javascript:') { return trim(recursion('a', text, 'atag')); } return '[url=' + href + ']' + trim(recursion('a', text, 'atag')) + '[/url]'; } function bbcode2html(str) { if(str == '') { return ''; } if(!fetchCheckbox('bbcodeoff') && allowbbcode) { str = str.replace(/\[code\]([\s\S]+?)\[\/code\]/ig, function($1, $2) {return parsecode($2);}); } if(!forumallowhtml || !allowhtml || !fetchCheckbox('htmlon')) { str = str.replace(/</g, '&lt;'); str = str.replace(/>/g, '&gt;'); if(!fetchCheckbox('parseurloff')) { str = parseurl(str, 'html', false); } } if(!fetchCheckbox('smileyoff') && allowsmilies) { if(typeof smilies_type == 'object') { for(var typeid in smilies_array) { for(var page in smilies_array[typeid]) { for(var i in smilies_array[typeid][page]) { re = new RegExp(preg_quote(smilies_array[typeid][page][i][1]), "g"); str = str.replace(re, '<img src="./images/smilies/' + smilies_type[typeid][1] + '/' + smilies_array[typeid][page][i][2] + '" border="0" smilieid="' + smilies_array[typeid][page][i][0] + '" alt="' + smilies_array[typeid][page][i][1] + '" />'); } } } } } if(!fetchCheckbox('bbcodeoff') && allowbbcode) { str= str.replace(/\[url\]\s*((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/|www\.)([^\[\"']+?)\s*\[\/url\]/ig, function($1, $2, $3, $4) {return cuturl($2 + $4);}); str= str.replace(/\[url=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/|www\.|mailto:)([^\s\[\"']+?)\]([\s\S]+?)\[\/url\]/ig, '<a href="$1$3" target="_blank">$4</a>'); str= str.replace(/\[email\](.*?)\[\/email\]/ig, '<a href="mailto:$1">$1</a>'); str= str.replace(/\[email=(.[^\[]*)\](.*?)\[\/email\]/ig, '<a href="mailto:$1" target="_blank">$2</a>'); str = str.replace(/\[color=([^\[\<]+?)\]/ig, '<font color="$1">'); str = str.replace(/\[size=(\d+?)\]/ig, '<font size="$1">'); str = str.replace(/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/ig, '<font style="font-size: $1">'); str = str.replace(/\[font=([^\[\<]+?)\]/ig, '<font face="$1">'); str = str.replace(/\[align=([^\[\<]+?)\]/ig, '<p align="$1">'); str = str.replace(/\[p=(\d{1,2}), (\d{1,2}), (left|center|right)\]/ig, '<p style="line-height: $1px; text-indent: $2em; text-align: $3;">'); str = str.replace(/\[float=([^\[\<]+?)\]/ig, '<br style="clear: both"><span style="float: $1;">'); re = /\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*([\s\S]+?)\s*\[\/table\]/ig; for (i = 0; i < 4; i++) { str = str.replace(re, function($1, $2, $3, $4) {return parsetable($2, $3, $4);}); } str = preg_replace([ '\\\[\\\/color\\\]', '\\\[\\\/size\\\]', '\\\[\\\/font\\\]', '\\\[\\\/align\\\]', '\\\[\\\/p\\\]', '\\\[b\\\]', '\\\[\\\/b\\\]', '\\\[i\\\]', '\\\[\\\/i\\\]', '\\\[u\\\]', '\\\[\\\/u\\\]', '\\\[s\\\]', '\\\[\\\/s\\\]', '\\\[hr\\\]', '\\\[list\\\]', '\\\[list=1\\\]', '\\\[list=a\\\]', '\\\[list=A\\\]', '\\\[\\\*\\\]', '\\\[\\\/list\\\]', '\\\[indent\\\]', '\\\[\\\/indent\\\]', '\\\[\\\/float\\\]' ], [ '</font>', '</font>', '</font>', '</p>', '</p>', '<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<strike>', '</strike>', '<hr class="solidline" />', '<ul>', '<ul type=1 class="litype_1">', '<ul type=a class="litype_2">', '<ul type=A class="litype_3">', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>' ], str, 'g'); } if(!fetchCheckbox('bbcodeoff')) { if(allowimgcode) { str = str.replace(/\[localimg=(\d{1,4}),(\d{1,4})\](\d+)\[\/localimg\]/ig, function ($1, $2, $3, $4) {if($('attachnew_' + $4)) {var src = $('attachnew_' + $4).value; if(src != '') return '<img style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=\'scale\',src=\'' + src + '\');width:' + $2 + ';height=' + $3 + '" src=\'images/common/none.gif\' border="0" aid="attach_' + $4 + '" alt="" />';}}); str = str.replace(/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '<img src="$1" border="0" alt="" />'); str = str.replace(/\[attachimg\](\d+)\[\/attachimg\]/ig, function ($1, $2) {return '<img src="' + $('image_' + $2).src + '" border="0" aid="attachimg_' + $2 + '" width="' + $('image_' + $2).getAttribute('_width') + '" alt="" />';}); str = str.replace(/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, function ($1, $2, $3, $4) {return '<img' + ($2 > 0 ? ' width="' + $2 + '"' : '') + ($3 > 0 ? ' height="' + $3 + '"' : '') + ' src="' + $4 + '" border="0" alt="" />'}); } else { str = str.replace(/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '<a href="$1" target="_blank">$1</a>'); str = str.replace(/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ig, '<a href="$1" target="_blank">$1</a>'); } } for(var i = 0; i <= DISCUZCODE['num']; i++) { str = str.replace("[\tDISCUZ_CODE_" + i + "\t]", DISCUZCODE['html'][i]); } if(!forumallowhtml || !allowhtml || !fetchCheckbox('htmlon')) { str = preg_replace(['\t', ' ', ' ', '(\r\n|\n|\r)'], ['&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;', '<br />'], str); } return str; } function cuturl(url) { var length = 65; var urllink = '<a href="' + (url.toLowerCase().substr(0, 4) == 'www.' ? 'http://' + url : url) + '" target="_blank">'; if(url.length > length) { url = url.substr(0, parseInt(length * 0.5)) + ' ... ' + url.substr(url.length - parseInt(length * 0.3)); } urllink += url + '</a>'; return urllink; } function dstag(options, text, tagname) { if(trim(text) == '') { return '\n'; } var pend = parsestyle(options, '', ''); var prepend = pend['prepend']; var append = pend['append']; if(in_array(tagname, ['div', 'p'])) { align = getoptionvalue('align', options); if(in_array(align, ['left', 'center', 'right'])) { prepend = '[align=' + align + ']' + prepend; append += '[/align]'; } else { append += '\n'; } } return prepend + recursion(tagname, text, 'dstag') + append; } function ptag(options, text, tagname) { if(trim(text) == '') { return '\n'; } else if(trim(options) == '') { return '\n' + text; } var lineHeight = 30; var textIndent = 2; var align, re, matches; re = /line-height\s?:\s?(\d{1,3})px/ig; matches = re.exec(options); if(matches != null) { lineHeight = matches[1]; } re = /text-indent\s?:\s?(\d{1,3})em/ig; matches = re.exec(options); if(matches != null) { textIndent = matches[1]; } re = /text-align\s?:\s?(left|center|right)/ig; matches = re.exec(options); if(matches != null) { align = matches[1]; } else { align = getoptionvalue('align', options); } align = in_array(align, ['left', 'center', 'right']) ? align : 'left'; return '[p=' + lineHeight + ', ' + textIndent + ', ' + align + ']' + text + '[/p]'; } function fetchCheckbox(cbn) { return $(cbn) && $(cbn).checked == true ? 1 : 0; } function fetchoptionvalue(option, text) { if((position = strpos(text, option)) !== false) { delimiter = position + option.length; if(text.charAt(delimiter) == '"') { delimchar = '"'; } else if(text.charAt(delimiter) == '\'') { delimchar = '\''; } else { delimchar = ' '; } delimloc = strpos(text, delimchar, delimiter + 1); if(delimloc === false) { delimloc = text.length; } else if(delimchar == '"' || delimchar == '\'') { delimiter++; } return trim(text.substr(delimiter, delimloc - delimiter)); } else { return ''; } } function fonttag(fontoptions, text) { var prepend = ''; var append = ''; var tags = new Array(); tags = {'font' : 'face=', 'size' : 'size=', 'color' : 'color='}; for(bbcode in tags) { optionvalue = fetchoptionvalue(tags[bbcode], fontoptions); if(optionvalue) { prepend += '[' + bbcode + '=' + optionvalue + ']'; append = '[/' + bbcode + ']' + append; } } var pend = parsestyle(fontoptions, prepend, append); return pend['prepend'] + recursion('font', text, 'fonttag') + pend['append']; } function getoptionvalue(option, text) { re = new RegExp(option + "(\s+?)?\=(\s+?)?[\"']?(.+?)([\"']|$|>)", "ig"); var matches = re.exec(text); if(matches != null) { return trim(matches[3]); } return ''; } function html2bbcode(str) { if((forumallowhtml && allowhtml && fetchCheckbox('htmlon')) || trim(str) == '') { str = str.replace(/<img[^>]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smileycode($3);}); str = str.replace(/<img([^>]*aid=[^>]*)>/ig, function($1, $2) {return imgtag($2);}); return str; } str= str.replace(/\[code\]([\s\S]+?)\[\/code\]/ig, function($1, $2) {return codetag($2);}); str = preg_replace(['<style.*?>[\\\s\\\S]*?<\/style>', '<script.*?>[\\\s\\\S]*?<\/script>', '<noscript.*?>[\\\s\\\S]*?<\/noscript>', '<select.*?>[\s\S]*?<\/select>', '<object.*?>[\s\S]*?<\/object>', '<!--[\\\s\\\S]*?-->', ' on[a-zA-Z]{3,16}\\\s?=\\\s?"[\\\s\\\S]*?"'], '', str); str= str.replace(/(\r\n|\n|\r)/ig, ''); str= trim(str.replace(/&((#(32|127|160|173))|shy|nbsp);/ig, ' ')); if(!fetchCheckbox('parseurloff')) { str = parseurl(str, 'bbcode', false); } str = str.replace(/<br\s+?style=(["']?)clear: both;?(\1)[^\>]*>/ig, ''); str = str.replace(/<br[^\>]*>/ig, "\n"); if(!fetchCheckbox('bbcodeoff') && allowbbcode) { str = preg_replace(['<table([^>]*(width|background|background-color|bgcolor)[^>]*)>', '<table[^>]*>', '<tr[^>]*(?:background|background-color|bgcolor)[:=]\\\s*(["\']?)([\(\)%,#\\\w]+)(\\1)[^>]*>', '<tr[^>]*>', '<t[dh]([^>]*(width|colspan|rowspan)[^>]*)>', '<t[dh][^>]*>', '<\/t[dh]>', '<\/tr>', '<\/table>'], [function($1, $2) {return tabletag($2);}, '[table]\n', function($1, $2, $3) {return '[tr=' + $3 + ']';}, '[tr]', function($1, $2) {return tdtag($2);}, '[td]', '[/td]', '[/tr]\n', '[/table]'], str); str = str.replace(/<h([0-9]+)[^>]*>(.*)<\/h\\1>/ig, "[size=$1]$2[/size]\n\n"); str = str.replace(/<hr[^>]*>/ig, "[hr]"); str = str.replace(/<img[^>]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smileycode($3);}); str = str.replace(/<img([^>]*src[^>]*)>/ig, function($1, $2) {return imgtag($2);}); str = str.replace(/<a\s+?name=(["']?)(.+?)(\1)[\s\S]*?>([\s\S]*?)<\/a>/ig, '$4'); str = recursion('b', str, 'simpletag', 'b'); str = recursion('strong', str, 'simpletag', 'b'); str = recursion('i', str, 'simpletag', 'i'); str = recursion('em', str, 'simpletag', 'i'); str = recursion('u', str, 'simpletag', 'u'); str = recursion('strike', str, 'simpletag', 's'); str = recursion('a', str, 'atag'); str = recursion('font', str, 'fonttag'); str = recursion('blockquote', str, 'simpletag', 'indent'); str = recursion('ol', str, 'listtag'); str = recursion('ul', str, 'listtag'); str = recursion('div', str, 'dstag'); str = recursion('p', str, 'ptag'); str = recursion('span', str, 'dstag'); } str = str.replace(/<[\/\!]*?[^<>]*?>/ig, ''); for(var i = 0; i <= DISCUZCODE['num']; i++) { str = str.replace("[\tDISCUZ_CODE_" + i + "\t]", DISCUZCODE['html'][i]); } return preg_replace(['&nbsp;', '&lt;', '&gt;', '&amp;'], [' ', '<', '>', '&'], str); } function htmlspecialchars(str) { return preg_replace(['&', '<', '>', '"'], ['&amp;', '&lt;', '&gt;', '&quot;'], str); } function imgtag(attributes) { var width = ''; var height = ''; re = /src=(["']?)([\s\S]*?)(\1)/i; var matches = re.exec(attributes); if(matches != null) { var src = matches[2]; } else { return ''; } re = /width\s?:\s?(\d{1,4})(px)?/ig; var matches = re.exec(attributes); if(matches != null) { width = matches[1]; } re = /height\s?:\s?(\d{1,4})(px)?/ig; var matches = re.exec(attributes); if(matches != null) { height = matches[1]; } if(!width) { re = /width=(["']?)(\d+)(\1)/i; var matches = re.exec(attributes); if(matches != null) { width = matches[2]; } } if(!height) { re = /height=(["']?)(\d+)(\1)/i; var matches = re.exec(attributes); if(matches != null) { height = matches[2]; } } re = /aid=(["']?)attach_(\d+)(\1)/i; var matches = re.exec(attributes); var imgtag = 'img'; if(matches != null) { imgtag = 'localimg'; src = matches[2]; } re = /aid=(["']?)attachimg_(\d+)(\1)/i; var matches = re.exec(attributes); if(matches != null) { return '[attachimg]' + matches[2] + '[/attachimg]'; } width = width > 0 ? width : 0; height = height > 0 ? height : 0; return width > 0 || height > 0 ? '[' + imgtag + '=' + width + ',' + height + ']' + src + '[/' + imgtag + ']' : '[img]' + src + '[/img]'; } function listtag(listoptions, text, tagname) { text = text.replace(/<li>(([\s\S](?!<\/li))*?)(?=<\/?ol|<\/?ul|<li|\[list|\[\/list)/ig, '<li>$1</li>') + (BROWSER.opera ? '</li>' : ''); text = recursion('li', text, 'litag'); var opentag = '[list]'; var listtype = fetchoptionvalue('type=', listoptions); listtype = listtype != '' ? listtype : (tagname == 'ol' ? '1' : ''); if(in_array(listtype, ['1', 'a', 'A'])) { opentag = '[list=' + listtype + ']'; } return text ? opentag + recursion(tagname, text, 'listtag') + '[/list]' : ''; } function litag(listoptions, text) { return '[*]' + text.replace(/(\s+)$/g, ''); } function parsecode(text) { DISCUZCODE['num']++; DISCUZCODE['html'][DISCUZCODE['num']] = '[code]' + htmlspecialchars(text) + '[/code]'; return "[\tDISCUZ_CODE_" + DISCUZCODE['num'] + "\t]"; } function parsestyle(tagoptions, prepend, append) { var searchlist = [ ['align', true, 'text-align:\\s*(left|center|right);?', 1], ['float', true, 'float:\\s*(left|right);?', 1], ['color', true, '^(?:\\s|)color:\\s*([^;]+);?', 1], ['font', true, 'font-family:\\s*([^;]+);?', 1], ['size', true, 'font-size:\\s*(\\d+(\\.\\d+)?(px|pt|in|cm|mm|pc|em|ex|%|));?', 1], ['b', false, 'font-weight:\\s*(bold);?'], ['i', false, 'font-style:\\s*(italic);?'], ['u', false, 'text-decoration:\\s*(underline);?'], ['s', false, 'text-decoration:\\s*(line-through);?'] ]; var style = getoptionvalue('style', tagoptions); re = /^(?:\s|)color:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)(;?)/ig; style = style.replace(re, function($1, $2, $3, $4, $5) {return("color:#" + parseInt($2).toString(16) + parseInt($3).toString(16) + parseInt($4).toString(16) + $5);}); var len = searchlist.length; for(var i = 0; i < len; i++) { re = new RegExp(searchlist[i][2], "ig"); match = re.exec(style); if(match != null) { opnvalue = match[searchlist[i][3]]; prepend += '[' + searchlist[i][0] + (searchlist[i][1] == true ? '=' + opnvalue + ']' : ']'); append = '[/' + searchlist[i][0] + ']' + append; } } return {'prepend' : prepend, 'append' : append}; } function parsetable(width, bgcolor, str) { if(isUndefined(width)) { var width = ''; } else { width = width.substr(width.length - 1, width.length) == '%' ? (width.substr(0, width.length - 1) <= 98 ? width : '98%') : (width <= 560 ? width : '98%'); } str = str.replace(/\[tr(?:=([\(\)%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4, $5) { return '<tr' + ($2 ? ' style="background: ' + $2 + '"' : '') + '><td' + ($3 ? ' colspan="' + $3 + '"' : '') + ($4 ? ' rowspan="' + $4 + '"' : '') + ($5 ? ' width="' + $5 + '"' : '') + '>'; }); str = str.replace(/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ig, function($1, $2, $3, $4) { return '</td><td' + ($2 ? ' colspan="' + $2 + '"' : '') + ($3 ? ' rowspan="' + $3 + '"' : '') + ($4 ? ' width="' + $4 + '"' : '') + '>'; }); str = str.replace(/\[\/td\]\s*\[\/tr\]\s*/ig, '</td></tr>'); return '<table ' + (width == '' ? '' : 'width="' + width + '" ') + 'class="t_table"' + (isUndefined(bgcolor) ? '' : ' style="background: ' + bgcolor + '"') + '>' + str + '</table>'; } function preg_replace(search, replace, str, regswitch) { var regswitch = !regswitch ? 'ig' : regswitch; var len = search.length; for(var i = 0; i < len; i++) { re = new RegExp(search[i], regswitch); str = str.replace(re, typeof replace == 'string' ? replace : (replace[i] ? replace[i] : replace[0])); } return str; } function preg_quote(str) { return (str+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, "\\$1"); } function recursion(tagname, text, dofunction, extraargs) { if(extraargs == null) { extraargs = ''; } tagname = tagname.toLowerCase(); var open_tag = '<' + tagname; var open_tag_len = open_tag.length; var close_tag = '</' + tagname + '>'; var close_tag_len = close_tag.length; var beginsearchpos = 0; do { var textlower = text.toLowerCase(); var tagbegin = textlower.indexOf(open_tag, beginsearchpos); if(tagbegin == -1) { break; } var strlen = text.length; var inquote = ''; var found = false; var tagnameend = false; var optionend = 0; var t_char = ''; for(optionend = tagbegin; optionend <= strlen; optionend++) { t_char = text.charAt(optionend); if((t_char == '"' || t_char == "'") && inquote == '') { inquote = t_char; } else if((t_char == '"' || t_char == "'") && inquote == t_char) { inquote = ''; } else if(t_char == '>' && !inquote) { found = true; break; } else if((t_char == '=' || t_char == ' ') && !tagnameend) { tagnameend = optionend; } } if(!found) { break; } if(!tagnameend) { tagnameend = optionend; } var offset = optionend - (tagbegin + open_tag_len); var tagoptions = text.substr(tagbegin + open_tag_len, offset); var acttagname = textlower.substr(tagbegin * 1 + 1, tagnameend - tagbegin - 1); if(acttagname != tagname) { beginsearchpos = optionend; continue; } var tagend = textlower.indexOf(close_tag, optionend); if(tagend == -1) { break; } var nestedopenpos = textlower.indexOf(open_tag, optionend); while(nestedopenpos != -1 && tagend != -1) { if(nestedopenpos > tagend) { break; } tagend = textlower.indexOf(close_tag, tagend + close_tag_len); nestedopenpos = textlower.indexOf(open_tag, nestedopenpos + open_tag_len); } if(tagend == -1) { beginsearchpos = optionend; continue; } var localbegin = optionend + 1; var localtext = eval(dofunction)(tagoptions, text.substr(localbegin, tagend - localbegin), tagname, extraargs); text = text.substring(0, tagbegin) + localtext + text.substring(tagend + close_tag_len); beginsearchpos = tagbegin + localtext.length; } while(tagbegin != -1); return text; } function simpletag(options, text, tagname, parseto) { if(trim(text) == '') { return ''; } text = recursion(tagname, text, 'simpletag', parseto); return '[' + parseto + ']' + text + '[/' + parseto + ']'; } function smileycode(smileyid) { if(typeof smilies_type != 'object') return; for(var typeid in smilies_array) { for(var page in smilies_array[typeid]) { for(var i in smilies_array[typeid][page]) { if(smilies_array[typeid][page][i][0] == smileyid) { return smilies_array[typeid][page][i][1]; break; } } } } } function strpos(haystack, needle, _offset) { if(isUndefined(_offset)) { _offset = 0; } var _index = haystack.toLowerCase().indexOf(needle.toLowerCase(), _offset); return _index == -1 ? false : _index; } function tabletag(attributes) { var width = ''; re = /width=(["']?)(\d{1,4}%?)(\1)/i; var matches = re.exec(attributes); if(matches != null) { width = matches[2].substr(matches[2].length - 1, matches[2].length) == '%' ? (matches[2].substr(0, matches[2].length - 1) <= 98 ? matches[2] : '98%') : (matches[2] <= 560 ? matches[2] : '98%'); } else { re = /width\s?:\s?(\d{1,4})([px|%])/ig; var matches = re.exec(attributes); if(matches != null) { width = matches[2] == '%' ? (matches[1] <= 98 ? matches[1] + '%' : '98%') : (matches[1] <= 560 ? matches[1] : '98%'); } } var bgcolor = ''; re = /(?:background|background-color|bgcolor)[:=]\s*(["']?)((rgb\(\d{1,3}%?,\s*\d{1,3}%?,\s*\d{1,3}%?\))|(#[0-9a-fA-F]{3,6})|([a-zA-Z]{1,20}))(\1)/i; var matches = re.exec(attributes); if(matches != null) { bgcolor = matches[2]; width = width ? width : '98%'; } return bgcolor ? '[table=' + width + ',' + bgcolor + ']\n' : (width ? '[table=' + width + ']\n' : '[table]\n'); } function tdtag(attributes) { var colspan = 1; var rowspan = 1; var width = ''; re = /colspan=(["']?)(\d{1,2})(\1)/ig; var matches = re.exec(attributes); if(matches != null) { colspan = matches[2]; } re = /rowspan=(["']?)(\d{1,2})(\1)/ig; var matches = re.exec(attributes); if(matches != null) { rowspan = matches[2]; } re = /width=(["']?)(\d{1,4}%?)(\1)/ig; var matches = re.exec(attributes); if(matches != null) { width = matches[2]; } return in_array(width, ['', '0', '100%']) ? (colspan == 1 && rowspan == 1 ? '[td]' : '[td=' + colspan + ',' + rowspan + ']') : '[td=' + colspan + ',' + rowspan + ',' + width + ']'; }
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/bbcode.js
JavaScript
asf20
21,802
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: md5.js 16688 2008-11-14 06:41:07Z cnteacher $ */ var hexcase = 0; var chrsz = 8; function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz)); } function core_md5(x, len) { x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return Array(a, b, c, d); } function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); } function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); } function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); } function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); } function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } function str2binl(str) { var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) { bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); } return bin; } function binl2hex(binarray) { var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; }
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/md5.js
JavaScript
asf20
5,334
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: moderate.js 20061 2009-09-18 02:07:08Z monkey $ */ function modaction(action, pid, extra) { if(!action) { return; } var extra = !extra ? '' : '&' + extra; if(!pid && in_array(action, ['delpost', 'banpost'])) { var checked = 0; var pid = ''; for(var i = 0; i < $('modactions').elements.length; i++) { if($('modactions').elements[i].name.match('topiclist')) { checked = 1; break; } } } else { var checked = 1; } if(!checked) { alert('请选择需要操作的帖子'); } else { $('modactions').action = 'topicadmin.php?action='+ action +'&fid=' + fid + '&tid=' + tid + '&infloat=yes&nopost=yes' + (!pid ? '' : '&topiclist[]=' + pid) + extra + '&r' + Math.random(); showWindow('mods', 'modactions', 'post'); if(BROWSER.ie) { doane(event); } hideMenu(); } } function modthreads(optgroup, operation) { var operation = !operation ? '' : operation; $('modactions').action = 'topicadmin.php?action=moderate&fid=' + fid + '&moderate[]=' + tid + '&infloat=yes&nopost=yes' + (optgroup != 3 && optgroup != 2 ? '&from=' + tid : ''); $('modactions').optgroup.value = optgroup; $('modactions').operation.value = operation; hideWindow('mods'); showWindow('mods', 'modactions', 'post', 0); if(BROWSER.ie) { doane(event); } } function pidchecked(obj) { if(obj.checked) { if(BROWSER.ie && !BROWSER.opera) { var inp = document.createElement('<input name="topiclist[]" />'); } else { var inp = document.createElement('input'); inp.name = 'topiclist[]'; } inp.id = 'topiclist_' + obj.value; inp.value = obj.value; inp.style.display = 'none'; $('modactions').appendChild(inp); } else { $('modactions').removeChild($('topiclist_' + obj.value)); } } var modclickcount = 0; function modclick(obj, pid) { if(obj.checked) { modclickcount++; } else { modclickcount--; } $('modcount').innerHTML = modclickcount; if(modclickcount > 0) { var offset = fetchOffset(obj); $('modlayer').style.top = offset['top'] - 65 + 'px'; $('modlayer').style.left = offset['left'] - 215 + 'px'; $('modlayer').style.display = ''; } else { $('modlayer').style.display = 'none'; } } function tmodclick(obj) { if(obj.checked) { modclickcount++; } else { modclickcount--; } $('modcount').innerHTML = modclickcount; if(modclickcount > 0) { var top_offset = obj.offsetTop; while((obj = obj.offsetParent).id != 'threadlist') { top_offset += obj.offsetTop; } $('modlayer').style.top = top_offset - 7 + 'px'; $('modlayer').style.display = ''; } else { $('modlayer').style.display = 'none'; } } function tmodthreads(optgroup, operation) { var checked = 0; var operation = !operation ? '' : operation; for(var i = 0; i < $('moderate').elements.length; i++) { if($('moderate').elements[i].name.match('moderate') && $('moderate').elements[i].checked) { checked = 1; break; } } if(!checked) { alert('请选择需要操作的帖子'); } else { $('moderate').optgroup.value = optgroup; $('moderate').operation.value = operation; showWindow('mods', 'moderate', 'post'); } }
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/moderate.js
JavaScript
asf20
3,293
document.writeln('<script type="text/javascript">'); document.writeln('function validate_google(theform) {'); document.writeln(' if(theform.site.value == 1) {'); document.writeln(' theform.q.value = \'site:' + google_host + ' \' + theform.q.value;'); document.writeln(' }'); document.writeln('}'); document.writeln('function submitFormWithChannel(channelname) {'); document.writeln(' document.gform.channel.value=channelname;'); document.writeln(' document.gform.submit();'); document.writeln(' return;'); document.writeln('}'); document.writeln('</script>'); document.writeln('<form name="gform" id="gform" method="get" action="http://www.google.cn/search?" target="_blank" onSubmit="validate_google(this);">'); document.writeln('<input type="hidden" name="client" value="aff-discuz" />'); document.writeln('<input type="hidden" name="ie" value="' + google_charset + '" />'); document.writeln('<input type="hidden" name="oe" value="UTF-8" />'); document.writeln('<input type="hidden" name="hl" value="' + google_hl + '" />'); document.writeln('<input type="hidden" name="lr" value="' + google_lr + '" />'); document.writeln('<input type="hidden" name="channel" value="search" />'); document.write('<div onclick="javascript:submitFormWithChannel(\'logo\')" style="cursor:pointer;float: left;width:70px;height:23px;background: url(images/common/Google_small.png) !important;background: none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/common/Google_small.png\', sizingMethod=\'scale\')"><img src="images/common/none.gif" border="0" alt="Google" /></div>'); document.writeln('&nbsp;&nbsp;<input type="text" class="txt" size="20" name="q" id="q" maxlength="255" value=""></input>'); document.writeln('<select name="site">'); document.writeln('<option value="0"' + google_default_0 + '>网页搜索</option>'); document.writeln('<option value="1"' + google_default_1 + '>站内搜索</option>'); document.writeln('</select>'); document.writeln('&nbsp;<button type="submit" name="sa" value="true">搜索</button>'); document.writeln('</form>');
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/google.js
JavaScript
asf20
2,095
var promptmsg = { 'post_newthread' : '点这里发表新话题', 'post_reply' : '点这里回复该话题', 'post_subject' : '在这里输入帖子标题', 'post_message' : '在这里输入帖子内容', 'post_submit' : '点这里发表帖子', 'sendpm' : '点这里给TA发送一条短消息', 'sendpm_message' : '在这里输入短消息内容', 'sendpm_submit' : '点这里发送短消息', 'addbuddy' : '点这里把TA加为好友', 'search_kw' : '点这里输入关键词', 'search_submit' : '点这里开始搜索', 'uploadavatar' : '点这里进入头像设置页面', 'modifyprofile_birthday' : '点这里选择生日', 'modifyprofile_qq' : '点这里输入您常用的 QQ 号', 'modifyprofile_submit' : '点这里确认修改' };
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/prompt.lang.js
JavaScript
asf20
769
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: qihoo.js 17449 2008-12-22 08:58:53Z cnteacher $ */ var qihoo_num = 0; var qihoo_perpage = 0; var qihoo_threads = ""; function qihoothreads(num) { var threadslist = ""; if(num) { for(i = 0; i < num; i++) { threadslist += "<tr><td><a href=\"viewthread.php?tid=" + qihoo_threads[i][1] + "\" target=\"_blank\">" + qihoo_threads[i][0] + "</a></td>" + "<td><a href=\"forumdisplay.php?fid=" + qihoo_threads[i][8] + "\" target=\"_blank\">" + qihoo_threads[i][2] + "</a></td>" + "<td><a href=\"space.php?username=" + qihoo_threads[i][3] + "\" target=\"_blank\">" + qihoo_threads[i][3] + "</a><br />" + qihoo_threads[i][6] + "</td>" + "<td>" + qihoo_threads[i][4] + "</td>" + "<td>" + qihoo_threads[i][5] + "</td>" + "<td>" + qihoo_threads[i][7] + "</td></tr>"; } } return threadslist; } function multi(num, perpage, curpage, mpurl, maxpages) { var multipage = ""; if(num > perpage) { var page = 10; var offset = 2; var form = 0; var to = 0; var maxpages = !maxpages ? 0 : maxpages; var realpages = Math.ceil(num / perpage); var pages = maxpages && maxpages < realpages ? maxpages : realpages; if(page > pages) { from = 1; to = pages; } else { from = curpage - offset; to = from + page - 1; if(from < 1) { to = curpage + 1 - from; from = 1; if(to - from < page) { to = page; } } else if(to > pages) { from = pages - page + 1; to = pages; } } multipage = (curpage - offset > 1 && pages > page ? "<a href=\"" + mpurl + "&page=1\" class=\"first\">1 ...</a>" : "") + (curpage > 1 ? "<a href=\"" + mpurl + "&page=" + (curpage - 1) + "\" class=\"prev\">&lsaquo;&lsaquo;</a>" : ""); for(i = from; i <= to; i++) { multipage += (i == curpage ? "<strong>" + i + "</strong>" : "<a href=\"" + mpurl + "&page=" + i + "\">" + i + "</a>"); } multipage += (curpage < pages ? "<a href=\"" + mpurl + "&page=" + (curpage + 1) + "\" class=\"next\" >&rsaquo;&rsaquo;</a>" : "") + (to < pages ? "<a href=\"" + mpurl + "&page=" + pages + "\ class=\"last\">... " + realpages + "</a>" : "") + (pages > page ? "<input type=\"text\" name=\"custompage\" size=\"3\" onKeyDown=\"if(event.keyCode==13) {window.location='" + mpurl + "&page=\'+this.value;}\">" : ""); multipage = "<div class=\"pages\">" + multipage + "</div>"; } return multipage; }
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/qihoo.js
JavaScript
asf20
2,508
/* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: iframe.js 20769 2009-10-19 06:23:23Z monkey $ */ function refreshmain(e) { e = e ? e : window.event; actualCode = e.keyCode ? e.keyCode : e.charCode; if(actualCode == 116 && parent.main) { parent.main.location.reload(); if(document.all) { e.keyCode = 0; e.returnValue = false; } else { e.cancelBubble = true; e.preventDefault(); } } } _attachEvent(document.documentElement, "keydown", refreshmain);
zyyhong
trunk/jiaju001/newbbs/bbs/include/js/iframe.js
JavaScript
asf20
550
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: cron.func.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function runcron($cronid = 0) { global $timestamp, $db, $tablepre, $_DCACHE; if($cron = $db->fetch_first("SELECT * FROM {$tablepre}crons WHERE ".($cronid ? "cronid='$cronid'" : "available>'0' AND nextrun<='$timestamp'")." ORDER BY nextrun LIMIT 1")) { $lockfile = DISCUZ_ROOT.'./forumdata/runcron_'.$cron['cronid'].'.lock'; $cron['filename'] = str_replace(array('..', '/', '\\'), '', $cron['filename']); $cronfile = DISCUZ_ROOT.'./include/crons/'.$cron['filename']; if(is_writable($lockfile) && filemtime($lockfile) > $timestamp - 600) { return NULL; } else { @touch($lockfile); } @set_time_limit(1000); @ignore_user_abort(TRUE); $cron['minute'] = explode("\t", $cron['minute']); cronnextrun($cron); extract($GLOBALS, EXTR_SKIP); if(!@include $cronfile) { errorlog('CRON', $cron['name'].' : Cron script('.$cron['filename'].') not found or syntax error', 0); } @unlink($lockfile); } $nextrun = $db->result_first("SELECT nextrun FROM {$tablepre}crons WHERE available>'0' ORDER BY nextrun LIMIT 1"); if(!$nextrun === FALSE) { require_once DISCUZ_ROOT.'./include/cache.func.php'; $_DCACHE['settings']['cronnextrun'] = $nextrun; updatesettings(); } } function cronnextrun($cron) { global $db, $tablepre, $_DCACHE, $timestamp; if(empty($cron)) return FALSE; list($yearnow, $monthnow, $daynow, $weekdaynow, $hournow, $minutenow) = explode('-', gmdate('Y-m-d-w-H-i', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600)); if($cron['weekday'] == -1) { if($cron['day'] == -1) { $firstday = $daynow; $secondday = $daynow + 1; } else { $firstday = $cron['day']; $secondday = $cron['day'] + gmdate('t', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600); } } else { $firstday = $daynow + ($cron['weekday'] - $weekdaynow); $secondday = $firstday + 7; } if($firstday < $daynow) { $firstday = $secondday; } if($firstday == $daynow) { $todaytime = crontodaynextrun($cron); if($todaytime['hour'] == -1 && $todaytime['minute'] == -1) { $cron['day'] = $secondday; $nexttime = crontodaynextrun($cron, 0, -1); $cron['hour'] = $nexttime['hour']; $cron['minute'] = $nexttime['minute']; } else { $cron['day'] = $firstday; $cron['hour'] = $todaytime['hour']; $cron['minute'] = $todaytime['minute']; } } else { $cron['day'] = $firstday; $nexttime = crontodaynextrun($cron, 0, -1); $cron['hour'] = $nexttime['hour']; $cron['minute'] = $nexttime['minute']; } $nextrun = @gmmktime($cron['hour'], $cron['minute'] > 0 ? $cron['minute'] : 0, 0, $monthnow, $cron['day'], $yearnow) - $_DCACHE['settings']['timeoffset'] * 3600; $availableadd = $nextrun > $timestamp ? '' : ', available=\'0\''; $db->query("UPDATE {$tablepre}crons SET lastrun='$timestamp', nextrun='$nextrun' $availableadd WHERE cronid='$cron[cronid]'"); return TRUE; } function crontodaynextrun($cron, $hour = -2, $minute = -2) { global $timestamp, $_DCACHE; $hour = $hour == -2 ? gmdate('H', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) : $hour; $minute = $minute == -2 ? gmdate('i', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600) : $minute; $nexttime = array(); if($cron['hour'] == -1 && !$cron['minute']) { $nexttime['hour'] = $hour; $nexttime['minute'] = $minute + 1; } elseif($cron['hour'] == -1 && $cron['minute'] != '') { $nexttime['hour'] = $hour; if(($nextminute = cronnextminute($cron['minute'], $minute)) === false) { ++$nexttime['hour']; $nextminute = $cron['minute'][0]; } $nexttime['minute'] = $nextminute; } elseif($cron['hour'] != -1 && $cron['minute'] == '') { if($cron['hour'] < $hour) { $nexttime['hour'] = $nexttime['minute'] = -1; } elseif($cron['hour'] == $hour) { $nexttime['hour'] = $cron['hour']; $nexttime['minute'] = $minute + 1; } else { $nexttime['hour'] = $cron['hour']; $nexttime['minute'] = 0; } } elseif($cron['hour'] != -1 && $cron['minute'] != '') { $nextminute = cronnextminute($cron['minute'], $minute); if($cron['hour'] < $hour || ($cron['hour'] == $hour && $nextminute === false)) { $nexttime['hour'] = -1; $nexttime['minute'] = -1; } else { $nexttime['hour'] = $cron['hour']; $nexttime['minute'] = $nextminute; } } return $nexttime; } function cronnextminute($nextminutes, $minutenow) { foreach($nextminutes as $nextminute) { if($nextminute > $minutenow) { return $nextminute; } } return false; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/cron.func.php
PHP
asf20
4,801
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: viewthread_activity.inc.php 17393 2008-12-17 07:30:46Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $sdb = loadmultiserver(); $applylist = array(); $activity = $sdb->fetch_first("SELECT * FROM {$tablepre}activities WHERE tid='$tid'"); $activityclose = $activity['expiration'] ? ($activity['expiration'] > $timestamp - date('Z') ? 0 : 1) : 0; $activity['starttimefrom'] = dgmdate("$dateformat $timeformat", $activity['starttimefrom'] + $timeoffset * 3600); $activity['starttimeto'] = $activity['starttimeto'] ? gmdate("$dateformat $timeformat", $activity['starttimeto'] + $timeoffset * 3600) : 0; $activity['expiration'] = $activity['expiration'] ? gmdate("$dateformat $timeformat", $activity['expiration'] + $timeoffset * 3600) : 0; $isverified = $applied = 0; if($discuz_uid) { $query = $db->query("SELECT verified FROM {$tablepre}activityapplies WHERE tid='$tid' AND uid='$discuz_uid'"); if($db->num_rows($query)) { $isverified = $db->result($query, 0); $applied = 1; } } $query = $db->query("SELECT aa.username, aa.uid, aa.dateline, aa.message, aa.payment, aa.contact, m.groupid FROM {$tablepre}activityapplies aa LEFT JOIN {$tablepre}members m USING(uid) LEFT JOIN {$tablepre}memberfields mf USING(uid) WHERE aa.tid='$tid' AND aa.verified=1 ORDER BY aa.dateline DESC LIMIT 9"); while($activityapplies = $db->fetch_array($query)) { $activityapplies['dateline'] = dgmdate("$dateformat $timeformat", $activityapplies['dateline'] + $timeoffset * 3600); $applylist[] = $activityapplies; } if($thread['authorid'] == $discuz_uid) { $applylistverified = array(); $query = $db->query("SELECT aa.username, aa.uid, aa.dateline, aa.message, aa.payment, aa.contact, m.groupid FROM {$tablepre}activityapplies aa LEFT JOIN {$tablepre}members m USING(uid) LEFT JOIN {$tablepre}memberfields mf USING(uid) WHERE aa.tid='$tid' AND aa.verified=0 ORDER BY aa.dateline DESC LIMIT 9"); while($activityapplies = $db->fetch_array($query)) { $activityapplies['dateline'] = dgmdate("$dateformat $timeformat", $activityapplies['dateline'] + $timeoffset * 3600); $applylistverified[] = $activityapplies; } } $applynumbers = $db->result_first("SELECT COUNT(*) FROM {$tablepre}activityapplies WHERE tid='$tid' AND verified=1"); $aboutmembers = $activity['number'] >= $applynumbers ? $activity['number'] - $applynumbers : 0; ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/viewthread_activity.inc.php
PHP
asf20
2,518
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: seccode.class.php 16698 2008-11-14 07:58:56Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } class seccode { var $code; var $type = 0; var $width = 150; var $height = 60; var $background = 1; var $adulterate = 1; var $ttf = 0; var $angle = 0; var $color = 1; var $size = 0; var $shadow = 1; var $animator = 0; var $fontpath = ''; var $datapath = ''; var $includepath= ''; var $fontcolor; var $im; function display() { $this->type == 2 && !extension_loaded('ming') && $this->type = 0; $this->width = $this->width >= 100 && $this->width <= 200 ? $this->width : 150; $this->height = $this->height >= 50 && $this->height <= 80 ? $this->height : 60; seccodeconvert($this->code); if($this->type < 2 && function_exists('imagecreate') && function_exists('imagecolorset') && function_exists('imagecopyresized') && function_exists('imagecolorallocate') && function_exists('imagechar') && function_exists('imagecolorsforindex') && function_exists('imageline') && function_exists('imagecreatefromstring') && (function_exists('imagegif') || function_exists('imagepng') || function_exists('imagejpeg'))) { $this->image(); } elseif($this->type == 2 && extension_loaded('ming')) { $this->flash(); } elseif($this->type == 3) { $this->audio(); } else { $this->bitmap(); } } function image() { $bgcontent = $this->background(); if($this->animator == 1 && function_exists('imagegif')) { include_once $this->includepath.'gifmerge.class.php'; $trueframe = mt_rand(1, 9); for($i = 0; $i <= 9; $i++) { $this->im = imagecreatefromstring($bgcontent); $x[$i] = $y[$i] = 0; $this->adulterate && $this->adulterate(); if($i == $trueframe) { $this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont(); $d[$i] = mt_rand(250, 400); } else { $this->adulteratefont(); $d[$i] = mt_rand(5, 15); } ob_start(); imagegif($this->im); imagedestroy($this->im); $frame[$i] = ob_get_contents(); ob_end_clean(); } $anim = new GifMerge($frame, 255, 255, 255, 0, $d, $x, $y, 'C_MEMORY'); dheader('Content-type: image/gif'); echo $anim->getAnimation(); } else { $this->im = imagecreatefromstring($bgcontent); $this->adulterate && $this->adulterate(); $this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont(); if(function_exists('imagepng')) { dheader('Content-type: image/png'); imagepng($this->im); } else { dheader('Content-type: image/jpeg'); imagejpeg($this->im, '', 100); } imagedestroy($this->im); } } function background() { $this->im = imagecreatetruecolor($this->width, $this->height); $backgroundcolor = imagecolorallocate($this->im, 255, 255, 255); $backgrounds = $c = array(); if($this->background && function_exists('imagecreatefromjpeg') && function_exists('imagecolorat') && function_exists('imagecopymerge') && function_exists('imagesetpixel') && function_exists('imageSX') && function_exists('imageSY')) { if($handle = @opendir($this->datapath.'background/')) { while($bgfile = @readdir($handle)) { if(preg_match('/\.jpg$/i', $bgfile)) { $backgrounds[] = $this->datapath.'background/'.$bgfile; } } @closedir($handle); } if($backgrounds) { $imwm = imagecreatefromjpeg($backgrounds[array_rand($backgrounds)]); $colorindex = imagecolorat($imwm, 0, 0); $this->c = imagecolorsforindex($imwm, $colorindex); $colorindex = imagecolorat($imwm, 1, 0); imagesetpixel($imwm, 0, 0, $colorindex); $c[0] = $c['red'];$c[1] = $c['green'];$c[2] = $c['blue']; imagecopymerge($this->im, $imwm, 0, 0, mt_rand(0, 200 - $this->width), mt_rand(0, 80 - $this->height), imageSX($imwm), imageSY($imwm), 100); imagedestroy($imwm); } } if(!$this->background || !$backgrounds) { for($i = 0;$i < 3;$i++) { $start[$i] = mt_rand(200, 255);$end[$i] = mt_rand(100, 150);$step[$i] = ($end[$i] - $start[$i]) / $this->width;$c[$i] = $start[$i]; } for($i = 0;$i < $this->width;$i++) { $color = imagecolorallocate($this->im, $c[0], $c[1], $c[2]); imageline($this->im, $i, 0, $i-$angle, $this->height, $color); $c[0] += $step[0];$c[1] += $step[1];$c[2] += $step[2]; } $c[0] -= 20;$c[1] -= 20;$c[2] -= 20; } ob_start(); if(function_exists('imagepng')) { imagepng($this->im); } else { imagejpeg($this->im, '', 100); } imagedestroy($this->im); $bgcontent = ob_get_contents(); ob_end_clean(); $this->fontcolor = $c; return $bgcontent; } function adulterate() { $linenums = $this->height / 10; for($i=0; $i <= $linenums; $i++) { $color = $this->color ? imagecolorallocate($this->im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)) : imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]); $x = mt_rand(0, $this->width); $y = mt_rand(0, $this->height); if(mt_rand(0, 1)) { imagearc($this->im, $x, $y, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, 360), mt_rand(0, 360), $color); } else { imageline($this->im, $x, $y, $linex + mt_rand(0, $linemaxlong), $liney + mt_rand(0, mt_rand($this->height, $this->width)), $color); } } } function adulteratefont() { $seccodeunits = 'BCEFGHJKMPQRTVWXY2346789'; $x = $this->width / 4; $y = $this->height / 10; $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]); for($i = 0; $i <= 3; $i++) { $adulteratecode = $seccodeunits[mt_rand(0, 23)]; imagechar($this->im, 5, $x * $i + mt_rand(0, $x - 10), mt_rand($y, $this->height - 10 - $y), $adulteratecode, $text_color); } } function ttffont() { $seccode = $this->code; $charset = $GLOBALS['charset']; $seccoderoot = $this->type ? $this->fontpath.'ch/' : $this->fontpath.'en/'; $dirs = opendir($seccoderoot); $seccodettf = array(); while($entry = readdir($dirs)) { if($entry != '.' && $entry != '..' && in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) { $seccodettf[] = $entry; } } if(empty($seccodettf)) { $this->giffont(); return; } $seccodelength = 4; if($this->type && !empty($seccodettf)) { if(strtoupper($charset) != 'UTF-8') { include $this->includepath.'chinese.class.php'; $cvt = new Chinese($charset, 'utf8'); $seccode = $cvt->Convert($seccode); } $seccode = array(substr($seccode, 0, 3), substr($seccode, 3, 3)); $seccodelength = 2; } $widthtotal = 0; for($i = 0; $i < $seccodelength; $i++) { $font[$i]['font'] = $seccoderoot.$seccodettf[array_rand($seccodettf)]; $font[$i]['angle'] = $this->angle ? mt_rand(-30, 30) : 0; $font[$i]['size'] = $this->type ? $this->width / 7 : $this->width / 6; $this->size && $font[$i]['size'] = mt_rand($font[$i]['size'] - $this->width / 40, $font[$i]['size'] + $this->width / 20); $box = imagettfbbox($font[$i]['size'], 0, $font[$i]['font'], $seccode[$i]); $font[$i]['zheight'] = max($box[1], $box[3]) - min($box[5], $box[7]); $box = imagettfbbox($font[$i]['size'], $font[$i]['angle'], $font[$i]['font'], $seccode[$i]); $font[$i]['height'] = max($box[1], $box[3]) - min($box[5], $box[7]); $font[$i]['hd'] = $font[$i]['height'] - $font[$i]['zheight']; $font[$i]['width'] = (max($box[2], $box[4]) - min($box[0], $box[6])) + mt_rand(0, $this->width / 8); $font[$i]['width'] = $font[$i]['width'] > $this->width / $seccodelength ? $this->width / $seccodelength : $font[$i]['width']; $widthtotal += $font[$i]['width']; } $x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 1, $this->width - $widthtotal); !$this->color && $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]); for($i = 0; $i < $seccodelength; $i++) { if($this->color) { $this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)); $this->shadow && $text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]); $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]); } elseif($this->shadow) { $text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]); } $y = $font[0]['angle'] > 0 ? mt_rand($font[$i]['height'], $this->height) : mt_rand($font[$i]['height'] - $font[$i]['hd'], $this->height - $font[$i]['hd']); $this->shadow && imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x + 1, $y + 1, $text_shadowcolor, $font[$i]['font'], $seccode[$i]); imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x, $y, $text_color, $font[$i]['font'], $seccode[$i]); $x += $font[$i]['width']; } } function giffont() { $seccode = $this->code; $seccodedir = array(); if(function_exists('imagecreatefromgif')) { $seccoderoot = $this->datapath.'gif/'; $dirs = opendir($seccoderoot); while($dir = readdir($dirs)) { if($dir != '.' && $dir != '..' && file_exists($seccoderoot.$dir.'/9.gif')) { $seccodedir[] = $dir; } } } $widthtotal = 0; for($i = 0; $i <= 3; $i++) { $this->imcodefile = $seccodedir ? $seccoderoot.$seccodedir[array_rand($seccodedir)].'/'.strtolower($seccode[$i]).'.gif' : ''; if(!empty($this->imcodefile) && file_exists($this->imcodefile)) { $font[$i]['file'] = $this->imcodefile; $font[$i]['data'] = getimagesize($this->imcodefile); $font[$i]['width'] = $font[$i]['data'][0] + mt_rand(0, 6) - 4; $font[$i]['height'] = $font[$i]['data'][1] + mt_rand(0, 6) - 4; $font[$i]['width'] += mt_rand(0, $this->width / 5 - $font[$i]['width']); $widthtotal += $font[$i]['width']; } else { $font[$i]['file'] = ''; $font[$i]['width'] = 8 + mt_rand(0, $this->width / 5 - 5); $widthtotal += $font[$i]['width']; } } $x = mt_rand(1, $this->width - $widthtotal); for($i = 0; $i <= 3; $i++) { $this->color && $this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)); if($font[$i]['file']) { $this->imcode = imagecreatefromgif($font[$i]['file']); if($this->size) { $font[$i]['width'] = mt_rand($font[$i]['width'] - $this->width / 20, $font[$i]['width'] + $this->width / 20); $font[$i]['height'] = mt_rand($font[$i]['height'] - $this->width / 20, $font[$i]['height'] + $this->width / 20); } $y = mt_rand(0, $this->height - $font[$i]['height']); if($this->shadow) { $this->imcodeshadow = $this->imcode; imagecolorset($this->imcodeshadow, 0 , 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]); imagecopyresized($this->im, $this->imcodeshadow, $x + 1, $y + 1, 0, 0, $font[$i]['width'], $font[$i]['height'], $font[$i]['data'][0], $font[$i]['data'][1]); } imagecolorset($this->imcode, 0 , $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]); imagecopyresized($this->im, $this->imcode, $x, $y, 0, 0, $font[$i]['width'], $font[$i]['height'], $font[$i]['data'][0], $font[$i]['data'][1]); } else { $y = mt_rand(0, $this->height - 20); if($this->shadow) { $text_shadowcolor = imagecolorallocate($this->im, 255 - $this->fontcolor[0], 255 - $this->fontcolor[1], 255 - $this->fontcolor[2]); imagechar($this->im, 5, $x + 1, $y + 1, $seccode[$i], $text_shadowcolor); } $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]); imagechar($this->im, 5, $x, $y, $seccode[$i], $text_color); } $x += $font[$i]['width']; } } function flash() { $spacing = 5; $codewidth = ($this->width - $spacing * 5) / 4; $strforswdaction = ''; for($i = 0; $i <= 3; $i++) { $strforswdaction .= $this->swfcode($codewidth, $spacing, $this->code[$i], $i+1); } ming_setScale(20.00000000); ming_useswfversion(6); $movie = new SWFMovie(); $movie->setDimension($this->width, $this->height); $movie->setBackground(255, 255, 255); $movie->setRate(31); $fontcolor = '0x'.(sprintf('%02s', dechex (mt_rand(0, 255)))).(sprintf('%02s', dechex (mt_rand(0, 128)))).(sprintf('%02s', dechex (mt_rand(0, 255)))); $strAction = " _root.createEmptyMovieClip ( 'triangle', 1 ); with ( _root.triangle ) { lineStyle( 3, $fontcolor, 100 ); $strforswdaction } "; $movie->add(new SWFAction( str_replace("\r", "", $strAction) )); header('Content-type: application/x-shockwave-flash'); $movie->output(); } function swfcode($width, $d, $code, $order) { $str = ''; $height = $this->height - $d * 2; $x_0 = ($order * ($width + $d) - $width); $x_1 = $x_0 + $width / 2; $x_2 = $x_0 + $width; $y_0 = $d; $y_2 = $y_0 + $height; $y_1 = $y_2 / 2; $y_0_5 = $y_2 / 4; $y_1_5 = $y_1 + $y_0_5; switch($code) { case 'B':$str .= 'moveTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_1.', '.$y_2.');lineTo('.$x_2.', '.$y_1_5.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break; case 'C':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');';break; case 'E':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break; case 'F':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break; case 'G':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break; case 'H':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break; case 'J':$str .= 'moveTo('.$x_1.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_1_5.');';break; case 'K':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');';break; case 'M':$str .= 'moveTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');';break; case 'P':$str .= 'moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');';break; case 'Q':$str .= 'moveTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_1.', '.$y_1.');';break; case 'R':$str .= 'moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');';break; case 'T':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');moveTo('.$x_1.', '.$y_0.');lineTo('.$x_1.', '.$y_2.');';break; case 'V':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');';break; case 'W':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');';break; case 'X':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');';break; case 'Y':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_1.', '.$y_2.');';break; case '2':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');';break; case '3':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break; case '4':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break; case '6':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');';break; case '7':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');';break; case '8':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break; case '9':$str .= 'moveTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');';break; } return $str; } function audio() { header('Content-type: audio/mpeg'); for($i = 0;$i <= 3; $i++) { readfile($this->datapath.'sound/'.strtolower($this->code[$i]).'.mp3'); } } function bitmap() { $numbers = array ( 'B' => array('00','fc','66','66','66','7c','66','66','fc','00'), 'C' => array('00','38','64','c0','c0','c0','c4','64','3c','00'), 'E' => array('00','fe','62','62','68','78','6a','62','fe','00'), 'F' => array('00','f8','60','60','68','78','6a','62','fe','00'), 'G' => array('00','78','cc','cc','de','c0','c4','c4','7c','00'), 'H' => array('00','e7','66','66','66','7e','66','66','e7','00'), 'J' => array('00','f8','cc','cc','cc','0c','0c','0c','7f','00'), 'K' => array('00','f3','66','66','7c','78','6c','66','f7','00'), 'M' => array('00','f7','63','6b','6b','77','77','77','e3','00'), 'P' => array('00','f8','60','60','7c','66','66','66','fc','00'), 'Q' => array('00','78','cc','cc','cc','cc','cc','cc','78','00'), 'R' => array('00','f3','66','6c','7c','66','66','66','fc','00'), 'T' => array('00','78','30','30','30','30','b4','b4','fc','00'), 'V' => array('00','1c','1c','36','36','36','63','63','f7','00'), 'W' => array('00','36','36','36','77','7f','6b','63','f7','00'), 'X' => array('00','f7','66','3c','18','18','3c','66','ef','00'), 'Y' => array('00','7e','18','18','18','3c','24','66','ef','00'), '2' => array('fc','c0','60','30','18','0c','cc','cc','78','00'), '3' => array('78','8c','0c','0c','38','0c','0c','8c','78','00'), '4' => array('00','3e','0c','fe','4c','6c','2c','3c','1c','1c'), '6' => array('78','cc','cc','cc','ec','d8','c0','60','3c','00'), '7' => array('30','30','38','18','18','18','1c','8c','fc','00'), '8' => array('78','cc','cc','cc','78','cc','cc','cc','78','00'), '9' => array('f0','18','0c','6c','dc','cc','cc','cc','78','00') ); foreach($numbers as $i => $number) { for($j = 0; $j < 6; $j++) { $a1 = substr('012', mt_rand(0, 2), 1).substr('012345', mt_rand(0, 5), 1); $a2 = substr('012345', mt_rand(0, 5), 1).substr('0123', mt_rand(0, 3), 1); mt_rand(0, 1) == 1 ? array_push($numbers[$i], $a1) : array_unshift($numbers[$i], $a1); mt_rand(0, 1) == 0 ? array_push($numbers[$i], $a1) : array_unshift($numbers[$i], $a2); } } $bitmap = array(); for($i = 0; $i < 20; $i++) { for($j = 0; $j <= 3; $j++) { $bytes = $numbers[$this->code[$j]][$i]; $a = mt_rand(0, 14); array_push($bitmap, $bytes); } } for($i = 0; $i < 8; $i++) { $a = substr('012345', mt_rand(0, 2), 1) . substr('012345', mt_rand(0, 5), 1); array_unshift($bitmap, $a); array_push($bitmap, $a); } $image = pack('H*', '424d9e000000000000003e000000280000002000000018000000010001000000'. '0000600000000000000000000000000000000000000000000000FFFFFF00'.implode('', $bitmap)); dheader('Content-Type: image/bmp'); echo $image; } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/seccode.class.php
PHP
asf20
20,720
<?php /* [Discuz!] (C)2001-2009 Comsenz Technology Ltd. This is NOT a freeware, use is subject to license terms $Id: ec_credit.func.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function updatecreditcache($uid, $type, $return = 0) { global $db, $tablepre; $all = countcredit($uid, $type); $halfyear = countcredit($uid, $type, 180); $thismonth = countcredit($uid, $type, 30); $thisweek = countcredit($uid, $type, 7); $before = array( 'good' => $all['good'] - $halfyear['good'], 'soso' => $all['soso'] - $halfyear['soso'], 'bad' => $all['bad'] - $halfyear['bad'], 'total' => $all['total'] - $halfyear['total'] ); $data = array('all' => $all, 'before' => $before, 'halfyear' => $halfyear, 'thismonth' => $thismonth, 'thisweek' => $thisweek); $db->query("REPLACE INTO {$tablepre}spacecaches (uid, variable, value, expiration) VALUES ('$uid', '$type', '".addslashes(serialize($data))."', '".getexpiration()."')"); if($return) { return $data; } } function countcredit($uid, $type, $days = 0) { global $timestamp, $db, $tablepre; $type = $type == 'buyercredit' ? 1 : 0; $timeadd = $days ? ("AND dateline>='".($timestamp - $days * 86400)."'") : ''; $query = $db->query("SELECT score FROM {$tablepre}tradecomments WHERE rateeid='$uid' AND type='$type' $timeadd"); $good = $soso = $bad = 0; while($credit = $db->fetch_array($query)) { if($credit['score'] == 1) { $good++; } elseif($credit['score'] == 0) { $soso++; } else { $bad++; } } return array('good' => $good, 'soso' => $soso, 'bad' => $bad, 'total' => $good + $soso + $bad); } function updateusercredit($uid, $type, $level) { global $timestamp, $db, $tablepre; $uid = intval($uid); if(!$uid || !in_array($type, array('buyercredit', 'sellercredit')) || !in_array($level, array('good', 'soso', 'bad'))) { return; } if($cache = $db->fetch_first("SELECT value, expiration FROM {$tablepre}spacecaches WHERE uid='$uid' AND variable='$type'")) { $expiration = $cache['expiration']; $cache = unserialize($cache['value']); } else { $init = array('good' => 0, 'soso' => 0, 'bad' => 0, 'total' => 0); $cache = array('all' => $init, 'before' => $init, 'halfyear' => $init, 'thismonth' => $init, 'thisweek' => $init); $expiration = getexpiration(); } foreach(array('all', 'before', 'halfyear', 'thismonth', 'thisweek') as $key) { $cache[$key][$level]++; $cache[$key]['total']++; } $db->query("REPLACE INTO {$tablepre}spacecaches (uid, variable, value, expiration) VALUES ('$uid', '$type', '".addslashes(serialize($cache))."', '$expiration')"); $score = $level == 'good' ? 1 : ($level == 'soso' ? 0 : -1); $db->query("UPDATE {$tablepre}memberfields SET $type=$type+($score) WHERE uid='$uid'"); } function getexpiration() { $date = getdate($GLOBALS['timestamp']); return mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']) + 86400; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/ec_credit.func.php
PHP
asf20
3,023
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: threadpay.inc.php 17362 2008-12-16 03:30:55Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if(!isset($extcredits[$creditstransextra[1]])) { showmessage('credits_transaction_disabled'); } $payment = $db->fetch_first("SELECT COUNT(*) AS payers, SUM(netamount) AS income FROM {$tablepre}paymentlog WHERE tid='$tid'"); $thread['payers'] = $payment['payers']; $thread['netprice'] = !$maxincperthread || ($maxincperthread && $payment['income'] < $maxincperthread) ? floor($thread['price'] * (1 - $creditstax)) : 0; $thread['creditstax'] = sprintf('%1.2f', $creditstax * 100).'%'; $thread['endtime'] = $maxchargespan ? dgmdate("$dateformat $timeformat", $thread['dateline'] + $maxchargespan * 3600 + $timeoffset * 3600) : 0; $firstpost = $db->fetch_first("SELECT * FROM {$tablepre}posts WHERE tid='$tid' AND first='1' LIMIT 1"); $pid = $firstpost['pid']; $freemessage = array(); $freemessage[$pid]['message'] = ''; if(preg_match_all("/\[free\](.+?)\[\/free\]/is", $firstpost['message'], $matches)) { foreach($matches[1] AS $match) { $freemessage[$pid]['message'] .= discuzcode($match, $firstpost['smileyoff'], $firstpost['bbcodeoff'], sprintf('%00b', $firstpost['htmlon']), $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml'], 0).'<br />'; } } $attachtags = array(); if($allowgetattach) { if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $freemessage[$pid]['message'], $matchaids)) { $attachtags[$pid] = $matchaids[1]; } } if($attachtags) { require_once DISCUZ_ROOT.'./include/attachment.func.php'; parseattach($pid, $attachtags, $freemessage, $showimages); } $thread['freemessage'] = $freemessage[$pid]['message']; unset($freemessage); ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/threadpay.inc.php
PHP
asf20
1,872
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: forumselect.inc.php 20900 2009-10-29 02:49:38Z tiger $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if(!isset($_DCACHE['forums'])) { require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; } $grouplist = $commonlist = ''; $forumlist = $subforumlist = array(); $i = array(); $commonfids = explode('D', $_DCOOKIE['visitedfid']); if($discuz_uid) { $query = $db->query("SELECT fid FROM {$tablepre}favorites WHERE uid='$discuz_uid' AND fid>0"); while($fav = $db->fetch_array($query)) { $commonfids[] = $fav['fid']; } } foreach($commonfids as $k => $fid) { if($_DCACHE['forums'][$fid]['type'] == 'sub') { $commonfids[] = $_DCACHE['forums'][$fid]['fup']; unset($commonfids[$k]); } } $commonfids = array_unique($commonfids); foreach($commonfids as $fid) { $commonlist .= '<li fid="'.$fid.'">'.$_DCACHE['forums'][$fid]['name'].'</li>'; } foreach($_DCACHE['forums'] as $forum) { if(!$forum['status'] || $forum['status'] == 2) { continue; } if($forum['type'] == 'group') { $grouplist .= '<li fid="'.$forum['fid'].'">'.$forum['name'].'</li>'; $visible[$forum['fid']] = true; } elseif($forum['type'] == 'forum' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$discuz_uid\t"))) { $forumlist[$forum['fup']] .= '<li fid="'.$forum['fid'].'">'.$forum['name'].'</li>'; $visible[$forum['fid']] = true; } elseif($forum['type'] == 'sub' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$discuz_uid\t"))) { $subforumlist[$forum['fup']] .= '<li fid="'.$forum['fid'].'">'.$forum['name'].'</li>'; } } include template('post_forumselect'); exit; ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/forumselect.inc.php
PHP
asf20
1,947
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: editor.func.php 17417 2008-12-19 06:16:25Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function absoluteurl($url) { global $boardurl; if($url{0} == '/') { return 'http://'.$_SERVER['HTTP_HOST'].$url; } else { return $boardurl.$url; } } function atag($aoptions, $text) { $href = getoptionvalue('href', $aoptions); if(substr($href, 0, 7) == 'mailto:') { $tag = 'email'; $href = substr($href, 7); } else { $tag = 'url'; if(!preg_match("/^[a-z0-9]+:/i", $href)) { $href = absoluteurl($href); } } return "[$tag=$href]".trim(recursion('a', $text, 'atag'))."[/$tag]"; } function divtag($divoptions, $text) { $prepend = $append = ''; parsestyle($divoptions, $prepend, $append); $align = getoptionvalue('align', $divoptions); switch($align) { case 'left': case 'center': case 'right': break; default: $align = ''; } if($align) { $prepend .= "[align=$align]"; $append .= "[/align]"; } $append .= "\n"; return $prepend.recursion('div', $text, 'divtag').$append; } function fetchoptionvalue($option, $text) { if(($position = strpos($text, $option)) !== false) { $delimiter = $position + strlen($option); if($text{$delimiter} == '"') { $delimchar = '"'; } elseif($text{$delimiter} == '\'') { $delimchar = '\''; } else { $delimchar = ' '; } $delimloc = strpos($text, $delimchar, $delimiter + 1); if($delimloc === false) { $delimloc = strlen($text); } elseif($delimchar == '"' OR $delimchar == '\'') { $delimiter++; } return trim(substr($text, $delimiter, $delimloc - $delimiter)); } else { return ''; } } function fonttag($fontoptions, $text) { $tags = array('font' => 'face=', 'size' => 'size=', 'color' => 'color='); $prependtags = $appendtags = ''; foreach($tags as $bbcode => $locate) { $optionvalue = fetchoptionvalue($locate, $fontoptions); if($optionvalue) { $prependtags .= "[$bbcode=$optionvalue]"; $appendtags = "[/$bbcode]$appendtags"; } } parsestyle($fontoptions, $prependtags, $appendtags); return $prependtags.recursion('font', $text, 'fonttag').$appendtags; } function getoptionvalue($option, $text) { preg_match("/$option(\s+?)?\=(\s+?)?[\"']?(.+?)([\"']|$|>)/is", $text, $matches); return trim($matches[3]); } function html2bbcode($text) { $text = strip_tags($text, '<table><tr><td><b><strong><i><em><u><a><div><span><p><strike><blockquote><ol><ul><li><font><img><br><br/><h1><h2><h3><h4><h5><h6><script>'); if(ismozilla()) { $text = preg_replace("/(?<!<br>|<br \/>|\r)(\r\n|\n|\r)/", ' ', $text); } $pregfind = array( "/<script.*>.*<\/script>/siU", '/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', "/(\r\n|\n|\r)/", "/<table([^>]*(width|background|background-color|bgcolor)[^>]*)>/siUe", "/<table.*>/siU", "/<tr.*>/siU", "/<td>/i", "/<td(.+)>/siUe", "/<\/td>/i", "/<\/tr>/i", "/<\/table>/i", '/<h([0-9]+)[^>]*>(.*)<\/h\\1>/siU', "/<img[^>]+smilieid=\"(\d+)\".*>/esiU", "/<img([^>]*src[^>]*)>/eiU", "/<a\s+?name=.+?\".\">(.+?)<\/a>/is", "/<br.*>/siU", "/<span\s+?style=\"float:\s+(left|right);\">(.+?)<\/span>/is", ); $pregreplace = array( '', '', '', "tabletag('\\1')", '[table]', '[tr]', '[td]', "tdtag('\\1')", '[/td]', '[/tr]', '[/table]', "[size=\\1]\\2[/size]\n\n", "smileycode('\\1')", "imgtag('\\1')", '\1', "\n", "[float=\\1]\\2[/float]", ); $text = preg_replace($pregfind, $pregreplace, $text); $text = recursion('b', $text, 'simpletag', 'b'); $text = recursion('strong', $text, 'simpletag', 'b'); $text = recursion('i', $text, 'simpletag', 'i'); $text = recursion('em', $text, 'simpletag', 'i'); $text = recursion('u', $text, 'simpletag', 'u'); $text = recursion('a', $text, 'atag'); $text = recursion('font', $text, 'fonttag'); $text = recursion('blockquote', $text, 'simpletag', 'indent'); $text = recursion('ol', $text, 'listtag'); $text = recursion('ul', $text, 'listtag'); $text = recursion('div', $text, 'divtag'); $text = recursion('span', $text, 'spantag'); $text = recursion('p', $text, 'ptag'); $pregfind = array("/(?<!\r|\n|^)\[(\/list|list|\*)\]/", "/<li>(.*)((?=<li>)|<\/li>)/iU", "/<p.*>/iU", "/<p><\/p>/i", "/(<a>|<\/a>|<\/li>)/is", "/<\/?(A|LI|FONT|DIV|SPAN)>/siU", "/\[url[^\]]*\]\[\/url\]/i", "/\[url=javascript:[^\]]*\](.+?)\[\/url\]/is"); $pregreplace = array("\n[\\1]", "\\1\n", "\n", '', '', '', '', "\\1"); $text = preg_replace($pregfind, $pregreplace, $text); $strfind = array('&nbsp;', '&lt;', '&gt;', '&amp;'); $strreplace = array(' ', '<', '>', '&'); $text = str_replace($strfind, $strreplace, $text); return trim($text); } function imgtag($attributes) { $value = array('src' => '', 'width' => '', 'height' => ''); preg_match_all("/(src|width|height)=([\"|\']?)([^\"']+)(\\2)/is", stripslashes($attributes), $matches); if(is_array($matches[1])) { foreach($matches[1] as $key => $attribute) { $value[strtolower($attribute)] = $matches[3][$key]; } } @extract($value); if(!preg_match("/^http:\/\//i", $src)) { $src = absoluteurl($src); } return $src ? ($width && $height ? '[img='.$width.','.$height.']'.$src.'[/img]' : '[img]'.$src.'[/img]') : ''; } function ismozilla() { $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); if(strpos($useragent, 'gecko') !== FALSE) { preg_match("/gecko\/(\d+)/", $useragent, $regs); return $regs[1]; } return FALSE; } function litag($listoptions, $text) { return '[*]'.rtrim($text); } function listtag($listoptions, $text, $tagname) { require_once DISCUZ_ROOT.'./include/post.func.php'; $text = preg_replace('/<li>((.(?!<\/li))*)(?=<\/?ol|<\/?ul|<li|\[list|\[\/list)/siU', '<li>\\1</li>', $text).(isopera() ? '</li>' : NULL); $text = recursion('li', $text, 'litag'); if($tagname == 'ol') { $listtype = fetchoptionvalue('type=', $listoptions) ? fetchoptionvalue('type=', $listoptions) : 1; if(in_array($listtype, array('1', 'a', 'A'))) { $opentag = '[list='.$listtype.']'; } } else { $opentag = '[list]'; } return $text ? $opentag.recursion($tagname, $text, 'listtag').'[/list]' : FALSE; } function parsestyle($tagoptions, &$prependtags, &$appendtags) { $searchlist = array( array('tag' => 'align', 'option' => TRUE, 'regex' => 'text-align:\s*(left);?', 'match' => 1), array('tag' => 'align', 'option' => TRUE, 'regex' => 'text-align:\s*(center);?', 'match' => 1), array('tag' => 'align', 'option' => TRUE, 'regex' => 'text-align:\s*(right);?', 'match' => 1), array('tag' => 'color', 'option' => TRUE, 'regex' => '(?<![a-z0-9-])color:\s*([^;]+);?', 'match' => 1), array('tag' => 'font', 'option' => TRUE, 'regex' => 'font-family:\s*([^;]+);?', 'match' => 1), array('tag' => 'size', 'option' => TRUE, 'regex' => 'font-size:\s*(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%|));?', 'match' => 1), array('tag' => 'b', 'option' => FALSE, 'regex' => 'font-weight:\s*(bold);?'), array('tag' => 'i', 'option' => FALSE, 'regex' => 'font-style:\s*(italic);?'), array('tag' => 'u', 'option' => FALSE, 'regex' => 'text-decoration:\s*(underline);?') ); $style = getoptionvalue('style', $tagoptions); $style = preg_replace( "/(?<![a-z0-9-])color:\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)(;?)/ie", 'sprintf("color: #%02X%02X%02X$4", $1, $2, $3)', $style ); foreach($searchlist as $searchtag) { if(preg_match('/'.$searchtag['regex'].'/i', $style, $match)) { $opnvalue = $match["$searchtag[match]"]; $prependtags .= '['.$searchtag['tag'].($searchtag['option'] == TRUE ? '='.$opnvalue.']' : ']'); $appendtags = '[/'.$searchtag['tag']."]$appendtags"; } } } function ptag($poptions, $text) { $align = getoptionvalue('align', $poptions); switch($align) { case 'left': case 'center': case 'right': break; default: $align = ''; } $prepend = $append = ''; parsestyle($poptions, $prepend, $append); if($align) { $prepend .= "[align=$align]"; $append .= "[/align]"; } $append .= "\n"; return $prepend.recursion('p', $text, 'ptag').$append; } function recursion($tagname, $text, $function, $extraargs = '') { $tagname = strtolower($tagname); $open_tag = "<$tagname"; $open_tag_len = strlen($open_tag); $close_tag = "</$tagname>"; $close_tag_len = strlen($close_tag); $beginsearchpos = 0; do { $textlower = strtolower($text); $tagbegin = @strpos($textlower, $open_tag, $beginsearchpos); if($tagbegin === FALSE) { break; } $strlen = strlen($text); $inquote = ''; $found = FALSE; $tagnameend = FALSE; for($optionend = $tagbegin; $optionend <= $strlen; $optionend++) { $char = $text{$optionend}; if(($char == '"' || $char == "'") && $inquote == '') { $inquote = $char; } elseif(($char == '"' || $char == "'") && $inquote == $char) { $inquote = ''; } elseif($char == '>' && !$inquote) { $found = TRUE; break; } elseif(($char == '=' || $char == ' ') && !$tagnameend) { $tagnameend = $optionend; } } if(!$found) { break; } if(!$tagnameend) { $tagnameend = $optionend; } $offset = $optionend - ($tagbegin + $open_tag_len); $tagoptions = substr($text, $tagbegin + $open_tag_len, $offset); $acttagname = substr($textlower, $tagbegin + 1, $tagnameend - $tagbegin - 1); if($acttagname != $tagname) { $beginsearchpos = $optionend; continue; } $tagend = strpos($textlower, $close_tag, $optionend); if($tagend === FALSE) { break; } $nestedopenpos = strpos($textlower, $open_tag, $optionend); while($nestedopenpos !== FALSE && $tagend !== FALSE) { if($nestedopenpos > $tagend) { break; } $tagend = strpos($textlower, $close_tag, $tagend + $close_tag_len); $nestedopenpos = strpos($textlower, $open_tag, $nestedopenpos + $open_tag_len); } if($tagend === FALSE) { $beginsearchpos = $optionend; continue; } $localbegin = $optionend + 1; $localtext = $function($tagoptions, substr($text, $localbegin, $tagend - $localbegin), $tagname, $extraargs); $text = substr_replace($text, $localtext, $tagbegin, $tagend + $close_tag_len - $tagbegin); $beginsearchpos = $tagbegin + strlen($localtext); } while($tagbegin !== FALSE); return $text; } function simpletag($options, $text, $tagname, $parseto) { if(trim($text) == '') { return ''; } $text = recursion($tagname, $text, 'simpletag', $parseto); return "[$parseto]{$text}[/$parseto]"; } function smileycode($smileyid) { global $_DCACHE; if(!is_array($_DCACHE['smileycodes'])) { @include DISCUZ_ROOT.'./forumdata/cache/cache_post.php'; } foreach($_DCACHE['smileycodes'] as $id => $code) { if($smileyid == $id) { return $code; } } } function spantag($spanoptions, $text) { $prependtags = $appendtags = ''; parsestyle($spanoptions, $prependtags, $appendtags); return $prependtags.recursion('span', $text, 'spantag').$appendtags; } function tabletag($attributes) { $attributes = stripslashes($attributes); $width = ''; if(preg_match("/width=([\"|\']?)(\d{1,4}%?)(\\1)/is", $attributes, $matches)) { $width = substr($matches[2], -1) == '%' ? (substr($matches[2], 0, -1) <= 98 ? $matches[2] : '98%') : ($matches[2] <= 560 ? $matches[2] : '560'); } elseif(preg_match("/width\s?:\s?(\d{1,4})([px|%])/is", $attributes, $matches)) { $width = $matches[2] == '%' ? ($matches[1] <= 98 ? $matches[1] : '98%') : ($matches[1] <= 560 ? $matches[1] : '560'); } if(preg_match("/(?:background|background-color|bgcolor)[:=]\s*([\"']?)((rgb\(\d{1,3}%?,\s*\d{1,3}%?,\s*\d{1,3}%?\))|(#[0-9a-fA-F]{3,6})|([a-zA-Z]{1,20}))(\\1)/i", $attributes, $matches)) { $bgcolor = $matches[2]; $width = $width ? $width : '98%'; } else { $bgcolor = ''; } return $bgcolor ? "[table=$width,$bgcolor]" :($width ? "[table=$width]" : '[table]'); } function tdtag($attributes) { $value = array('colspan' => 1, 'rowspan' => 1, 'width' => ''); preg_match_all("/(colspan|rowspan|width)=([\"|\']?)(\d{1,4}%?)(\\2)/is", stripslashes($attributes), $matches); if(is_array($matches[1])) { foreach($matches[1] as $key => $attribute) { $value[strtolower($attribute)] = $matches[3][$key]; } } @extract($value); return $width == '' ? ($colspan == 1 && $rowspan == 1 ? '[td]' : "[td=$colspan,$rowspan]") : "[td=$colspan,$rowspan,$width]"; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/editor.func.php
PHP
asf20
12,713
<? /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: image.class.php 19557 2009-09-04 08:44:50Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } class Image { var $attachinfo = ''; var $targetfile = ''; var $imagecreatefromfunc = ''; var $imagefunc = ''; var $attach = array(); var $animatedgif = 0; var $error = 0; function Image($targetfile, $attach = array()) { global $imagelib, $watermarktext, $imageimpath; $this->targetfile = $targetfile; $this->attach = $attach; $this->attachinfo = @getimagesize($targetfile); if(!$imagelib || !$imageimpath) { switch($this->attachinfo['mime']) { case 'image/jpeg': $this->imagecreatefromfunc = function_exists('imagecreatefromjpeg') ? 'imagecreatefromjpeg' : ''; $this->imagefunc = function_exists('imagejpeg') ? 'imagejpeg' : ''; break; case 'image/gif': $this->imagecreatefromfunc = function_exists('imagecreatefromgif') ? 'imagecreatefromgif' : ''; $this->imagefunc = function_exists('imagegif') ? 'imagegif' : ''; break; case 'image/png': $this->imagecreatefromfunc = function_exists('imagecreatefrompng') ? 'imagecreatefrompng' : ''; $this->imagefunc = function_exists('imagepng') ? 'imagepng' : ''; break; } } else { $this->imagecreatefromfunc = $this->imagefunc = TRUE; } $this->attach['size'] = empty($this->attach['size']) ? @filesize($targetfile) : $this->attach['size']; if($this->attachinfo['mime'] == 'image/gif') { if($this->imagecreatefromfunc && !@imagecreatefromgif($targetfile)) { $this->error = 1; $this->imagecreatefromfunc = $this->imagefunc = ''; return FALSE; } $fp = fopen($targetfile, 'rb'); $targetfilecontent = fread($fp, $this->attach['size']); fclose($fp); $this->animatedgif = strpos($targetfilecontent, 'NETSCAPE2.0') === FALSE ? 0 : 1; } } function Thumb($thumbwidth, $thumbheight, $preview = 0) { global $imagelib, $imageimpath, $thumbstatus, $watermarkstatus; $imagelib && $imageimpath ? $this->Thumb_IM($thumbwidth, $thumbheight, $preview) : $this->Thumb_GD($thumbwidth, $thumbheight, $preview); if($thumbstatus == 2 && $watermarkstatus) { $this->Image($this->targetfile, $this->attach); } $this->attach['size'] = filesize($this->targetfile); } function Watermark($preview = 0) { global $imagelib, $imageimpath, $watermarktype, $watermarktext, $watermarkminwidth, $watermarkminheight; if(($watermarkminwidth && $this->attachinfo[0] <= $watermarkminwidth && $watermarkminheight && $this->attachinfo[1] <= $watermarkminheight) || ($watermarktype == 2 && (!file_exists($watermarktext['fontpath']) || !is_file($watermarktext['fontpath'])))) { return; } $imagelib && $imageimpath ? $this->Watermark_IM($preview) : $this->Watermark_GD($preview); } function Thumb_GD($thumbwidth, $thumbheight, $preview = 0) { global $thumbstatus, $thumbquality; if($thumbstatus && function_exists('imagecreatetruecolor') && function_exists('imagecopyresampled') && function_exists('imagejpeg')) { $imagecreatefromfunc = $this->imagecreatefromfunc; $imagefunc = $thumbstatus == 1 ? 'imagejpeg' : $this->imagefunc; list($img_w, $img_h) = $this->attachinfo; if(!$this->animatedgif && ($img_w >= $thumbwidth || $img_h >= $thumbheight)) { if($thumbstatus != 3) { $attach_photo = $imagecreatefromfunc($this->targetfile); $x_ratio = $thumbwidth / $img_w; $y_ratio = $thumbheight / $img_h; if(($x_ratio * $img_h) < $thumbheight) { $thumb['height'] = ceil($x_ratio * $img_h); $thumb['width'] = $thumbwidth; } else { $thumb['width'] = ceil($y_ratio * $img_w); $thumb['height'] = $thumbheight; } $targetfile = !$preview ? ($thumbstatus == 1 ? $this->targetfile.'.thumb.jpg' : $this->targetfile) : DISCUZ_ROOT.'./forumdata/watermark_temp.jpg'; $cx = $img_w; $cy = $img_h; } else { $attach_photo = $imagecreatefromfunc($this->targetfile); $imgratio = $img_w / $img_h; $thumbratio = $thumbwidth / $thumbheight; if($imgratio >= 1 && $imgratio >= $thumbratio || $imgratio < 1 && $imgratio > $thumbratio) { $cuty = $img_h; $cutx = $cuty * $thumbratio; } elseif($imgratio >= 1 && $imgratio <= $thumbratio || $imgratio < 1 && $imgratio < $thumbratio) { $cutx = $img_w; $cuty = $cutx / $thumbratio; } $dst_photo = imagecreatetruecolor($cutx, $cuty); @imageCopyMerge($dst_photo, $attach_photo, 0, 0, 0, 0, $cutx, $cuty, 100); $thumb['width'] = $thumbwidth; $thumb['height'] = $thumbheight; $targetfile = !$preview ? $this->targetfile.'.thumb.jpg' : DISCUZ_ROOT.'./forumdata/watermark_temp.jpg'; $cx = $cutx; $cy = $cuty; } $thumb_photo = imagecreatetruecolor($thumb['width'], $thumb['height']); @imageCopyreSampled($thumb_photo, $attach_photo ,0, 0, 0, 0, $thumb['width'], $thumb['height'], $cx, $cy); clearstatcache(); if($this->attachinfo['mime'] == 'image/jpeg') { $imagefunc($thumb_photo, $targetfile, $thumbquality); } else { $imagefunc($thumb_photo, $targetfile); } $this->attach['thumb'] = $thumbstatus == 1 || $thumbstatus == 3 ? 1 : 0; } } } function Watermark_GD($preview = 0) { global $watermarkstatus, $watermarktype, $watermarktrans, $watermarkquality, $watermarktext; $watermarkstatus = $GLOBALS['forum']['disablewatermark'] ? 0 : $watermarkstatus; if($watermarkstatus && function_exists('imagecopy') && function_exists('imagealphablending') && function_exists('imagecopymerge')) { $imagecreatefromfunc = $this->imagecreatefromfunc; $imagefunc = $this->imagefunc; list($img_w, $img_h) = $this->attachinfo; if($watermarktype < 2) { $watermark_file = $watermarktype == 1 ? './images/common/watermark.png' : './images/common/watermark.gif'; $watermarkinfo = @getimagesize($watermark_file); $watermark_logo = $watermarktype == 1 ? @imageCreateFromPNG($watermark_file) : @imageCreateFromGIF($watermark_file); if(!$watermark_logo) { return; } list($logo_w, $logo_h) = $watermarkinfo; } else { $watermarktextcvt = pack("H*", $watermarktext['text']); $box = imagettfbbox($watermarktext['size'], $watermarktext['angle'], $watermarktext['fontpath'], $watermarktextcvt); $logo_h = max($box[1], $box[3]) - min($box[5], $box[7]); $logo_w = max($box[2], $box[4]) - min($box[0], $box[6]); $ax = min($box[0], $box[6]) * -1; $ay = min($box[5], $box[7]) * -1; } $wmwidth = $img_w - $logo_w; $wmheight = $img_h - $logo_h; if(($watermarktype < 2 && is_readable($watermark_file) || $watermarktype == 2) && $wmwidth > 10 && $wmheight > 10 && !$this->animatedgif) { switch($watermarkstatus) { case 1: $x = +5; $y = +5; break; case 2: $x = ($img_w - $logo_w) / 2; $y = +5; break; case 3: $x = $img_w - $logo_w - 5; $y = +5; break; case 4: $x = +5; $y = ($img_h - $logo_h) / 2; break; case 5: $x = ($img_w - $logo_w) / 2; $y = ($img_h - $logo_h) / 2; break; case 6: $x = $img_w - $logo_w; $y = ($img_h - $logo_h) / 2; break; case 7: $x = +5; $y = $img_h - $logo_h - 5; break; case 8: $x = ($img_w - $logo_w) / 2; $y = $img_h - $logo_h - 5; break; case 9: $x = $img_w - $logo_w - 5; $y = $img_h - $logo_h - 5; break; } $dst_photo = imagecreatetruecolor($img_w, $img_h); $target_photo = @$imagecreatefromfunc($this->targetfile); @imageCopy($dst_photo, $target_photo, 0, 0, 0, 0, $img_w, $img_h); if($watermarktype == 1) { @imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h); } elseif($watermarktype == 2) { if(($watermarktext['shadowx'] || $watermarktext['shadowy']) && $watermarktext['shadowcolor']) { $shadowcolorrgb = explode(',', $watermarktext['shadowcolor']); $shadowcolor = imagecolorallocate($dst_photo, $shadowcolorrgb[0], $shadowcolorrgb[1], $shadowcolorrgb[2]); imagettftext($dst_photo, $watermarktext['size'], $watermarktext['angle'], $x + $ax + $watermarktext['shadowx'], $y + $ay + $watermarktext['shadowy'], $shadowcolor, $watermarktext['fontpath'], $watermarktextcvt); } $colorrgb = explode(',', $watermarktext['color']); $color = imagecolorallocate($dst_photo, $colorrgb[0], $colorrgb[1], $colorrgb[2]); imagettftext($dst_photo, $watermarktext['size'], $watermarktext['angle'], $x + $ax, $y + $ay, $color, $watermarktext['fontpath'], $watermarktextcvt); } else { imageAlphaBlending($watermark_logo, true); @imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $watermarktrans); } $targetfile = !$preview ? $this->targetfile : DISCUZ_ROOT.'./forumdata/watermark_temp.jpg'; clearstatcache(); if($this->attachinfo['mime'] == 'image/jpeg') { $imagefunc($dst_photo, $targetfile, $watermarkquality); } else { $imagefunc($dst_photo, $targetfile); } $this->attach['size'] = filesize($targetfile); } } } function Thumb_IM($thumbwidth, $thumbheight, $preview = 0) { global $thumbstatus, $imageimpath, $thumbquality; if($thumbstatus) { list($img_w, $img_h) = $this->attachinfo; $targetfile = !$preview ? ($thumbstatus == 1 || $thumbstatus == 3 ? $this->targetfile.'.thumb.jpg' : $this->targetfile) : DISCUZ_ROOT.'./forumdata/watermark_temp.jpg'; if(!$this->animatedgif && ($img_w >= $thumbwidth || $img_h >= $thumbheight)) { if($thumbstatus != 3) { $exec_str = $imageimpath.'/convert -quality '.intval($thumbquality).' -geometry '.$thumbwidth.'x'.$thumbheight.' '.$this->targetfile.' '.$targetfile; @exec($exec_str, $output, $return); if(empty($return) && empty($output)) { $this->attach['thumb'] = $thumbstatus == 1 ? 1 : 0; } } else { $imgratio = $img_w / $img_h; $thumbratio = $thumbwidth / $thumbheight; if($imgratio >= 1 && $imgratio >= $thumbratio || $imgratio < 1 && $imgratio > $thumbratio) { $cuty = $img_h; $cutx = $cuty * $thumbratio; } elseif($imgratio >= 1 && $imgratio <= $thumbratio || $imgratio < 1 && $imgratio < $thumbratio) { $cutx = $img_w; $cuty = $cutx / $thumbratio; } $exec_str = $imageimpath.'/convert -crop '.$cutx.'x'.$cuty.'+0+0 '.$this->targetfile.' '.$targetfile; @exec($exec_str, $output, $return); $exec_str = $imageimpath.'/convert -quality '.intval($thumbquality).' -geometry '.$thumbwidth.'x'.$thumbheight.' '.$targetfile.' '.$targetfile; @exec($exec_str, $output, $return); if(empty($return) && empty($output)) { $this->attach['thumb'] = $thumbstatus == 1 || $thumbstatus == 3 ? 1 : 0; } } } } } function Watermark_IM($preview = 0) { global $watermarkstatus, $watermarktype, $watermarktrans, $watermarkquality, $watermarktext, $imageimpath; $watermarkstatus = $GLOBALS['forum']['disablewatermark'] ? 0 : $watermarkstatus; switch($watermarkstatus) { case 1: $gravity = 'NorthWest'; break; case 2: $gravity = 'North'; break; case 3: $gravity = 'NorthEast'; break; case 4: $gravity = 'West'; break; case 5: $gravity = 'Center'; break; case 6: $gravity = 'East'; break; case 7: $gravity = 'SouthWest'; break; case 8: $gravity = 'South'; break; case 9: $gravity = 'SouthEast'; break; } $targetfile = !$preview ? $this->targetfile : DISCUZ_ROOT.'./forumdata/watermark_temp.jpg'; if($watermarktype < 2) { $watermark_file = $watermarktype == 1 ? DISCUZ_ROOT.'./images/common/watermark.png' : DISCUZ_ROOT.'./images/common/watermark.gif'; $exec_str = $imageimpath.'/composite'. ($watermarktype != 1 && $watermarktrans != '100' ? ' -watermark '.$watermarktrans.'%' : ''). ' -quality '.$watermarkquality. ' -gravity '.$gravity. ' '.$watermark_file.' '.$this->targetfile.' '.$targetfile; } else { $watermarktextcvt = str_replace(array("\n", "\r", "'"), array('', '', '\''), pack("H*", $watermarktext['text'])); $watermarktext['angle'] = -$watermarktext['angle']; $translate = $watermarktext['translatex'] || $watermarktext['translatey'] ? ' translate '.$watermarktext['translatex'].','.$watermarktext['translatey'] : ''; $skewX = $watermarktext['skewx'] ? ' skewX '.$watermarktext['skewx'] : ''; $skewY = $watermarktext['skewy'] ? ' skewY '.$watermarktext['skewy'] : ''; $exec_str = $imageimpath.'/convert'. ' -quality '.$watermarkquality. ' -font "'.$watermarktext['fontpath'].'"'. ' -pointsize '.$watermarktext['size']. (($watermarktext['shadowx'] || $watermarktext['shadowy']) && $watermarktext['shadowcolor'] ? ' -fill "rgb('.$watermarktext['shadowcolor'].')"'. ' -draw "'. ' gravity '.$gravity.$translate.$skewX.$skewY. ' rotate '.$watermarktext['angle']. ' text '.$watermarktext['shadowx'].','.$watermarktext['shadowy'].' \''.$watermarktextcvt.'\'"' : ''). ' -fill "rgb('.$watermarktext['color'].')"'. ' -draw "'. ' gravity '.$gravity.$translate.$skewX.$skewY. ' rotate '.$watermarktext['angle']. ' text 0,0 \''.$watermarktextcvt.'\'"'. ' '.$this->targetfile.' '.$targetfile; } @exec($exec_str, $output, $return); if(empty($return) && empty($output)) { $this->attach['size'] = filesize($this->targetfile); } } }
zyyhong
trunk/jiaju001/newbbs/bbs/include/image.class.php
PHP
asf20
13,870
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: gift.inc.php 17385 2008-12-17 05:05:02Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess($task = array()) { if(!isset($task['newbie'])) { dheader("Location: task.php?action=draw&id=$task[taskid]"); } } function task_csc($task = array()) { return true; } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/gift.inc.php
PHP
asf20
685
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.inc.php 17065 2008-12-05 01:30:57Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { return TRUE; } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/newbie_search.inc.php
PHP
asf20
573
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.inc.php 17065 2008-12-05 01:30:57Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { global $discuz_uid; include_once DISCUZ_ROOT.'./uc_client/client.php'; if(uc_check_avatar($discuz_uid)) { return true; } return array('csc' => 0, 'remaintime' => 0); } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/newbie_uploadavatar.inc.php
PHP
asf20
739
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: post.inc.php 17326 2008-12-15 03:09:58Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { global $db, $tablepre, $discuz_uid, $timestamp; $taskvars = array('num' => 0); $query = $db->query("SELECT variable, value FROM {$tablepre}taskvars WHERE taskid='$task[taskid]'"); while($taskvar = $db->fetch_array($query)) { if($taskvar['value']) { $taskvars[$taskvar['variable']] = $taskvar['value']; } } $tbladd = $sqladd = ''; if($taskvars['threadid']) { $sqladd .= " AND p.tid='$taskvars[threadid]'"; } else { if($taskvars['forumid']) { $sqladd .= " AND p.fid='$taskvars[forumid]'"; } if($taskvars['authorid']) { $tbladd .= ", {$tablepre}threads t"; $sqladd .= " AND p.tid=t.tid AND t.authorid='$taskvars[authorid]'"; } } if($taskvars['act']) { if($taskvars['act'] == 'newthread') { $sqladd .= " AND p.first='1'"; } elseif($taskvars['act'] == 'newreply') { $sqladd .= " AND p.first='0'"; } } $sqladd .= ($taskvars['time'] = floatval($taskvars['time'])) ? " AND p.dateline BETWEEN $task[applytime] AND $task[applytime]+3600*$taskvars[time]" : " AND p.dateline>$task[applytime]"; $num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts p $tbladd WHERE p.authorid='$discuz_uid' $sqladd"); if($num && $num >= $taskvars['num']) { return TRUE; } elseif($taskvars['time'] && $timestamp >= $task['applytime'] + 3600 * $taskvars['time'] && (!$num || $num < $taskvars['num'])) { return FALSE; } else { return array('csc' => $num > 0 && $taskvars['num'] ? sprintf("%01.2f", $num / $taskvars['num'] * 100) : 0, 'remaintime' => $taskvars['time'] ? $task['applytime'] + $taskvars['time'] * 3600 - $timestamp : 0); } } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/post.inc.php
PHP
asf20
2,006
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: mod.inc.php 16697 2008-11-14 07:36:51Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { return true; } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/mod.inc.php
PHP
asf20
395
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.inc.php 17065 2008-12-05 01:30:57Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { global $discuz_uid; include_once DISCUZ_ROOT.'./uc_client/client.php'; include language('tasks'); if(uc_check_avatar($discuz_uid)) { showmessage($tasklang['avatar_apply_var_desc_noavatar']); } } function task_preprocess() { } function task_csc($task = array()) { global $discuz_uid; include_once DISCUZ_ROOT.'./uc_client/client.php'; if(uc_check_avatar($discuz_uid)) { return true; } return array('csc' => 0, 'remaintime' => 0); } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/avatar.inc.php
PHP
asf20
947
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.inc.php 17065 2008-12-05 01:30:57Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { global $db, $tablepre, $discuz_uid; $threadid = $db->result_first("SELECT value FROM {$tablepre}taskvars WHERE taskid='$task[taskid]' AND variable='threadid'"); return $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$threadid' AND first='0' AND authorid='$discuz_uid'") ? TRUE : array('csc' => 0, 'remaintime' => 0); } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/newbie_post_reply.inc.php
PHP
asf20
905
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: gift.cfg.php 16697 2008-11-14 07:36:51Z monkey $ */ $task_name = $tasklang['gift_name']; $task_description = $tasklang['gift_desc']; $task_icon = 'gift.gif'; $task_period = ''; $task_conditions = array( array('sort' => '', 'name' => '', 'description' => '', 'variable' => '', 'value' => '', 'type' => '', 'extra' => ''), ); $task_version = '1.0'; $task_copyright = $tasklang['gift_copyright']; ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/gift.cfg.php
PHP
asf20
550
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.inc.php 17065 2008-12-05 01:30:57Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { global $db, $tablepre, $discuz_uid; $forumid = $db->result_first("SELECT value FROM {$tablepre}taskvars WHERE taskid='$task[taskid]' AND variable='forumid'"); return $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid='$forumid' AND authorid='$discuz_uid'") ? TRUE : array('csc' => 0, 'remaintime' => 0); } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/newbie_post_newthread.inc.php
PHP
asf20
888
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.cfg.php 16697 2008-11-14 07:36:51Z monkey $ */ $task_name = $tasklang['avatar_name']; $task_description = $tasklang['avatar_desc']; $task_icon = ''; $task_period = ''; $task_conditions = array( array('sort' => 'apply', 'name' => $tasklang['avatar_apply_var_name_noavatar'], 'description' => $tasklang['avatar_apply_var_desc_noavatar'], 'variable' => '', 'value' => '', 'type' => '', 'extra' => ''), array('sort' => 'complete', 'name' => $tasklang['avatar_complete_var_name_uploadavatar'], 'description' => $tasklang['avatar_complete_var_desc_uploadavatar'], 'variable' => '', 'value' => '', 'type' => '', 'extra' => '') ); $task_version = '1.0'; $task_copyright = $task_copyright = $tasklang['avatar_copyright']; ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/avatar.cfg.php
PHP
asf20
879
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.inc.php 17065 2008-12-05 01:30:57Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { global $db, $tablepre, $msgto; return intval($msgto) == $db->result_first("SELECT value FROM {$tablepre}taskvars WHERE taskid='$task[taskid]' AND variable='authorid'") ? TRUE : array('csc' => 0, 'remaintime' => 0); } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/newbie_sendpm.inc.php
PHP
asf20
777
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: member.inc.php 17090 2008-12-05 05:15:08Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_condition() { } function task_preprocess() { global $db, $tablepre, $task, $discuz_uid, $timestamp; $act = $db->result_first("SELECT value FROM {$tablepre}taskvars WHERE taskid='$task[taskid]' AND variable='act'"); if($act == 'buddy') { include_once DISCUZ_ROOT.'./uc_client/client.php'; $db->query("REPLACE INTO {$tablepre}spacecaches (uid, variable, value, expiration) VALUES ('$discuz_uid', 'buddy$task[taskid]', '".(uc_friend_totalnum($discuz_uid, 1) + uc_friend_totalnum($discuz_uid, 3))."', '$timestamp')"); } elseif($act == 'favorite') { $db->query("REPLACE INTO {$tablepre}spacecaches (uid, variable, value, expiration) VALUES ('$discuz_uid', 'favorite$task[taskid]', '".$db->result_first("SELECT COUNT(*) FROM {$tablepre}favorites WHERE uid='$discuz_uid' AND tid>'0'")."', '$timestamp')"); } } function task_csc($task = array()) { global $db, $tablepre, $discuz_uid, $timestamp; $taskvars = array('num' => 0); $num = 0; $query = $db->query("SELECT variable, value FROM {$tablepre}taskvars WHERE taskid='$task[taskid]'"); while($taskvar = $db->fetch_array($query)) { if($taskvar['value']) { $taskvars[$taskvar['variable']] = $taskvar['value']; } } $taskvars['time'] = floatval($taskvars['time']); if($taskvars['act'] == 'buddy') { include_once DISCUZ_ROOT.'./uc_client/client.php'; $num = uc_friend_totalnum($discuz_uid, 1) + uc_friend_totalnum($discuz_uid, 3) - $db->result_first("SELECT value FROM {$tablepre}spacecaches WHERE uid='$discuz_uid' AND variable='buddy$task[taskid]'"); } elseif($taskvars['act'] == 'favorite') { $num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}favorites WHERE uid='$discuz_uid' AND tid>'0'") - $db->result_first("SELECT value FROM {$tablepre}spacecaches WHERE uid='$discuz_uid' AND variable='favorite$task[taskid]'"); } elseif($taskvars['act'] == 'magic') { $num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}magiclog WHERE action='2' AND uid='$discuz_uid'".($taskvars['time'] ? " AND dateline BETWEEN $task[applytime] AND $task[applytime]+3600*$taskvars[time]" : " AND dateline>$task[applytime]")); } if($num && $num >= $taskvars['num']) { if(in_array($taskvars['act'], array('buddy', 'favorite'))) { $db->query("DELETE FROM {$tablepre}spacecaches WHERE uid='$discuz_uid' AND variable='$taskvars[act]$task[taskid]'"); } return TRUE; } elseif($taskvars['time'] && $timestamp >= $task['applytime'] + 3600 * $taskvars['time'] && (!$num || $num < $taskvars['num'])) { return FALSE; } else { return array('csc' => $num > 0 && $taskvars['num'] ? sprintf("%01.2f", $num / $taskvars['num'] * 100) : 0, 'remaintime' => $taskvars['time'] ? $task['applytime'] + $taskvars['time'] * 3600 - $timestamp : 0); } } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/member.inc.php
PHP
asf20
3,055
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: promotion.inc.php 17523 2009-01-12 03:41:50Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess() { global $db, $tablepre, $discuz_uid, $timestamp, $task; $promotions = $db->result_first("SELECT COUNT(*) FROM {$tablepre}promotions WHERE uid='$discuz_uid'"); $db->query("REPLACE INTO {$tablepre}spacecaches (uid, variable, value, expiration) VALUES ('$discuz_uid', 'promotion$task[taskid]', '$promotions', '$timestamp')"); } function task_csc($task = array()) { global $db, $tablepre, $discuz_uid; $num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}promotions WHERE uid='$discuz_uid'") - $db->result_first("SELECT value FROM {$tablepre}spacecaches WHERE uid='$discuz_uid' AND variable='promotion$task[taskid]'"); $numlimit = $db->result_first("SELECT value FROM {$tablepre}taskvars WHERE taskid='$task[taskid]' AND variable='num'"); if($num && $num >= $numlimit) { return TRUE; } else { return array('csc' => $num > 0 && $numlimit ? sprintf("%01.2f", $num / $numlimit * 100) : 0, 'remaintime' => 0); } } function task_sufprocess() { global $db, $tablepre, $discuz_uid, $task; $db->query("DELETE FROM {$tablepre}spacecaches WHERE uid='$discuz_uid' AND variable='promotion$task[taskid]'"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/promotion.inc.php
PHP
asf20
1,619
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.inc.php 17065 2008-12-05 01:30:57Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { global $db, $tablepre, $buddyid; return intval($buddyid[0]) == $db->result_first("SELECT value FROM {$tablepre}taskvars WHERE taskid='$task[taskid]' AND variable='authorid'") ? TRUE : array('csc' => 0, 'remaintime' => 0); } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/newbie_addbuddy.inc.php
PHP
asf20
786
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: avatar.inc.php 17065 2008-12-05 01:30:57Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function task_install() { global $db, $tablepre; } function task_uninstall() { global $db, $tablepre; } function task_upgrade() { global $db, $tablepre; } function task_condition() { } function task_preprocess() { } function task_csc($task = array()) { return TRUE; } function task_sufprocess() { } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/newbie_modifyprofile.inc.php
PHP
asf20
573
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: promotion.cfg.php 16697 2008-11-14 07:36:51Z monkey $ */ $task_name = $tasklang['promotion_name']; $task_description = $tasklang['promotion_desc']; $task_icon = ''; $task_period = ''; $task_conditions = array( array('sort' => 'complete', 'name' => $tasklang['promotion_complete_var_name_iplimit'], 'description' => $tasklang['promotion_complete_var_desc_iplimit'], 'variable' => 'num', 'value' => '100', 'type' => 'number', 'extra' => ''), ); $task_version = '1.0'; $task_copyright = $tasklang['promotion_copyright']; ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/tasks/promotion.cfg.php
PHP
asf20
674
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: newthread.inc.php 21084 2009-11-11 07:30:21Z tiger $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $discuz_action = 11; if(empty($forum['fid']) || $forum['type'] == 'group') { showmessage('forum_nonexistence'); } if(($special == 1 && !$allowpostpoll) || ($special == 2 && !$allowposttrade) || ($special == 3 && !$allowpostreward) || ($special == 4 && !$allowpostactivity) || ($special == 5 && !$allowpostdebate)) { showmessage('group_nopermission', NULL, 'NOPERM'); } if(!$discuz_uid && !((!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])))) { //showmessage('postperm_login_nopermission', NULL, 'NOPERM'); //header("location:http://www.jiaju001.com/member/login.html"); //exit; } elseif(empty($forum['allowpost'])) { if(!$forum['postperm'] && !$allowpost) { showmessage('postperm_none_nopermission', NULL, 'NOPERM'); } elseif($forum['postperm'] && !forumperm($forum['postperm'])) { showmessagenoperm('postperm', $fid); } } elseif($forum['allowpost'] == -1) { showmessage('post_forum_newthread_nopermission', NULL, 'HALTED'); } if($url && !empty($qihoo['relate']['webnum'])) { $from = in_array($from, array('direct', 'iframe')) ? $from : ''; if($data = @implode('', file("http://search.qihoo.com/sint/content.html?surl=$url&md5=$md5&ocs=$charset&ics=$charset&from=$from"))) { preg_match_all("/(\w+):([^\>]+)/i", $data, $data); if(!$data[2][1]) { $subject = trim($data[2][3]); $message = !$editormode ? str_replace('[br]', "\n", trim($data[2][4])) : str_replace('[br]', '<br />', trim($data[2][4])); } else { showmessage('reprint_invalid'); } } } checklowerlimit($postcredits); if(!submitcheck('topicsubmit', 0, $seccodecheck, $secqaacheck)) { $modelid = $modelid ? intval($modelid) : ''; $isfirstpost = 1; $tagoffcheck = ''; $showthreadsorts = !empty($sortid); $icons = ''; if(!$special && is_array($_DCACHE['icons'])) { $key = 1; foreach($_DCACHE['icons'] as $id => $icon) { $icons .= ' <input class="radio" type="radio" name="iconid" value="'.$id.'" /><img src="images/icons/'.$icon.'" alt="" />'; $icons .= !(++$key % 10) ? '<br />' : ''; } } if($special == 2 && $allowposttrade) { $expiration_7days = date('Y-m-d', $timestamp + 86400 * 7); $expiration_14days = date('Y-m-d', $timestamp + 86400 * 14); $trade['expiration'] = $expiration_month = date('Y-m-d', mktime(0, 0, 0, date('m')+1, date('d'), date('Y'))); $expiration_3months = date('Y-m-d', mktime(0, 0, 0, date('m')+3, date('d'), date('Y'))); $expiration_halfyear = date('Y-m-d', mktime(0, 0, 0, date('m')+6, date('d'), date('Y'))); $expiration_year = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')+1)); $forum['tradetypes'] = $forum['tradetypes'] == '' ? -1 : unserialize($forum['tradetypes']); } elseif($specialextra) { @include_once DISCUZ_ROOT.'./plugins/'.$threadplugins[$specialextra]['module'].'.class.php'; $classname = 'threadplugin_'.$specialextra; if(method_exists($classname, 'newthread')) { $threadpluginclass = new $classname; $threadplughtml = $threadpluginclass->newthread($fid); $buttontext = $threadpluginclass->buttontext; $iconfile = $threadpluginclass->iconfile; $iconsflip = array_flip($_DCACHE['icons']); $thread['iconid'] = $iconsflip[$iconfile]; } } if($special == 4) { $activitytypelist = $activitytype ? explode("\n", trim($activitytype)) : ''; } if($allowpostattach) { $attachlist = getattach(); $attachs = $attachlist['attachs']; $imgattachs = $attachlist['imgattachs']; unset($attachlist); } $infloat ? include template('post_infloat') : include template('post'); } else { if($subject == '') { showmessage('post_sm_isnull'); } if(!$sortid && !$special && $message == '') { showmessage('post_sm_isnull'); } if($post_invalid = checkpost($special)) { showmessage($post_invalid); } if(checkflood()) { showmessage('post_flood_ctrl'); } if($discuz_uid) { $attentionon = empty($attention_add) ? 0 : 1; } $typeid = isset($typeid) && isset($forum['threadtypes']['types'][$typeid]) ? $typeid : 0; $iconid = !empty($iconid) && isset($_DCACHE['icons'][$iconid]) ? $iconid : 0; $displayorder = $modnewthreads ? -2 : (($forum['ismoderator'] && !empty($sticktopic)) ? 1 : 0); $digest = ($forum['ismoderator'] && !empty($addtodigest)) ? 1 : 0; $readperm = $allowsetreadperm ? $readperm : 0; $isanonymous = $isanonymous && $allowanonymous ? 1 : 0; $price = intval($price); $price = $maxprice && !$special ? ($price <= $maxprice ? $price : $maxprice) : 0; if(!$typeid && $forum['threadtypes']['required'] && !$special) { showmessage('post_type_isnull'); } if(!$sortid && $forum['threadsorts']['required'] && !$special) { showmessage('post_sort_isnull'); } if($price > 0 && floor($price * (1 - $creditstax)) == 0) { showmessage('post_net_price_iszero'); } if($special == 1) { $pollarray = array(); foreach($polloption as $key => $value) { if(trim($value) === '') { unset($polloption[$key]); } } if(count($polloption) > $maxpolloptions) { showmessage('post_poll_option_toomany'); } elseif(count($polloption) < 2) { showmessage('post_poll_inputmore'); } $maxchoices = !empty($multiplepoll) ? (!$maxchoices || $maxchoices >= count($polloption) ? count($polloption) : $maxchoices) : ''; $pollarray['options'] = $polloption; $pollarray['multiple'] = !empty($multiplepoll); $pollarray['visible'] = empty($visibilitypoll); $pollarray['overt'] = !empty($overt); if(preg_match("/^\d*$/", trim($maxchoices)) && preg_match("/^\d*$/", trim($expiration))) { if(!$pollarray['multiple']) { $pollarray['maxchoices'] = 1; } elseif(empty($maxchoices)) { $pollarray['maxchoices'] = 0; } elseif($maxchoices == 1) { $pollarray['multiple'] = 0; $pollarray['maxchoices'] = $maxchoices; } else { $pollarray['maxchoices'] = $maxchoices; } if(empty($expiration)) { $pollarray['expiration'] = 0; } else { $pollarray['expiration'] = $timestamp + 86400 * $expiration; } } else { showmessage('poll_maxchoices_expiration_invalid'); } } elseif($special == 3) { $rewardprice = intval($rewardprice); if($rewardprice < 1) { showmessage('reward_credits_please'); } elseif($rewardprice > 32767) { showmessage('reward_credits_overflow'); } elseif($rewardprice < $minrewardprice || ($maxrewardprice > 0 && $rewardprice > $maxrewardprice)) { if($maxrewardprice > 0) { showmessage('reward_credits_between'); } else { showmessage('reward_credits_lower'); } } elseif(($realprice = $rewardprice + ceil($rewardprice * $creditstax)) > $_DSESSION["extcredits$creditstransextra[2]"]) { showmessage('reward_credits_shortage'); } $price = $rewardprice; $db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]-$realprice WHERE uid='$discuz_uid'"); } elseif($special == 4) { $activitytime = intval($activitytime); if(empty($starttimefrom[$activitytime])) { showmessage('activity_fromtime_please'); } elseif(@strtotime($starttimefrom[$activitytime]) === -1 || @strtotime($starttimefrom[$activitytime]) === FALSE) { showmessage('activity_fromtime_error'); } elseif($activitytime && ((@strtotime($starttimefrom) > @strtotime($starttimeto) || !$starttimeto))) { showmessage('activity_fromtime_error'); } elseif(!trim($activityclass)) { showmessage('activity_sort_please'); } elseif(!trim($activityplace)) { showmessage('activity_address_please'); } elseif(trim($activityexpiration) && (@strtotime($activityexpiration) === -1 || @strtotime($activityexpiration) === FALSE)) { showmessage('activity_totime_error'); } $activity = array(); $activity['class'] = dhtmlspecialchars(trim($activityclass)); $activity['starttimefrom'] = @strtotime($starttimefrom[$activitytime]); $activity['starttimeto'] = $activitytime ? @strtotime($starttimeto) : 0; $activity['place'] = dhtmlspecialchars(trim($activityplace)); $activity['cost'] = intval($cost); $activity['gender'] = intval($gender); $activity['number'] = intval($activitynumber); if($activityexpiration) { $activity['expiration'] = @strtotime($activityexpiration); } else { $activity['expiration'] = 0; } if(trim($activitycity)) { $subject .= '['.dhtmlspecialchars(trim($activitycity)).']'; } } elseif($special == 5) { if(empty($affirmpoint) || empty($negapoint)) { showmessage('debate_position_nofound'); } elseif(!empty($endtime) && (!($endtime = @strtotime($endtime)) || $endtime < $timestamp)) { showmessage('debate_endtime_invalid'); } elseif(!empty($umpire)) { if(!$db->result_first("SELECT COUNT(*) FROM {$tablepre}members WHERE username='$umpire'")) { $umpire = dhtmlspecialchars($umpire); showmessage('debate_umpire_invalid'); } } $affirmpoint = dhtmlspecialchars($affirmpoint); $negapoint = dhtmlspecialchars($negapoint); $stand = intval($stand); } elseif($specialextra) { @include_once DISCUZ_ROOT.'./plugins/'.$threadplugins[$specialextra]['module'].'.class.php'; $classname = 'threadplugin_'.$specialextra; if(method_exists($classname, 'newthread_submit')) { $threadpluginclass = new $classname; $threadpluginclass->newthread_submit($fid); } $special = 127; } $sortid = $special && $forum['threadsorts']['types'][$sortid] ? 0 : $sortid; $typeexpiration = intval($typeexpiration); if($forum['threadsorts']['expiration'][$typeid] && !$typeexpiration) { showmessage('threadtype_expiration_invalid'); } $optiondata = array(); if($forum['threadsorts']['types'][$sortid] && !$forum['allowspecialonly']) { $optiondata = threadsort_validator($typeoption); } $author = !$isanonymous ? $discuz_user : ''; $moderated = $digest || $displayorder > 0 ? 1 : 0; $thread['status'] = 0; $ordertype && $thread['status'] = setstatus(4, 1, $thread['status']); $hiddenreplies && $thread['status'] = setstatus(2, 1, $thread['status']); if($allowpostrushreply && $rushreply) { $thread['status'] = setstatus(3, 1, $thread['status']); $thread['status'] = setstatus(1, 1, $thread['status']); } $db->query("INSERT INTO {$tablepre}threads (fid, readperm, price, iconid, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, special, attachment, moderated, status) VALUES ('$fid', '$readperm', '$price', '$iconid', '$typeid', '$sortid', '$author', '$discuz_uid', '$subject', '$timestamp', '$timestamp', '$author', '$displayorder', '$digest', '$special', '0', '$moderated', '$thread[status]')"); $tid = $db->insert_id(); if($discuz_uid) { $stataction = ''; if($attentionon) { $stataction = 'attentionon'; $db->query("REPLACE INTO {$tablepre}favoritethreads (tid, uid, dateline) VALUES ('$tid', '$discuz_uid', '$timestamp')", 'UNBUFFERED'); } if($stataction) { write_statlog('', 'item=attention&action=newthread_'.$stataction, '', '', 'my.php'); } $db->query("UPDATE {$tablepre}favoriteforums SET newthreads=newthreads+1 WHERE fid='$fid' AND uid<>'$discuz_uid'", 'UNBUFFERED'); } if($special == 3 && $allowpostreward) { $db->query("INSERT INTO {$tablepre}rewardlog (tid, authorid, netamount, dateline) VALUES ('$tid', '$discuz_uid', $realprice, '$timestamp')"); } if($moderated) { updatemodlog($tid, ($displayorder > 0 ? 'STK' : 'DIG')); updatemodworks(($displayorder > 0 ? 'STK' : 'DIG'), 1); } if($special == 1) { $db->query("INSERT INTO {$tablepre}polls (tid, multiple, visible, maxchoices, expiration, overt) VALUES ('$tid', '$pollarray[multiple]', '$pollarray[visible]', '$pollarray[maxchoices]', '$pollarray[expiration]', '$pollarray[overt]')"); foreach($pollarray['options'] as $polloptvalue) { $polloptvalue = dhtmlspecialchars(trim($polloptvalue)); $db->query("INSERT INTO {$tablepre}polloptions (tid, polloption) VALUES ('$tid', '$polloptvalue')"); } } elseif($special == 4 && $allowpostactivity) { $db->query("INSERT INTO {$tablepre}activities (tid, uid, cost, starttimefrom, starttimeto, place, class, gender, number, expiration) VALUES ('$tid', '$discuz_uid', '$activity[cost]', '$activity[starttimefrom]', '$activity[starttimeto]', '$activity[place]', '$activity[class]', '$activity[gender]', '$activity[number]', '$activity[expiration]')"); } elseif($special == 5 && $allowpostdebate) { $db->query("INSERT INTO {$tablepre}debates (tid, uid, starttime, endtime, affirmdebaters, negadebaters, affirmvotes, negavotes, umpire, winner, bestdebater, affirmpoint, negapoint, umpirepoint) VALUES ('$tid', '$discuz_uid', '$timestamp', '$endtime', '0', '0', '0', '0', '$umpire', '', '', '$affirmpoint', '$negapoint', '')"); } elseif($special == 127) { $message .= chr(0).chr(0).chr(0).$specialextra; } if($forum['threadsorts']['types'][$sortid] && !empty($optiondata) && is_array($optiondata)) { $filedname = $valuelist = $separator = ''; foreach($optiondata as $optionid => $value) { if(($_DTYPE[$optionid]['search'] || in_array($_DTYPE[$optionid]['type'], array('radio', 'select', 'number'))) && $value) { $filedname .= $separator.$_DTYPE[$optionid]['identifier']; $valuelist .= $separator."'$value'"; $separator = ' ,'; } $db->query("INSERT INTO {$tablepre}typeoptionvars (sortid, tid, optionid, value, expiration) VALUES ('$sortid', '$tid', '$optionid', '$value', '".($typeexpiration ? $timestamp + $typeexpiration : 0)."')"); } if($filedname && $valuelist) { $db->query("INSERT INTO {$tablepre}optionvalue$sortid ($filedname, tid, fid) VALUES ($valuelist, '$tid', '$fid')"); } } $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff)); $smileyoff = checksmilies($message, !empty($smileyoff)); $parseurloff = !empty($parseurloff); $htmlon = bindec(($tagstatus && !empty($tagoff) ? 1 : 0).($allowhtml && !empty($htmlon) ? 1 : 0)); $pinvisible = $modnewthreads ? -2 : 0; $message = preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $message); $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment) VALUES ('$fid', '$tid', '1', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '$message', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '0')"); $pid = $db->insert_id(); if($pid && getstatus($thread['status'], 1)) { savepostposition($tid, $pid); } if($tagstatus && $tags != '') { $tags = str_replace(array(chr(0xa3).chr(0xac), chr(0xa1).chr(0x41), chr(0xef).chr(0xbc).chr(0x8c)), ',', censor($tags)); if(strexists($tags, ',')) { $tagarray = array_unique(explode(',', $tags)); } else { $tags = str_replace(array(chr(0xa1).chr(0xa1), chr(0xa1).chr(0x40), chr(0xe3).chr(0x80).chr(0x80)), ' ', $tags); $tagarray = array_unique(explode(' ', $tags)); } $tagcount = 0; foreach($tagarray as $tagname) { $tagname = trim($tagname); if(preg_match('/^([\x7f-\xff_-]|\w|\s){3,20}$/', $tagname)) { $query = $db->query("SELECT closed FROM {$tablepre}tags WHERE tagname='$tagname'"); if($db->num_rows($query)) { if(!$tagstatus = $db->result($query, 0)) { $db->query("UPDATE {$tablepre}tags SET total=total+1 WHERE tagname='$tagname'", 'UNBUFFERED'); } } else { $db->query("INSERT INTO {$tablepre}tags (tagname, closed, total) VALUES ('$tagname', 0, 1)", 'UNBUFFERED'); $tagstatus = 0; } if(!$tagstatus) { $db->query("INSERT {$tablepre}threadtags (tagname, tid) VALUES ('$tagname', $tid)", 'UNBUFFERED'); } $tagcount++; if($tagcount > 4) { unset($tagarray); break; } } } } $allowpostattach && ($attachnew || $attachdel || $sortid) && updateattach(); if($modnewthreads) { $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED'); showmessage('post_newthread_mod_succeed', "forumdisplay.php?fid=$fid"); } else { $feed = array( 'icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data'=>array(), 'images'=>array() ); if($addfeed && $forum['allowfeed'] && !$isanonymous) { if($special == 0) { $feed['icon'] = 'thread'; $feed['title_template'] = 'feed_thread_title'; $feed['body_template'] = 'feed_thread_message'; $feed['body_data'] = array( 'subject' => "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$subject</a>", 'message' => cutstr(strip_tags(preg_replace(array("/\[hide=?\d*\].+?\[\/hide\]/is", "/\[.+?\]/is"), array('', ''), $message)), 150) ); } elseif($special > 0) { if($special == 1) { $feed['icon'] = 'poll'; $feed['title_template'] = 'feed_thread_poll_title'; $feed['body_template'] = 'feed_thread_poll_message'; $feed['body_data'] = array( 'subject' => "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$subject</a>", 'message' => cutstr(strip_tags(preg_replace(array("/\[hide=?\d*\].+?\[\/hide\]/is", "/\[.+?\]/is"), array('', ''), $message)), 150) ); } elseif($special == 3) { $feed['icon'] = 'reward'; $feed['title_template'] = 'feed_thread_reward_title'; $feed['body_template'] = 'feed_thread_reward_message'; $feed['body_data'] = array( 'subject'=> "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$subject</a>", 'rewardprice'=> $rewardprice, 'extcredits' => $extcredits[$creditstransextra[2]]['title'], 'message' => cutstr(strip_tags(preg_replace(array("/\[hide=?\d*\].+?\[\/hide\]/is", "/\[.+?\]/is"), array('', ''), $message)), 150) ); } elseif($special == 4) { $feed['icon'] = 'activity'; $feed['title_template'] = 'feed_thread_activity_title'; $feed['body_template'] = 'feed_thread_activity_message'; $feed['body_data'] = array( 'subject'=> "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$subject</a>", 'starttimefrom' => $starttimefrom[$activitytime], 'activityplace'=> $activityplace, 'cost'=> $cost, 'message' => cutstr(strip_tags(preg_replace(array("/\[hide=?\d*\].+?\[\/hide\]/is", "/\[.+?\]/is"), array('', ''), $message)), 150) ); } elseif($special == 5) { $feed['icon'] = 'debate'; $feed['title_template'] = 'feed_thread_debate_title'; $feed['body_template'] = 'feed_thread_debate_message'; $feed['body_data'] = array( 'subject'=> "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$subject</a>", 'message' => cutstr(strip_tags(preg_replace(array("/\[hide=?\d*\].+?\[\/hide\]/is", "/\[.+?\]/is"), array('', ''), $message)), 150), 'affirmpoint'=> cutstr(strip_tags(preg_replace("/\[.+?\]/is", '', $affirmpoint)), 150), 'negapoint'=> cutstr(strip_tags(preg_replace("/\[.+?\]/is", '', $negapoint)), 150) ); } } if($feed) { postfeed($feed); } } if($specialextra) { $classname = 'threadplugin_'.$specialextra; if(method_exists($classname, 'newthread_submit_end')) { $threadpluginclass = new $classname; $threadpluginclass->newthread_submit_end($fid); } } if($digest) { foreach($digestcredits as $id => $addcredits) { $postcredits[$id] = (isset($postcredits[$id]) ? $postcredits[$id] : 0) + $addcredits; } } updatepostcredits('+', $discuz_uid, $postcredits); $db->query("UPDATE {$tablepre}members SET threads=threads+1 WHERE uid='$discuz_uid'"); if(is_array($dzfeed_limit['user_threads']) && in_array(($threads + 1), $dzfeed_limit['user_threads'])) { $arg = $data = array(); $arg['type'] = 'user_threads'; $arg['uid'] = $discuz_uid; $arg['username'] = $discuz_userss; $data['title']['actor'] = "<a href=\"space.php?uid={$discuz_uid}\" target=\"_blank\">{$discuz_user}</a>"; $data['title']['count'] = $threads + 1; add_feed($arg, $data); } $subject = str_replace("\t", ' ', $subject); $lastpost = "$tid\t$subject\t$timestamp\t$author"; $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED'); if($forum['type'] == 'sub') { $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED'); } showmessage('post_newthread_succeed', "viewthread.php?tid=$tid&extra=$extra"); } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/newthread.inc.php
PHP
asf20
21,051
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: post.func.php 21337 2010-01-06 08:09:58Z tiger $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function attach_upload($varname = 'attach', $multi = 0) { global $db, $tablepre, $extension, $typemaxsize, $allowsetattachperm, $attachperm, $maxprice, $attachprice, $attachdesc, $attachsave, $attachdir, $thumbstatus, $thumbwidth, $thumbheight, $maxattachsize, $maxsizeperday, $maxattachnum, $attachextensions, $watermarkstatus, $watermarktype, $watermarktrans, $watermarkquality, $watermarktext, $_FILES, $discuz_uid, $imageexists; $attachments = $attacharray = array(); $imageexists = 0; static $safeext = array('jpg', 'jpeg', 'gif', 'png', 'swf', 'bmp', 'txt', 'zip', 'rar', 'doc', 'mp3'); static $imgext = array('jpg', 'jpeg', 'gif', 'png', 'bmp'); if($multi) { if(isset($_FILES[$varname]) && is_array($_FILES[$varname])) { foreach($_FILES[$varname] as $key => $var) { foreach($var as $id => $val) { $attachments[$id][$key] = $val; } } } } else { $attachments[0] = $_FILES[$varname]; } if(empty($attachments)) { return FALSE; } $allowuploadnum = count($attachments); if($maxattachnum) { $allowuploadnum = $maxattachnum - $db->result_first("SELECT count(*) FROM {$tablepre}attachments WHERE uid='$GLOBALS[discuz_uid]' AND dateline>'$GLOBALS[timestamp]'-86400"); $allowuploadnum = $allowuploadnum < 0 ? 0 : $allowuploadnum; } foreach($attachments as $key => $attach) { $attach_saved = false; $attach['uid'] = $discuz_uid; if($allowuploadnum == 0 || !disuploadedfile($attach['tmp_name']) || !($attach['tmp_name'] != 'none' && $attach['tmp_name'] && $attach['name'])) { continue; } $filename = daddslashes($attach['name']); $attach['ext'] = strtolower(fileext($attach['name'])); $extension = in_array($attach['ext'], $safeext) ? $attach['ext'] : 'attach'; if(in_array($attach['ext'], $imgext)) { $attach['isimage'] = $attach['isimage'] ? $attach['isimage'] : 1; $imageexists = 1; } else { $attach['isimage'] = 0; } $attach['thumb'] = 0; $attach['name'] = htmlspecialchars($attach['name'], ENT_QUOTES); if(strlen($attach['name']) > 90) { $attach['name'] = 'abbr_'.md5($attach['name']).'.'.$attach['ext']; } if($attachextensions && (!preg_match("/(^|\s|,)".preg_quote($attach['ext'], '/')."($|\s|,)/i", $attachextensions) || !$attach['ext'])) { if($multi) { upload_error('post_attachment_ext_notallowed', $attacharray); } else { return 1; } } if(empty($attach['size'])) { if($multi) { upload_error('post_attachment_size_invalid', $attacharray); } else { return 2; } } if($maxattachsize && $attach['size'] > $maxattachsize) { if($multi) { upload_error('post_attachment_toobig', $attacharray); } else { return 3; } } if($type = $db->fetch_first("SELECT maxsize FROM {$tablepre}attachtypes WHERE extension='".addslashes($attach['ext'])."'")) { if($type['maxsize'] == 0) { if($multi) { upload_error('post_attachment_ext_notallowed', $attacharray); } else { return 4; } } elseif($attach['size'] > $type['maxsize']) { require_once DISCUZ_ROOT.'./include/attachment.func.php'; $typemaxsize = sizecount($type['maxsize']); if($multi) { upload_error('post_attachment_type_toobig', $attacharray); } else { return 5; } } } if($attach['size'] && $maxsizeperday) { if(!isset($todaysize)) { $todaysize = intval($db->result_first("SELECT SUM(filesize) FROM {$tablepre}attachments WHERE uid='$GLOBALS[discuz_uid]' AND dateline>'$GLOBALS[timestamp]'-86400")); } $todaysize += $attach['size']; if($todaysize >= $maxsizeperday) { $maxsizeperday = $maxsizeperday / 1048576 >= 1 ? round(($maxsizeperday / 1048576), 1).'MB' : round(($maxsizeperday / 1024)).'KB'; if($multi) { upload_error('post_attachment_quota_exceed', $attacharray); } else { return 6; } } } if($attachsave) { if($multi) { switch($attachsave) { case 1: $attach_subdir = 'forumid_'.$GLOBALS['fid']; break; case 2: $attach_subdir = 'ext_'.$extension; break; case 3: $attach_subdir = 'month_'.date('ym'); break; case 4: $attach_subdir = 'day_'.date('ymd'); break; } } else { $attach_subdir = 'swfupload'; } $attach_dir = $attachdir.'/'.$attach_subdir; if(!is_dir($attach_dir)) { @mkdir($attach_dir, 0777); @fclose(fopen($attach_dir.'/index.htm', 'w')); } $attach['attachment'] = $attach_subdir.'/'; } else { $attach['attachment'] = ''; } $attach['attachment'] .= preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\.|$)/i", "_\\1\\2", date('ymdHi').substr(md5($filename.microtime().random(6)), 8, 16).'.'.$extension); $target = $attachdir.'/'.$attach['attachment']; if(@copy($attach['tmp_name'], $target) || (function_exists('move_uploaded_file') && @move_uploaded_file($attach['tmp_name'], $target))) { @unlink($attach['tmp_name']); $attach_saved = true; } if(!$attach_saved && @is_readable($attach['tmp_name'])) { @$fp = fopen($attach['tmp_name'], 'rb'); @flock($fp, 2); @$attachedfile = fread($fp, $attach['size']); @fclose($fp); @$fp = fopen($target, 'wb'); @flock($fp, 2); if(@fwrite($fp, $attachedfile)) { @unlink($attach['tmp_name']); $attach_saved = true; } @fclose($fp); } if($attach_saved) { @chmod($target, 0644); $width = $height = $type = 0; if($attach['isimage'] || $attach['ext'] == 'swf') { $imagesize = @getimagesize($target); list($width, $height, $type) = (array)$imagesize; $size = $width * $height; if($size > 16777216 || $size < 4 || empty($type) || ($attach['isimage'] && !in_array($type, array(1,2,3,6,13)))) { @unlink($target); if($multi) { upload_error('post_attachment_image_checkerror', $attacharray); } else { return 7; } } } if($attach['isimage'] && ($thumbstatus || $watermarkstatus)) { require_once DISCUZ_ROOT.'./include/image.class.php'; $image = new Image($target, $attach); if($image->imagecreatefromfunc && $image->imagefunc) { $image->Thumb($thumbwidth, $thumbheight); $multi && $image->Watermark(); $attach = $image->attach; } } $attach['width'] = 0; if($attach['isimage'] || $attach['ext'] == 'swf') { $imagesize = @getimagesize($target); list($width) = (array)$imagesize; $attach['width'] = $width; } $attach['remote'] = $multi ? ftpupload($target, $attach) : 0; $attach['perm'] = $allowsetattachperm ? intval($attachperm[$key]) : 0; $attach['description'] = cutstr(dhtmlspecialchars($attachdesc[$key]), 100); $attach['price'] = $maxprice ? (intval($attachprice[$key]) <= $maxprice ? intval($attachprice[$key]) : $maxprice) : 0; $attacharray[$key] = $attach; $allowuploadnum--; } else { if($multi) { upload_error('post_attachment_save_error', $attacharray); } else { return 8; } } } return !empty($attacharray) ? $attacharray : false; } function upload_error($message, $attacharray = array()) { if(!empty($attacharray)) { foreach($attacharray as $attach) { @unlink($GLOBALS['attachdir'].'/'.$attach['attachment']); } } showmessage($message); } function ftpupload($source, $attach) { global $authkey, $ftp; $ftp['pwd'] = isset($ftp['pwd']) ? $ftp['pwd'] : FALSE; $dest = $attach['attachment']; if($ftp['on'] && ((!$ftp['allowedexts'] && !$ftp['disallowedexts']) || ($ftp['allowedexts'] && in_array($attach['ext'], explode("\n", strtolower($ftp['allowedexts'])))) || ($ftp['disallowedexts'] && !in_array($attach['ext'], explode("\n", strtolower($ftp['disallowedexts']))))) && (!$ftp['minsize'] || $attach['size'] >= $ftp['minsize'] * 1024)) { require_once DISCUZ_ROOT.'./include/ftp.func.php'; if(!$ftp['connid']) { if(!($ftp['connid'] = dftp_connect($ftp['host'], $ftp['username'], authcode($ftp['password'], 'DECODE', md5($authkey)), $ftp['attachdir'], $ftp['port'], $ftp['ssl']))) { if($ftp['mirror'] == 1) { ftpupload_error($source, $attach); } else { return 0; } } $ftp['pwd'] = FALSE; } $tmp = explode('/', $dest); if(count($tmp) > 1) { if(!$ftp['pwd'] && !dftp_chdir($ftp['connid'], $tmp[0])) { if(!dftp_mkdir($ftp['connid'], $tmp[0])) { errorlog('FTP', "Mkdir '$ftp[attachdir]/$tmp[0]' error.", 0); if($ftp['mirror'] == 1) { ftpupload_error($source, $attach); } else { return 0; } } if(!function_exists('ftp_chmod') || !dftp_chmod($ftp['connid'], 0777, $tmp[0])) { dftp_site($ftp['connid'], "'CHMOD 0777 $tmp[0]'"); } if(!dftp_chdir($ftp['connid'], $tmp[0])) { errorlog('FTP', "Chdir '$ftp[attachdir]/$tmp[0]' error.", 0); if($ftp['mirror'] == 1) { ftpupload_error($source, $attach); } else { return 0; } } dftp_put($ftp['connid'], 'index.htm', $GLOBALS['attachdir'].'/index.htm', FTP_BINARY); } $dest = $tmp[1]; $ftp['pwd'] = TRUE; } if(dftp_put($ftp['connid'], $dest, $source, FTP_BINARY)) { if($attach['thumb']) { if(dftp_put($ftp['connid'], $dest.'.thumb.jpg', $source.'.thumb.jpg', FTP_BINARY)) { if($ftp['mirror'] != 2) { @unlink($source); @unlink($source.'.thumb.jpg'); } return 1; } else { dftp_delete($ftp['connid'], $dest); } } else { if($ftp['mirror'] != 2) { @unlink($source); } return 1; } } errorlog('FTP', "Upload '$source' error.", 0); $ftp['mirror'] == 1 && ftpupload_error($source, $attach); } return 0; } function ftpupload_error($source, $attach) { global $db, $tablepre; @unlink($source); if($attach['thumb']) { @unlink($source.'.thumb.jpg'); } $db->query("DELETE FROM {$tablepre}attachments WHERE aid='$attach[aid]'", 'SILENT'); showmessage('post_attachment_remote_save_error'); } function getattach($posttime = 0) { global $db, $tablepre, $discuz_uid, $dateformat, $timeformat, $timeoffset, $pid, $ftp, $attachurl; require_once DISCUZ_ROOT.'./include/attachment.func.php'; $attachs = $imgattachs = array(); $sqladd1 = $posttime > 0 ? "AND a.dateline>'$posttime'" : ''; $sqladd2 = $pid > 0 ? "OR a.pid='$pid'" : ''; $query = $db->query("SELECT a.*, af.description FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid WHERE (a.uid='$discuz_uid' AND a.tid='0' $sqladd1) $sqladd2 ORDER BY dateline"); while($attach = $db->fetch_array($query)) { $attach['filenametitle'] = $attach['filename']; $attach['ext'] = fileext($attach['filename']); $attach['filename'] = cutstr($attach['filename'], 30); $attach['attachsize'] = sizecount($attach['filesize']); $attach['dateline'] = gmdate("$dateformat $timeformat", $attach['dateline'] + $timeoffset * 3600); $attach['filetype'] = attachtype($attach['ext']."\t".$attach['filetype']); if($attach['isimage'] < 1) { if($attach['isimage']) { $attach['url'] = $attach['remote'] ? $ftp['attachurl'] : $attachurl; $attach['width'] = $attach['width'] > 110 ? 110 : $attach['width']; } if($attach['pid']) { $attachs['used'][] = $attach; } else { $attachs['unused'][] = $attach; } } else { $attach['url'] = $attach['remote'] ? $ftp['attachurl'] : $attachurl; $attach['width'] = $attach['width'] > 110 ? 110 : $attach['width']; if($attach['pid']) { $imgattachs['used'][] = $attach; } else { $imgattachs['unused'][] = $attach; } } } return array('attachs' => $attachs, 'imgattachs' => $imgattachs); } function parseattachmedia($attach) { $attachurl = 'attach://'.$attach['aid'].'.'.$attach['ext']; switch(strtolower($attach['ext'])) { case 'mp3': case 'wma': case 'ra': case 'ram': case 'wav': case 'mid': return '[audio]'.$attachurl.'[/audio]'; case 'wmv': case 'rm': case 'rmvb': case 'avi': case 'asf': case 'mpg': case 'mpeg': case 'mov': case 'flv': case 'swf': return '[media='.$attach['ext'].',400,300]'.$attachurl.'[/media]'; default: return; } } function updateattach() { global $db, $tablepre, $attachsave, $attachdir, $discuz_uid, $postattachcredits, $tid, $pid, $attachextensions, $attachnew, $attachdel, $allowsetattachperm, $maxprice, $watermarkstatus; $imageexists = 0; $attachnew = (array)$attachnew; $sqladd = $pid > 0 ? "OR pid='$pid'" : ''; $query = $db->query("SELECT * FROM {$tablepre}attachments WHERE (uid='$discuz_uid' AND tid='0') $sqladd"); $attachnum = $db->num_rows($query); if($attachnum) { if($attachnum -= count($attachdel)) { checklowerlimit($postattachcredits, $attachnum); } $attachcount = 0; $delaids = array(); while($attach = $db->fetch_array($query)) { if(is_array($attachdel) && in_array($attach['aid'], $attachdel)) { dunlink($attach['attachment'], $attach['thumb']); $delaids[] = $attach['aid']; continue; } $extension = strtolower(fileext($attach['filename'])); if($attachextensions && (!preg_match("/(^|\s|,)".preg_quote($extension, '/')."($|\s|,)/i", $attachextensions) || !$extension)) { continue; } $anew = $attachnew[$attach['aid']]; $anew['aid'] = $attach['aid']; $anew['ext'] = $extension; $anew['size'] = $attach['filesize']; if($attach['pid'] == 0) { $attach_basename = basename($attach['attachment']); $attach_src = $attachdir.'/'.$attach['attachment']; if($attachsave) { switch($attachsave) { case 1: $attach_subdir = 'forumid_'.$GLOBALS['fid']; break; case 2: $attach_subdir = 'ext_'.$extension; break; case 3: $attach_subdir = 'month_'.date('ym'); break; case 4: $attach_subdir = 'day_'.date('ymd'); break; } $attach_descdir = $attachdir.'/'.$attach_subdir; $anew['attachment'] = $attach_subdir.'/'.$attach_basename; } else { $attach_descdir = $attachdir; $anew['attachment'] = $attach_basename; } $anew['thumb'] = $attach['thumb']; $attach_desc = $attach_descdir.'/'.$attach_basename; if($attach['isimage'] && $watermarkstatus) { require_once DISCUZ_ROOT.'./include/image.class.php'; $image = new Image($attach_src, $attach); if($image->imagecreatefromfunc && $image->imagefunc) { $image->Watermark(); $attach = $image->attach; $attach['filesize'] = $attach['size']; } } if(!is_dir($attach_descdir)) { @mkdir($attach_descdir, 0777); @fclose(fopen($attach_descdir.'/index.htm', 'w')); } if($attach['thumb'] == 1) { if(!@rename($attach_src.'.thumb.jpg', $attach_desc.'.thumb.jpg') && @copy($attach_src.'.thumb.jpg', $attach_desc.'.thumb.jpg')) { @unlink($attach_src.'.thumb.jpg'); } } if(!@rename($attach_src, $attach_desc) && @copy($attach_src, $attach_desc)) { @unlink($attach_src); } $anew['remote'] = ftpupload($attach_desc, $anew); $attachcount++; } if($attach['isimage']) { $imageexists = 1; } $anew['filesize'] = $attach['filesize']; $anew['perm'] = $allowsetattachperm ? $anew['perm'] : 0; $anew['description'] = cutstr(dhtmlspecialchars($anew['description']), 100); $anew['price'] = $maxprice ? (intval($anew['price']) <= $maxprice ? intval($anew['price']) : $maxprice) : 0; $sqladd = $attach['pid'] == 0 ? ", tid='$tid', pid='$pid', attachment='$anew[attachment]', remote='$anew[remote]'" : ''; $db->query("UPDATE {$tablepre}attachments SET readperm='$anew[readperm]', price='$anew[price]', filesize='$anew[filesize]' $sqladd WHERE aid='$attach[aid]'"); if($anew['description']) { $db->query("REPLACE INTO {$tablepre}attachmentfields (aid, tid, pid, uid, description) VALUES ('$attach[aid]', '$tid', '$pid', '$attach[uid]', '$anew[description]')"); } } if($delaids) { $db->query("DELETE FROM {$tablepre}attachments WHERE aid IN (".implodeids($delaids).")", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}attachmentfields WHERE aid IN (".implodeids($delaids).")", 'UNBUFFERED'); } $attachment = $imageexists ? 2 : 1; if($attachcount) { $db->query("UPDATE {$tablepre}threads SET attachment='$attachment' WHERE tid='$tid'", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}posts SET attachment='$attachment' WHERE pid='$pid'", 'UNBUFFERED'); updatecredits($discuz_uid, $postattachcredits, $attachcount); } } } function checkflood() { global $db, $tablepre, $disablepostctrl, $floodctrl, $maxpostsperhour, $discuz_uid, $timestamp, $lastpost, $forum; if(!$disablepostctrl && $discuz_uid) { $floodmsg = $floodctrl && ($timestamp - $floodctrl <= $lastpost) ? 'post_flood_ctrl' : ''; if(empty($floodmsg) && $maxpostsperhour) { $query = $db->query("SELECT COUNT(*) from {$tablepre}posts WHERE authorid='$discuz_uid' AND dateline>$timestamp-3600"); $floodmsg = ($userposts = $db->result($query, 0)) && ($userposts >= $maxpostsperhour) ? 'thread_maxpostsperhour_invalid' : ''; } if(empty($floodmsg)) { return FALSE; } elseif(CURSCRIPT != 'wap') { showmessage($floodmsg); } else { wapmsg($floodmsg); } } return FALSE; } function checkpost($special = 0) { global $subject, $message, $disablepostctrl, $minpostsize, $maxpostsize; if(strlen($subject) > 80) { return 'post_subject_toolong'; } if(!$disablepostctrl && !$special) { if($maxpostsize && strlen($message) > $maxpostsize) { return 'post_message_toolong'; } elseif($minpostsize && strlen(preg_replace("/\[quote\].+?\[\/quote\]/is", '', $message)) < $minpostsize) { return 'post_message_tooshort'; } } return FALSE; } function checkbbcodes($message, $bbcodeoff) { return !$bbcodeoff && !strpos($message, '[/') ? -1 : $bbcodeoff; } function checksmilies($message, $smileyoff) { global $_DCACHE; if($smileyoff) { return 1; } else { if(!empty($_DCACHE['smileycodes']) && is_array($_DCACHE['smileycodes'])) { $message = stripslashes($message); foreach($_DCACHE['smileycodes'] as $id => $code) { if(strpos($message, $code) !== FALSE) { return 0; } } } return -1; } } function updatepostcredits($operator, $uidarray, $creditsarray) { global $db, $tablepre, $discuz_uid, $timestamp, $creditnotice, $cookiecredits; $membersarray = $postsarray = array(); $self = $creditnotice && $uidarray == $discuz_uid; foreach((is_array($uidarray) ? $uidarray : array($uidarray)) as $id) { $membersarray[intval(trim($id))]++; } foreach($membersarray as $uid => $posts) { $postsarray[$posts][] = $uid; } $lastpostadd = $uidarray == $discuz_uid ? ", lastpost='$timestamp'" : ''; $creditsadd1 = ''; if(is_array($creditsarray)) { if($self && !isset($cookiecredits)) { $cookiecredits = !empty($_COOKIE['discuz_creditnotice']) ? explode('D', $_COOKIE['discuz_creditnotice']) : array_fill(0, 9, 0); } foreach($creditsarray as $id => $addcredits) { if(($operator == '-' && $addcredits > 0) || $operator == '+') { $creditsadd1 .= ", extcredits$id=extcredits$id$operator($addcredits)*\$posts"; if($self) { eval("\$cookiecredits[$id] += $operator($addcredits)*\$posts;"); } } } if($self) { dsetcookie('discuz_creditnotice', implode('D', $cookiecredits).'D'.$discuz_uid, 43200, 0); } } foreach($postsarray as $posts => $uidarray) { $uids = implode(',', $uidarray); eval("\$creditsadd2 = \"$creditsadd1\";"); $db->query("UPDATE {$tablepre}members SET posts=posts+('$operator$posts') $lastpostadd $creditsadd2 WHERE uid IN ($uids)", 'UNBUFFERED'); } } function updateattachcredits($operator, $uidarray, $creditsarray) { global $db, $tablepre, $discuz_uid; $creditsadd1 = ''; if(is_array($creditsarray)) { foreach($creditsarray as $id => $addcredits) { $creditsadd1[] = "extcredits$id=extcredits$id$operator$addcredits*\$attachs"; } } if(is_array($creditsadd1)) { $creditsadd1 = implode(', ', $creditsadd1); foreach($uidarray as $uid => $attachs) { eval("\$creditsadd2 = \"$creditsadd1\";"); $db->query("UPDATE {$tablepre}members SET $creditsadd2 WHERE uid = $uid", 'UNBUFFERED'); } } } function updateforumcount($fid) { global $db, $tablepre, $lang; extract($db->fetch_first("SELECT COUNT(*) AS threadcount, SUM(t.replies)+COUNT(*) AS replycount FROM {$tablepre}threads t, {$tablepre}forums f WHERE f.fid='$fid' AND t.fid=f.fid AND t.displayorder>='0'")); $thread = $db->fetch_first("SELECT tid, subject, author, lastpost, lastposter FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1"); $thread['subject'] = addslashes($thread['subject']); $thread['lastposter'] = $thread['author'] ? addslashes($thread['lastposter']) : $lang['anonymous']; $db->query("UPDATE {$tablepre}forums SET posts='$replycount', threads='$threadcount', lastpost='$thread[tid]\t$thread[subject]\t$thread[lastpost]\t$thread[lastposter]' WHERE fid='$fid'", 'UNBUFFERED'); } function updatethreadcount($tid, $updateattach = 0) { global $db, $tablepre, $lang; $replycount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0'") - 1; $lastpost = $db->fetch_first("SELECT author, anonymous, dateline FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline DESC LIMIT 1"); $lastpost['author'] = $lastpost['anonymous'] ? $lang['anonymous'] : addslashes($lastpost['author']); if($updateattach) { $query = $db->query("SELECT attachment FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' AND attachment>0 LIMIT 1"); $attachadd = ', attachment=\''.($db->num_rows($query)).'\''; } else { $attachadd = ''; } $db->query("UPDATE {$tablepre}threads SET replies='$replycount', lastposter='$lastpost[author]', lastpost='$lastpost[dateline]' $attachadd WHERE tid='$tid'", 'UNBUFFERED'); } function updatemodlog($tids, $action, $expiration = 0, $iscron = 0, $stamp = 0) { global $db, $tablepre, $timestamp; $uid = empty($iscron) ? $GLOBALS['discuz_uid'] : 0; $username = empty($iscron) ? $GLOBALS['discuz_user'] : 0; $expiration = empty($expiration) ? 0 : intval($expiration); $data = $comma = ''; $stampadd = $stampaddvalue = ''; if($stamp) { $stampadd = ', stamp'; $stampaddvalue = ", '$stamp'"; } foreach(explode(',', str_replace(array('\'', ' '), array('', ''), $tids)) as $tid) { if($tid) { $data .= "{$comma} ('$tid', '$uid', '$username', '$timestamp', '$action', '$expiration', '1'$stampaddvalue)"; $comma = ','; } } !empty($data) && $db->query("INSERT INTO {$tablepre}threadsmod (tid, uid, username, dateline, action, expiration, status$stampadd) VALUES $data", 'UNBUFFERED'); } function isopera() { $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); if(strpos($useragent, 'opera') !== false) { preg_match('/opera(\/| )([0-9\.]+)/', $useragent, $regs); return $regs[2]; } return FALSE; } function deletethreadcaches($tids) { global $cachethreadon; if(!$cachethreadon) { return FALSE; } include_once DISCUZ_ROOT.'./include/forum.func.php'; if(!empty($tids)) { foreach(explode(',', $tids) as $tid) { $fileinfo = getcacheinfo($tid); @unlink($fileinfo['filename']); } } return TRUE; } function threadsort_checkoption($unchangeable = 1, $trade = 0) { global $selectsortid, $optionlist, $trade_create, $tradetypeid, $sortid, $_DTYPE, $checkoption, $forum, $action; if($trade) { $selectsortid = $tradetypeid ? intval($tradetypeid) : ''; } else { $selectsortid = $sortid ? intval($sortid) : ''; } @include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$selectsortid.'.php'; $optionlist = $_DTYPE; foreach($_DTYPE as $optionid => $option) { $checkoption[$option['identifier']]['optionid'] = $optionid; $checkoption[$option['identifier']]['title'] = $option['title']; $checkoption[$option['identifier']]['type'] = $option['type']; $checkoption[$option['identifier']]['required'] = $option['required'] ? 1 : 0; $checkoption[$option['identifier']]['unchangeable'] = $action == 'edit' && $unchangeable && $option['unchangeable'] ? 1 : 0; $checkoption[$option['identifier']]['maxnum'] = $option['maxnum'] ? intval($option['maxnum']) : ''; $checkoption[$option['identifier']]['minnum'] = $option['minnum'] ? intval($option['minnum']) : ''; $checkoption[$option['identifier']]['maxlength'] = $option['maxlength'] ? intval($option['maxlength']) : ''; } } function threadsort_optiondata() { global $db, $tablepre, $tid, $pid, $tradetype, $_DTYPE, $_DTYPEDESC, $optiondata, $optionlist, $thread; $optiondata = array(); if(!$tradetype) { $id = $tid; $field = 'tid'; $table = 'typeoptionvars'; } else { $id = $pid; $field = 'pid'; $table = 'tradeoptionvars'; } if($id) { $query = $db->query("SELECT optionid, value FROM {$tablepre}$table WHERE $field='$id'"); while($option = $db->fetch_array($query)) { $optiondata[$option['optionid']] = $option['value']; } foreach($_DTYPE as $optionid => $option) { $optionlist[$optionid]['unchangeable'] = $_DTYPE[$optionid]['unchangeable'] ? 'readonly' : ''; if($_DTYPE[$optionid]['type'] == 'radio') { $optionlist[$optionid]['value'] = array($optiondata[$optionid] => 'checked="checked"'); } elseif($_DTYPE[$optionid]['type'] == 'select') { $optionlist[$optionid]['value'] = array($optiondata[$optionid] => 'selected="selected"'); } elseif($_DTYPE[$optionid]['type'] == 'checkbox') { foreach(explode("\t", $optiondata[$optionid]) as $value) { $optionlist[$optionid]['value'][$value] = array($value => 'checked="checked"'); } } else { $optionlist[$optionid]['value'] = $optiondata[$optionid]; } if(!isset($optiondata[$optionid])) { $db->query("INSERT INTO {$tablepre}$table (sortid, $field, optionid) VALUES ('$thread[sortid]', '$id', '$optionid')"); } } } } function threadsort_validator($sortoption) { global $checkoption, $var, $selectsortid, $fid, $tid, $pid; $postaction = $tid && $pid ? "edit&tid=$tid&pid=$pid" : 'newthread'; $optiondata = array(); foreach($checkoption as $var => $option) { if($checkoption[$var]['required'] && !$sortoption[$var]) { showmessage('threadtype_required_invalid', "post.php?action=$postaction&fid=$fid&sortid=$selectsortid"); } elseif($sortoption[$var] && ($checkoption[$var]['type'] == 'number' && !is_numeric($sortoption[$var]) || $checkoption[$var]['type'] == 'email' && !isemail($sortoption[$var]))){ showmessage('threadtype_format_invalid', "post.php?action=$postaction&fid=$fid&sortid=$selectsortid"); } elseif($sortoption[$var] && $checkoption[$var]['maxlength'] && strlen($typeoption[$var]) > $checkoption[$var]['maxlength']) { showmessage('threadtype_toolong_invalid', "post.php?action=$postaction&fid=$fid&sortid=$selectsortid"); } elseif($sortoption[$var] && (($checkoption[$var]['maxnum'] && $sortoption[$var] >= $checkoption[$var]['maxnum']) || ($checkoption[$var]['minnum'] && $sortoption[$var] < $checkoption[$var]['minnum']))) { showmessage('threadtype_num_invalid', "post.php?action=$postaction&fid=$fid&sortid=$selectsortid"); } elseif($sortoption[$var] && $checkoption[$var]['unchangeable'] && !($tid && $pid)) { showmessage('threadtype_unchangeable_invalid', "post.php?action=$postaction&fid=$fid&sortid=$selectsortid"); } if($checkoption[$var]['type'] == 'checkbox') { $sortoption[$var] = $sortoption[$var] ? implode("\t", $sortoption[$var]) : ''; } elseif($checkoption[$var]['type'] == 'url') { $sortoption[$var] = $sortoption[$var] ? (substr(strtolower($sortoption[$var]), 0, 4) == 'www.' ? 'http://'.$sortoption[$var] : $sortoption[$var]) : ''; } $sortoption[$var] = dhtmlspecialchars(censor(trim($sortoption[$var]))); $optiondata[$checkoption[$var]['optionid']] = $sortoption[$var]; } return $optiondata; } function disuploadedfile($file) { return function_exists('is_uploaded_file') && (is_uploaded_file($file) || is_uploaded_file(str_replace('\\\\', '\\', $file))); } function postfeed($feed) { global $discuz_uid, $discuz_user; require_once DISCUZ_ROOT.'./templates/default/feed.lang.php'; require_once DISCUZ_ROOT.'./uc_client/client.php'; $feed['title_template'] = $feed['title_template'] ? $language[$feed['title_template']] : ''; $feed['body_template'] = $feed['title_template'] ? $language[$feed['body_template']] : ''; uc_feed_add($feed['icon'], $discuz_uid, $discuz_user, $feed['title_template'], $feed['title_data'], $feed['body_template'], $feed['body_data'], '', '', $feed['images']); } function messagecutstr($str, $length) { global $language, $_DCACHE; if(empty($language['post_edit_regexp']) || empty($language['post_hidden'])) { include language('misc'); } include_once DISCUZ_ROOT.'./forumdata/cache/cache_post.php'; $bbcodes = 'b|i|u|p|color|size|font|align|list|indent|float'; $bbcodesclear = 'url|email|code|free|table|tr|td|img|swf|flash|attach|media|audio|payto'.($_DCACHE['bbcodes_display'] ? '|'.implode('|', array_keys($_DCACHE['bbcodes_display'])) : ''); $str = cutstr(strip_tags(preg_replace(array( "/\[hide=?\d*\](.+?)\[\/hide\]/is", "/\[quote](.*?)\[\/quote]/si", $language['post_edit_regexp'], "/\[($bbcodesclear)=?.*?\].+?\[\/\\1\]/si", "/\[($bbcodes)=?.*?\]/i", "/\[\/($bbcodes)\]/i", ), array( "[b]$language[post_hidden][/b]", '', '', '', '', '' ), $str)), $length); $str = preg_replace($_DCACHE['smilies']['searcharray'], '', $str); return trim($str); } function get_url_list($message) { $return = array(); (strpos($message, '[/img]') || strpos($message, '[/flash]')) && $message = preg_replace("/\[img[^\]]*\].+?\[\/img\]|\[flash[^\]]*\].+?\[\/flash\]/is", '', $message); if(preg_match_all("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+\s*)/i", $message, $urllist)) { foreach($urllist[0] as $key => $val) { $val = trim($val); $return[0][$key] = $val; if(!preg_match('/^http:\/\//is', $val)) $val = 'http://'.$val; $tmp = parse_url($val); $return[1][$key] = $tmp['host']; if($tmp['port']){ $return[1][$key] .= ":$tmp[port]"; } } } return $return; } function iswhitelist($host) { global $_DCACHE; static $iswhitelist = array(); if(isset($iswhitelist[$host])) { return $iswhitelist[$host]; } $hostlen = strlen($host); $iswhitelist[$host] = false; if(is_array($_DCACHE['domainwhitelist'])) foreach($_DCACHE['domainwhitelist'] as $val) { $domainlen = strlen($val); if($domainlen > $hostlen) { continue; } if(substr($host, -$domainlen) == $val) { $iswhitelist[$host] = true; break; } } if($iswhitelist[$host] == false) { $iswhitelist[$host] = $host == $_SERVER['HTTP_HOST']; } return $iswhitelist[$host]; } function savepostposition($tid, $pid, $position = 0) { global $db, $tablepre; if(!$position) { $pos = $db->result_first("SELECT max(position) FROM {$tablepre}postposition WHERE tid='$tid'"); $pos ++; } else { $pos = $position; } $res = $db->query("INSERT INTO {$tablepre}postposition SET tid='$tid', position='$pos', pid='$pid'"); return $res; } function deletepostposition($tid) { global $db, $tablepre; $db->query("DELETE FROM {$tablepre}postposition WHERE tid='$tid'"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/post.func.php
PHP
asf20
32,030
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: forumselect.inc.php 20900 2009-10-29 02:49:38Z tiger $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function quicksearch() { global $_DTYPE; $quicksearch = array(); foreach($_DTYPE as $optionid => $option) { if(in_array($option['type'], array('radio', 'select'))) { $quicksearch['option'][$optionid]['title'] = $option['title']; $quicksearch['option'][$optionid]['choices'] = $option['choices']; $quicksearch['option'][$optionid]['identifier'] = $option['identifier']; } $quicksearch['search'] .= $option['search'] ? $option['search'] : ''; } return $quicksearch; } function sortshowlist($searchoid = 0, $searchvid = 0, $threadids = array(), $searchoption = array(), $selecturladd = array()) { global $sdb, $bbname, $tablepre, $_DTYPE, $_DSTYPETEMPLATE, $tpp, $page, $threadmaxpages, $optionvaluelist, $threadlist, $threadcount, $sortid, $filter; $searchtitle = $searchvalue = $searchunit = $stemplate = $optionvaluelist = $searchtids = $sortlistarray = $optionide = array(); $selectadd = $and = $selectsql = ''; $searchoid = intval($searchoid); $searchvid = intval($searchvid); $sortid = intval($sortid); if($filter == 'sort' && $selecturladd) { foreach($_DTYPE as $option) { if(in_array($option['type'], array('radio', 'select'))) { $optionide[$option['identifier']] = 1; } } $optionadd = "&amp;sortid=$sortid"; foreach($selecturladd as $fieldname => $value) { if($optionide[$fieldname] && $value != 'all') { $selectsql .= $and."$fieldname='$value'"; $and = ' AND '; } } } if(!empty($searchoption) && is_array($searchoption)) { foreach($searchoption as $optionid => $option) { $fieldname = $_DTYPE[$optionid]['identifier'] ? $_DTYPE[$optionid]['identifier'] : 1; if($option['value']) { if(in_array($option['type'], array('number', 'radio', 'select'))) { $option['value'] = intval($option['value']); $exp = '='; if($option['condition']) { $exp = $option['condition'] == 1 ? '>' : '<'; } $sql = "$fieldname$exp'$option[value]'"; } elseif($option['type'] == 'checkbox') { $sql = "$fieldname LIKE '%".(implode("%", $option['value']))."%'"; } else { $sql = "$fieldname LIKE '%$option[value]%'"; } $selectsql .= $and."$sql "; $and = 'AND '; } } } if($selectsql) { $query = $sdb->query("SELECT tid FROM {$tablepre}optionvalue$sortid ".($selectsql ? 'WHERE '.$selectsql : '').""); while($thread = $sdb->fetch_array($query)) { $searchtids[$thread['tid']] = $thread['tid']; } $threadids = $searchtids ? $searchtids : ''; } if($threadids && is_array($threadids)) { $query = $sdb->query("SELECT tid, optionid, value FROM {$tablepre}typeoptionvars WHERE tid IN (".implodeids($threadids).")"); while($sortthread = $sdb->fetch_array($query)) { $optionid = $sortthread['optionid']; if($_DTYPE[$optionid]['subjectshow']) { $optionvaluelist[$sortthread['tid']][$_DTYPE[$optionid]['identifier']]['title'] = $_DTYPE[$optionid]['title']; $optionvaluelist[$sortthread['tid']][$_DTYPE[$optionid]['identifier']]['unit'] = $_DTYPE[$optionid]['unit']; if(in_array($_DTYPE[$optionid]['type'], array('radio', 'checkbox', 'select'))) { if($_DTYPE[$optionid]['type'] == 'checkbox') { foreach(explode("\t", $sortthread['value']) as $choiceid) { $sortthreadlist[$sortthread['tid']][$_DTYPE[$optionid]['title']] .= $_DTYPE[$optionid]['choices'][$choiceid].'&nbsp;'; $optionvaluelist[$sortthread['tid']][$_DTYPE[$optionid]['identifier']]['value'] .= $_DTYPE[$optionid]['choices'][$choiceid].'&nbsp;'; } } else { $sortthreadlist[$sortthread['tid']][$_DTYPE[$optionid]['title']] = $optionvaluelist[$sortthread['tid']][$_DTYPE[$optionid]['identifier']]['value'] = $_DTYPE[$optionid]['choices'][$sortthread['value']]; } } else { $sortthreadlist[$sortthread['tid']][$_DTYPE[$optionid]['title']] = $optionvaluelist[$sortthread['tid']][$_DTYPE[$optionid]['identifier']]['value'] = $sortthread['value']; } } } if($_DSTYPETEMPLATE && $sortthreadlist) { foreach($_DTYPE as $option) { if($option['subjectshow']) { $searchtitle[] = '/{('.$option['identifier'].')}/e'; $searchvalue[] = '/\[('.$option['identifier'].')value\]/e'; $searchunit[] = '/\[('.$option['identifier'].')unit\]/e'; } } foreach($sortthreadlist as $tid => $option) { $stemplate[$tid] = preg_replace($searchtitle, "showoption('\\1', 'title', '$tid')", $_DSTYPETEMPLATE); $stemplate[$tid] = preg_replace($searchvalue, "showoption('\\1', 'value', '$tid')", $stemplate[$tid]); $stemplate[$tid] = preg_replace($searchunit, "showoption('\\1', 'unit', '$tid')", $stemplate[$tid]); } } if($searchtids) { foreach($threadlist as $thread) { if(in_array($thread['tid'], $searchtids) || in_array($thread['displayorder'], array(1, 2, 3, 4))) { $resultlist[] = $thread; } } $threadlist = $resultlist ? $resultlist : array(); $threadcount = count($threadlist); $multipage = multi($threadcount, $tpp, $page, "forumdisplay.php?fid=$fid&amp;sortid=$sortid&amp;optionid=$optionid&amp;valueid=$valueid$forumdisplayadd", $threadmaxpages); } } else { $threadlist = array(); $threadcount = 0; } $sortlistarray['sortthreadlist'] = $sortthreadlist; $sortlistarray['stemplate'] = $stemplate; $sortlistarray['thread']['list'] = $threadlist; $sortlistarray['thread']['count'] = $threadcount; $sortlistarray['thread']['multipage'] = $multipage; return $sortlistarray; } function showoption($var, $type, $tid) { global $optionvaluelist; if($optionvaluelist[$tid][$var][$type]) { return $optionvaluelist[$tid][$var][$type]; } else { return ''; } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/forumsort.func.php
PHP
asf20
5,988
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: counter.inc.php 17570 2009-02-11 07:41:54Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $visitor = array(); $visitor['agent'] = $_SERVER['HTTP_USER_AGENT']; list($visitor['month'], $visitor['week'], $visitor['hour']) = explode("\t", gmdate("Ym\tw\tH", $timestamp + $_DCACHE['settings']['timeoffset'] * 3600)); if(!$sessionexists) { if(strexists($visitor['agent'], 'Netscape')) { $visitor['browser'] = 'Netscape'; } elseif(strexists($visitor['agent'], 'Lynx')) { $visitor['browser'] = 'Lynx'; } elseif(strexists($visitor['agent'], 'Opera')) { $visitor['browser'] = 'Opera'; } elseif(strexists($visitor['agent'], 'Konqueror')) { $visitor['browser'] = 'Konqueror'; } elseif(strexists($visitor['agent'], 'MSIE')) { $visitor['browser'] = 'MSIE'; } elseif(strexists($visitor['agent'], 'Firefox')) { $visitor['browser'] = 'Firefox'; } elseif(strexists($visitor['agent'], 'Safari')) { $visitor['browser'] = 'Safari'; } elseif(substr($visitor['agent'], 0, 7) == 'Mozilla') { $visitor['browser'] = 'Mozilla'; } else { $visitor['browser'] = 'Other'; } if(strexists($visitor['agent'], 'Win')) { $visitor['os'] = 'Windows'; } elseif(strexists($visitor['agent'], 'Mac')) { $visitor['os'] = 'Mac'; } elseif(strexists($visitor['agent'], 'Linux')) { $visitor['os'] = 'Linux'; } elseif(strexists($visitor['agent'], 'FreeBSD')) { $visitor['os'] = 'FreeBSD'; } elseif(strexists($visitor['agent'], 'SunOS')) { $visitor['os'] = 'SunOS'; } elseif(strexists($visitor['agent'], 'OS/2')) { $visitor['os'] = 'OS/2'; } elseif(strexists($visitor['agent'], 'AIX')) { $visitor['os'] = 'AIX'; } elseif(preg_match("/(Bot|Crawl|Spider)/i", $visitor['agent'])) { $visitor['os'] = 'Spiders'; } else { $visitor['os'] = 'Other'; } $visitorsadd = "OR (type='browser' AND variable='$visitor[browser]') OR (type='os' AND variable='$visitor[os]')". ($discuz_user ? " OR (type='total' AND variable='members')" : " OR (type='total' AND variable='guests')"); $updatedrows = 7; } else { $visitorsadd = ''; $updatedrows = 4; } $db->query("UPDATE {$tablepre}stats SET count=count+1 WHERE (type='total' AND variable='hits') $visitorsadd OR (type='month' AND variable='$visitor[month]') OR (type='week' AND variable='$visitor[week]') OR (type='hour' AND variable='$visitor[hour]')"); if($updatedrows > $db->affected_rows()) { $db->query("INSERT INTO {$tablepre}stats (type, variable, count) VALUES ('month', '$visitor[month]', '1')", 'SILENT'); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/counter.inc.php
PHP
asf20
2,685
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: viewthread_trade.inc.php 19254 2009-08-20 05:33:53Z wangjinbo $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if(empty($do) || $do == 'tradeinfo') { if($do == 'tradeinfo') { $tradelistadd = "AND pid = '$pid'"; } else { $tradelistadd = ''; !$tradenum && $allowpostreply = FALSE; } $query = $db->query("SELECT * FROM {$tablepre}trades WHERE tid='$tid' $tradelistadd ORDER BY displayorder"); $trades = $tradesstick = array();$tradelist = 0; if(empty($do)) { $sellerid = 0; $listcount = $db->num_rows($query); $tradelist = $tradenum - $listcount; } $tradesaids = $tradesaids = array(); while($trade = $db->fetch_array($query)) { 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; } } $tradesaids[] = $trade['aid']; $tradespids[] = $trade['pid']; if($trade['displayorder'] < 0) { $trades[$trade['pid']] = $trade; } else { $tradesstick[$trade['pid']] = $trade; } } $trades = $tradesstick + $trades; $tradespids = implodeids($tradespids); unset($trade); if($tradespids) { $query = $db->query("SELECT a.*,af.description FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid WHERE a.pid IN ($tradespids)"); while($attach = $db->fetch_array($query)) { if($attach['isimage'] && is_array($tradesaids) && in_array($attach['aid'], $tradesaids)) { $trades[$attach['pid']]['attachurl'] = ($attach['remote'] ? $ftp['attachurl'] : $attachurl).'/'.$attach['attachment']; $trades[$attach['pid']]['thumb'] = $trades[$attach['pid']]['attachurl'].($attach['thumb'] ? '.thumb.jpg' : ''); } } } if($do == 'tradeinfo') { $subjectpos = strrpos($navigation, '&raquo; '); $subject = substr($navigation, $subjectpos + 8); $navigation = substr($navigation, 0, $subjectpos).'&raquo; <a href="viewthread.php?tid='.$tid.'">'.$subject.'</a>'; $trade = $trades[$pid]; unset($trades); $post = $db->fetch_first("SELECT p.*, m.uid, m.username, m.groupid, m.adminid, m.regdate, m.lastactivity, m.posts, 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.avatarheight, mf.customstatus, mf.spacename, mf.buyercredit, mf.sellercredit $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 WHERE pid='$pid'"); $postlist[$post['pid']] = viewthread_procpost($post); if($attachpids) { require_once DISCUZ_ROOT.'./include/attachment.func.php'; parseattach($attachpids, $attachtags, $postlist, $showimages, array($trade['aid'])); } $post = $postlist[$pid]; $post['buyerrank'] = 0; if($post['buyercredit']){ foreach($ec_credit['rank'] AS $level => $credit) { if($post['buyercredit'] <= $credit) { $post['buyerrank'] = $level; break; } } } $post['sellerrank'] = 0; if($post['sellercredit']){ foreach($ec_credit['rank'] AS $level => $credit) { if($post['sellercredit'] <= $credit) { $post['sellerrank'] = $level; break; } } } $navtitle = $trade['subject'].' - '; $tradetypeid = $trade['typeid']; $typetemplate = ''; $optiondata = $optionlist = array(); if($tradetypeid && isset($tradetypes[$tradetypeid])) { if(@include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$tradetypeid.'.php') { $query = $db->query("SELECT optionid, value FROM {$tablepre}tradeoptionvars WHERE pid='$pid'"); while($option = $db->fetch_array($query)) { $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].'&nbsp;'; } } 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>" : ''; } else { $optionlist[$option['identifier']]['value'] = $optiondata[$optionid]; } } $typetemplate = $_DTYPETEMPLATE ? preg_replace(array("/\[(.+?)value\]/ies", "/{(.+?)}/ies"), array("showoption('\\1', 'value')", "showoption('\\1', 'title')"), $_DTYPETEMPLATE) : ''; } $post['subject'] = '['.$tradetypes[$tradetypeid].'] '.$post['subject']; } include template('trade_info'); exit; } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/viewthread_trade.inc.php
PHP
asf20
6,024
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: chinese.class.php 20401 2009-09-25 09:26:17Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } define('CODETABLE_DIR', DISCUZ_ROOT.'./include/tables/'); class Chinese { var $table = ''; var $iconv_enabled = false; var $convertbig5 = false; var $unicode_table = array(); var $config = array ( 'SourceLang' => '', 'TargetLang' => '', 'GBtoUnicode_table' => 'gb-unicode.table', 'BIG5toUnicode_table' => 'big5-unicode.table', 'GBtoBIG5_table' => 'gb-big5.table', ); function Chinese($SourceLang, $TargetLang, $ForceTable = FALSE) { $this->config['SourceLang'] = $this->_lang($SourceLang); $this->config['TargetLang'] = $this->_lang($TargetLang); if(function_exists('iconv') && $this->config['TargetLang'] != 'BIG5' && !$ForceTable) { $this->iconv_enabled = true; } else { $this->iconv_enabled = false; $this->OpenTable(); } } function _lang($LangCode) { $LangCode = strtoupper($LangCode); if(substr($LangCode, 0, 2) == 'GB') { return 'GBK'; } elseif(substr($LangCode, 0, 3) == 'BIG') { return 'BIG5'; } elseif(substr($LangCode, 0, 3) == 'UTF') { return 'UTF-8'; } elseif(substr($LangCode, 0, 3) == 'UNI') { return 'UNICODE'; } } function _hex2bin($hexdata) { for($i=0; $i < strlen($hexdata); $i += 2) { $bindata .= chr(hexdec(substr($hexdata, $i, 2))); } return $bindata; } function OpenTable() { $this->unicode_table = array(); if(!$this->iconv_enabled && $this->config['TargetLang'] == 'BIG5') { $this->config['TargetLang'] = 'GBK'; $this->convertbig5 = TRUE; } if($this->config['SourceLang'] == 'GBK' || $this->config['TargetLang'] == 'GBK') { $this->table = CODETABLE_DIR.$this->config['GBtoUnicode_table']; } elseif($this->config['SourceLang'] == 'BIG5' || $this->config['TargetLang'] == 'BIG5') { $this->table = CODETABLE_DIR.$this->config['BIG5toUnicode_table']; } $fp = fopen($this->table, 'rb'); $tabletmp = fread($fp, filesize($this->table)); for($i = 0; $i < strlen($tabletmp); $i += 4) { $tmp = unpack('nkey/nvalue', substr($tabletmp, $i, 4)); if($this->config['TargetLang'] == 'UTF-8') { $this->unicode_table[$tmp['key']] = '0x'.dechex($tmp['value']); } elseif($this->config['SourceLang'] == 'UTF-8') { $this->unicode_table[$tmp['value']] = '0x'.dechex($tmp['key']); } elseif($this->config['TargetLang'] == 'UNICODE') { $this->unicode_table[$tmp['key']] = dechex($tmp['value']); } } } function CHSUtoUTF8($c) { $str = ''; if($c < 0x80) { $str .= $c; } elseif($c < 0x800) { $str .= (0xC0 | $c >> 6); $str .= (0x80 | $c & 0x3F); } elseif($c < 0x10000) { $str .= (0xE0 | $c >> 12); $str .= (0x80 | $c >> 6 & 0x3F); $str .=( 0x80 | $c & 0x3F); } elseif($c < 0x200000) { $str .= (0xF0 | $c >> 18); $str .= (0x80 | $c >> 12 & 0x3F); $str .= (0x80 | $c >> 6 & 0x3F); $str .= (0x80 | $c & 0x3F); } return $str; } function GB2312toBIG5($c) { $f = fopen(CODETABLE_DIR.$this->config['GBtoBIG5_table'], 'r'); $max=strlen($c)-1; for($i = 0;$i < $max;$i++){ $h=ord($c[$i]); if($h>=160) { $l=ord($c[$i+1]); if($h==161 && $l==64){ $gb=" "; } else{ fseek($f,($h-160)*510+($l-1)*2); $gb=fread($f,2); } $c[$i]=$gb[0]; $c[$i+1]=$gb[1]; $i++; } } $result = $c; return $result; } function Convert($SourceText) { if($this->config['SourceLang'] == $this->config['TargetLang']) { return $SourceText; } elseif($this->iconv_enabled) { if($this->config['TargetLang'] <> 'UNICODE') { return iconv($this->config['SourceLang'], $this->config['TargetLang'], $SourceText); } else { $return = ''; while($SourceText != '') { if(ord(substr($SourceText, 0, 1)) > 127) { $return .= "&#x".dechex($this->Utf8_Unicode(iconv($this->config['SourceLang'],"UTF-8", substr($SourceText, 0, 2)))).";"; $SourceText = substr($SourceText, 2, strlen($SourceText)); } else { $return .= substr($SourceText, 0, 1); $SourceText = substr($SourceText, 1, strlen($SourceText)); } } return $return; } } elseif($this->config['TargetLang'] == 'UNICODE') { $utf = ''; while($SourceText != '') { if(ord(substr($SourceText, 0, 1)) > 127) { if($this->config['SourceLang'] == 'GBK') { $utf .= '&#x'.$this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2))) - 0x8080].';'; } elseif($this->config['SourceLang'] == 'BIG5') { $utf .= '&#x'.$this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2)))].';'; } $SourceText = substr($SourceText, 2, strlen($SourceText)); } else { $utf .= substr($SourceText, 0, 1); $SourceText = substr($SourceText, 1, strlen($SourceText)); } } return $utf; } else { $ret = ''; if($this->config['SourceLang'] == 'UTF-8') { $out = ''; $len = strlen($SourceText); $i = 0; while($i < $len) { $c = ord(substr($SourceText, $i++, 1)); switch($c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: $out .= substr($SourceText, $i - 1, 1); break; case 12: case 13: $char2 = ord(substr($SourceText, $i++, 1)); $char3 = $this->unicode_table[(($c & 0x1F) << 6) | ($char2 & 0x3F)]; if($this->config['TargetLang'] == 'GBK') { $out .= $this->_hex2bin(dechex($char3 + 0x8080)); } elseif($this->config['TargetLang'] == 'BIG5') { $out .= $this->_hex2bin($char3); } break; case 14: $char2 = ord(substr($SourceText, $i++, 1)); $char3 = ord(substr($SourceText, $i++, 1)); $char4 = $this->unicode_table[(($c & 0x0F) << 12) | (($char2 & 0x3F) << 6) | (($char3 & 0x3F) << 0)]; if($this->config['TargetLang'] == 'GBK') { $out .= $this->_hex2bin(dechex($char4 + 0x8080)); } elseif($this->config['TargetLang'] == 'BIG5') { $out .= $this->_hex2bin($char4); } break; } } return !$this->convertbig5 ? $out : $this->GB2312toBIG5($out); } else { while($SourceText != '') { if(ord(substr($SourceText, 0, 1)) > 127) { if($this->config['SourceLang'] == 'BIG5') { $utf8 = $this->CHSUtoUTF8(hexdec($this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2)))])); } elseif($this->config['SourceLang'] == 'GBK') { $utf8=$this->CHSUtoUTF8(hexdec($this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2))) - 0x8080])); } for($i = 0; $i < strlen($utf8); $i += 3) { $ret .= chr(substr($utf8, $i, 3)); } $SourceText = substr($SourceText, 2, strlen($SourceText)); } else { $ret .= substr($SourceText, 0, 1); $SourceText = substr($SourceText, 1, strlen($SourceText)); } } //$this->unicode_table = array(); $SourceText = ''; return $ret; } } } function Utf8_Unicode($char) { switch(strlen($char)) { case 1: return ord($char); case 2: $n = (ord($char[0]) & 0x3f) << 6; $n += ord($char[1]) & 0x3f; return $n; case 3: $n = (ord($char[0]) & 0x1f) << 12; $n += (ord($char[1]) & 0x3f) << 6; $n += ord($char[2]) & 0x3f; return $n; case 4: $n = (ord($char[0]) & 0x0f) << 18; $n += (ord($char[1]) & 0x3f) << 12; $n += (ord($char[2]) & 0x3f) << 6; $n += ord($char[3]) & 0x3f; return $n; } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/chinese.class.php
PHP
asf20
7,727
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: moderation.inc.php 21052 2009-11-09 10:12:34Z monkey $ */ if(!empty($tid)) { $moderate = array($tid); } if(!defined('IN_DISCUZ') || CURSCRIPT != 'topicadmin') { exit('Access Denied'); } if(empty($operations)) { $operations = array(); } if($operations && $operations != array_intersect($operations, array('delete', 'highlight', 'open', 'close', 'stick', 'digest', 'bump', 'down', 'recommend', 'type', 'move')) || (!$allowdelpost && in_array('delete', $operations)) || (!$allowstickthread && in_array('stick', $operations))) { showmessage('admin_moderate_invalid'); } $threadlist = $loglist = array(); if($tids = implodeids($moderate)) { $query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid IN ($tids) AND fid='$fid' AND displayorder>='0' AND digest>='0' LIMIT $tpp"); while($thread = $db->fetch_array($query)) { $thread['lastposterenc'] = rawurlencode($thread['lastposter']); $thread['dblastpost'] = $thread['lastpost']; $thread['lastpost'] = dgmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600); $threadlist[$thread['tid']] = $thread; $tid = empty($tid) ? $thread['tid'] : $tid; } } if(empty($threadlist)) { showmessage('admin_moderate_invalid'); } $modpostsnum = count($threadlist); $single = $modpostsnum == 1 ? TRUE : FALSE; switch($frommodcp) { case '1': $referer = "modcp.php?action=threads&fid=$fid&op=threads&do=".($frommodcp == 1 ? '' : 'list'); break; case '2': $referer = "modcp.php?action=forums&op=recommend".($show ? "&show=$show" : '')."&fid=$fid"; break; default: $referer = "forumdisplay.php?fid=$fid&".rawurldecode($listextra); break; } if(!submitcheck('modsubmit')) { if($optgroup == 1 && $single) { $stickcheck = $digestcheck = array(); empty($threadlist[$tid]['displayorder']) ? $stickcheck[0] ='selected="selected"' : $stickcheck[$threadlist[$tid]['displayorder']] = 'selected="selected"'; empty($threadlist[$tid]['digest']) ? $digestcheck[0] = 'selected="selected"' : $digestcheck[$threadlist[$tid]['digest']] = 'selected="selected"'; $string = sprintf('%02d', $threadlist[$tid]['highlight']); $stylestr = sprintf('%03b', $string[0]); for($i = 1; $i <= 3; $i++) { $stylecheck[$i] = $stylestr[$i - 1] ? 1 : 0; } $colorcheck = $string[1]; $forum['modrecommend'] = is_array($forum['modrecommend']) ? $forum['modrecommend'] : array(); } elseif($optgroup == 2) { require_once DISCUZ_ROOT.'./include/forum.func.php'; $forumselect = forumselect(FALSE, 0, $single ? $threadlist[$tid]['fid'] : 0); $typeselect = typeselect($single ? $threadlist[$tid]['typeid'] : 0); } elseif($optgroup == 4 && $single) { $closecheck = array(); empty($threadlist[$tid]['closed']) ? $closecheck[0] = 'checked="checked"' : $closecheck[1] = 'checked="checked"'; } $defaultcheck[$operation] = 'checked="checked"'; $imgattach = array(); if(count($threadlist) == 1 && $operation == 'recommend') { $query = $db->query("SELECT a.*, af.description FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid WHERE a.tid='$tid' AND a.isimage IN ('1', '-1')"); while($row = $db->fetch_array($query)) { $imgattach[] = $row; } $query = $db->query("SELECT * FROM {$tablepre}forumrecommend WHERE tid='$tid'"); if($oldthread = $db->fetch_array($query)) { $threadlist[$tid]['subject'] = $oldthread['subject']; $selectposition[$oldthread['position']] = ' selected="selected"'; $selectattach = $oldthread['aid']; } else { $selectattach = $imgattach[0]['aid']; $selectposition[0] = ' selected="selected"'; } } include template('topicadmin'); } else { $moderatetids = implodeids(array_keys($threadlist)); checkreasonpm(); $stampstatus = 0; if(empty($operations)) { showmessage('admin_nonexistence'); } else { $posts = $images = array(); foreach($operations as $operation) { if(in_array($operation, array('stick', 'highlight', 'digest', 'recommend'))) { if(empty($posts)) { $query = $db->query("SELECT * FROM {$tablepre}posts WHERE tid IN ($moderatetids) AND first='1'"); while($post = $db->fetch_array($query)) { $post['message'] = messagecutstr($post['message'], 200); $posts[$post['tid']] = $post; } } } $updatemodlog = TRUE; if($operation == 'stick') { $sticklevel = intval($sticklevel); if($sticklevel < 0 || $sticklevel > 3 || $sticklevel > $allowstickthread) { showmessage('undefined_action'); } $expiration = checkexpiration($expirationstick); $expirationstick = $sticklevel ? $expirationstick : 0; $forumstickthreads = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='forumstickthreads'"); $forumstickthreads = isset($forumstickthreads) ? unserialize($forumstickthreads) : array(); $db->query("UPDATE {$tablepre}threads SET displayorder='$sticklevel', moderated='1' WHERE tid IN ($moderatetids)"); $delkeys = array_keys($threadlist); foreach($delkeys as $k) { unset($forumstickthreads[$k]); } $forumstickthreads = serialize($forumstickthreads); $db->query("UPDATE {$tablepre}settings SET value='$forumstickthreads' WHERE variable='forumstickthreads'"); $stickmodify = 0; foreach($threadlist as $thread) { $stickmodify = (in_array($thread['displayorder'], array(2, 3)) || in_array($sticklevel, array(2, 3))) && $sticklevel != $thread['displayorder'] ? 1 : $stickmodify; } if($globalstick && $stickmodify) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('globalstick'); } $modaction = $sticklevel ? ($expiration ? 'EST' : 'STK') : 'UST'; $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('STK', 'UST', 'EST', 'UES')", 'UNBUFFERED'); if($sticklevel > 0) { send_thread_feed('thread_pin', $threadlist); } $stampstatus = 1; } elseif($operation == 'highlight') { if(!$allowhighlightthread) { showmessage('undefined_action'); } $expiration = checkexpiration($expirationhighlight); $stylebin = ''; for($i = 1; $i <= 3; $i++) { $stylebin .= empty($highlight_style[$i]) ? '0' : '1'; } $highlight_style = bindec($stylebin); if($highlight_style < 0 || $highlight_style > 7 || $highlight_color < 0 || $highlight_color > 8) { showmessage('undefined_action', NULL, 'HALTED'); } $db->query("UPDATE {$tablepre}threads SET highlight='$highlight_style$highlight_color', moderated='1' WHERE tid IN ($moderatetids)", 'UNBUFFERED'); if($db->fetch_first("SELECT * FROM {$tablepre}forumrecommend WHERE tid IN ($moderatetids)")) { $db->query("UPDATE {$tablepre}forumrecommend SET highlight='$highlight_style$highlight_color' WHERE tid IN ($moderatetids)", 'UNBUFFERED'); } $modaction = ($highlight_style + $highlight_color) ? ($expiration ? 'EHL' : 'HLT') : 'UHL'; $expiration = $modaction == 'UHL' ? 0 : $expiration; $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('HLT', 'UHL', 'EHL', 'UEH')", 'UNBUFFERED'); if($highlight_style > 0) { send_thread_feed('thread_highlight', $threadlist); } } elseif($operation == 'digest') { $digestlevel = intval($digestlevel); if($digestlevel < 0 || $digestlevel > 3 || $digestlevel > $allowdigestthread) { showmessage('undefined_action'); } $expiration = checkexpiration($expirationdigest); $expirationdigest = $digestlevel ? $expirationdigest : 0; $db->query("UPDATE {$tablepre}threads SET digest='$digestlevel', moderated='1' WHERE tid IN ($moderatetids)"); foreach($threadlist as $thread) { if($thread['digest'] != $digestlevel) { $digestpostsadd = ($thread['digest'] > 0 && $digestlevel == 0) || ($thread['digest'] == 0 && $digestlevel > 0) ? 'digestposts=digestposts+\''.($digestlevel == 0 ? '-' : '+').'1\'' : ''; updatecredits($thread['authorid'], $digestcredits, $digestlevel - $thread['digest'], $digestpostsadd); } } $modaction = $digestlevel ? ($expiration ? 'EDI' : 'DIG') : 'UDG'; $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('DIG', 'UDI', 'EDI', 'UED')", 'UNBUFFERED'); if($digestlevel > 0) { send_thread_feed('thread_digest', $threadlist); } $stampstatus = 2; } elseif($operation == 'recommend') { if(!$allowrecommendthread) { showmessage('undefined_action'); } $modrecommend = $forum['modrecommend'] ? unserialize($forum['modrecommend']) : array(); $imgw = $modrecommend['imagewidth'] ? intval($modrecommend['imagewidth']) : 200; $imgh = $modrecommend['imageheight'] ? intval($modrecommend['imageheight']) : 150; $expiration = checkexpiration($expirationrecommend); $db->query("UPDATE {$tablepre}threads SET moderated='1' WHERE tid IN ($moderatetids)"); $modaction = $isrecommend ? 'REC' : 'URE'; $thread = daddslashes($thread, 1); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('REC')", 'UNBUFFERED'); if($isrecommend) { $addthread = $comma = ''; $oldrecommendlist = array(); $query = $db->query("SELECT * FROM {$tablepre}forumrecommend WHERE tid IN ($moderatetids)"); while($row = $db->fetch_array($query)) { if($row['aid']) { @unlink(DISCUZ_ROOT.'./forumdata/imagecaches/'.intval($row['aid']).'_'.$imgw.'_'.$imgh.'.jpg'); } $oldrecommendlist[$row['tid']] = $row; } foreach($threadlist as $thread) { if(count($threadlist) > 1) { if($oldrecommendlist[$thread['tid']]) { $oldthread = $oldrecommendlist[$thread['tid']]; $reducetitle = $oldthread['subject']; $selectattach = $oldthread['aid']; $typeid = $oldthread['typeid']; $position = $oldthread['position']; } else { $reducetitle = $thread['subject']; $typeid = 0; $position = 0; } } else { empty($reducetitle) && $reducetitle = $thread['subject']; $typeid = $selectattach ? 1 : 0; empty($position) && $position = 0; } if($selectattach) { $key = authcode($selectattach."\t".$imgw."\t".$imgh, 'ENCODE', $_DCACHE['settings']['authkey']); $filename = 'image.php?aid='.$selectattach.'&size='.$imgw.'x'.$imgh.'&key='.rawurlencode($key); } else { $selectattach = 0; $filename = ''; } $addthread .= $comma."('$thread[fid]', '$thread[tid]', '$typeid', '0', '".addslashes($reducetitle)."', '".addslashes($thread['author'])."', '$thread[authorid]', '$discuz_uid', '$expiration', '$position', '$selectattach', '$filename', '$thread[highlight]')"; $comma = ', '; $reducetitle = ''; } if($addthread) { $db->query("REPLACE INTO {$tablepre}forumrecommend (fid, tid, typeid, displayorder, subject, author, authorid, moderatorid, expiration, position, aid, filename, highlight) VALUES $addthread"); } send_thread_feed('thread_recommend', $threadlist); $stampstatus = 3; } else { $db->query("DELETE FROM {$tablepre}forumrecommend WHERE fid='$fid' AND tid IN ($moderatetids)"); } } elseif($operation == 'bump') { if(!$allowbumpthread) { showmessage('undefined_action'); } $modaction = 'BMP'; $thread = $threadlist; $thread = array_pop($thread); $thread['subject'] = addslashes($thread['subject']); $thread['lastposter'] = addslashes($thread['lastposter']); $db->query("UPDATE {$tablepre}threads SET lastpost='$timestamp', moderated='1' WHERE tid IN ($moderatetids)"); $db->query("UPDATE {$tablepre}forums SET lastpost='$thread[tid]\t$thread[subject]\t$timestamp\t$thread[lastposter]' WHERE fid='$fid'"); $forum['threadcaches'] && deletethreadcaches($thread['tid']); } elseif($operation == 'down') { if(!$allowbumpthread) { showmessage('undefined_action'); } $modaction = 'DWN'; $downtime = $timestamp - 86400 * 730; $db->query("UPDATE {$tablepre}threads SET lastpost='$downtime', moderated='1' WHERE tid IN ($moderatetids)"); $forum['threadcaches'] && deletethreadcaches($thread['tid']); } elseif($operation == 'delete') { if(!$allowdelpost) { showmessage('undefined_action'); } $stickmodify = 0; foreach($threadlist as $thread) { if($thread['digest']) { updatecredits($thread['authorid'], $digestcredits, -$thread['digest'], 'digestposts=digestposts-1'); } if(in_array($thread['displayorder'], array(2, 3))) { $stickmodify = 1; } } $losslessdel = $losslessdel > 0 ? $timestamp - $losslessdel * 86400 : 0; //Update members' credits and post counter $uidarray = $tuidarray = $ruidarray = array(); $query = $db->query("SELECT first, authorid, dateline FROM {$tablepre}posts WHERE tid IN ($moderatetids)"); while($post = $db->fetch_array($query)) { if($post['dateline'] < $losslessdel) { $uidarray[] = $post['authorid']; } else { if($post['first']) { $tuidarray[] = $post['authorid']; } else { $ruidarray[] = $post['authorid']; } } } if($uidarray) { updatepostcredits('-', $uidarray, array()); } if($tuidarray) { updatepostcredits('-', $tuidarray, $postcredits); } if($ruidarray) { updatepostcredits('-', $ruidarray, $replycredits); } $modaction = 'DEL'; if($forum['recyclebin']) { $db->query("UPDATE {$tablepre}threads SET displayorder='-1', digest='0', moderated='1' WHERE tid IN ($moderatetids)"); $db->query("UPDATE {$tablepre}posts SET invisible='-1' WHERE tid IN ($moderatetids)"); } else { $auidarray = array(); $query = $db->query("SELECT uid, attachment, dateline, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($moderatetids)"); 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, $postattachcredits); } 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 ($moderatetids)", 'UNBUFFERED'); } $updatemodlog = FALSE; } if($globalstick && $stickmodify) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('globalstick'); } updateforumcount($fid); } elseif($operation == 'close') { if(!$allowclosethread) { showmessage('undefined_action'); } $expiration = checkexpiration($expirationclose); $modaction = $expiration ? 'ECL' : 'CLS'; $db->query("UPDATE {$tablepre}threads SET closed='1', moderated='1' WHERE tid IN ($moderatetids)"); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('CLS','OPN','ECL','UCL','EOP','UEO')", 'UNBUFFERED'); } elseif($operation == 'open') { if(!$allowclosethread) { showmessage('undefined_action'); } $expiration = checkexpiration($expirationopen); $modaction = $expiration ? 'EOP' : 'OPN'; $db->query("UPDATE {$tablepre}threads SET closed='0', moderated='1' WHERE tid IN ($moderatetids)"); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('CLS','OPN','ECL','UCL','EOP','UEO')", 'UNBUFFERED'); } elseif($operation == 'move') { if(!$allowmovethread) { showmessage('undefined_action'); } $toforum = $db->fetch_first("SELECT f.fid, f.name, f.modnewposts, f.allowpostspecial, ff.threadplugin FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid WHERE f.fid='$moveto' AND f.status='1' AND f.type<>'group'"); if(!$toforum) { showmessage('admin_move_invalid'); } elseif($fid == $toforum['fid']) { continue; } else { $moveto = $toforum['fid']; $modnewthreads = (!$allowdirectpost || $allowdirectpost == 1) && $toforum['modnewposts'] ? 1 : 0; $modnewreplies = (!$allowdirectpost || $allowdirectpost == 2) && $toforum['modnewposts'] ? 1 : 0; if($modnewthreads || $modnewreplies) { showmessage('admin_move_have_mod'); } } if($adminid == 3) { if($accessmasks) { $accessadd1 = ', a.allowview, a.allowpost, a.allowreply, a.allowgetattach, a.allowpostattach'; $accessadd2 = "LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid='$moveto'"; } $priv = $db->fetch_first("SELECT ff.postperm, m.uid AS istargetmod $accessadd1 FROM {$tablepre}forumfields ff $accessadd2 LEFT JOIN {$tablepre}moderators m ON m.fid='$moveto' AND m.uid='$discuz_uid' WHERE ff.fid='$moveto'"); if((($priv['postperm'] && !in_array($groupid, explode("\t", $priv['postperm']))) || ($accessmasks && ($priv['allowview'] || $priv['allowreply'] || $priv['allowgetattach'] || $priv['allowpostattach']) && !$priv['allowpost'])) && !$priv['istargetmod']) { showmessage('admin_move_nopermission'); } } $moderate = array(); $stickmodify = 0; $toforumallowspecial = array( 1 => $toforum['allowpostspecial'] & 1, 2 => $toforum['allowpostspecial'] & 2, 3 => isset($extcredits[$creditstransextra[2]]) && ($toforum['allowpostspecial'] & 4), 4 => $toforum['allowpostspecial'] & 8, 5 => $toforum['allowpostspecial'] & 16, 127 => $threadplugins ? unserialize($toforum['threadplugin']) : array(), ); foreach($threadlist as $tid => $thread) { $allowmove = 0; if(!$thread['special']) { $allowmove = 1; } else { if($thread['special'] != 127) { $allowmove = $toforum['allowpostspecial'] ? $toforumallowspecial[$thread['special']] : 0; } else { if($toforumallowspecial[127]) { $message = $db->result_first("SELECT message FROM {$tablepre}posts WHERE tid='$thread[tid]' AND first='1'"); $sppos = strrpos($message, chr(0).chr(0).chr(0)); $specialextra = substr($message, $sppos + 3); $allowmove = in_array($specialextra, $toforumallowspecial[127]); } else { $allowmove = 0; } } } if($allowmove) { $moderate[] = $tid; if(in_array($thread['displayorder'], array(2, 3))) { $stickmodify = 1; } if($type == 'redirect') { $thread = daddslashes($thread, 1); $db->query("INSERT INTO {$tablepre}threads (fid, readperm, iconid, author, authorid, subject, dateline, lastpost, lastposter, views, replies, displayorder, digest, closed, special, attachment) VALUES ('$thread[fid]', '$thread[readperm]', '$thread[iconid]', '".addslashes($thread['author'])."', '$thread[authorid]', '".addslashes($thread['subject'])."', '$thread[dateline]', '$thread[dblastpost]', '".addslashes($thread['lastposter'])."', '0', '0', '0', '0', '$thread[tid]', '0', '0')"); } } } if(!$moderatetids = implode(',', $moderate)) { showmessage('admin_moderate_invalid'); } $displayorderadd = $adminid == 3 ? ', displayorder=\'0\'' : ''; $db->query("UPDATE {$tablepre}threads SET fid='$moveto', moderated='1' $displayorderadd WHERE tid IN ($moderatetids)"); $db->query("UPDATE {$tablepre}posts SET fid='$moveto' WHERE tid IN ($moderatetids)"); if($globalstick && $stickmodify) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('globalstick'); } $modaction = 'MOV'; updateforumcount($moveto); updateforumcount($fid); } elseif($operation == 'type') { if(!$allowedittypethread) { showmessage('undefined_action'); } if(!isset($forum['threadtypes']['types'][$typeid]) && ($typeid != 0 || $forum['threadtypes']['required'])) { showmessage('admin_type_invalid'); } $db->query("UPDATE {$tablepre}threads SET typeid='$typeid', moderated='1' WHERE tid IN ($moderatetids)"); $modaction = 'TYP'; } if($updatemodlog) { updatemodlog($moderatetids, $modaction, $expiration); } updatemodworks($modaction, $modpostsnum); foreach($threadlist as $thread) { modlog($thread, $modaction); } if($sendreasonpm) { include_once language('modactions'); $modaction = $modactioncode[$modaction]; foreach($threadlist as $thread) { sendreasonpm('thread', $operation == 'move' ? 'reason_move' : 'reason_moderate'); } } procreportlog($moderatetids, '', $operation == 'delete'); if($stampstatus) { set_stamp($stampstatus); } } showmessage('admin_succeed', $referer); } } function checkexpiration($expiration) { global $operation, $timestamp, $timeoffset; if(!empty($expiration) && in_array($operation, array('recommend', 'stick', 'digest', 'highlight', 'close'))) { $expiration = strtotime($expiration) - $timeoffset * 3600 + date('Z'); if(gmdate('Ymd', $expiration + $timeoffset * 3600) <= gmdate('Ymd', $timestamp + $timeoffset * 3600) || ($expiration > $timestamp + 86400 * 180)) { showmessage('admin_expiration_invalid'); } } else { $expiration = 0; } return $expiration; } function set_stamp($typeid) { global $tablepre, $db, $_DCACHE, $moderatetids, $expiration; if(array_key_exists($typeid, $_DCACHE['stamptypeid'])) { $db->query("UPDATE {$tablepre}threads SET ".buildbitsql('status', 5, TRUE)." WHERE tid IN ($moderatetids)"); updatemodlog($moderatetids, 'SPA', $expiration, 0, $_DCACHE['stamptypeid'][$typeid]); } } function send_thread_feed($type, $threadlist) { global $tablepre, $db; include DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; $arg = $data = array(); $arg['type'] = $type; $user_digest = array(); foreach($threadlist as $key => $val) { if($type == 'thread_pin') { if($val['displayorder'] != 0) continue; } elseif($type == 'thread_highlight') { if($val['highlight'] != 0) continue; } elseif($type == 'thread_digest') { if($val['digest'] != 0) continue; } if($type == 'user_digest' && $dzfeed_limit['user_digest']) { $user_digest[$val['authorid']]++; } $arg['fid'] = $val['fid']; $arg['typeid'] = $val['typeid']; $arg['sortid'] = $val['sortid']; $arg['uid'] = $val['authorid']; $arg['username'] = addslashes($val['author']); $data['title']['actor'] = $val['authorid'] ? "<a href=\"space.php?uid={$val[authorid]}\" target=\"_blank\">{$val[author]}</a>" : $val['author']; $data['title']['forum'] = "<a href=\"forumdisplay.php?fid={$val[fid]}\" target=\"_blank\">".$_DCACHE['forums'][$val['fid']]['name'].'</a>'; $data['title']['operater'] = "<a href=\"space.php?uid={$GLOBALS[discuz_uid]}\" target=\"_blank\">{$GLOBALS[discuz_userss]}</a>"; $data['title']['subject'] = "<a href=\"viewthread.php?tid={$val[tid]}\" target=\"_blank\">{$val[subject]}</a>"; add_feed($arg, $data); } if($type == 'user_digest' && is_array($dzfeed_limit['user_digest']) && ($uids = implodeids(array_keys($user_digest)))) { $query = $db->query("SELECT uid, username, digestposts FROM {$tablepre}members WHERE uid IN ($uids)"); while($row = $db->fetch_array($query)) { $send_feed = false; foreach($dzfeed_limit['user_digest'] as $val) { if($row['digestposts'] < $val && ($row['digestposts'] + $user_digest[$row['uid']]) > $val) { $send_feed = true; $count = $val; } } if($send_feed) { $arg = $data = array(); $arg['type'] = 'user_digest'; $arg['uid'] = $row['uid']; $arg['username'] = addslashes($row['username']); $data['title']['actor'] = "<a href=\"space.php?uid={$row[uid]}\" target=\"_blank\">{$row[username]}</a>"; $data['title']['count'] = $count; add_feed($arg, $data); } } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/moderation.inc.php
PHP
asf20
24,649
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: search_sort.inc.php 21043 2009-11-09 03:08:08Z tiger $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if(!empty($searchid)) { $page = max(1, intval($page)); $start_limit = ($page - 1) * $tpp; $index = $db->fetch_first("SELECT searchstring, keywords, threads, threadsortid, tids FROM {$tablepre}searchindex WHERE searchid='$searchid' AND threadsortid='$sortid'"); if(!$index) { showmessage('search_id_invalid'); } $threadlist = $typelist = $resultlist = $optionlist = array(); $query = $db->query("SELECT tid, subject, dateline, iconid FROM {$tablepre}threads WHERE tid IN ($index[tids]) AND displayorder>=0 ORDER BY dateline LIMIT $start_limit, $tpp"); while($info = $db->fetch_array($query)) { $threadlist[$info['tid']]['icon'] = isset($GLOBALS['_DCACHE']['icons'][$info['iconid']]) ? '<img src="images/icons/'.$GLOBALS['_DCACHE']['icons'][$info['iconid']].'" alt="Icon'.$info['iconid'].'" class="icon" />' : '&nbsp;'; $threadlist[$info['tid']]['dateline'] = dgmdate("$dateformat $timeformat", $info['dateline'] + $timeoffset * 3600); $threadlist[$info['tid']]['subject'] = $info['subject']; } @include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$index['threadsortid'].'.php'; $query = $db->query("SELECT tid, optionid, value FROM {$tablepre}typeoptionvars WHERE tid IN ($index[tids])"); while($info = $db->fetch_array($query)) { if($_DTYPE[$info['optionid']]['search']) { $optionid = $info['optionid']; $identifier = $_DTYPE[$optionid]['identifier']; $unit = $_DTYPE[$optionid]['unit']; $typelist[$info['tid']][$optionid]['value'] = $info['value']; $optionlist[$identifier] = $_DTYPE[$optionid]['title'].($unit ? "($unit)" : ''); } } $optionlist = $optionlist ? array_unique($optionlist) : ''; $choiceshow = array(); foreach($threadlist as $tid => $thread) { $resultlist[$tid]['icon'] = $thread['icon']; $resultlist[$tid]['subject'] = $thread['subject']; $resultlist[$tid]['dateline'] = $thread['dateline']; if(is_array($typelist[$tid])) { foreach($typelist[$tid] as $optionid => $value) { $identifier = $_DTYPE[$optionid]['identifier']; if(in_array($_DTYPE[$optionid]['type'], array('select', 'radio'))) { $resultlist[$tid]['option'][$identifier] = $_DTYPE[$optionid]['choices'][$value['value']]; } elseif($_DTYPE[$optionid]['type'] == 'checkbox') { foreach(explode("\t", $value['value']) as $choiceid) { $choiceshow[$tid] .= $_DTYPE[$optionid]['choices'][$choiceid].'&nbsp;'; } $resultlist[$tid]['option'][$identifier] = $choiceshow[$tid]; } elseif($_DTYPE[$optionid]['type'] == 'image') { $maxwidth = $_DTYPE[$optionid]['maxwidth'] ? 'width="'.$_DTYPE[$optionid]['maxwidth'].'"' : ''; $maxheight = $_DTYPE[$optionid]['maxheight'] ? 'height="'.$_DTYPE[$optionid]['maxheight'].'"' : ''; $resultlist[$tid]['option'][$identifier] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\"><img src=\"$value[value]\" $maxwidth $maxheight border=\"0\"></a>" : ''; } elseif($_DTYPE[$optionid]['type'] == 'url') { $resultlist[$tid]['option'][$identifier] = $optiondata[$optionid] ? "<a href=\"$value[value]\" target=\"_blank\">$value[value]</a>" : ''; } else { $resultlist[$tid]['option'][$identifier] = $value['value']; } } } } $colspan = count($optionlist) + 2; $multipage = multi($index['threads'], $tpp, $page, "search.php?searchid=$searchid&srchtype=threadsort&sortid=$index[threadsortid]&searchsubmit=yes"); $url_forward = 'search.php?'.$_SERVER['QUERY_STRING']; include template('search_sort'); } else { !($exempt & 2) && checklowerlimit($creditspolicy['search'], -1); $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 = ','; } } } $srchoption = $tab = ''; if($searchoption && is_array($searchoption)) { foreach($searchoption as $optionid => $option) { $srchoption .= $tab.$optionid; $tab = "\t"; } } $searchstring = 'type|'.addslashes($srchoption); $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?srchtype=threadsort&sortid=$selectsortid&srchfid=$fid"); } } if($searchindex['id']) { $searchid = $searchindex['id']; } else { if((!$searchoption || !is_array($searchoption)) && !$selectsortid) { showmessage('search_threadtype_invalid', "search.php?srchtype=threadsort&sortid=$selectsortid&srchfid=$fid"); } elseif(isset($srchfid) && $srchfid != 'all' && !(is_array($srchfid) && in_array('all', $srchfid)) && empty($forumsarray)) { showmessage('search_forum_invalid', "search.php?srchtype=threadsort&sortid=$selectsortid&srchfid=$fid"); } 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'); } } @include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$selectsortid.'.php'; $sqlsrch = $or = ''; if(!empty($searchoption) && is_array($searchoption)) { foreach($searchoption as $optionid => $option) { $fieldname = $_DTYPE[$optionid]['identifier'] ? $_DTYPE[$optionid]['identifier'] : 1; if($option['value']) { if(in_array($option['type'], array('number', 'radio', 'select'))) { $option['value'] = intval($option['value']); $exp = '='; if($option['condition']) { $exp = $option['condition'] == 1 ? '>' : '<'; } $sql = "$fieldname$exp'$option[value]'"; } elseif($option['type'] == 'checkbox') { $sql = "$fieldname LIKE '%\t".(implode("\t", $option['value']))."\t%'"; } else { $sql = "$fieldname LIKE '%$option[value]%'"; } $sqlsrch .= $and."$sql "; $and = 'AND '; } } } $threads = $tids = 0; $query = $db->query("SELECT tid FROM {$tablepre}optionvalue$selectsortid ".($sqlsrch ? 'WHERE '.$sqlsrch : '').""); while($post = $db->fetch_array($query)) { $tids .= ','.$post['tid']; } $db->free_result($query); if($fids) { $query = $db->query("SELECT tid, closed FROM {$tablepre}threads WHERE tid IN ($tids) AND fid IN ($fids) LIMIT $maxsearchresults"); while($post = $db->fetch_array($query)) { if($thread['closed'] <= 1) { $tids .= ','.$post['tid']; $threads++; } } } $db->query("INSERT INTO {$tablepre}searchindex (keywords, searchstring, useip, uid, dateline, expiration, threads, threadsortid, tids) VALUES ('$keywords', '$searchstring', '$onlineip', '$discuz_uid', '$timestamp', '$expiration', '$threads', '$selectsortid', '$tids')"); $searchid = $db->insert_id(); !($exempt & 2) && updatecredits($discuz_uid, $creditspolicy['search'], -1); } showmessage('search_redirect', "search.php?searchid=$searchid&srchtype=threadsort&sortid=$selectsortid&searchsubmit=yes"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/search_sort.inc.php
PHP
asf20
8,376
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: category.inc.php 21018 2009-11-06 06:57:53Z wangjinbo $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $gquery = $db->query("SELECT f.fid, f.fup, f.type, f.name, ff.moderators, ff.extra FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid WHERE f.fid='$gid'"); $sql = $accessmasks ? "SELECT f.fid, f.fup, f.type, f.name, f.threads, f.posts, f.todayposts, f.lastpost, f.inheritedmod, ff.description, ff.moderators, ff.icon, ff.viewperm, ff.extra, 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.fup='$gid' AND f.status='1' AND f.type='forum' ORDER BY f.displayorder" : "SELECT f.fid, f.fup, f.type, f.name, f.threads, f.posts, f.todayposts, f.lastpost, f.inheritedmod, ff.description, ff.moderators, ff.icon, ff.viewperm, ff.extra FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING(fid) WHERE f.fup='$gid' AND f.status='1' AND f.type='forum' ORDER BY f.displayorder"; $query = $db->query($sql); if(!$db->num_rows($gquery) || !$db->num_rows($query)) { showmessage('forum_nonexistence', NULL, 'HALTED'); } while(($forum = $db->fetch_array($gquery)) || ($forum = $db->fetch_array($query))) { $forum['extra'] = unserialize($forum['extra']); if(!is_array($forum['extra'])) { $forum['extra'] = array(); } if($forum['type'] != 'group') { $threads += $forum['threads']; $posts += $forum['posts']; $todayposts += $forum['todayposts']; if(forum($forum)) { $forum['orderid'] = $catlist[$forum['fup']]['forumscount'] ++; $forum['subforums'] = ''; $forumlist[$forum['fid']] = $forum; $catlist[$forum['fup']]['forums'][] = $forum['fid']; $fids .= ','.$forum['fid']; } } else { $forum['collapseimg'] = 'collapsed_no.gif'; $collapse['category_'.$forum['fid']] = ''; if($forum['moderators']) { $forum['moderators'] = moddisplay($forum['moderators'], 'flat'); } $forum['forumscount'] = 0; $forum['forumcolumns'] = 0; $catlist[$forum['fid']] = $forum; $navigation = '&raquo; '.$forum['name']; $navtitle = strip_tags($forum['name']).' - '; } } $query = $db->query("SELECT fid, fup, name, threads, posts, todayposts FROM {$tablepre}forums WHERE status='1' AND fup IN ($fids) AND type='sub' ORDER BY displayorder"); while($forum = $db->fetch_array($query)) { if($subforumsindex && $forumlist[$forum['fup']]['permission'] == 2) { $forumlist[$forum['fup']]['subforums'] .= '<a href="forumdisplay.php?fid='.$forum['fid'].'"><u>'.$forum['name'].'</u></a>&nbsp;&nbsp;'; } $forumlist[$forum['fup']]['threads'] += $forum['threads']; $forumlist[$forum['fup']]['posts'] += $forum['posts']; $forumlist[$forum['fup']]['todayposts'] += $forum['todayposts']; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/category.inc.php
PHP
asf20
2,978
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: global.func.php 21342 2010-01-06 08:52:53Z zhaoxiongfei $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { $ckey_length = 4; $key = md5($key ? $key : $GLOBALS['discuz_auth_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 aidencode($aid) { static $sidauth = ''; $sidauth = $sidauth != '' ? $sidauth : authcode($GLOBALS['sid'], 'ENCODE', $GLOBALS['authkey']); return rawurlencode(base64_encode($aid.'|'.substr(md5($aid.md5($GLOBALS['authkey']).$GLOBALS['timestamp']), 0, 8).'|'.$GLOBALS['timestamp'].'|'.$sidauth)); } function clearcookies() { global $discuz_uid, $discuz_user, $discuz_pw, $discuz_secques, $adminid, $credits; foreach(array('sid', 'auth', 'visitedfid', 'onlinedetail', 'loginuser', 'activationauth', 'indextype') as $k) { dsetcookie($k); } $discuz_uid = $adminid = $credits = 0; $discuz_user = $discuz_pw = $discuz_secques = ''; } function checklowerlimit($creditsarray, $coef = 1) { if(is_array($creditsarray)) { global $extcredits, $id; foreach($creditsarray as $id => $addcredits) { $addcredits = $addcredits * $coef; if($addcredits < 0 && ($GLOBALS['extcredits'.$id] < $extcredits[$id]['lowerlimit'] || (($GLOBALS['extcredits'.$id] + $addcredits) < $extcredits[$id]['lowerlimit']))) { showmessage('credits_policy_lowerlimit'); } } } } function checkmd5($md5, $verified, $salt = '') { if(md5($md5.$salt) == $verified) { $result = !empty($salt) ? 1 : 2; } elseif(empty($salt)) { $result = $md5 == $verified ? 3 : ((strlen($verified) == 16 && substr($md5, 8, 16) == $verified) ? 4 : 0); } else { $result = 0; } return $result; } function checktplrefresh($maintpl, $subtpl, $timecompare, $templateid, $tpldir) { global $tplrefresh; if(empty($timecompare) || $tplrefresh == 1 || ($tplrefresh > 1 && !($GLOBALS['timestamp'] % $tplrefresh))) { if(empty($timecompare) || @filemtime($subtpl) > $timecompare) { require_once DISCUZ_ROOT.'./include/template.func.php'; parse_template($maintpl, $templateid, $tpldir); return TRUE; } } return FALSE; } function cutstr($string, $length, $dot = ' ...') { global $charset; if(strlen($string) <= $length) { return $string; } $string = str_replace(array('&amp;', '&quot;', '&lt;', '&gt;'), array('&', '"', '<', '>'), $string); $strcut = ''; if(strtolower($charset) == 'utf-8') { $n = $tn = $noc = 0; while($n < strlen($string)) { $t = ord($string[$n]); if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) { $tn = 1; $n++; $noc++; } elseif(194 <= $t && $t <= 223) { $tn = 2; $n += 2; $noc += 2; } elseif(224 <= $t && $t <= 239) { $tn = 3; $n += 3; $noc += 2; } elseif(240 <= $t && $t <= 247) { $tn = 4; $n += 4; $noc += 2; } elseif(248 <= $t && $t <= 251) { $tn = 5; $n += 5; $noc += 2; } elseif($t == 252 || $t == 253) { $tn = 6; $n += 6; $noc += 2; } else { $n++; } if($noc >= $length) { break; } } if($noc > $length) { $n -= $tn; } $strcut = substr($string, 0, $n); } else { for($i = 0; $i < $length; $i++) { $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i]; } } $strcut = str_replace(array('&', '"', '<', '>'), array('&amp;', '&quot;', '&lt;', '&gt;'), $strcut); return $strcut.$dot; } function daddslashes($string, $force = 0) { !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); if(!MAGIC_QUOTES_GPC || $force) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = daddslashes($val, $force); } } else { $string = addslashes($string); } } return $string; } function datecheck($ymd, $sep='-') { if(!empty($ymd)) { list($year, $month, $day) = explode($sep, $ymd); return checkdate($month, $day, $year); } else { return FALSE; } } function debuginfo() { if($GLOBALS['debug']) { global $db, $discuz_starttime, $debuginfo; $mtime = explode(' ', microtime()); $debuginfo = array('time' => number_format(($mtime[1] + $mtime[0] - $discuz_starttime), 6), 'queries' => $db->querynum); return TRUE; } else { return FALSE; } } function dexit($message = '') { echo $message; output(); exit(); } function dfopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) { $return = ''; $matches = parse_url($url); $host = $matches['host']; $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; $port = !empty($matches['port']) ? $matches['port'] : 80; if($post) { $out = "POST $path HTTP/1.0\r\n"; $out .= "Accept: */*\r\n"; //$out .= "Referer: $boardurl\r\n"; $out .= "Accept-Language: zh-cn\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; $out .= "Host: $host\r\n"; $out .= 'Content-Length: '.strlen($post)."\r\n"; $out .= "Connection: Close\r\n"; $out .= "Cache-Control: no-cache\r\n"; $out .= "Cookie: $cookie\r\n\r\n"; $out .= $post; } else { $out = "GET $path HTTP/1.0\r\n"; $out .= "Accept: */*\r\n"; //$out .= "Referer: $boardurl\r\n"; $out .= "Accept-Language: zh-cn\r\n"; $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; $out .= "Host: $host\r\n"; $out .= "Connection: Close\r\n"; $out .= "Cookie: $cookie\r\n\r\n"; } $fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout); if(!$fp) { return ''; } else { stream_set_blocking($fp, $block); stream_set_timeout($fp, $timeout); @fwrite($fp, $out); $status = stream_get_meta_data($fp); if(!$status['timed_out']) { while (!feof($fp)) { if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) { break; } } $stop = false; while(!feof($fp) && !$stop) { $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit)); $return .= $data; if($limit) { $limit -= strlen($data); $stop = $limit <= 0; } } } @fclose($fp); return $return; } } function dhtmlspecialchars($string) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = dhtmlspecialchars($val); } } else { $string = preg_replace('/&amp;((#(\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', //$string = preg_replace('/&amp;((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', '&\\1', str_replace(array('&', '"', '<', '>'), array('&amp;', '&quot;', '&lt;', '&gt;'), $string)); } return $string; } function dheader($string, $replace = true, $http_response_code = 0) { $string = str_replace(array("\r", "\n"), array('', ''), $string); if(empty($http_response_code) || PHP_VERSION < '4.3' ) { @header($string, $replace); } else { @header($string, $replace, $http_response_code); } if(preg_match('/^\s*location:/is', $string)) { exit(); } } function dreferer($default = '') { global $referer, $indexname; $default = empty($default) ? $indexname : ''; if(empty($referer) && isset($GLOBALS['_SERVER']['HTTP_REFERER'])) { $referer = preg_replace("/([\?&])((sid\=[a-z0-9]{6})(&|$))/i", '\\1', $GLOBALS['_SERVER']['HTTP_REFERER']); $referer = substr($referer, -1) == '?' ? substr($referer, 0, -1) : $referer; } else { $referer = dhtmlspecialchars($referer); } if(strpos($referer, 'logging.php')) { $referer = $default; } return $referer; } function dsetcookie($var, $value = '', $life = 0, $prefix = 1, $httponly = false) { global $cookiepre, $cookiedomain, $cookiepath, $timestamp, $_SERVER; $var = ($prefix ? $cookiepre : '').$var; if($value == '' || $life < 0) { $value = ''; $life = -1; } $life = $life > 0 ? $timestamp + $life : ($life < 0 ? $timestamp - 31536000 : 0); $path = $httponly && PHP_VERSION < '5.2.0' ? "$cookiepath; HttpOnly" : $cookiepath; $secure = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0; if(PHP_VERSION < '5.2.0') { setcookie($var, $value, $life, $path, $cookiedomain, $secure); } else { setcookie($var, $value, $life, $path, $cookiedomain, $secure, $httponly); } } function dunlink($filename, $havethumb = 0, $remote = 0) { global $authkey, $ftp, $attachdir; if($remote) { require_once DISCUZ_ROOT.'./include/ftp.func.php'; if(!$ftp['connid']) { if(!($ftp['connid'] = dftp_connect($ftp['host'], $ftp['username'], authcode($ftp['password'], 'DECODE', md5($authkey)), $ftp['attachdir'], $ftp['port'], $ftp['ssl']))) { return; } } dftp_delete($ftp['connid'], $filename); $havethumb && dftp_delete($ftp['connid'], $filename.'.thumb.jpg'); } else { @unlink($attachdir.'/'.$filename); $havethumb && @unlink($attachdir.'/'.$filename.'.thumb.jpg'); } } function dgmdate($format, $timestamp, $convert = 1) { $s = gmdate($format, $timestamp); if($GLOBALS['dateconvert'] && $convert) { if($GLOBALS['discuz_uid']) { if(!isset($GLOBALS['disableddateconvert'])) { $customshow = str_pad(base_convert($GLOBALS['customshow'], 10, 3), 4, '0', STR_PAD_LEFT); $GLOBALS['disableddateconvert'] = $customshow{0}; } if($GLOBALS['disableddateconvert']) { return $s; } } if(!isset($GLOBALS['todaytimestamp'])) { $GLOBALS['todaytimestamp'] = $GLOBALS['timestamp'] - ($GLOBALS['timestamp'] + $GLOBALS['timeoffset'] * 3600) % 86400 + $GLOBALS['timeoffset'] * 3600; } $lang = $GLOBALS['dlang']['date']; $time = $GLOBALS['timestamp'] + $GLOBALS['timeoffset'] * 3600 - $timestamp; if($timestamp >= $GLOBALS['todaytimestamp']) { if($time > 3600) { return '<span title="'.$s.'">'.intval($time / 3600).'&nbsp;'.$lang[4].$lang[0].'</span>'; } elseif($time > 1800) { return '<span title="'.$s.'">'.$lang[5].$lang[4].$lang[0].'</span>'; } elseif($time > 60) { return '<span title="'.$s.'">'.intval($time / 60).'&nbsp;'.$lang[6].$lang[0].'</span>'; } elseif($time > 0) { return '<span title="'.$s.'">'.$time.'&nbsp;'.$lang[7].$lang[0].'</span>'; } elseif($time == 0) { return '<span title="'.$s.'">'.$lang[8].'</span>'; } else { return $s; } } elseif(($days = intval(($GLOBALS['todaytimestamp'] - $timestamp) / 86400)) >= 0 && $days < 7) { if($days == 0) { return '<span title="'.$s.'">'.$lang[2].'&nbsp;'.gmdate($GLOBALS['timeformat'], $timestamp).'</span>'; } elseif($days == 1) { return '<span title="'.$s.'">'.$lang[3].'&nbsp;'.gmdate($GLOBALS['timeformat'], $timestamp).'</span>'; } else { return '<span title="'.$s.'">'.($days + 1).'&nbsp;'.$lang[1].$lang[0].'&nbsp;'.gmdate($GLOBALS['timeformat'], $timestamp).'</span>'; } } else { return $s; } } else { return $s; } } function errorlog($type, $message, $halt = 1) { global $timestamp, $discuz_userss, $onlineip, $_SERVER; $user = empty($discuz_userss) ? '' : $discuz_userss.'<br />'; $user .= $onlineip.'|'.$_SERVER['REMOTE_ADDR']; writelog('errorlog', dhtmlspecialchars("$timestamp\t$type\t$user\t".str_replace(array("\r", "\n"), array(' ', ' '), trim($message)))); if($halt) { exit(); } } function fileext($filename) { return trim(substr(strrchr($filename, '.'), 1, 10)); } function formhash($specialadd = '') { global $discuz_user, $discuz_uid, $discuz_pw, $timestamp, $discuz_auth_key; $hashadd = defined('IN_ADMINCP') ? 'Only For Discuz! Admin Control Panel' : ''; return substr(md5(substr($timestamp, 0, -7).$discuz_user.$discuz_uid.$discuz_pw.$discuz_auth_key.$hashadd.$specialadd), 8, 8); } function forumperm($permstr) { global $groupid, $extgroupids; $groupidarray = array($groupid); foreach(explode("\t", $extgroupids) as $extgroupid) { if($extgroupid = intval(trim($extgroupid))) { $groupidarray[] = $extgroupid; } } return preg_match("/(^|\t)(".implode('|', $groupidarray).")(\t|$)/", $permstr); } function formulaperm($formula, $type = 0, $wap = FALSE) { global $db, $tablepre, $_DSESSION, $extcredits, $formulamessage, $usermsg, $forum, $language, $medalstatus, $discuz_uid, $timestamp; $formula = unserialize($formula); $medalperm = $formula['medal']; $permusers = $formula['users']; $permmessage = $formula['message']; if(!$type && $medalstatus && $medalperm) { $exists = 1; $formulamessage = ''; $medalpermc = $medalperm; if($discuz_uid) { $medals = explode("\t", $db->result_first("SELECT medals FROM {$tablepre}memberfields WHERE uid='$discuz_uid'")); foreach($medalperm as $k => $medal) { foreach($medals as $r) { list($medalid) = explode("|", $r); if($medalid == $medal) { $exists = 0; unset($medalpermc[$k]); } } } } else { $exists = 0; } if($medalpermc) { if(!$wap) { @include DISCUZ_ROOT.'./forumdata/cache/cache_medals.php'; foreach($medalpermc as $medal) { if($_DCACHE['medals'][$medal]) { $formulamessage .= '<img src="images/common/'.$_DCACHE['medals'][$medal]['image'].'" />'.$_DCACHE['medals'][$medal]['name'].'&nbsp; '; } } showmessage('forum_permforum_nomedal', NULL, 'NOPERM'); } else { wapmsg('forum_nopermission'); } } } $formula = $formula[1]; if(!$type && ($_DSESSION['adminid'] == 1 || $forum['ismoderator'])) { return FALSE; } if(!$type && $permusers) { $permusers = str_replace(array("\r\n", "\r"), array("\n", "\n"), $permusers); $permusers = explode("\n", trim($permusers)); if(!in_array($GLOBALS['discuz_user'], $permusers)) { showmessage('forum_permforum_disallow', NULL, 'NOPERM'); } } if(!$formula) { return FALSE; } if(strexists($formula, '$memberformula[')) { preg_match_all("/\\\$memberformula\['(\w+?)'\]/", $formula, $a); $fields = $profilefields = array(); $mfadd = ''; foreach($a[1] as $field) { switch($field) { case 'regdate': $formula = preg_replace("/\{(\d{4})\-(\d{1,2})\-(\d{1,2})\}/e", "'\\1-'.sprintf('%02d', '\\2').'-'.sprintf('%02d', '\\3')", $formula); case 'regday': $fields[] = 'm.regdate';break; case 'regip': case 'lastip': $formula = preg_replace("/\{([\d\.]+?)\}/", "'\\1'", $formula); $fields[] = 'm.'.$field;break; case substr($field, 0, 6) == 'field_': $profilefields[] = $field; case 'buyercredit': case 'sellercredit': $mfadd = "LEFT JOIN {$tablepre}memberfields mf ON m.uid=mf.uid"; $fields[] = 'mf.'.$field;break; } } $memberformula = array(); if($discuz_uid) { $memberformula = $db->fetch_first("SELECT ".implode(',', $fields)." FROM {$tablepre}members m $mfadd WHERE m.uid='$discuz_uid'"); if(in_array('regday', $a[1])) { $memberformula['regday'] = intval(($timestamp - $memberformula['regdate']) / 86400); } if(in_array('regdate', $a[1])) { $memberformula['regdate'] = date('Y-m-d', $memberformula['regdate']); } $memberformula['lastip'] = $memberformula['lastip'] ? $memberformula['lastip'] : $GLOBALS['onlineip']; } else { if(isset($memberformula['regip'])) { $memberformula['regip'] = $GLOBALS['onlineip']; } if(isset($memberformula['lastip'])) { $memberformula['lastip'] = $GLOBALS['onlineip']; } } } @eval("\$formulaperm = ($formula) ? TRUE : FALSE;"); if(!$formulaperm || $type == 2) { if(!$permmessage) { include_once language('misc'); $search = array('$memberformula[\'regdate\']', '$memberformula[\'regday\']', '$memberformula[\'regip\']', '$memberformula[\'lastip\']', '$memberformula[\'buyercredit\']', '$memberformula[\'sellercredit\']', '$_DSESSION[\'digestposts\']', '$_DSESSION[\'posts\']', '$_DSESSION[\'threads\']', '$_DSESSION[\'oltime\']', '$_DSESSION[\'pageviews\']'); $replace = array($language['formulaperm_regdate'], $language['formulaperm_regday'], $language['formulaperm_regip'], $language['formulaperm_lastip'], $language['formulaperm_buyercredit'], $language['formulaperm_sellercredit'], $language['formulaperm_digestposts'], $language['formulaperm_posts'], $language['formulaperm_threads'], $language['formulaperm_oltime'], $language['formulaperm_pageviews']); for($i = 1; $i <= 8; $i++) { $search[] = '$_DSESSION[\'extcredits'.$i.'\']'; $replace[] = $extcredits[$i]['title'] ? $extcredits[$i]['title'] : $language['formulaperm_extcredits'].$i; } if($profilefields) { @include DISCUZ_ROOT.'./forumdata/cache/cache_profilefields.php'; foreach($profilefields as $profilefield) { $search[] = '$memberformula[\''.$profilefield.'\']'; $replace[] = !empty($_DCACHE['fields_optional'][$profilefield]) ? $_DCACHE['fields_optional'][$profilefield]['title'] : $_DCACHE['fields_required'][$profilefield]['title']; } } $i = 0;$usermsg = ''; foreach($search as $s) { if(!in_array($s, array('$memberformula[\'regdate\']', '$memberformula[\'regip\']', '$memberformula[\'lastip\']'))) { $usermsg .= strexists($formula, $s) ? '<br />&nbsp;&nbsp;&nbsp;'.$replace[$i].': '.(@eval('return intval('.$s.');')) : ''; } elseif($s == '$memberformula[\'regdate\']') { $usermsg .= strexists($formula, $s) ? '<br />&nbsp;&nbsp;&nbsp;'.$replace[$i].': '.(@eval('return '.$s.';')) : ''; } $i++; } $search = array_merge($search, array('and', 'or', '>=', '<=', '==')); $replace = array_merge($replace, array('&nbsp;&nbsp;<b>'.$language['formulaperm_and'].'</b>&nbsp;&nbsp;', '&nbsp;&nbsp;<b>'.$language['formulaperm_or'].'</b>&nbsp;&nbsp;', '&ge;', '&le;', '=')); $formulamessage = str_replace($search, $replace, $formula); } else { $formulamessage = nl2br(htmlspecialchars($permmessage)); } if($type == 1 || $type == 2) { return $formulamessage; } elseif(!$wap) { if(!$permmessage) { showmessage('forum_permforum_nopermission', NULL, 'NOPERM'); } else { showmessage('forum_permforum_nopermission_custommsg', NULL, 'NOPERM'); } } else { wapmsg('forum_nopermission'); } } return TRUE; } function getgroupid($uid, $group, &$member) { global $creditsformula, $db, $tablepre, $dzfeed_limit; if(!empty($creditsformula)) { $updatearray = array(); eval("\$credits = round($creditsformula);"); if($credits != $member['credits']) { $send_feed = false; if(is_array($dzfeed_limit['user_credit'])) foreach($dzfeed_limit['user_credit'] as $val) { if($member['credits'] < $val && $credits > $val) { $send_feed = true; $count = $val; } } if($send_feed) { $arg = $data = array(); $arg['type'] = 'user_credit'; $arg['uid'] = $uid; $arg['username'] = addslashes($member['username'] ? $member['username'] : $member['discuz_user']); $data['title']['actor'] = "<a href=\"space.php?uid={$arg[uid]}\" target=\"_blank\">".($member['username'] ? $member['username'] : $member['discuz_user'])."</a>"; $data['title']['count'] = $count; add_feed($arg, $data); } $updatearray[] = "credits='$credits'"; $member['credits'] = $credits; } if($group['type'] == 'member' && !($member['credits'] >= $group['creditshigher'] && $member['credits'] < $group['creditslower'])) { $query = $db->query("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND $member[credits]>=creditshigher AND $member[credits]<creditslower LIMIT 1"); if($db->num_rows($query)) { $newgroupid = $db->result($query, 0); $query = $db->query("SELECT groupid FROM {$tablepre}members WHERE uid='$uid'"); $member['groupid'] = $db->result($query, 0); if($member['groupid'] != $newgroupid) { $member['groupid'] = $newgroupid; $updatearray[] = "groupid='$member[groupid]'"; include language('notice'); $grouptitle = $db->result_first("SELECT grouptitle FROM {$tablepre}usergroups WHERE groupid='$member[groupid]'"); $data = array(); $data['usergroup'] = "<a href=\"faq.php?action=grouppermission&searchgroupid={$member[groupid]}\" target=\"_blank\">{$grouptitle}</a>"; $msg_template = $language['user_usergroup']; $message = transval($msg_template, $data); sendnotice($uid, $message, 'systempm'); if(is_array($dzfeed_limit['user_usergroup']) && in_array($member['groupid'], $dzfeed_limit['user_usergroup'])) { $arg = $data = array(); $arg['type'] = 'user_usergroup'; $arg['uid'] = $uid; $arg['username'] = addslashes($member['username'] ? $member['username'] : $member['discuz_user']); $data['title']['actor'] = "<a href=\"space.php?uid={$arg[uid]}\" target=\"_blank\">".($member['username'] ? $member['username'] : $member['discuz_user'])."</a>"; $data['title']['usergroup'] = "<a href=\"faq.php?action=grouppermission&searchgroupid={$member[groupid]}\" target=\"_blank\">{$grouptitle}</a>"; add_feed($arg, $data); } } } } if($updatearray) { $db->query("UPDATE {$tablepre}members SET ".implode(', ', $updatearray)." WHERE uid='$uid'"); } } return $member['groupid']; } function getrobot() { if(!defined('IS_ROBOT')) { $kw_spiders = 'Bot|Crawl|Spider|slurp|sohu-search|lycos|robozilla'; $kw_browsers = 'MSIE|Netscape|Opera|Konqueror|Mozilla'; if(!strexists($_SERVER['HTTP_USER_AGENT'], 'http://') && preg_match("/($kw_browsers)/i", $_SERVER['HTTP_USER_AGENT'])) { define('IS_ROBOT', FALSE); } elseif(preg_match("/($kw_spiders)/i", $_SERVER['HTTP_USER_AGENT'])) { define('IS_ROBOT', TRUE); } else { define('IS_ROBOT', FALSE); } } return IS_ROBOT; } function get_home($uid) { $uid = sprintf("%05d", $uid); $dir1 = substr($uid, 0, -4); $dir2 = substr($uid, -4, 2); $dir3 = substr($uid, -2, 2); return $dir1.'/'.$dir2.'/'.$dir3; } function groupexpiry($terms) { $terms = is_array($terms) ? $terms : unserialize($terms); $groupexpiry = isset($terms['main']['time']) ? intval($terms['main']['time']) : 0; if(is_array($terms['ext'])) { foreach($terms['ext'] as $expiry) { if((!$groupexpiry && $expiry) || $expiry < $groupexpiry) { $groupexpiry = $expiry; } } } return $groupexpiry; } function ipaccess($ip, $accesslist) { return preg_match("/^(".str_replace(array("\r\n", ' '), array('|', ''), preg_quote($accesslist, '/')).")/", $ip); } function implodeids($array) { if(!empty($array)) { return "'".implode("','", is_array($array) ? $array : array($array))."'"; } else { return ''; } } function ipbanned($onlineip) { global $ipaccess, $timestamp, $cachelost; if($ipaccess && !ipaccess($onlineip, $ipaccess)) { return TRUE; } $cachelost .= (@include DISCUZ_ROOT.'./forumdata/cache/cache_ipbanned.php') ? '' : ' ipbanned'; if(empty($_DCACHE['ipbanned'])) { return FALSE; } else { if($_DCACHE['ipbanned']['expiration'] < $timestamp) { @unlink(DISCUZ_ROOT.'./forumdata/cache/cache_ipbanned.php'); } return preg_match("/^(".$_DCACHE['ipbanned']['regexp'].")$/", $onlineip); } } function isemail($email) { return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email); } 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; } } function modthreadkey($tid) { global $adminid, $discuz_user, $discuz_uid, $discuz_pw, $timestamp, $discuz_auth_key; return $adminid > 0 ? md5($discuz_user.$discuz_uid.$discuz_auth_key.substr($timestamp, 0, -7).$tid) : ''; } function multi($num, $perpage, $curpage, $mpurl, $maxpages = 0, $page = 10, $autogoto = TRUE, $simple = FALSE) { global $maxpage; $ajaxtarget = !empty($_GET['ajaxtarget']) ? " ajaxtarget=\"".dhtmlspecialchars($_GET['ajaxtarget'])."\" " : ''; if(defined('IN_ADMINCP')) { $shownum = $showkbd = TRUE; $lang['prev'] = '&lsaquo;&lsaquo;'; $lang['next'] = '&rsaquo;&rsaquo;'; } else { $shownum = $showkbd = FALSE; $lang['prev'] = '&nbsp'; $lang['next'] = $GLOBALS['dlang']['nextpage']; } $multipage = ''; $mpurl .= strpos($mpurl, '?') ? '&amp;' : '?'; $realpages = 1; if($num > $perpage) { $offset = 2; $realpages = @ceil($num / $perpage); $pages = $maxpages && $maxpages < $realpages ? $maxpages : $realpages; if($page > $pages) { $from = 1; $to = $pages; } else { $from = $curpage - $offset; $to = $from + $page - 1; if($from < 1) { $to = $curpage + 1 - $from; $from = 1; if($to - $from < $page) { $to = $page; } } elseif($to > $pages) { $from = $pages - $page + 1; $to = $pages; } } $multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="'.$mpurl.'page=1" class="first"'.$ajaxtarget.'>1 ...</a>' : ''). ($curpage > 1 && !$simple ? '<a href="'.$mpurl.'page='.($curpage - 1).'" class="prev"'.$ajaxtarget.'>'.$lang['prev'].'</a>' : ''); for($i = $from; $i <= $to; $i++) { $multipage .= $i == $curpage ? '<strong>'.$i.'</strong>' : '<a href="'.$mpurl.'page='.$i.($ajaxtarget && $i == $pages && $autogoto ? '#' : '').'"'.$ajaxtarget.'>'.$i.'</a>'; } $multipage .= ($to < $pages ? '<a href="'.$mpurl.'page='.$pages.'" class="last"'.$ajaxtarget.'>... '.$realpages.'</a>' : ''). ($curpage < $pages && !$simple ? '<a href="'.$mpurl.'page='.($curpage + 1).'" class="next"'.$ajaxtarget.'>'.$lang['next'].'</a>' : ''). ($showkbd && !$simple && $pages > $page && !$ajaxtarget ? '<kbd><input type="text" name="custompage" size="3" onkeydown="if(event.keyCode==13) {window.location=\''.$mpurl.'page=\'+this.value; return false;}" /></kbd>' : ''); $multipage = $multipage ? '<div class="pages">'.($shownum && !$simple ? '<em>&nbsp;'.$num.'&nbsp;</em>' : '').$multipage.'</div>' : ''; } $maxpage = $realpages; return $multipage; } function output() { if(defined('DISCUZ_OUTPUTED')) { return; } define('DISCUZ_OUTPUTED', 1); global $sid, $transsidstatus, $rewritestatus, $ftp, $advlist, $thread, $inajax, $forumdomains, $binddomains, $indexname; if($advlist && !defined('IN_ADMINCP') && !$inajax) { include template('adv'); } funcstat(); stat_code(); if(($transsidstatus = empty($GLOBALS['_DCOOKIE']['sid']) && $transsidstatus) || $rewritestatus || ($binddomains && $forumdomains)) { $content = ob_get_contents(); if($transsidstatus) { $searcharray = array ( "/\<a(\s*[^\>]+\s*)href\=([\"|\']?)([^\"\'\s]+)/ies", "/(\<form.+?\>)/is" ); $replacearray = array ( "transsid('\\3','<a\\1href=\\2')", "\\1\n<input type=\"hidden\" name=\"sid\" value=\"$sid\" />" ); $content = preg_replace($searcharray, $replacearray, $content); } if($binddomains && $forumdomains) { $bindsearcharray = $bindreplacearray = array(); $indexname = basename($indexname); foreach($forumdomains as $fid => $domain) { $bindsearcharray[] = "href=\"forumdisplay.php?fid=$fid&amp;"; $bindreplacearray[] = 'href="http://'.$domain.'/'.$indexname.'?'; $bindsearcharray[] = "href=\"forumdisplay.php?fid=$fid"; $bindreplacearray[] = 'href="http://'.$domain.'/'.$indexname; } $content = str_replace($bindsearcharray, $bindreplacearray, $content); } if($rewritestatus) { $searcharray = $replacearray = array(); if($rewritestatus & 1) { $searcharray[] = "/\<a href\=\"forumdisplay\.php\?fid\=(\d+)(&amp;page\=(\d+))?\"([^\>]*)\>/e"; $replacearray[] = "rewrite_forum('\\1', '\\3', '\\4')"; } if($rewritestatus & 2) { $searcharray[] = "/\<a href\=\"viewthread\.php\?tid\=(\d+)(&amp;extra\=page\%3D(\d+))?(&amp;page\=(\d+))?\"([^\>]*)\>/e"; $replacearray[] = "rewrite_thread('\\1', '\\5', '\\3', '\\6')"; } if($rewritestatus & 4) { $searcharray[] = "/\<a href\=\"space\.php\?(uid\=(\d+)|username\=([^&]+?))\"([^\>]*)\>/e"; $replacearray[] = "rewrite_space('\\2', '\\3', '\\4')"; } if($rewritestatus & 8) { $searcharray[] = "/\<a href\=\"tag\.php\?name\=([^&]+?)\"([^\>]*)\>/e"; $replacearray[] = "rewrite_tag('\\1', '\\2')"; } $content = preg_replace($searcharray, $replacearray, $content); } ob_end_clean(); $GLOBALS['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start(); echo $content; } if($ftp['connid']) { @ftp_close($ftp['connid']); } $ftp = array(); if(defined('CACHE_FILE') && CACHE_FILE && !defined('CACHE_FORBIDDEN')) { global $cachethreaddir; if(diskfreespace(DISCUZ_ROOT.'./'.$cachethreaddir) > 1000000) { if($fp = @fopen(CACHE_FILE, 'w')) { flock($fp, LOCK_EX); fwrite($fp, empty($content) ? ob_get_contents() : $content); } @fclose($fp); chmod(CACHE_FILE, 0777); } } } function periodscheck($periods, $showmessage = 1) { global $timestamp, $disableperiodctrl, $_DCACHE, $banperiods; if(!$disableperiodctrl && $_DCACHE['settings'][$periods]) { $now = gmdate('G.i', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600); foreach(explode("\r\n", str_replace(':', '.', $_DCACHE['settings'][$periods])) as $period) { list($periodbegin, $periodend) = explode('-', $period); if(($periodbegin > $periodend && ($now >= $periodbegin || $now < $periodend)) || ($periodbegin < $periodend && $now >= $periodbegin && $now < $periodend)) { $banperiods = str_replace("\r\n", ', ', $_DCACHE['settings'][$periods]); if($showmessage) { showmessage('period_nopermission', NULL, 'NOPERM'); } else { return TRUE; } } } } return FALSE; } function quescrypt($questionid, $answer) { return $questionid > 0 && $answer != '' ? substr(md5($answer.md5($questionid)), 16, 8) : ''; } function rewrite_thread($tid, $page = 0, $prevpage = 0, $extra = '') { return '<a href="thread-'.$tid.'-'.($page ? $page : 1).'-'.($prevpage && !IS_ROBOT ? $prevpage : 1).'.html"'.stripslashes($extra).'>'; } function rewrite_forum($fid, $page = 0, $extra = '') { return '<a href="forum-'.$fid.'-'.($page ? $page : 1).'.html"'.stripslashes($extra).'>'; } function rewrite_space($uid, $username, $extra = '') { $GLOBALS['rewritecompatible'] && $username = rawurlencode($username); return '<a href="space-'.($uid ? 'uid-'.$uid : 'username-'.$username).'.html"'.stripslashes($extra).'>'; } function rewrite_tag($name, $extra = '') { $GLOBALS['rewritecompatible'] && $name = rawurlencode($name); return '<a href="tag-'.$name.'.html"'.stripslashes($extra).'>'; } function random($length, $numeric = 0) { PHP_VERSION < '4.2.0' ? mt_srand((double)microtime() * 1000000) : mt_srand(); $seed = base_convert(md5(print_r($_SERVER, 1).microtime()), 16, $numeric ? 10 : 35); $seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); $hash = ''; $max = strlen($seed) - 1; for($i = 0; $i < $length; $i++) { $hash .= $seed[mt_rand(0, $max)]; } return $hash; } function request($cachekey, $fid = 0, $type = 0, $return = 0) { global $timestamp, $_DCACHE; $datalist = ''; if($fid && CURSCRIPT == 'forumdisplay') { $specialfid = $GLOBALS['forum']['fid']; $key = $cachekey = empty($GLOBALS['infosidestatus']['f'.$specialfid][$type]) ? $GLOBALS['infosidestatus'][$type] : $GLOBALS['infosidestatus']['f'.$specialfid][$type]; $cachekey .= '_fid'.$specialfid; } else { $specialfid = 0; if(!$type) { $key = $cachekey; } else { $key = $cachekey = $cachekey[$type]; } } $cachefile = DISCUZ_ROOT.'./forumdata/cache/request_'.md5($cachekey).'.php'; if(((@!include($cachefile)) || $expiration < $timestamp) && (!file_exists($cachefile.'.lock') || $timestamp - filemtime($cachefile.'.lock') > 3600)) { include_once DISCUZ_ROOT.'./forumdata/cache/cache_request.php'; require_once DISCUZ_ROOT.'./include/request.func.php'; parse_str($_DCACHE['request'][$key]['url'], $requestdata); $datalist = parse_request($requestdata, $cachefile, 0, $specialfid, $key); } if(!empty($nocachedata)) { include_once DISCUZ_ROOT.'./forumdata/cache/cache_request.php'; require_once DISCUZ_ROOT.'./include/request.func.php'; foreach($nocachedata as $key => $v) { $cachefile = DISCUZ_ROOT.'./forumdata/cache/request_'.md5($key).'.php'; if(!file_exists($cachefile.'.lock')) { parse_str($_DCACHE['request'][$key]['url'], $requestdata); $datalist = str_replace($v, parse_request($requestdata, $cachefile, 0, $specialfid, $key), $datalist); } } } if(!$return) { echo $datalist; } else { return $datalist; } } function sendmail($email_to, $email_subject, $email_message, $email_from = '') { extract($GLOBALS, EXTR_SKIP); require DISCUZ_ROOT.'./include/sendmail.inc.php'; } function sendnotice($toid, $message, $type, $extraid = 0, $actor = array(), $uselang = 1) { if(!$toid || $message === '') { return; } extract($GLOBALS, EXTR_SKIP); if($uselang) { include language('notice'); if(isset($language[$message])) { eval("\$message = addslashes(\"".$language[$message]."\");"); } } $typeid = $prompts[$type]['id']; if(!$typeid) { return; } $toids = explode(',', $toid); foreach($toids as $toid) { $keysadd = $valuesadd = $statnewnotice = ''; if($extraid && $actor) { $promptmsg = $db->fetch_first("SELECT actor FROM {$tablepre}promptmsgs WHERE uid='$toid' AND typeid='$typeid' AND extraid='$extraid' LIMIT 1"); if($promptmsg) { list($actorcount, $actors) = explode("\t", $promptmsg['actor']); $actorarray = array_unique(explode(',', $actors)); if(!in_array($actor['user'], $actorarray)) { array_unshift($actorarray, $actor['user']); $actors = implode(',', array_slice($actorarray, 0, $actor['maxusers'])); $actorcount++; } $statnewnotice = 1; $db->query("UPDATE {$tablepre}promptmsgs SET actor='".addslashes($actorcount."\t".$actors)."', dateline='$timestamp', new='1' WHERE uid='$toid' AND typeid='$typeid' AND extraid='$extraid'"); } else { $statnewnotice = 1; $db->query("INSERT INTO {$tablepre}promptmsgs (typeid, uid, new, dateline, message, extraid, actor) VALUES ('$typeid', '$toid', '1', '$timestamp', '$message', '$extraid', '".addslashes("1\t".$actor['user'])."')"); } } else { $statnewnotice = 1; $db->query("INSERT INTO {$tablepre}promptmsgs (typeid, uid, new, dateline, message) VALUES ('$typeid', '$toid', '1', '$timestamp', '$message')"); } if($statnewnotice) { write_statlog('', 'action=counttype&typeid='.$typeid, '', '', 'notice.php'); } $count = $db->result_first("SELECT count(*) FROM {$tablepre}promptmsgs WHERE uid='$toid' AND typeid='$typeid' AND new='1'"); updateprompt($type, $toid, $count); } } function sendpm($toid, $subject, $message, $fromid = '') { if($fromid === '') { require_once DISCUZ_ROOT.'./uc_client/client.php'; $fromid = $discuz_uid; } if($fromid) { uc_pm_send($fromid, $toid, $subject, $message); } else { global $promptkeys; if(in_array($subject, $promptkeys)) { $type = $subject; } else { extract($GLOBALS, EXTR_SKIP); require_once DISCUZ_ROOT.'./include/discuzcode.func.php'; eval("\$message = addslashes(\"".$message."\");"); $type = 'systempm'; $message = '<div>'.$subject.' {time}<br />'.discuzcode($message, 1, 0).'</div>'; } sendnotice($toid, $message, $type); } } function showmessage($message, $url_forward = '', $extra = '', $forwardtype = 0) { extract($GLOBALS, EXTR_SKIP); global $hookscriptmessage, $extrahead, $discuz_uid, $discuz_action, $debuginfo, $seccode, $seccodestatus, $fid, $tid, $charset, $show_message, $inajax, $_DCACHE, $advlist; define('CACHE_FORBIDDEN', TRUE); $hookscriptmessage = $show_message = $message;$messagehandle = 0; $msgforward = unserialize($_DCACHE['settings']['msgforward']); $refreshtime = intval($msgforward['refreshtime']); $refreshtime = empty($forwardtype) ? $refreshtime : ($refreshtime ? $refreshtime : 3); $msgforward['refreshtime'] = $refreshtime * 1000; $url_forward = empty($url_forward) ? '' : (empty($_DCOOKIE['sid']) && $transsidstatus ? transsid($url_forward) : $url_forward); $seccodecheck = $seccodestatus & 2; if($_DCACHE['settings']['funcsiteid'] && $_DCACHE['settings']['funckey'] && $funcstatinfo && !IS_ROBOT) { $statlogfile = DISCUZ_ROOT.'./forumdata/funcstat.log'; if($fp = @fopen($statlogfile, 'a')) { @flock($fp, 2); if(is_array($funcstatinfo)) { $funcstatinfo = array_unique($funcstatinfo); foreach($funcstatinfo as $funcinfo) { fwrite($fp, funcstat_query($funcinfo, $message)."\n"); } } else { fwrite($fp, funcstat_query($funcstatinfo, $message)."\n"); } fclose($fp); $funcstatinfo = $GLOBALS['funcstatinfo'] = ''; } } if(!defined('STAT_DISABLED') && STAT_ID > 0 && !IS_ROBOT) { write_statlog($message); } if($url_forward && (!empty($quickforward) || empty($inajax) && $msgforward['quick'] && $msgforward['messages'] && @in_array($message, $msgforward['messages']))) { updatesession(); dheader("location: ".str_replace('&amp;', '&', $url_forward)); } if(!empty($infloat)) { if($extra) { $messagehandle = $extra; } $extra = ''; } if(in_array($extra, array('HALTED', 'NOPERM'))) { $discuz_action = 254; } else { $discuz_action = 255; } include language('messages'); $vars = explode(':', $message); if(count($vars) == 2 && isset($scriptlang[$vars[0]][$vars[1]])) { eval("\$show_message = \"".str_replace('"', '\"', $scriptlang[$vars[0]][$vars[1]])."\";"); } elseif(isset($language[$message])) { $pre = $inajax ? 'ajax_' : ''; eval("\$show_message = \"".(isset($language[$pre.$message]) ? $language[$pre.$message] : $language[$message])."\";"); unset($pre); } if(empty($infloat)) { $show_message .= $url_forward && empty($inajax) ? '<script>setTimeout("window.location.href =\''.$url_forward.'\';", '.$msgforward['refreshtime'].');</script>' : ''; } elseif($handlekey) { $show_message = str_replace("'", "\'", $show_message); if($url_forward) { $show_message = "<script type=\"text/javascript\" reload=\"1\">\nif($('return_$handlekey')) $('return_$handlekey').className = 'onright';\nif(typeof submithandle_$handlekey =='function') {submithandle_$handlekey('$url_forward', '$show_message');} else {location.href='$url_forward'}\n</script>"; } else { $show_message .= "<script type=\"text/javascript\" reload=\"1\">\nif(typeof messagehandle_$handlekey =='function') {messagehandle_$handlekey('$messagehandle', '$show_message');}\n</script>"; } } if($advlist = array_merge($globaladvs ? $globaladvs['type'] : array(), $redirectadvs ? $redirectadvs['type'] : array())) { $advitems = ($globaladvs ? $globaladvs['items'] : array()) + ($redirectadvs ? $redirectadvs['items'] : array()); foreach($advlist AS $type => $redirectadvs) { $advlist[$type] = $advitems[$redirectadvs[array_rand($redirectadvs)]]; } } if($extra == 'NOPERM') { include template('nopermission'); } else { include template('showmessage'); } dexit(); } function showmessagenoperm($type, $fid) { include DISCUZ_ROOT.'./forumdata/cache/cache_nopermission.php'; include DISCUZ_ROOT.'./forumdata/cache/cache_usergroups.php'; $v = $noperms[$fid][$type][$GLOBALS['groupid']][0]; $gids = $noperms[$fid][$type][$GLOBALS['groupid']][1]; $comma = $GLOBALS['permgroups'] = ''; foreach($gids as $gid) { if($gid && $_DCACHE['usergroups'][$gid]) { $GLOBALS['permgroups'] .= $comma.$_DCACHE['usergroups'][$gid]['grouptitle']; $comma = ', '; } } showmessage($type.'_'.$v.'_nopermission', NULL, 'NOPERM'); } function site() { return $_SERVER['HTTP_HOST']; } function strexists($haystack, $needle) { return !(strpos($haystack, $needle) === FALSE); } function seccodeconvert(&$seccode) { global $seccodedata, $charset; $seccode = substr($seccode, -6); if($seccodedata['type'] == 1) { include_once language('seccode'); $len = strtoupper($charset) == 'GBK' ? 2 : 3; $code = array(substr($seccode, 0, 3), substr($seccode, 3, 3)); $seccode = ''; for($i = 0; $i < 2; $i++) { $seccode .= substr($lang['chn'], $code[$i] * $len, $len); } return; } elseif($seccodedata['type'] == 3) { $s = sprintf('%04s', base_convert($seccode, 10, 20)); $seccodeunits = 'CEFHKLMNOPQRSTUVWXYZ'; } else { $s = sprintf('%04s', base_convert($seccode, 10, 24)); $seccodeunits = 'BCEFGHJKMPQRTVWXY2346789'; } $seccode = ''; for($i = 0; $i < 4; $i++) { $unit = ord($s{$i}); $seccode .= ($unit >= 0x30 && $unit <= 0x39) ? $seccodeunits[$unit - 0x30] : $seccodeunits[$unit - 0x57]; } } function submitcheck($var, $allowget = 0, $seccodecheck = 0, $secqaacheck = 0) { if(empty($GLOBALS[$var])) { return FALSE; } else { global $_SERVER, $seclevel, $seccode, $seccodedata, $seccodeverify, $secanswer, $_DCACHE, $_DCOOKIE, $timestamp, $discuz_uid; if($allowget || ($_SERVER['REQUEST_METHOD'] == 'POST' && $GLOBALS['formhash'] == formhash() && empty($_SERVER['HTTP_X_FLASH_VERSION']) && (empty($_SERVER['HTTP_REFERER']) || preg_replace("/https?:\/\/([^\:\/]+).*/i", "\\1", $_SERVER['HTTP_REFERER']) == preg_replace("/([^\:]+).*/", "\\1", $_SERVER['HTTP_HOST'])))) { if($seccodecheck) { if(!$seclevel) { $key = $seccodedata['type'] != 3 ? '' : $_DCACHE['settings']['authkey'].date('Ymd'); list($seccode, $expiration, $seccodeuid) = explode("\t", authcode($_DCOOKIE['secc'], 'DECODE', $key)); if($seccodeuid != $discuz_uid || $timestamp - $expiration > 600) { showmessage('submit_seccode_invalid'); } dsetcookie('secc', ''); } else { $tmp = substr($seccode, 0, 1); } seccodeconvert($seccode); if(strtoupper($seccodeverify) != $seccode) { showmessage('submit_seccode_invalid'); } $seclevel && $seccode = random(6, 1) + $tmp * 1000000; } if($secqaacheck) { if(!$seclevel) { list($seccode, $expiration, $seccodeuid) = explode("\t", authcode($_DCOOKIE['secq'], 'DECODE')); if($seccodeuid != $discuz_uid || $timestamp - $expiration > 600) { showmessage('submit_secqaa_invalid'); } dsetcookie('secq', ''); } require_once DISCUZ_ROOT.'./forumdata/cache/cache_secqaa.php'; if(md5($secanswer) != $_DCACHE['secqaa'][substr($seccode, 0, 1)]['answer']) { showmessage('submit_secqaa_invalid'); } $seclevel && $seccode = random(1, 1) * 1000000 + substr($seccode, -6); } return TRUE; } else { showmessage('submit_invalid'); } } } function template($file, $templateid = 0, $tpldir = '') { global $inajax, $hookscript; if(strexists($file, ':')) { list($templateid, $file) = explode(':', $file); $tpldir = './plugins/'.$templateid.'/templates'; } $file .= $inajax && ($file == 'header' || $file == 'footer') ? '_ajax' : ''; $tpldir = $tpldir ? $tpldir : TPLDIR; $templateid = $templateid ? $templateid : TEMPLATEID; $tplfile = DISCUZ_ROOT.'./'.$tpldir.'/'.$file.'.htm'; $filebak = $file; $file == 'header' && CURSCRIPT && $file = 'header_'.CURSCRIPT; $objfile = DISCUZ_ROOT.'./forumdata/templates/'.STYLEID.'_'.$templateid.'_'.$file.'.tpl.php'; if($templateid != 1 && !file_exists($tplfile)) { $tplfile = DISCUZ_ROOT.'./templates/default/'.$filebak.'.htm'; } @checktplrefresh($tplfile, $tplfile, filemtime($objfile), $templateid, $tpldir); return $objfile; } function transsid($url, $tag = '', $wml = 0) { global $sid; $tag = stripslashes($tag); if(!$tag || (!preg_match("/^(http:\/\/|mailto:|#|javascript)/i", $url) && !strpos($url, 'sid='))) { if($pos = strpos($url, '#')) { $urlret = substr($url, $pos); $url = substr($url, 0, $pos); } else { $urlret = ''; } $url .= (strpos($url, '?') ? ($wml ? '&amp;' : '&') : '?').'sid='.$sid.$urlret; } return $tag.$url; } function typeselect($curtypeid = 0) { if($threadtypes = $GLOBALS['forum']['threadtypes']) { $html = '<select name="typeid" id="typeid"><option value="0">&nbsp;</option>'; foreach($threadtypes['types'] as $typeid => $name) { $html .= '<option value="'.$typeid.'" '.($curtypeid == $typeid ? 'selected' : '').'>'.strip_tags($name).'</option>'; } $html .= '</select>'; return $html; } else { return ''; } } function sortselect($cursortid = 0, $modelid = 0, $onchange = '') { global $fid, $sid, $extra; if($threadsorts = $GLOBALS['forum']['threadsorts']) { $onchange = $onchange ? $onchange : "onchange=\"ajaxget('post.php?action=threadsorts&sortid='+this.options[this.selectedIndex].value+'&fid=$fid&sid=$sid', 'threadsorts', 'threadsortswait')\""; $selecthtml = ''; foreach($threadsorts['types'] as $sortid => $name) { $sorthtml = '<option value="'.$sortid.'" '.($cursortid == $sortid ? 'selected="selected"' : '').' class="special">'.strip_tags($name).'</option>'; $selecthtml .= $modelid ? ($threadsorts['modelid'][$sortid] == $modelid ? $sorthtml : '') : $sorthtml; } $hiddeninput = $cursortid ? '<input type="hidden" name="sortid" value="'.$cursortid.'" />' : ''; $html = '<select name="sortid" '.$onchange.'><option value="0">&nbsp;</option>'.$selecthtml.'</select><span id="threadsortswait"></span>'.$hiddeninput; return $html; } else { return ''; } } function updatecredits($uids, $creditsarray, $coef = 1, $extrasql = '') { if($uids && ((!empty($creditsarray) && is_array($creditsarray)) || $extrasql)) { global $db, $tablepre, $discuz_uid, $creditnotice, $cookiecredits; $self = $creditnotice && $uids == $discuz_uid; if($self && !isset($cookiecredits)) { $cookiecredits = !empty($_COOKIE['discuz_creditnotice']) ? explode('D', $_COOKIE['discuz_creditnotice']) : array_fill(0, 9, 0); } $creditsadd = $comma = ''; foreach($creditsarray as $id => $addcredits) { $creditsadd .= $comma.'extcredits'.$id.'=extcredits'.$id.'+('.intval($addcredits).')*('.$coef.')'; $comma = ', '; if($self) { $cookiecredits[$id] += intval($addcredits) * $coef; } } if($self) { dsetcookie('discuz_creditnotice', implode('D', $cookiecredits).'D'.$discuz_uid, 43200, 0); } if($creditsadd || $extrasql) { $db->query("UPDATE {$tablepre}members SET $creditsadd ".($creditsadd && $extrasql ? ', ' : '')." $extrasql WHERE uid IN ('$uids')", 'UNBUFFERED'); } } } function updatesession() { if(!empty($GLOBALS['sessionupdated'])) { return TRUE; } global $db, $tablepre, $sessionexists, $sessionupdated, $sid, $onlineip, $discuz_uid, $discuz_user, $timestamp, $lastactivity, $seccode, $pvfrequence, $spageviews, $lastolupdate, $oltimespan, $onlinehold, $groupid, $styleid, $invisible, $discuz_action, $fid, $tid; $fid = intval($fid); $tid = intval($tid); if($oltimespan && $discuz_uid && $lastactivity && $timestamp - ($lastolupdate ? $lastolupdate : $lastactivity) > $oltimespan * 60) { $lastolupdate = $timestamp; $db->query("UPDATE {$tablepre}onlinetime SET total=total+'$oltimespan', thismonth=thismonth+'$oltimespan', lastupdate='$timestamp' WHERE uid='$discuz_uid' AND lastupdate<='".($timestamp - $oltimespan * 60)."'"); if(!$db->affected_rows()) { $db->query("INSERT INTO {$tablepre}onlinetime (uid, thismonth, total, lastupdate) VALUES ('$discuz_uid', '$oltimespan', '$oltimespan', '$timestamp')", 'SILENT'); } } else { $lastolupdate = intval($lastolupdate); } if($sessionexists == 1) { if($pvfrequence && $discuz_uid) { if($spageviews >= $pvfrequence) { $pageviewsadd = ', pageviews=\'0\''; $db->query("UPDATE {$tablepre}members SET pageviews=pageviews+'$spageviews' WHERE uid='$discuz_uid'", 'UNBUFFERED'); } else { $pageviewsadd = ', pageviews=pageviews+1'; } } else { $pageviewsadd = ''; } $db->query("UPDATE {$tablepre}sessions SET uid='$discuz_uid', username='$discuz_user', groupid='$groupid', styleid='$styleid', invisible='$invisible', action='$discuz_action', lastactivity='$timestamp', lastolupdate='$lastolupdate', seccode='$seccode', fid='$fid', tid='$tid' $pageviewsadd WHERE sid='$sid'"); } else { $ips = explode('.', $onlineip); $db->query("DELETE FROM {$tablepre}sessions WHERE sid='$sid' OR lastactivity<($timestamp-$onlinehold) OR ('$discuz_uid'<>'0' AND uid='$discuz_uid') OR (uid='0' AND ip1='$ips[0]' AND ip2='$ips[1]' AND ip3='$ips[2]' AND ip4='$ips[3]' AND lastactivity>$timestamp-60)"); $db->query("INSERT INTO {$tablepre}sessions (sid, ip1, ip2, ip3, ip4, uid, username, groupid, styleid, invisible, action, lastactivity, lastolupdate, seccode, fid, tid) VALUES ('$sid', '$ips[0]', '$ips[1]', '$ips[2]', '$ips[3]', '$discuz_uid', '$discuz_user', '$groupid', '$styleid', '$invisible', '$discuz_action', '$timestamp', '$lastolupdate', '$seccode', '$fid', '$tid')", 'SILENT'); if($discuz_uid && $timestamp - $lastactivity > 21600) { if($oltimespan && $timestamp - $lastactivity > 86400) { $query = $db->query("SELECT total FROM {$tablepre}onlinetime WHERE uid='$discuz_uid'"); $oltimeadd = ', oltime='.round(intval($db->result($query, 0)) / 60); } else { $oltimeadd = ''; } $db->query("UPDATE {$tablepre}members SET lastip='$onlineip', lastvisit=lastactivity, lastactivity='$timestamp' $oltimeadd WHERE uid='$discuz_uid'", 'UNBUFFERED'); } } $sessionupdated = 1; } function updatemodworks($modaction, $posts = 1) { global $modworkstatus, $db, $tablepre, $discuz_uid, $timestamp, $_DCACHE; $today = gmdate('Y-m-d', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600); if($modworkstatus && $modaction && $posts) { $db->query("UPDATE {$tablepre}modworks SET count=count+1, posts=posts+'$posts' WHERE uid='$discuz_uid' AND modaction='$modaction' AND dateline='$today'"); if(!$db->affected_rows()) { $db->query("INSERT INTO {$tablepre}modworks (uid, modaction, dateline, count, posts) VALUES ('$discuz_uid', '$modaction', '$today', 1, '$posts')"); } } } function updateannouncements($threadarray) { global $db, $tablepre, $discuz_user, $timestamp; if($threadarray && is_array($threadarray)) { $endtime = $timestamp + 3600; foreach($threadarray as $thread) { $db->query("INSERT INTO {$tablepre}announcements (author, subject, type, starttime, endtime, message) VALUES ('$discuz_user', '$thread[subject]', 1, '$timestamp', '$endtime', '$thread[url]')"); } } } function writelog($file, $log) { global $timestamp, $_DCACHE; $yearmonth = gmdate('Ym', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600); $logdir = DISCUZ_ROOT.'./forumdata/logs/'; $logfile = $logdir.$yearmonth.'_'.$file.'.php'; if(@filesize($logfile) > 2048000) { $dir = opendir($logdir); $length = strlen($file); $maxid = $id = 0; while($entry = readdir($dir)) { if(strexists($entry, $yearmonth.'_'.$file)) { $id = intval(substr($entry, $length + 8, -4)); $id > $maxid && $maxid = $id; } } closedir($dir); $logfilebak = $logdir.$yearmonth.'_'.$file.'_'.($maxid + 1).'.php'; @rename($logfile, $logfilebak); } if($fp = @fopen($logfile, 'a')) { @flock($fp, 2); $log = is_array($log) ? $log : array($log); foreach($log as $tmp) { fwrite($fp, "<?PHP exit;?>\t".str_replace(array('<?', '?>'), '', $tmp)."\n"); } fclose($fp); } } function wipespecial($str) { return str_replace(array( "\n", "\r", '..'), array('', '', ''), $str); } function discuz_uc_avatar($uid, $size = '', $returnsrc = FALSE) { if($uid > 0) { $size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle'; $uid = abs(intval($uid)); if(empty($GLOBALS['avatarmethod'])) { return $returnsrc ? UC_API.'/avatar.php?uid='.$uid.'&size='.$size : '<img src="'.UC_API.'/avatar.php?uid='.$uid.'&size='.$size.'" />'; } else { $uid = sprintf("%09d", $uid); $dir1 = substr($uid, 0, 3); $dir2 = substr($uid, 3, 2); $dir3 = substr($uid, 5, 2); $file = UC_API.'/data/avatar/'.$dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2).'_avatar_'.$size.'.jpg'; return $returnsrc ? $file : '<img src="'.$file.'" onerror="this.onerror=null;this.src=\''.UC_API.'/images/noavatar_'.$size.'.gif\'" />'; } } else { $file = $GLOBALS['boardurl'].IMGDIR.'/syspm.gif'; return $returnsrc ? $file : '<img src="'.$file.'" />'; } } 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; } function swapclass($classname) { global $swapc; $swapc = isset($swapc) && $swapc != $classname ? $classname : ''; return $swapc; } function hookscript($script, $type = 'funcs', $param = array()) { global $hookscript, $pluginhooks, $pluginclasses, $pluginlangs, $adminid, $scriptlang; foreach($hookscript[$script]['module'] as $identifier => $include) { $hooksadminid[$identifier] = !$hookscript[$script]['adminid'][$identifier] || ($hookscript[$script]['adminid'][$identifier] && $adminid > 0 && $hookscript[$script]['adminid'][$identifier] >= $adminid); if($hooksadminid[$identifier]) { if(@in_array($identifier, $pluginlangs)) { @include_once DISCUZ_ROOT.'./forumdata/cache/cache_scriptlang.php'; } @include_once DISCUZ_ROOT.'./plugins/'.$include.'.class.php'; } } if(is_array($hookscript[$script][$type])) { foreach($hookscript[$script][$type] as $hookkey => $hookfuncs) { foreach($hookfuncs as $hookfunc) { if($hooksadminid[$hookfunc[0]]) { if(!isset($pluginclasses[$hookfunc[0]])) { eval('$pluginclasses[$hookfunc[0]] = new plugin_'.$hookfunc[0].';'); } eval('$return = $pluginclasses[$hookfunc[0]]->'.$hookfunc[1].'($param);'); if(is_array($return)) { foreach($return as $k => $v) { $pluginhooks[$hookkey][$k] .= $v; } } else { $pluginhooks[$hookkey] .= $return; } } } } } } function hookscriptoutput($tplfile) { global $hookscript, $hookscriptmessage; if(isset($hookscript['global']['module'])) { hookscript('global'); } if(isset($hookscript[CURSCRIPT]['outputfuncs'])) { hookscript(CURSCRIPT, 'outputfuncs', array('template' => $tplfile, 'message' => $hookscriptmessage)); } } function updateprompt($key, $uid, $number, $updatedb = 1) { global $db, $tablepre, $prompts; $prompts = $prompts ? $prompts : $GLOBALS['_DCACHE']['settings']['prompts']; if($updatedb) { if($number) { $db->query("REPLACE INTO {$tablepre}prompt (uid, typeid, number) VALUES ('$uid', '".$prompts[$key]['id']."', '$number')"); $db->query("UPDATE {$tablepre}members SET prompt=prompt|1 WHERE uid='$uid'", 'UNBUFFERED'); } else { $db->query("DELETE FROM {$tablepre}prompt WHERE uid='$uid' AND typeid='".$prompts[$key]['id']."'"); if(!$db->result_first("SELECT count(*) FROM {$tablepre}prompt WHERE uid='$uid'")) { $db->query("UPDATE {$tablepre}members SET prompt=prompt^1 WHERE uid='$discuz_uid' AND prompt=prompt|1", 'UNBUFFERED'); } } } return '$(\'prompt_'.$key.'\').innerHTML=\''.$prompts[$key]['name'].($number ? ' ('.$number.')\';$(\'prompt_'.$key.'\').parentNode.style.display=\'\';' : '\';'); } function manyoulog($type, $uid, $action, $fuid = 0) { if(!$GLOBALS['my_status'] || !in_array($type, array('user', 'friend')) || !in_array($action, array('add', 'update', 'delete'))) { return; } $logfile = DISCUZ_ROOT.'./forumdata/logs/manyou_'.$type.'.log'; if($fp = @fopen($logfile, 'a')) { @flock($fp, 2); $uids = !is_array($uid) ? array($uid) : $uid; $fuid = intval($fuid); foreach($uids as $uid) { fwrite($fp, "<?PHP exit;?>\t".$GLOBALS['timestamp']."\t".$uid."\t".$action.($fuid ? "\t".$fuid : '')."\n"); } fclose($fp); } } function add_feed($arg, $data, $template = '') { global $tablepre, $db, $timestamp; $type = 'default'; $fid = 0; $typeid = 0; $sortid = 0; $appid = ''; $uid = 0; $username = ''; extract($arg, EXTR_OVERWRITE); if(empty($data['title'])) { return false; } if($uid && in_array($type, array('thread_views', 'thread_replies', 'thread_rate', 'post_rate', 'user_credit', 'user_threads', 'user_posts', 'user_digest'))) { include language('notice'); $title_template = $language[$type]; $body_template = $language[$type]; $noticemsg['title'] = transval($title_template, $data['title']); $noticemsg['body'] = transval($body_template, $data['body']); $message = $noticemsg['title']; if($noticemsg['body']) { $message .= '<br /><br />'.$noticemsg['body']; } if(in_array($type, array('thread_views', 'thread_replies', 'thread_rate', 'post_rate'))) { sendnotice($uid, $message, 'threads'); } else { sendnotice($uid, $message, 'systempm'); } } $db->query("INSERT INTO {$tablepre}feeds (type, fid, typeid, sortid, appid, uid, username, data, template, dateline) VALUES ('$type', '$fid', '$typeid', '$sortid', '$appid', '$uid', '$username', '".addslashes(serialize($data))."', '".addslashes(serialize($template))."', '$timestamp')"); return $db->insert_id(); } function get_feed($conf = array()) { global $tablepre, $db, $timestamp; $where = '1'; $page_url = ''; if(empty($conf['type'])) { $where .= " AND type != 'manyou'"; } elseif($conf['type'] = trim($conf['type'])) { $where .= " AND type='$conf[type]'"; $page_url .= "type={$conf[type]}&"; } if($conf['fid'] = intval($conf['fid'])) { $where .= " AND fid='$conf[fid]'"; $page_url .= "fid={$conf[fid]}&"; } if($conf['typeid'] = intval($conf['typeid'])) { $where .= " AND typeid='$conf[typeid]'"; $page_url .= "typeid={$conf[typeid]}&"; } if($conf['sortid'] = intval($conf['sortid'])) { $where .= " AND sortid='$conf[sortid]'"; $page_url .= "sortid={$conf[sortid]}&"; } if(!empty($conf['uid']) && is_array($conf['uid'])) { $where .= " AND uid IN (".implodeids($conf['uid']).")"; } elseif($conf['uid'] = intval($conf['uid'])) { $where .= " AND uid='$conf[uid]'"; $page_url .= "uid={$conf[uid]}&"; } if(!empty($conf['appid']) && is_array($conf['appid'])) { $where .= " AND appid IN (".implodeids($conf['appid']).")"; } $conf['num'] = empty($conf['num']) ? 3 : intval($conf['num']); if($conf['multipage']) { $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1; $start_limit = ($page - 1) * $conf['num']; } else { $start_limit = 0; } $sql = "SELECT * FROM {$tablepre}feeds WHERE $where ORDER BY feed_id DESC LIMIT $start_limit, $conf[num]"; $nocache = true; if($conf['cachelife'] = intval($conf['cachelife'])) { $cache_file = DISCUZ_ROOT.'./forumdata/feedcaches/'.md5($sql); $nocache = !file_exists($cache_file) || (filemtime($cache_file) < $timestamp - $conf['cachelife']); } if($nocache) { include language('dz_feeds'); $feedlist = array(); $feedlist['data'] = array(); if($conf['multipage']) { $feeds = $db->result_first("SELECT COUNT(*) FROM {$tablepre}feeds WHERE $where"); $page_url = $page_url ? (strpos($conf['page_url'], '?') ? $conf['page_url'].'&'.$page_url : $conf['page_url'].'?'.$page_url) : $conf['page_url']; $feedlist['multipage'] = multi($feeds, $conf['num'], $page, $page_url); } $query = $db->query($sql); while($row = $db->fetch_array($query)) { $row['data'] = unserialize($row['data']); $row['template'] = empty($row['template']) ? array() : unserialize($row['template']); $title_template = empty($row['template']['title']) ? $language['feed_'.$row['type'].'_title'] : $row['template']['title']; $body_template = empty($row['template']['body']) ? $language['feed_'.$row['type'].'_body'] : $row['template']['body']; $feed = array(); $feed['title'] = transval($title_template, $row['data']['title']); $feed['body'] = transval($body_template, $row['data']['body']); $feed['dbdateline'] = $row['dateline']; $feed['dateline'] = dgmdate($GLOBALS['timeformat'], $row['dateline'] + $GLOBALS['timeoffset'] * 3600); $feed['image'] = array(); if(is_array($row['data']['image'])) foreach($row['data']['image'] as $val) { $feed['image'][] = '<a href="'.$val['link'].'" target="_blank"><img src="'.$val['src'].'" /></a>'; } $feed['icon'] = 'images/feeds/'.$row['type'].'.gif'; $feed['appid'] = $row['appid']; $feed['uid'] = $row['uid']; $feed['username'] = $row['username']; $feedlist['data'][$row['feed_id']] = $feed; } if($conf['cachelife']) { if($fp = @fopen($cache_file, 'w')) { flock($fp, LOCK_EX); fwrite($fp, serialize($feedlist)); } @fclose($fp); @chmod(CACHE_FILE, 0777); } } else { $feedlist = unserialize(file_get_contents($cache_file)); } return $feedlist; } function transval($template, $data) { if(empty($template) || empty($data)) return; $trans = array(); foreach($data as $key => $val) { $trans['{'.$key.'}'] = $val; } return strtr($template, $trans); } function stat_code($scriptpath = '', $imgcode = 0) { if(!defined('STAT_DISABLED') && STAT_ID > 0 && !IS_ROBOT) { $statserver = 'http://stat.discuz.com/'; if(!defined('CACHE_FILE') || $GLOBALS['discuz_uid']) { $url = $statserver.'stat.php?q='.rawurlencode(base64_encode(stat_query('', '', '', $scriptpath))); echo !$imgcode ? '<script type="text/javascript" src="'.$url.'" reload="1"></script>' : '<img src="'.$url.'&amp;img=1" />'; $statlogold = DISCUZ_ROOT.'./forumdata/stat.log'; if(file_exists($statlogold)) { $statlogfile = DISCUZ_ROOT.'./forumdata/stat.log.'.random(3); @rename($statlogold, $statlogfile); if(($logs = @file($statlogfile)) !== FALSE && is_array($logs)) { foreach($logs as $log) { if($log) { $url = $statserver.'stat.php?q='.rawurlencode(base64_encode(trim($log))); echo !$imgcode ? '<script type="text/javascript" src="'.$url.'" reload="1"></script>' : '<img src="'.$url.'&amp;img=1" />'; } } } @unlink($statlogfile); } } else { echo '<script type="text/javascript" src="'.$statserver.'stat.php" reload="1"></script>'; echo '<script text="text/javascript" reload="1"> if(window.addEventListener) { window.addEventListener("load", function () {document.body.stat("", "'.$GLOBALS['BASESCRIPT'].'")}, false); } else if(document.attachEvent) { window.attachEvent("onload", function () {document.body.stat("", "'.$GLOBALS['BASESCRIPT'].'")}); } </script>'; } } } function stat_query($message = '', $query = '', $referer = '', $scriptpath = '', $script = '') { preg_match("/(Netscape|Lynx|Opera|Konqueror|MSIE|Firefox|Safari|Chrome)[\/\s]([\.\d]+)/", $_SERVER['HTTP_USER_AGENT'], $a); empty($a[1]) && preg_match("/Mozilla[\/\s]([\.\d]+)/", $_SERVER['HTTP_USER_AGENT'], $a); $query = array( 'siteid' => STAT_ID, 'timestamp' => $GLOBALS['timestamp'], 'sid' => $GLOBALS['sid'], 'uid' => $GLOBALS['discuz_uid'], 'ip' => $GLOBALS['onlineip'], 'script' => !$script ? $scriptpath.basename($_SERVER['SCRIPT_NAME']) : $script, 'query' => !$query ? $_SERVER['QUERY_STRING'] : $query, 'referer' => !$referer ? $_SERVER['HTTP_REFERER'] : $referer, 'message' => !$message ? '' : $message, 'succeed' => !$message ? '' : (strpos($message, 'succeed') !== FALSE ? 1 : 0), 'browser' => !empty($a[1]) ? $a[1].'/'.$a[2] : 'Other', ); $s = ''; foreach($query as $k => $v) { trim($v) !== '' && $s .= '&'.$k.'='.rawurlencode($v); } return substr($s, 1); } function write_statlog($message = '', $query = '', $referer = '', $scriptpath = '', $script = '') { if(defined('STAT_ID') && STAT_ID > 0) { $statlogfile = DISCUZ_ROOT.'./forumdata/stat.log'; if($fp = @fopen($statlogfile, 'a')) { @flock($fp, 2); fwrite($fp, stat_query($message, $query, $referer, $scriptpath, $script)."\n"); fclose($fp); } } } function funcstat($funcinfo = '', $scriptpath = '', $imgcode = 0) { global $_DCACHE, $funcstatinfo; $funcsiteid = $_DCACHE['settings']['funcsiteid']; $funckey = $_DCACHE['settings']['funckey']; $funcinfo = empty($funcinfo) ? $funcstatinfo : $funcinfo; if(is_array($funcinfo)) { $funcinfo = array_unique($funcinfo); foreach($funcinfo as $finfo) { funcstat($finfo); } } else { list($funcmark, $funcversion) = explode(',', $funcinfo); if($funcsiteid && $funckey && $funcmark && $funcversion && !IS_ROBOT) { $statserver = 'http://stat.discuz.com/func/'; if(!defined('CACHE_FILE') || $GLOBALS['discuz_uid']) { $url = $statserver.'funcstat.php?q='.rawurlencode(base64_encode(funcstat_query($funcinfo,'', '', '', $scriptpath))); echo !$imgcode ? '<script type="text/javascript" src="'.$url.'" reload="1"></script>' : '<img src="'.$url.'&amp;img=1" />'; $statlogold = DISCUZ_ROOT.'./forumdata/funcstat.log'; if(file_exists($statlogold)) { $statlogfile = DISCUZ_ROOT.'./forumdata/funcstat.log.'.random(3); @rename($statlogold, $statlogfile); if(($logs = @file($statlogfile)) !== FALSE && is_array($logs)) { foreach($logs as $log) { if($log) { $url = $statserver.'funcstat.php?q='.rawurlencode(base64_encode(trim($log))); echo !$imgcode ? '<script type="text/javascript" src="'.$url.'" reload="1"></script>' : '<img src="'.$url.'&amp;img=1" />'; } } } @unlink($statlogfile); } } } } } function funcstat_query($funcinfo, $message = '', $query = '', $referer = '', $scriptpath = '', $script = '') { preg_match("/(Netscape|Lynx|Opera|Konqueror|MSIE|Firefox|Safari|Chrome)[\/\s]([\.\d]+)/", $_SERVER['HTTP_USER_AGENT'], $a); empty($a[1]) && preg_match("/Mozilla[\/\s]([\.\d]+)/", $_SERVER['HTTP_USER_AGENT'], $a); if(empty($funcinfo)) { return; } list($funcmark, $funcversion) = explode(',', $funcinfo); $query = array( 'funcmark' => $funcmark, 'funcversion' => $funcversion, 'siteid' => $GLOBALS['_DCACHE']['settings']['funcsiteid'], 'timestamp' => $GLOBALS['timestamp'], 'sid' => $GLOBALS['sid'], 'uid' => $GLOBALS['discuz_uid'], 'ip' => $GLOBALS['onlineip'], 'script' => !$script ? $scriptpath.basename($_SERVER['SCRIPT_NAME']) : $script, 'query' => !$query ? $_SERVER['QUERY_STRING'] : $query, 'referer' => !$referer ? $_SERVER['HTTP_REFERER'] : $referer, 'message' => !$message ? '' : $message, 'succeed' => !$message ? '' : (strpos($message, 'succeed') !== FALSE ? 1 : 0), 'browser' => !empty($a[1]) ? $a[1].'/'.$a[2] : 'Other', ); if($GLOBALS['adminid'] == 1) { $query['adminid'] = 1; } if($GLOBALS['discuz_uid']) { $mq = $GLOBALS['db']->query("SELECT gender,regdate,bday,groupid,lastvisit,lastactivity,lastpost,posts FROM {$GLOBALS[tablepre]}members WHERE uid='$GLOBALS[discuz_uid]'"); $m = $GLOBALS['db']->fetch_array($mq); foreach($m as $k => $v) { $query[$k] = $v; } } $s = ''; foreach($query as $k => $v) { trim($v) !== '' && $s .= '&'.$k.'='.rawurlencode($v); } return substr($s, 1); } function setstatus($position, $value, $baseon = null) { $t = pow(2, $position - 1); if($value) { $t = $baseon | $t; } elseif ($baseon !== null) { $t = $baseon & ~$t; } else { $t = ~$t; } return $t & 0xFFFF; } function getstatus($status, $position) { $t = $status & pow(2, $position - 1) ? 1 : 0; return $t; } function buildbitsql($fieldname, $position, $value) { $t = " `$fieldname`=`$fieldname`"; if($value) { $t .= ' | '.setstatus($position, 1); } else { $t .= ' & '.setstatus($position, 0); } return $t.' '; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/global.func.php
PHP
asf20
70,361
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: ftp.func.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function dftp_connect($ftphost, $ftpuser, $ftppass, $ftppath, $ftpport = 21, $ftpssl = 0, $silent = 0) { global $ftp; @set_time_limit(0); $ftphost = wipespecial($ftphost); $ftpport = intval($ftpport); $ftpssl = intval($ftpssl); $ftp['timeout'] = intval($ftp['timeout']); $func = $ftpssl && function_exists('ftp_ssl_connect') ? 'ftp_ssl_connect' : 'ftp_connect'; if($func == 'ftp_connect' && !function_exists('ftp_connect')) { if($silent) { return -4; } else { errorlog('FTP', "FTP not supported.", 0); } } if($ftp_conn_id = @$func($ftphost, $ftpport, 20)) { if($ftp['timeout'] && function_exists('ftp_set_option')) { @ftp_set_option($ftp_conn_id, FTP_TIMEOUT_SEC, $ftp['timeout']); } if(dftp_login($ftp_conn_id, $ftpuser, $ftppass)) { if($ftp['pasv']) { dftp_pasv($ftp_conn_id, TRUE); } if(dftp_chdir($ftp_conn_id, $ftppath)) { return $ftp_conn_id; } else { if($silent) { return -3; } else { errorlog('FTP', "Chdir '$ftppath' error.", 0); } } } else { if($silent) { return -2; } else { errorlog('FTP', '530 Not logged in.', 0); } } } else { if($silent) { return -1; } else { errorlog('FTP', "Couldn't connect to $ftphost:$ftpport.", 0); } } dftp_close($ftp_conn_id); return -1; } function dftp_mkdir($ftp_stream, $directory) { $directory = wipespecial($directory); return @ftp_mkdir($ftp_stream, $directory); } function dftp_rmdir($ftp_stream, $directory) { $directory = wipespecial($directory); return @ftp_rmdir($ftp_stream, $directory); } function dftp_put($ftp_stream, $remote_file, $local_file, $mode, $startpos = 0 ) { $remote_file = wipespecial($remote_file); $local_file = wipespecial($local_file); $mode = intval($mode); $startpos = intval($startpos); return @ftp_put($ftp_stream, $remote_file, $local_file, $mode, $startpos); } function dftp_size($ftp_stream, $remote_file) { $remote_file = wipespecial($remote_file); return @ftp_size($ftp_stream, $remote_file); } function dftp_close($ftp_stream) { return @ftp_close($ftp_stream); } function dftp_delete($ftp_stream, $path) { $path = wipespecial($path); return @ftp_delete($ftp_stream, $path); } function dftp_get($ftp_stream, $local_file, $remote_file, $mode, $resumepos = 0) { $remote_file = wipespecial($remote_file); $local_file = wipespecial($local_file); $mode = intval($mode); $resumepos = intval($resumepos); return @ftp_get($ftp_stream, $local_file, $remote_file, $mode, $resumepos); } function dftp_login($ftp_stream, $username, $password) { $username = wipespecial($username); $password = str_replace(array("\n", "\r"), array('', ''), $password); return @ftp_login($ftp_stream, $username, $password); } function dftp_pasv($ftp_stream, $pasv) { $pasv = intval($pasv); return @ftp_pasv($ftp_stream, $pasv); } function dftp_chdir($ftp_stream, $directory) { $directory = wipespecial($directory); return @ftp_chdir($ftp_stream, $directory); } function dftp_site($ftp_stream, $cmd) { $cmd = wipespecial($cmd); return @ftp_site($ftp_stream, $cmd); } function dftp_chmod($ftp_stream, $mode, $filename) { $mode = intval($mode); $filename = wipespecial($filename); if(function_exists('ftp_chmod')) { return @ftp_chmod($ftp_stream, $mode, $filename); } else { return dftp_site($ftp_stream, 'CHMOD '.$mode.' '.$filename); } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/ftp.func.php
PHP
asf20
3,711
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: discuzcode.func.php 21257 2009-11-23 08:21:38Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } include template('discuzcode'); $discuzcodes = array( 'pcodecount' => -1, 'codecount' => 0, 'codehtml' => '', 'smiliesreplaced' => 0, 'seoarray' => array( 0 => '', 1 => $_SERVER['HTTP_HOST'], 2 => $bbname, 3 => $seotitle, 4 => $seokeywords, 5 => $seodescription ) ); $authorreplyexist = ''; if(!isset($_DCACHE['bbcodes']) || !is_array($_DCACHE['bbcodes']) || !is_array($_DCACHE['smilies'])) { @include DISCUZ_ROOT.'./forumdata/cache/cache_bbcodes.php'; } mt_srand((double)microtime() * 1000000); function attachtag($pid, $aid, &$postlist) { return attachinpost($postlist[$pid]['attachments'][$aid]); } function censor($message) { global $_DCACHE, $posts; require_once(DISCUZ_ROOT.'/forumdata/cache/cache_censor.php'); if($_DCACHE['censor']['banned']) { $bbcodes = 'b|i|u|color|size|font|align|list|indent|url|email|hide|quote|code|free|table|tr|td|img|swf|attach|payto|float'.($_DCACHE['bbcodes_display'] ? '|'.implode('|', array_keys($_DCACHE['bbcodes_display'])) : ''); if(preg_match($_DCACHE['censor']['banned'], @preg_replace(array("/\[($bbcodes)=?.*\]/iU", "/\[\/($bbcodes)\]/i"), '', $message))) { showmessage('word_banned'); } } return empty($_DCACHE['censor']['filter']) ? $message : @preg_replace($_DCACHE['censor']['filter']['find'], $_DCACHE['censor']['filter']['replace'], $message); } function censormod($message) { global $_DCACHE, $posts; require_once(DISCUZ_ROOT.'/forumdata/cache/cache_censor.php'); if($_DCACHE['censor']['mod']) { if(preg_match($_DCACHE['censor']['mod'], $message)) { return TRUE; } } return FALSE; } function creditshide($creditsrequire, $message, $pid) { global $hideattach; if($GLOBALS['credits'] >= $creditsrequire || $GLOBALS['forum']['ismoderator']) { return tpl_hide_credits($creditsrequire, str_replace('\\"', '"', $message)); } else { return tpl_hide_credits_hidden($creditsrequire); } } function codedisp($code) { global $discuzcodes; $discuzcodes['pcodecount']++; $code = dhtmlspecialchars(str_replace('\\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code))); $code = str_replace("\n", "<li>", $code); $discuzcodes['codehtml'][$discuzcodes['pcodecount']] = tpl_codedisp($discuzcodes, $code); $discuzcodes['codecount']++; return "[\tDISCUZ_CODE_$discuzcodes[pcodecount]\t]"; } function karmaimg($rate, $ratetimes) { $karmaimg = ''; if($rate && $ratetimes) { $image = $rate > 0 ? 'agree.gif' : 'disagree.gif'; for($i = 0; $i < ceil(abs($rate) / $ratetimes); $i++) { $karmaimg .= '<img src="'.IMGDIR.'/'.$image.'" border="0" alt="" />'; } } return $karmaimg; } function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0) { global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach, $allowattachurl; if($parsetype != 1 && !$bbcodeoff && $allowbbcode && (strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) { $message = preg_replace("/\s?\[code\](.+?)\[\/code\]\s?/ies", "codedisp('\\1')", $message); } $msglower = strtolower($message); //$htmlon = $htmlon && $allowhtml ? 1 : 0; if(!$htmlon) { $message = $jammer ? preg_replace("/\r\n|\n|\r/e", "jammer()", dhtmlspecialchars($message)) : dhtmlspecialchars($message); } if(!$smileyoff && $allowsmilies && !empty($GLOBALS['_DCACHE']['smilies']) && is_array($GLOBALS['_DCACHE']['smilies'])) { if(!$discuzcodes['smiliesreplaced']) { foreach($GLOBALS['_DCACHE']['smilies']['replacearray'] AS $key => $smiley) { $GLOBALS['_DCACHE']['smilies']['replacearray'][$key] = '<img src="images/smilies/'.$GLOBALS['_DCACHE']['smileytypes'][$GLOBALS['_DCACHE']['smilies']['typearray'][$key]]['directory'].'/'.$smiley.'" smilieid="'.$key.'" border="0" alt="" />'; } $discuzcodes['smiliesreplaced'] = 1; } $message = preg_replace($GLOBALS['_DCACHE']['smilies']['searcharray'], $GLOBALS['_DCACHE']['smilies']['replacearray'], $message, $maxsmilies); } if($allowattachurl && strpos($msglower, 'attach://') !== FALSE) { $message = preg_replace("/attach:\/\/(\d+)\.?(\w*)/ie", "parseattachurl('\\1', '\\2')", $message); } if(!$bbcodeoff && $allowbbcode) { if(strpos($msglower, '[/url]') !== FALSE) { $message = preg_replace("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/|www\.|mailto:)([^\s\[\"']+?))?\](.+?)\[\/url\]/ies", "parseurl('\\1', '\\5')", $message); } if(strpos($msglower, '[/email]') !== FALSE) { $message = preg_replace("/\[email(=([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+))?\](.+?)\[\/email\]/ies", "parseemail('\\1', '\\4')", $message); } $message = str_replace(array( '[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[/p]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', '[*]', '[/list]', '[indent]', '[/indent]', '[/float]' ), array( '</font>', '</font>', '</font>', '</p>', '<strong>', '</strong>', '<strike>', '</strike>', '<hr class="solidline" />', '</p>', '<i class="pstatus">', '<i>', '</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">', '<ul type="A" class="litype_3">', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>' ), preg_replace(array( "/\[color=([#\w]+?)\]/i", "/\[size=(\d+?)\]/i", "/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/i", "/\[font=([^\[\<]+?)\]/i", "/\[align=(left|center|right)\]/i", "/\[p=(\d{1,2}), (\d{1,2}), (left|center|right)\]/i", "/\[float=(left|right)\]/i" ), array( "<font color=\"\\1\">", "<font size=\"\\1\">", "<font style=\"font-size: \\1\">", "<font face=\"\\1 \">", "<p align=\"\\1\">", "<p style=\"line-height: \\1px; text-indent: \\2em; text-align: \\3;\">", "<span style=\"float: \\1;\">" ), $message)); $nest = 0; while(strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE){ $message = preg_replace("/\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*(.+?)\s*\[\/table\]/ies", "parsetable('\\1', '\\2', '\\3')", $message); if(++$nest > 4) break; } if($parsetype != 1) { if(strpos($msglower, '[/quote]') !== FALSE) { $message = preg_replace("/\s?\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s?/is", tpl_quote(), $message); } if(strpos($msglower, '[/free]') !== FALSE) { $message = preg_replace("/\s*\[free\][\n\r]*(.+?)[\n\r]*\[\/free\]\s*/is", tpl_free(), $message); } } if(strpos($msglower, '[/media]') !== FALSE) { $message = preg_replace("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/ies", $allowmediacode ? "parsemedia('\\1', '\\2')" : "bbcodeurl('\\2', '<a href=\"%s\" target=\"_blank\">%s</a>')", $message); } if($allowmediacode && strpos($msglower, '[/audio]') !== FALSE) { $message = preg_replace("/\[audio\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/ies", "parseaudio('\\1')", $message); } if($allowmediacode && strpos($msglower, '[/flash]') !== FALSE) { $message = preg_replace("/\[flash\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/is", "<script type=\"text/javascript\" reload=\"1\">document.write(AC_FL_RunContent('width', '550', 'height', '400', 'allowNetworking', 'internal', 'allowScriptAccess', 'never', 'src', '\\1', 'quality', 'high', 'bgcolor', '#ffffff', 'wmode', 'transparent', 'allowfullscreen', 'true'));</script>", $message); } if($parsetype != 1 && $allowbbcode == 2 && $GLOBALS['_DCACHE']['bbcodes']) { $message = preg_replace($GLOBALS['_DCACHE']['bbcodes']['searcharray'], $GLOBALS['_DCACHE']['bbcodes']['replacearray'], $message); } if($parsetype != 1 && strpos($msglower, '[/hide]') !== FALSE) { if(strpos($msglower, '[hide]') !== FALSE) { if($GLOBALS['authorreplyexist'] === '') { $GLOBALS['authorreplyexist'] = !$GLOBALS['forum']['ismoderator'] ? $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND ".($discuz_uid ? "authorid='$discuz_uid'" : "authorid=0 AND useip='$GLOBALS[onlineip]'")." LIMIT 1") : TRUE; } if($GLOBALS['authorreplyexist']) { $message = preg_replace("/\[hide\]\s*(.+?)\s*\[\/hide\]/is", tpl_hide_reply(), $message); } else { $message = preg_replace("/\[hide\](.+?)\[\/hide\]/is", tpl_hide_reply_hidden(), $message); $message .= '<script type="text/javascript">replyreload += \',\' + '.$pid.';</script>'; } } if(strpos($msglower, '[hide=') !== FALSE) { $message = preg_replace("/\[hide=(\d+)\]\s*(.+?)\s*\[\/hide\]/ies", "creditshide(\\1,'\\2', $pid)", $message); } } } if(!$bbcodeoff) { if($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) { $message = preg_replace("/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/ies", "bbcodeurl('\\1', ' <img src=\"images/attachicons/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"%s\" target=\"_blank\">Flash: %s</a> ')", $message); } if(strpos($msglower, '[/img]') !== FALSE) { $message = preg_replace(array( "/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies", "/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies" ), $allowimgcode ? array( "bbcodeurl('\\1', '<img src=\"%s\" onload=\"thumbImg(this)\" alt=\"\" />')", "parseimg('\\1', '\\2', '\\3')" ) : array( "bbcodeurl('\\1', '<a href=\"%s\" target=\"_blank\">%s</a>')", "bbcodeurl('\\3', '<a href=\"%s\" target=\"_blank\">%s</a>')" ), $message); } } for($i = 0; $i <= $discuzcodes['pcodecount']; $i++) { $message = str_replace("[\tDISCUZ_CODE_$i\t]", $discuzcodes['codehtml'][$i], $message); } if($highlight) { $highlightarray = explode('+', $highlight); $sppos = strrpos($message, chr(0).chr(0).chr(0)); if($sppos !== FALSE) { $specialextra = substr($postlist[$firstpid]['message'], $sppos + 3); $message = substr($message, 0, $sppos); } $message = preg_replace(array("/(^|>)([^<]+)(?=<|$)/sUe", "/<highlight>(.*)<\/highlight>/siU"), array("highlight('\\2', \$highlightarray, '\\1')", "<strong><font color=\"#FF0000\">\\1</font></strong>"), $message); if($sppos !== FALSE) { $message = $message.chr(0).chr(0).chr(0).$specialextra; } } unset($msglower); return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $message)); } function parseurl($url, $text) { if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) { $url = $matches[0]; $length = 65; if(strlen($url) > $length) { $text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3)); } return '<a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>'; } else { $url = substr($url, 1); if(substr(strtolower($url), 0, 4) == 'www.') { $url = 'http://'.$url; } return '<a href="'.$url.'" target="_blank">'.$text.'</a>'; } } function parseattachurl($aid, $ext) { $GLOBALS['skipaidlist'][] = $aid; return $GLOBALS['boardurl'].'attachment.php?aid='.aidencode($aid).($ext ? '&request=yes&_f=.'.$ext : ''); } function parseemail($email, $text) { if(!$email && preg_match("/\s*([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+)\s*/i", $text, $matches)) { $email = trim($matches[0]); return '<a href="mailto:'.$email.'">'.$email.'</a>'; } else { return '<a href="mailto:'.substr($email, 1).'">'.$text.'</a>'; } } function parsetable($width, $bgcolor, $message) { if(!preg_match("/^\[tr(?:=([\(\)%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/", $message) && !preg_match("/^<tr[^>]*?>\s*<td[^>]*?>/", $message)) { return str_replace('\\"', '"', preg_replace("/\[tr(?:=([\(\)%,#\w]+))?\]|\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]|\[\/td\]|\[\/tr\]/", '', $message)); } if(substr($width, -1) == '%') { $width = substr($width, 0, -1) <= 98 ? intval($width).'%' : '98%'; } else { $width = intval($width); $width = $width ? ($width <= 560 ? $width.'px' : '98%') : ''; } return '<table cellspacing="0" class="t_table" '. ($width == '' ? NULL : 'style="width:'.$width.'"'). ($bgcolor ? ' bgcolor="'.$bgcolor.'">' : '>'). str_replace('\\"', '"', preg_replace(array( "/\[tr(?:=([\(\)%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ie", "/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ie", "/\[\/td\]\s*\[\/tr\]\s*/i" ), array( "parsetrtd('\\1', '\\2', '\\3', '\\4')", "parsetrtd('td', '\\1', '\\2', '\\3')", '</td></tr>' ), $message) ).'</table>'; } function parsetrtd($bgcolor, $colspan, $rowspan, $width) { return ($bgcolor == 'td' ? '</td>' : '<tr'.($bgcolor ? ' bgcolor="'.$bgcolor.'"' : '').'>').'<td'.($colspan > 1 ? ' colspan="'.$colspan.'"' : '').($rowspan > 1 ? ' rowspan="'.$rowspan.'"' : '').($width ? ' width="'.$width.'"' : '').'>'; } function parseaudio($url, $width = 400, $autostart = 0) { $ext = strtolower(substr(strrchr($url, '.'), 1, 5)); switch($ext) { case 'mp3': case 'wma': case 'mid': case 'wav': return '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'.$width.'" height="64"><param name="invokeURLs" value="0"><param name="autostart" value="'.$autostart.'" /><param name="url" value="'.$url.'" /><embed src="'.$url.'" autostart="'.$autostart.'" type="application/x-mplayer2" width="'.$width.'" height="64"></embed></object>'; case 'ra': case 'rm': case 'ram': $mediaid = 'media_'.random(3); return '<object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="'.$width.'" height="32"><param name="autostart" value="'.$autostart.'" /><param name="src" value="'.$url.'" /><param name="controls" value="controlpanel" /><param name="console" value="'.$mediaid.'_" /><embed src="'.$url.'" type="audio/x-pn-realaudio-plugin" controls="ControlPanel" console="'.$mediaid.'_" width="'.$width.'" height="32"></embed></object>'; } } function parsemedia($params, $url) { $params = explode(',', $params); $width = intval($params[1]) > 800 ? 800 : intval($params[1]); $height = intval($params[2]) > 600 ? 600 : intval($params[2]); $autostart = !empty($params[3]) ? 1 : 0; if($flv = parseflv($url, $width, $height)) { return $flv; } if(in_array(count($params), array(3, 4))) { $type = $params[0]; $url = str_replace(array('<', '>'), '', str_replace('\\"', '\"', $url)); switch($type) { case 'mp3': case 'wma': case 'ra': case 'ram': case 'wav': case 'mid': return parseaudio($url, $width, $autostart); case 'rm': case 'rmvb': case 'rtsp': $mediaid = 'media_'.random(3); return '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'.$width.'" height="'.$height.'"><param name="autostart" value="'.$autostart.'" /><param name="src" value="'.$url.'" /><param name="controls" value="imagewindow" /><param name="console" value="'.$mediaid.'_" /><embed src="'.$url.'" type="audio/x-pn-realaudio-plugin" controls="imagewindow" console="'.$mediaid.'_" width="'.$width.'" height="'.$height.'"></embed></object><br /><object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="'.$width.'" height="32"><param name="src" value="'.$url.'" /><param name="controls" value="controlpanel" /><param name="console" value="'.$mediaid.'_" /><embed src="'.$url.'" type="audio/x-pn-realaudio-plugin" controls="controlpanel" console="'.$mediaid.'_" width="'.$width.'" height="32"'.($autostart ? ' autostart="true"' : '').'></embed></object>'; case 'flv': return '<script type="text/javascript" reload="1">document.write(AC_FL_RunContent(\'width\', \''.$width.'\', \'height\', \''.$height.'\', \'allowNetworking\', \'internal\', \'allowScriptAccess\', \'never\', \'src\', \'images/common/flvplayer.swf\', \'flashvars\', \'file='.rawurlencode($url).'\', \'quality\', \'high\', \'wmode\', \'transparent\', \'allowfullscreen\', \'true\'));</script>'; case 'swf': return '<script type="text/javascript" reload="1">document.write(AC_FL_RunContent(\'width\', \''.$width.'\', \'height\', \''.$height.'\', \'allowNetworking\', \'internal\', \'allowScriptAccess\', \'never\', \'src\', \''.$url.'\', \'quality\', \'high\', \'bgcolor\', \'#ffffff\', \'wmode\', \'transparent\', \'allowfullscreen\', \'true\'));</script>'; case 'asf': case 'asx': case 'wmv': case 'mms': case 'avi': case 'mpg': case 'mpeg': return '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'.$width.'" height="'.$height.'"><param name="invokeURLs" value="0"><param name="autostart" value="'.$autostart.'" /><param name="url" value="'.$url.'" /><embed src="'.$url.'" autostart="'.$autostart.'" type="application/x-mplayer2" width="'.$width.'" height="'.$height.'"></embed></object>'; case 'mov': return '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'.$width.'" height="'.$height.'"><param name="autostart" value="'.($autostart ? '' : 'false').'" /><param name="src" value="'.$url.'" /><embed src="'.$url.'" autostart="'.($autostart ? 'true' : 'false').'" type="video/quicktime" controller="true" width="'.$width.'" height="'.$height.'"></embed></object>'; default: return '<a href="'.$url.'" target="_blank">'.$url.'</a>'; } } return; } function bbcodeurl($url, $tags) { if(!preg_match("/<.+?>/s", $url)) { if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://'))) { $url = 'http://'.$url; } return str_replace(array('submit', 'logging.php'), array('', ''), sprintf($tags, $url, addslashes($url))); } else { return '&nbsp;'.$url; } } function jammer() { $randomstr = ''; for($i = 0; $i < mt_rand(5, 15); $i++) { $randomstr .= chr(mt_rand(32, 59)).' '.chr(mt_rand(63, 126)); } $seo = !$GLOBALS['tagstatus'] ? $GLOBALS['discuzcodes']['seoarray'][mt_rand(0, 5)] : ''; return mt_rand(0, 1) ? '<font style="font-size:0px;color:'.WRAPBG.'">'.$seo.$randomstr.'</font>'."\r\n" : "\r\n".'<span style="display:none">'.$randomstr.$seo.'</span>'; } function highlight($text, $words, $prepend) { $text = str_replace('\"', '"', $text); foreach($words AS $key => $replaceword) { $text = str_replace($replaceword, '<highlight>'.$replaceword.'</highlight>', $text); } return "$prepend$text"; } function parseflv($url, $width, $height) { $lowerurl = strtolower($url); $flv = ''; if($lowerurl != str_replace(array('player.youku.com/player.php/sid/','tudou.com/v/','player.ku6.com/refer/'), '', $lowerurl)) { $flv = $url; } elseif(strpos($lowerurl, 'v.youku.com/v_show/') !== FALSE) { if(preg_match("/http:\/\/v.youku.com\/v_show\/id_([^\/]+)(.html|)/i", $url, $matches)) { $flv = 'http://player.youku.com/player.php/sid/'.$matches[1].'/v.swf'; } } elseif(strpos($lowerurl, 'tudou.com/programs/view/') !== FALSE) { if(preg_match("/http:\/\/(www.)?tudou.com\/programs\/view\/([^\/]+)/i", $url, $matches)) { $flv = 'http://www.tudou.com/v/'.$matches[2]; } } elseif(strpos($lowerurl, 'v.ku6.com/show/') !== FALSE) { if(preg_match("/http:\/\/v.ku6.com\/show\/([^\/]+).html/i", $url, $matches)) { $flv = 'http://player.ku6.com/refer/'.$matches[1].'/v.swf'; } } elseif(strpos($lowerurl, 'v.ku6.com/special/show_') !== FALSE) { if(preg_match("/http:\/\/v.ku6.com\/special\/show_\d+\/([^\/]+).html/i", $url, $matches)) { $flv = 'http://player.ku6.com/refer/'.$matches[1].'/v.swf'; } } if($flv) { return '<script type="text/javascript" reload="1">document.write(AC_FL_RunContent(\'width\', \''.$width.'\', \'height\', \''.$height.'\', \'allowNetworking\', \'internal\', \'allowScriptAccess\', \'never\', \'src\', \''.$flv.'\', \'quality\', \'high\', \'bgcolor\', \'#ffffff\', \'wmode\', \'transparent\', \'allowfullscreen\', \'true\'));</script>'; } else { return FALSE; } } function parseimg($width, $height, $src) { return bbcodeurl($src, '<img'.($width > 0 ? " width=\"$width\"" : '').($height > 0 ? " height=\"$height\"" : '')." src=\"$src\" border=\"0\" alt=\"\" />"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/discuzcode.func.php
PHP
asf20
20,737
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: cache.func.php 21311 2009-11-26 01:35:43Z liulanbo $ */ define('DISCUZ_KERNEL_VERSION', '7.2'); define('DISCUZ_KERNEL_RELEASE', '20091126'); function updatecache($cachename = '') { global $db, $bbname, $tablepre, $maxbdays; static $cachescript = array ( 'settings' => array('settings'), 'forums' => array('forums'), 'icons' => array('icons'), 'stamps' => array('stamps'), 'ranks' => array('ranks'), 'usergroups' => array('usergroups'), 'request' => array('request'), 'medals' => array('medals'), 'magics' => array('magics'), 'topicadmin' => array('modreasons', 'stamptypeid'), 'archiver' => array('advs_archiver'), 'register' => array('advs_register', 'ipctrl'), 'faqs' => array('faqs'), 'secqaa' => array('secqaa'), 'censor' => array('censor'), 'ipbanned' => array('ipbanned'), 'smilies' => array('smilies_js'), 'forumstick' => array('forumstick'), 'index' => array('announcements', 'onlinelist', 'forumlinks', 'advs_index', 'heats'), 'forumdisplay' => array('smilies', 'announcements_forum', 'globalstick', 'forums', 'icons', 'onlinelist', 'advs_forumdisplay', 'forumstick'), 'viewthread' => array('smilies', 'smileytypes', 'forums', 'usergroups', 'ranks', 'stamps', 'bbcodes', 'smilies', 'advs_viewthread', 'tags_viewthread', 'custominfo', 'groupicon', 'focus', 'stamps'), 'post' => array('bbcodes_display', 'bbcodes', 'smileycodes', 'smilies', 'smileytypes', 'icons', 'domainwhitelist'), 'profilefields' => array('fields_required', 'fields_optional'), 'viewpro' => array('fields_required', 'fields_optional', 'custominfo'), 'bbcodes' => array('bbcodes', 'smilies', 'smileytypes'), ); if($maxbdays) { $cachescript['birthdays'] = array('birthdays'); $cachescript['index'][] = 'birthdays_index'; } $updatelist = empty($cachename) ? array_values($cachescript) : (is_array($cachename) ? array('0' => $cachename) : array(array('0' => $cachename))); $updated = array(); foreach($updatelist as $value) { foreach($value as $cname) { if(empty($updated) || !in_array($cname, $updated)) { $updated[] = $cname; getcachearray($cname); } } } foreach($cachescript as $script => $cachenames) { if(empty($cachename) || (!is_array($cachename) && in_array($cachename, $cachenames)) || (is_array($cachename) && array_intersect($cachename, $cachenames))) { $cachedata = ''; $query = $db->query("SELECT data FROM {$tablepre}caches WHERE cachename in(".implodeids($cachenames).")"); while($data = $db->fetch_array($query)) { $cachedata .= $data['data']; } writetocache($script, $cachenames, $cachedata); } } if(!$cachename || $cachename == 'styles') { $stylevars = $styledata = $styleicons = array(); $defaultstyleid = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable = 'styleid'"); list(, $imagemaxwidth) = explode("\t", $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable = 'zoomstatus'")); $imagemaxwidth = $imagemaxwidth ? $imagemaxwidth : 600; $imagemaxwidthint = intval($imagemaxwidth); $query = $db->query("SELECT sv.* FROM {$tablepre}stylevars sv LEFT JOIN {$tablepre}styles s ON s.styleid = sv.styleid AND (s.available=1 OR s.styleid='$defaultstyleid')"); while($var = $db->fetch_array($query)) { $stylevars[$var['styleid']][$var['variable']] = $var['substitute']; } $query = $db->query("SELECT s.*, t.directory AS tpldir FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON s.templateid=t.templateid WHERE s.available=1 OR s.styleid='$defaultstyleid'"); while($data = $db->fetch_array($query)) { $data = array_merge($data, $stylevars[$data['styleid']]); $datanew = array(); $data['imgdir'] = $data['imgdir'] ? $data['imgdir'] : 'images/default'; $data['styleimgdir'] = $data['styleimgdir'] ? $data['styleimgdir'] : $data['imgdir']; foreach($data as $k => $v) { if(substr($k, -7, 7) == 'bgcolor') { $newkey = substr($k, 0, -7).'bgcode'; $datanew[$newkey] = setcssbackground($data, $k); } } $data = array_merge($data, $datanew); $styleicons[$data['styleid']] = $data['menuhover']; if(strstr($data['boardimg'], ',')) { $flash = explode(",", $data['boardimg']); $flash[0] = trim($flash[0]); $flash[0] = preg_match('/^http:\/\//i', $flash[0]) ? $flash[0] : $data['styleimgdir'].'/'.$flash[0]; $data['boardlogo'] = "<embed src=\"".$flash[0]."\" width=\"".trim($flash[1])."\" height=\"".trim($flash[2])."\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></embed>"; } else { $data['boardimg'] = preg_match('/^http:\/\//i', $data['boardimg']) ? $data['boardimg'] : $data['styleimgdir'].'/'.$data['boardimg']; $data['boardlogo'] = "<img src=\"$data[boardimg]\" alt=\"$bbname\" border=\"0\" />"; } $data['bold'] = $data['nobold'] ? 'normal' : 'bold'; $contentwidthint = intval($data['contentwidth']); $contentwidthint = $contentwidthint ? $contentwidthint : 600; if(substr(trim($data['contentwidth']), -1, 1) != '%') { if(substr(trim($imagemaxwidth), -1, 1) != '%') { $data['imagemaxwidth'] = $imagemaxwidthint > $contentwidthint ? $contentwidthint : $imagemaxwidthint; } else { $data['imagemaxwidth'] = intval($contentwidthint * $imagemaxwidthint / 100); } } else { if(substr(trim($imagemaxwidth), -1, 1) != '%') { $data['imagemaxwidth'] = '%'.$imagemaxwidthint; } else { $data['imagemaxwidth'] = ($imagemaxwidthint > $contentwidthint ? $contentwidthint : $imagemaxwidthint).'%'; } } $data['verhash'] = random(3); $styledata[] = $data; } foreach($styledata as $data) { $data['styleicons'] = $styleicons; writetocache($data['styleid'], '', getcachevars($data, 'CONST'), 'style_'); writetocsscache($data); } } if(!$cachename || $cachename == 'usergroups') { @include_once DISCUZ_ROOT.'forumdata/cache/cache_settings.php'; $threadplugins = !isset($_DCACHE['settings']) ? $GLOBALS['threadplugins'] : $_DCACHE['settings']; $allowthreadplugin = $threadplugins ? unserialize($db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='allowthreadplugin'")) : array(); $query = $db->query("SELECT * FROM {$tablepre}usergroups u LEFT JOIN {$tablepre}admingroups a ON u.groupid=a.admingid"); while($data = $db->fetch_array($query)) { $ratearray = array(); if($data['raterange']) { foreach(explode("\n", $data['raterange']) as $rating) { $rating = explode("\t", $rating); $ratearray[$rating[0]] = array('min' => $rating[1], 'max' => $rating[2], 'mrpd' => $rating[3]); } } $data['raterange'] = $ratearray; $data['grouptitle'] = $data['color'] ? '<font color="'.$data['color'].'">'.$data['grouptitle'].'</font>' : $data['grouptitle']; $data['grouptype'] = $data['type']; $data['grouppublic'] = $data['system'] != 'private'; $data['groupcreditshigher'] = $data['creditshigher']; $data['groupcreditslower'] = $data['creditslower']; $data['allowthreadplugin'] = $threadplugins ? $allowthreadplugin[$data['groupid']] : array(); unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['color'], $data['groupavatar'], $data['admingid']); writetocache($data['groupid'], '', getcachevars($data), 'usergroup_'); } } if(!$cachename || $cachename == 'admingroups') { $query = $db->query("SELECT * FROM {$tablepre}admingroups"); while($data = $db->fetch_array($query)) { writetocache($data['admingid'], '', getcachevars($data), 'admingroup_'); } } if(!$cachename || $cachename == 'plugins') { $query = $db->query("SELECT pluginid, available, adminid, name, identifier, datatables, directory, copyright, modules FROM {$tablepre}plugins"); while($plugin = $db->fetch_array($query)) { $data = array_merge($plugin, array('modules' => array()), array('vars' => array())); $plugin['modules'] = unserialize($plugin['modules']); if(is_array($plugin['modules'])) { foreach($plugin['modules'] as $module) { $data['modules'][$module['name']] = $module; } } $queryvars = $db->query("SELECT variable, value FROM {$tablepre}pluginvars WHERE pluginid='$plugin[pluginid]'"); while($var = $db->fetch_array($queryvars)) { $data['vars'][$var['variable']] = $var['value']; } writetocache($plugin['identifier'], '', "\$_DPLUGIN['$plugin[identifier]'] = ".arrayeval($data), 'plugin_'); } } if(!$cachename || $cachename == 'threadsorts') { $sortlist = $templatedata = array(); $query = $db->query("SELECT t.typeid AS sortid, tt.optionid, tt.title, tt.type, tt.unit, tt.rules, tt.identifier, tt.description, tv.required, tv.unchangeable, tv.search, tv.subjectshow FROM {$tablepre}threadtypes t LEFT JOIN {$tablepre}typevars tv ON t.typeid=tv.sortid LEFT JOIN {$tablepre}typeoptions tt ON tv.optionid=tt.optionid WHERE t.special='1' AND tv.available='1' ORDER BY tv.displayorder"); while($data = $db->fetch_array($query)) { $data['rules'] = unserialize($data['rules']); $sortid = $data['sortid']; $optionid = $data['optionid']; $sortlist[$sortid][$optionid] = array( 'title' => dhtmlspecialchars($data['title']), 'type' => dhtmlspecialchars($data['type']), 'unit' => dhtmlspecialchars($data['unit']), 'identifier' => dhtmlspecialchars($data['identifier']), 'description' => dhtmlspecialchars($data['description']), 'required' => intval($data['required']), 'unchangeable' => intval($data['unchangeable']), 'search' => intval($data['search']), 'subjectshow' => intval($data['subjectshow']), ); if(in_array($data['type'], array('select', 'checkbox', 'radio'))) { if($data['rules']['choices']) { $choices = array(); foreach(explode("\n", $data['rules']['choices']) as $item) { list($index, $choice) = explode('=', $item); $choices[trim($index)] = trim($choice); } $sortlist[$sortid][$optionid]['choices'] = $choices; } else { $typelist[$sortid][$optionid]['choices'] = array(); } } elseif(in_array($data['type'], array('text', 'textarea'))) { $sortlist[$sortid][$optionid]['maxlength'] = intval($data['rules']['maxlength']); } elseif($data['type'] == 'image') { $sortlist[$sortid][$optionid]['maxwidth'] = intval($data['rules']['maxwidth']); $sortlist[$sortid][$optionid]['maxheight'] = intval($data['rules']['maxheight']); } elseif($data['type'] == 'number') { $sortlist[$sortid][$optionid]['maxnum'] = intval($data['rules']['maxnum']); $sortlist[$sortid][$optionid]['minnum'] = intval($data['rules']['minnum']); } } $query = $db->query("SELECT typeid, description, template, stemplate FROM {$tablepre}threadtypes WHERE special='1'"); while($data = $db->fetch_array($query)) { $templatedata[$data['typeid']] = $data['template']; $stemplatedata[$data['typeid']] = $data['stemplate']; $threaddesc[$data['typeid']] = dhtmlspecialchars($data['description']); } foreach($sortlist as $sortid => $option) { writetocache($sortid, '', "\$_DTYPE = ".arrayeval($option).";\n\n\$_DTYPETEMPLATE = \"".str_replace('"', '\"', $templatedata[$sortid])."\";\n\n\$_DSTYPETEMPLATE = \"".str_replace('"', '\"', $stemplatedata[$sortid])."\";\n", 'threadsort_'); } } } function setcssbackground(&$data, $code) { $codes = explode(' ', $data[$code]); $css = $codevalue = ''; for($i = 0; $i < count($codes); $i++) { if($i < 2) { if($codes[$i] != '') { if($codes[$i]{0} == '#') { $css .= strtoupper($codes[$i]).' '; $codevalue = strtoupper($codes[$i]); } elseif(preg_match('/^http:\/\//i', $codes[$i])) { $css .= 'url(\"'.$codes[$i].'\") '; } else { $css .= 'url("'.$data['styleimgdir'].'/'.$codes[$i].'") '; } } } else { $css .= $codes[$i].' '; } } $data[$code] = $codevalue; $css = trim($css); return $css ? 'background: '.$css : ''; } function updatesettings() { global $_DCACHE; if(isset($_DCACHE['settings']) && is_array($_DCACHE['settings'])) { writetocache('settings', '', '$_DCACHE[\'settings\'] = '.arrayeval($_DCACHE['settings']).";\n\n"); } } function writetocache($script, $cachenames, $cachedata = '', $prefix = 'cache_') { global $authkey; if(is_array($cachenames) && !$cachedata) { foreach($cachenames as $name) { $cachedata .= getcachearray($name, $script); } } $dir = DISCUZ_ROOT.'./forumdata/cache/'; if(!is_dir($dir)) { @mkdir($dir, 0777); } if($fp = @fopen("$dir$prefix$script.php", 'wb')) { fwrite($fp, "<?php\n//Discuz! cache file, DO NOT modify me!". "\n//Created: ".date("M j, Y, G:i"). "\n//Identify: ".md5($prefix.$script.'.php'.$cachedata.$authkey)."\n\n$cachedata?>"); fclose($fp); } else { exit('Can not write to cache files, please check directory ./forumdata/ and ./forumdata/cache/ .'); } } function writetocsscache($data) { $cssdata = ''; foreach(array('_common' => array('css_common', 'css_append'), '_special' => array('css_special', 'css_special_append'), '_wysiwyg' => array('css_wysiwyg', '_wysiwyg_append'), '_seditor' => array('css_seditor', 'css_seditor_append'), '_calendar' => array('css_calendar', 'css_calendar_append'), '_moderator' => array('css_moderator', 'css_moderator_append'), '_script' => array('css_script', 'css_script_append'), '_task_newbie' => array('css_task_newbie', 'css_task_newbie_append') ) as $extra => $cssfiles) { $cssdata = ''; foreach($cssfiles as $css) { $cssfile = DISCUZ_ROOT.'./'.$data['tpldir'].'/'.$css.'.htm'; !file_exists($cssfile) && $cssfile = DISCUZ_ROOT.'./templates/default/'.$css.'.htm'; if(file_exists($cssfile)) { $fp = fopen($cssfile, 'r'); $cssdata .= @fread($fp, filesize($cssfile))."\n\n"; fclose($fp); } } $cssdata = preg_replace("/\{([A-Z0-9]+)\}/e", '\$data[strtolower(\'\1\')]', $cssdata); $cssdata = preg_replace("/<\?.+?\?>\s*/", '', $cssdata); $cssdata = !preg_match('/^http:\/\//i', $data['styleimgdir']) ? str_replace("url(\"$data[styleimgdir]", "url(\"../../$data[styleimgdir]", $cssdata) : $cssdata; $cssdata = !preg_match('/^http:\/\//i', $data['styleimgdir']) ? str_replace("url($data[styleimgdir]", "url(../../$data[styleimgdir]", $cssdata) : $cssdata; $cssdata = !preg_match('/^http:\/\//i', $data['imgdir']) ? str_replace("url(\"$data[imgdir]", "url(\"../../$data[imgdir]", $cssdata) : $cssdata; $cssdata = !preg_match('/^http:\/\//i', $data['imgdir']) ? str_replace("url($data[imgdir]", "url(../../$data[imgdir]", $cssdata) : $cssdata; if($extra != '_script') { $cssdata = preg_replace(array('/\s*([,;:\{\}])\s*/', '/[\t\n\r]/', '/\/\*.+?\*\//'), array('\\1', '',''), $cssdata); } if(@$fp = fopen(DISCUZ_ROOT.'./forumdata/cache/style_'.$data['styleid'].$extra.'.css', 'w')) { fwrite($fp, $cssdata); fclose($fp); } else { exit('Can not write to cache files, please check directory ./forumdata/ and ./forumdata/cache/ .'); } } } function writetojscache() { $dir = DISCUZ_ROOT.'include/js/'; $dh = opendir($dir); $remove = array( '/(^|\r|\n)\/\*.+?(\r|\n)\*\/(\r|\n)/is', '/\/\/note.+?(\r|\n)/i', '/\/\/debug.+?(\r|\n)/i', '/(^|\r|\n)(\s|\t)+/', '/(\r|\n)/', ); while(($entry = readdir($dh)) !== false) { if(fileext($entry) == 'js') { $jsfile = $dir.$entry; $fp = fopen($jsfile, 'r'); $jsdata = @fread($fp, filesize($jsfile)); fclose($fp); $jsdata = preg_replace($remove, '', $jsdata); if(@$fp = fopen(DISCUZ_ROOT.'./forumdata/cache/'.$entry, 'w')) { fwrite($fp, $jsdata); fclose($fp); } else { exit('Can not write to cache files, please check directory ./forumdata/ and ./forumdata/cache/ .'); } } } } function getcachearray($cachename, $script = '') { global $db, $timestamp, $tablepre, $timeoffset, $maxbdays, $smcols, $smrows, $charset, $scriptlang; $cols = '*'; $conditions = ''; switch($cachename) { case 'settings': $table = 'settings'; $conditions = "WHERE variable NOT IN ('siteuniqueid', 'mastermobile', 'bbrules', 'bbrulestxt', 'closedreason', 'creditsnotify', 'backupdir', 'custombackup', 'jswizard', 'maxonlines', 'modreasons', 'newsletter', 'welcomemsg', 'welcomemsgtxt', 'postno', 'postnocustom', 'customauthorinfo', 'focus', 'domainwhitelist', 'ipregctrl', 'ipverifywhite')"; break; case 'ipctrl': $table = 'settings'; $conditions = "WHERE variable IN ('ipregctrl', 'ipverifywhite')"; break; case 'custominfo': $table = 'settings'; $conditions = "WHERE variable IN ('extcredits', 'customauthorinfo', 'postno', 'postnocustom')"; break; case 'request': $table = 'request'; $conditions = ''; break; case 'usergroups': $table = 'usergroups'; $cols = 'groupid, type, grouptitle, creditshigher, creditslower, stars, color, groupavatar, readaccess, allowcusbbcode, allowgetattach, edittimelimit'; $conditions = "ORDER BY creditslower"; break; case 'ranks': $table = 'ranks'; $cols = 'ranktitle, postshigher, stars, color'; $conditions = "ORDER BY postshigher DESC"; break; case 'announcements': $table = 'announcements'; $cols = 'id, subject, type, starttime, endtime, displayorder, groups, message'; $conditions = "WHERE starttime<='$timestamp' AND (endtime>='$timestamp' OR endtime='0') ORDER BY displayorder, starttime DESC, id DESC"; break; case 'announcements_forum': $table = 'announcements a'; $cols = 'a.id, a.author, m.uid AS authorid, a.subject, a.message, a.type, a.starttime, a.displayorder'; $conditions = "LEFT JOIN {$tablepre}members m ON m.username=a.author WHERE a.type!=2 AND a.groups = '' AND a.starttime<='$timestamp' ORDER BY a.displayorder, a.starttime DESC, a.id DESC LIMIT 1"; break; case 'globalstick': $table = 'forums'; $cols = 'fid, type, fup'; $conditions = "WHERE status='1' AND type IN ('forum', 'sub') ORDER BY type"; break; case 'forumstick': $table = 'settings'; $cols = 'variable, value'; $conditions = "WHERE variable='forumstickthreads'"; break; case 'forums': $table = 'forums f'; $cols = 'f.fid, f.type, f.name, f.fup, f.simple, f.status, ff.viewperm, ff.formulaperm, ff.viewperm, ff.postperm, ff.replyperm, ff.getattachperm, ff.postattachperm, ff.extra, a.uid'; $conditions = "LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid LEFT JOIN {$tablepre}access a ON a.fid=f.fid AND a.allowview>'0' ORDER BY f.type, f.displayorder"; break; case 'onlinelist': $table = 'onlinelist'; $conditions = "ORDER BY displayorder"; break; case 'groupicon': $table = 'onlinelist'; $conditions = "ORDER BY displayorder"; break; case 'forumlinks': $table = 'forumlinks'; $conditions = "ORDER BY displayorder"; break; case 'bbcodes': $table = 'bbcodes'; $conditions = "WHERE available>'0'"; break; case 'bbcodes_display': $table = 'bbcodes'; $cols = 'tag, icon, explanation, params, prompt'; $conditions = "WHERE available='2' AND icon!='' ORDER BY displayorder"; break; case 'smilies': $table = 'smilies s'; $cols = 's.id, s.code, s.url, t.typeid'; $conditions = "LEFT JOIN {$tablepre}imagetypes t ON t.typeid=s.typeid WHERE s.type='smiley' AND s.code<>'' AND t.available='1' ORDER BY LENGTH(s.code) DESC"; break; case 'smileycodes': $table = 'imagetypes'; $cols = 'typeid, directory'; $conditions = "WHERE type='smiley' AND available='1' ORDER BY displayorder"; break; case 'smileytypes': $table = 'imagetypes'; $cols = 'typeid, name, directory'; $conditions = "WHERE type='smiley' AND available='1' ORDER BY displayorder"; break; case 'smilies_js': $table = 'imagetypes'; $cols = 'typeid, name, directory'; $conditions = "WHERE type='smiley' AND available='1' ORDER BY displayorder"; break; case 'icons': $table = 'smilies'; $cols = 'id, url'; $conditions = "WHERE type='icon' ORDER BY displayorder"; break; case 'stamps': $table = 'smilies'; $cols = 'id, url, displayorder'; $conditions = "WHERE type='stamp' ORDER BY displayorder"; break; case 'stamptypeid': $table = 'smilies'; $cols = 'displayorder, typeid'; $conditions = "WHERE type='stamp' AND typeid>'0'"; break; case 'fields_required': $table = 'profilefields'; $cols = 'fieldid, invisible, title, description, required, unchangeable, selective, choices'; $conditions = "WHERE available='1' AND required='1' ORDER BY displayorder"; break; case 'fields_optional': $table = 'profilefields'; $cols = 'fieldid, invisible, title, description, required, unchangeable, selective, choices'; $conditions = "WHERE available='1' AND required='0' ORDER BY displayorder"; break; case 'ipbanned': $db->query("DELETE FROM {$tablepre}banned WHERE expiration<'$timestamp'"); $table = 'banned'; $cols = 'ip1, ip2, ip3, ip4, expiration'; break; case 'censor': $table = 'words'; $cols = 'find, replacement, extra'; break; case 'medals': $table = 'medals'; $cols = 'medalid, name, image'; $conditions = "WHERE available='1'"; break; case 'magics': $table = 'magics'; $cols = 'magicid, type, available, identifier, name, description, weight, price'; break; case 'birthdays_index': $table = 'members'; $cols = 'uid, username, email, bday'; $conditions = "WHERE RIGHT(bday, 5)='".gmdate('m-d', $timestamp + $timeoffset * 3600)."' ORDER BY bday LIMIT $maxbdays"; break; case 'birthdays': $table = 'members'; $cols = 'uid'; $conditions = "WHERE RIGHT(bday, 5)='".gmdate('m-d', $timestamp + $timeoffset * 3600)."' ORDER BY bday"; break; case 'modreasons': $table = 'settings'; $cols = 'value'; $conditions = "WHERE variable='modreasons'"; break; case 'faqs': $table = 'faqs'; $cols = 'fpid, id, identifier, keyword'; $conditions = "WHERE identifier!='' AND keyword!=''"; break; case 'tags_viewthread': global $viewthreadtags; $taglimit = intval($viewthreadtags); $table = 'tags'; $cols = 'tagname, total'; $conditions = "WHERE closed=0 ORDER BY total DESC LIMIT $taglimit"; break; case 'domainwhitelist': $table = 'settings'; $cols = 'value'; $conditions = "WHERE variable='domainwhitelist'"; break; } $data = array(); if(!in_array($cachename, array('focus', 'secqaa', 'heats')) && substr($cachename, 0, 5) != 'advs_') { if(empty($table) || empty($cols)) return ''; $query = $db->query("SELECT $cols FROM {$tablepre}$table $conditions"); } switch($cachename) { case 'settings': while($setting = $db->fetch_array($query)) { if($setting['variable'] == 'extcredits') { if(is_array($setting['value'] = unserialize($setting['value']))) { foreach($setting['value'] as $key => $value) { if($value['available']) { unset($setting['value'][$key]['available']); } else { unset($setting['value'][$key]); } } } } elseif($setting['variable'] == 'creditsformula') { if(!preg_match("/^([\+\-\*\/\.\d\(\)]|((extcredits[1-8]|digestposts|posts|threads|pageviews|oltime)([\+\-\*\/\(\)]|$)+))+$/", $setting['value']) || !is_null(@eval(preg_replace("/(digestposts|posts|threads|pageviews|oltime|extcredits[1-8])/", "\$\\1", $setting['value']).';'))) { $setting['value'] = '$member[\'extcredits1\']'; } else { $setting['value'] = preg_replace("/(digestposts|posts|threads|pageviews|oltime|extcredits[1-8])/", "\$member['\\1']", $setting['value']); } } elseif($setting['variable'] == 'maxsmilies') { $setting['value'] = $setting['value'] <= 0 ? -1 : $setting['value']; } elseif($setting['variable'] == 'threadsticky') { $setting['value'] = explode(',', $setting['value']); } elseif($setting['variable'] == 'attachdir') { $setting['value'] = preg_replace("/\.asp|\\0/i", '0', $setting['value']); $setting['value'] = str_replace('\\', '/', substr($setting['value'], 0, 2) == './' ? DISCUZ_ROOT.$setting['value'] : $setting['value']); } elseif($setting['variable'] == 'onlinehold') { $setting['value'] = $setting['value'] * 60; } elseif($setting['variable'] == 'userdateformat') { if(empty($setting['value'])) { $setting['value'] = array(); } else { $setting['value'] = dhtmlspecialchars(explode("\n", $setting['value'])); $setting['value'] = array_map('trim', $setting['value']); } } elseif(in_array($setting['variable'], array('creditspolicy', 'ftp', 'secqaa', 'ec_credit', 'qihoo', 'spacedata', 'infosidestatus', 'uc', 'outextcredits', 'relatedtag', 'sitemessage', 'msn', 'uchome', 'heatthread', 'recommendthread', 'disallowfloat', 'indexhot', 'dzfeed_limit', 'binddomains', 'forumdomains', 'allowviewuserthread'))) { $setting['value'] = @unserialize($setting['value']); } $GLOBALS[$setting['variable']] = $data[$setting['variable']] = $setting['value']; } if($data['heatthread']['iconlevels']) { $data['heatthread']['iconlevels'] = explode(',', $data['heatthread']['iconlevels']); arsort($data['heatthread']['iconlevels']); } else { $data['heatthread']['iconlevels'] = array(); } if($data['recommendthread']['status']) { if($data['recommendthread']['iconlevels']) { $data['recommendthread']['iconlevels'] = explode(',', $data['recommendthread']['iconlevels']); arsort($data['recommendthread']['iconlevels']); } else { $data['recommendthread']['iconlevels'] = array(); } } else { $data['recommendthread'] = array('allow' => 0); } $data['allowviewuserthread'] = $data['allowviewuserthread']['allow'] && is_array($data['allowviewuserthread']['fids']) && $data['allowviewuserthread']['fids'] ? implodeids($data['allowviewuserthread']['fids']) : ''; $data['sitemessage']['time'] = !empty($data['sitemessage']['time']) ? $data['sitemessage']['time'] * 1000 : 0; $data['sitemessage']['register'] = !empty($data['sitemessage']['register']) ? explode("\n", $data['sitemessage']['register']) : ''; $data['sitemessage']['login'] = !empty($data['sitemessage']['login']) ? explode("\n", $data['sitemessage']['login']) : ''; $data['sitemessage']['newthread'] = !empty($data['sitemessage']['newthread']) ? explode("\n", $data['sitemessage']['newthread']) : ''; $data['sitemessage']['reply'] = !empty($data['sitemessage']['reply']) ? explode("\n", $data['sitemessage']['reply']) : ''; $GLOBALS['version'] = $data['version'] = DISCUZ_KERNEL_VERSION; $GLOBALS['totalmembers'] = $data['totalmembers'] = $db->result_first("SELECT COUNT(*) FROM {$tablepre}members"); $GLOBALS['lastmember'] = $data['lastmember'] = $db->result_first("SELECT username FROM {$tablepre}members ORDER BY uid DESC LIMIT 1"); $data['cachethreadon'] = $db->result_first("SELECT COUNT(*) FROM {$tablepre}forums WHERE status='1' AND threadcaches>0") ? 1 : 0; $data['cronnextrun'] = $db->result_first("SELECT nextrun FROM {$tablepre}crons WHERE available>'0' AND nextrun>'0' ORDER BY nextrun LIMIT 1"); $data['disallowfloat'] = is_array($data['disallowfloat']) ? implode('|', $data['disallowfloat']) : ''; $data['ftp']['connid'] = 0; $data['indexname'] = empty($data['indexname']) ? 'index.php' : $data['indexname']; if(!$data['imagelib']) { unset($data['imageimpath']); } if(is_array($data['relatedtag']['order'])) { asort($data['relatedtag']['order']); $relatedtag = array(); foreach($data['relatedtag']['order'] AS $k => $v) { $relatedtag['status'][$k] = $data['relatedtag']['status'][$k]; $relatedtag['name'][$k] = $data['relatedtag']['name'][$k]; $relatedtag['limit'][$k] = $data['relatedtag']['limit'][$k]; $relatedtag['template'][$k] = $data['relatedtag']['template'][$k]; } $data['relatedtag'] = $relatedtag; foreach((array)$data['relatedtag']['status'] AS $appid => $status) { if(!$status) { unset($data['relatedtag']['limit'][$appid]); } } unset($data['relatedtag']['status'], $data['relatedtag']['order'], $relatedtag); } $data['seccodedata'] = $data['seccodedata'] ? unserialize($data['seccodedata']) : array(); if($data['seccodedata']['type'] == 2) { if(extension_loaded('ming')) { unset($data['seccodedata']['background'], $data['seccodedata']['adulterate'], $data['seccodedata']['ttf'], $data['seccodedata']['angle'], $data['seccodedata']['color'], $data['seccodedata']['size'], $data['seccodedata']['animator']); } else { $data['seccodedata']['animator'] = 0; } } $secqaacheck = sprintf('%03b', $data['secqaa']['status']); $data['secqaa']['status'] = array( 1 => $secqaacheck{2}, 2 => $secqaacheck{1}, 3 => $secqaacheck{0} ); if(!$data['secqaa']['status'][2] && !$data['secqaa']['status'][3]) { unset($data['secqaa']['minposts']); } if($data['watermarktype'] == 2 && $data['watermarktext']) { $data['watermarktext'] = unserialize($data['watermarktext']); if($data['watermarktext']['text'] && strtoupper($charset) != 'UTF-8') { require_once DISCUZ_ROOT.'include/chinese.class.php'; $c = new Chinese($charset, 'utf8'); $data['watermarktext']['text'] = $c->Convert($data['watermarktext']['text']); } $data['watermarktext']['text'] = bin2hex($data['watermarktext']['text']); $data['watermarktext']['fontpath'] = 'images/fonts/'.$data['watermarktext']['fontpath']; $data['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')", $data['watermarktext']['color']); $data['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')", $data['watermarktext']['shadowcolor']); } else { $data['watermarktext'] = array(); } $tradetypes = implodeids(unserialize($data['tradetypes'])); $data['tradetypes'] = array(); if($tradetypes) { $query = $db->query("SELECT typeid, name FROM {$tablepre}threadtypes WHERE typeid in ($tradetypes)"); while($type = $db->fetch_array($query)) { $data['tradetypes'][$type['typeid']] = $type['name']; } } $data['styles'] = array(); $query = $db->query("SELECT styleid, name FROM {$tablepre}styles WHERE available='1'"); while($style = $db->fetch_array($query)) { $data['styles'][$style['styleid']] = dhtmlspecialchars($style['name']); } $data['stylejumpstatus'] = $data['stylejump'] && count($data['styles']) > 1; $globaladvs = advertisement('all'); $data['globaladvs'] = $globaladvs['all'] ? $globaladvs['all'] : array(); $data['redirectadvs'] = $globaladvs['redirect'] ? $globaladvs['redirect'] : array(); $data['invitecredit'] = ''; if($data['inviteconfig'] = unserialize($data['inviteconfig'])) { $data['invitecredit'] = $data['inviteconfig']['invitecredit']; } unset($data['inviteconfig']); $data['newbietasks'] = array(); $query = $db->query("SELECT taskid, name, scriptname FROM {$tablepre}tasks WHERE available='2' AND newbietask='1' ORDER BY displayorder"); while($task = $db->fetch_array($query)) { $taskid = $task['taskid']; unset($task['taskid']); $task['scriptname'] = substr($task['scriptname'], 7); $data['newbietasks'][$taskid] = $task; } $outextcreditsrcs = $outextcredits = array(); foreach((array)$data['outextcredits'] as $value) { $outextcreditsrcs[$value['creditsrc']] = $value['creditsrc']; $key = $value['appiddesc'].'|'.$value['creditdesc']; if(!isset($outextcredits[$key])) { $outextcredits[$key] = array('title' => $value['title'], 'unit' => $value['unit']); } $outextcredits[$key]['ratiosrc'][$value['creditsrc']] = $value['ratiosrc']; $outextcredits[$key]['ratiodesc'][$value['creditsrc']] = $value['ratiodesc']; $outextcredits[$key]['creditsrc'][$value['creditsrc']] = $value['ratio']; } $data['outextcredits'] = $outextcredits; $exchcredits = array(); $allowexchangein = $allowexchangeout = FALSE; foreach((array)$data['extcredits'] as $id => $credit) { $data['extcredits'][$id]['img'] = $credit['img'] ? '<img style="vertical-align:middle" src="'.$credit['img'].'" />' : ''; if(!empty($credit['ratio'])) { $exchcredits[$id] = $credit; $credit['allowexchangein'] && $allowexchangein = TRUE; $credit['allowexchangeout'] && $allowexchangeout = TRUE; } $data['creditnotice'] && $data['creditnames'][] = str_replace("'", "\'", htmlspecialchars($id.'|'.$credit['title'].'|'.$credit['unit'])); } $data['creditnames'] = $data['creditnotice'] ? implode(',', $data['creditnames']) : ''; $creditstranssi = explode(',', $data['creditstrans']); $data['creditstrans'] = $creditstranssi[0]; unset($creditstranssi[0]); $data['creditstransextra'] = $creditstranssi; for($i = 1;$i < 6;$i++) { $data['creditstransextra'][$i] = !$data['creditstransextra'][$i] ? $data['creditstrans'] : $data['creditstransextra'][$i]; } $data['exchangestatus'] = $allowexchangein && $allowexchangeout; $data['transferstatus'] = isset($data['extcredits'][$data['creditstrans']]); list($data['zoomstatus'], $data['imagemaxwidth']) = explode("\t", $data['zoomstatus']); $data['imagemaxwidth'] = substr(trim($data['imagemaxwidth']), -1, 1) != '%' && $data['imagemaxwidth'] <= 1920 ? $data['imagemaxwidth'] : ''; $data['msn']['on'] = $data['msn']['on'] && $data['msn']['domain'] ? 1 : 0; $data['msn']['domain'] = $data['msn']['on'] ? $data['msn']['domain'] : 'discuz.org'; if($data['qihoo']['status']) { $qihoo = $data['qihoo']; $data['qihoo']['links'] = $data['qihoo']['relate'] = array(); foreach(explode("\n", trim($qihoo['keywords'])) AS $keyword) { if($keyword = trim($keyword)) { $data['qihoo']['links']['keywords'][] = '<a href="search.php?srchtype=qihoo&amp;srchtxt='.rawurlencode($keyword).'&amp;searchsubmit=yes" target="_blank">'.dhtmlspecialchars(trim($keyword)).'</a>'; } } foreach((array)$qihoo['topics'] AS $topic) { if($topic['topic'] = trim($topic['topic'])) { $data['qihoo']['links']['topics'][] = '<a href="topic.php?topic='.rawurlencode($topic['topic']).'&amp;keyword='.rawurlencode($topic['keyword']).'&amp;stype='.$topic['stype'].'&amp;length='.$topic['length'].'&amp;relate='.$topic['relate'].'" target="_blank">'.dhtmlspecialchars(trim($topic['topic'])).'</a>'; } } if(is_array($qihoo['relatedthreads'])) { if($data['qihoo']['relate']['bbsnum'] = intval($qihoo['relatedthreads']['bbsnum'])) { $data['qihoo']['relate']['position'] = intval($qihoo['relatedthreads']['position']); $data['qihoo']['relate']['validity'] = intval($qihoo['relatedthreads']['validity']); if($data['qihoo']['relate']['webnum'] = intval($qihoo['relatedthreads']['webnum'])) { $data['qihoo']['relate']['banurl'] = $qihoo['relatedthreads']['banurl'] ? '/('.str_replace("\r\n", '|', $qihoo['relatedthreads']['banurl']).')/i' : ''; $data['qihoo']['relate']['type'] = implode('|', (array)$qihoo['relatedthreads']['type']); $data['qihoo']['relate']['order'] = intval($qihoo['relatedthreads']['order']); } } else { $data['qihoo']['relate'] = array(); } } unset($qihoo, $data['qihoo']['keywords'], $data['qihoo']['topics'], $data['qihoo']['relatedthreads']); } else { $data['qihoo'] = array(); } $data['prompts'] = $data['promptkeys'] = $data['promptpmids'] = array(); $query = $db->query("SELECT * FROM {$tablepre}prompttype ORDER BY id"); while($prompttype = $db->fetch_array($query)) { if($prompttype['key'] == 'task' && !$data['taskon'] || $prompttype['key'] == 'magics' && !$data['magicstatus']) { continue; } $data['prompts'][$prompttype['key']] = array('name' => $prompttype['name'], 'script' => $prompttype['script'], 'id' => $prompttype['id'], 'new' => 0); $data['promptkeys'][$prompttype['id']] = $prompttype['key']; if(!$prompttype['script']) { $data['promptpmids'][] = $prompttype['id']; } } require_once DISCUZ_ROOT.'./uc_client/client.php'; $ucnewpm = uc_pm_checknew($GLOBALS['discuz_uid'], 2); $data['announcepm'] = $ucnewpm['announcepm']; $data['plugins'] = $data['pluginlangs'] = $data['templatelangs'] = $data['pluginlinks'] = $data['hookscript'] = $data['threadplugins'] = $data['specialicon'] = $adminmenu = $scriptlang = array(); $threadpluginicons = FALSE; $query = $db->query("SELECT pluginid, available, name, identifier, directory, datatables, modules FROM {$tablepre}plugins"); $data['plugins']['available'] = array(); while($plugin = $db->fetch_array($query)) { $templatelang = array(); $addadminmenu = $plugin['available'] && $db->result_first("SELECT count(*) FROM {$tablepre}pluginvars WHERE pluginid='$plugin[pluginid]'") ? TRUE : FALSE; $plugin['modules'] = unserialize($plugin['modules']); if($plugin['available']) { $data['plugins']['available'][] = $plugin['identifier']; if(!empty($plugin['modules']['extra']['langexists'])) { @include DISCUZ_ROOT.'./forumdata/plugins/'.$plugin['identifier'].'.lang.php'; if(!empty($scriptlang)) { $data['pluginlangs'][] = $plugin['identifier']; } if(!empty($templatelang)) { $data['templatelangs'][] = $plugin['identifier']; } } } $plugin['directory'] = $plugin['directory'].((!empty($plugin['directory']) && substr($plugin['directory'], -1) != '/') ? '/' : ''); if(is_array($plugin['modules'])) { unset($plugin['modules']['extra']); foreach($plugin['modules'] as $module) { if($plugin['available'] && isset($module['name'])) { $k = ''; switch($module['type']) { case 1: $k = 'links'; case 5: $k = !$k ? 'jsmenu' : $k; case 7: $k = !$k ? 'plinks_my' : $k; case 9: $k = !$k ? 'plinks_tools' : $k; $data['plugins'][$k][] = array('displayorder' => $module['displayorder'], 'adminid' => $module['adminid'], 'url' => "<a id=\"mn_plink_$module[name]\" href=\"$module[url]\">$module[menu]</a>"); break; case 2: $k = 'links'; case 6: $k = !$k ? 'jsmenu' : $k; case 8: $k = !$k ? 'plinks_my' : $k; case 10: $k = !$k ? 'plinks_tools' : $k; $data['plugins'][$k][] = array('displayorder' => $module['displayorder'], 'id' => $plugin['identifier'].':'.$module['name'], 'adminid' => $module['adminid'], 'url' => "<a id=\"mn_plugin_$plugin[identifier]_$module[name]\" href=\"plugin.php?id=$plugin[identifier]:$module[name]\">$module[menu]</a>"); $data['pluginlinks'][$plugin['identifier']][$module['name']] = array('adminid' => $module['adminid'], 'directory' => $plugin['directory']); break; case 13: $data['plugins']['script'][$plugin['identifier']][$module['name']] = array('directory' => $plugin['directory']); break; case 14: $k = 'faq'; case 15: $k = !$k ? 'modcp_base' : $k; case 16: $k = !$k ? 'modcp_tools' : $k; $data['plugins'][$k][$plugin['identifier'].':'.$module['name']] = array('displayorder' => $module['displayorder'], 'name' => $module['menu'], 'directory' => $plugin['directory']); break; case 3: $addadminmenu = TRUE; break; case 4: $data['plugins']['include'][$plugin['identifier']] = array('displayorder' => $module['displayorder'], 'adminid' => $module['adminid'], 'script' => $plugin['directory'].$module['name']); break; case 11: $script = $plugin['directory'].$module['name']; @include_once './plugins/'.$script.'.class.php'; if(class_exists('plugin_'.$plugin['identifier'])) { $classname = 'plugin_'.$plugin['identifier']; $hookmethods = get_class_methods($classname); foreach($hookmethods as $funcname) { $v = explode('_', $funcname); $curscript = $v[0]; if(!$curscript || $classname == $funcname) { continue; } if(!@in_array($script, $data['hookscript'][$curscript]['module'])) { $data['hookscript'][$curscript]['module'][$plugin['identifier']] = $script; $data['hookscript'][$curscript]['adminid'][$plugin['identifier']] = $module['adminid']; } if(preg_match('/\_output$/', $funcname)) { $varname = preg_replace('/\_output$/', '', $funcname); $data['hookscript'][$curscript]['outputfuncs'][$varname][] = array('displayorder' => $module['displayorder'], 'func' => array($plugin['identifier'], $funcname)); } else { $data['hookscript'][$curscript]['funcs'][$funcname][] = array('displayorder' => $module['displayorder'], 'func' => array($plugin['identifier'], $funcname)); } } } break; case 12: $script = $plugin['directory'].$module['name']; @include_once './plugins/'.$script.'.class.php'; if(class_exists('threadplugin_'.$plugin['identifier'])) { $classname = 'threadplugin_'.$plugin['identifier']; $hookclass = new $classname; if($hookclass->name) { $data['threadplugins'][$plugin['identifier']]['name'] = $hookclass->name; $data['threadplugins'][$plugin['identifier']]['module'] = $script; if($hookclass->iconfile) { $threadpluginicons = TRUE; $data['threadplugins'][$plugin['identifier']]['icon'] = $hookclass->iconfile; } } } break; } } } } if($addadminmenu) { $adminmenu[] = array('url' => "plugins&operation=config&pluginid=$plugin[pluginid]", 'name' => $plugin['name']); } } $data['my_status'] = $data['plugins']['available'] && in_array('manyou', $data['plugins']['available']) ? $data['my_status'] : 0; writetocache('scriptlang', '', getcachevars(array('scriptlang' => $scriptlang))); if($threadpluginicons) { $existicons = array(); $query = $db->query("SELECT id, url FROM {$tablepre}smilies WHERE type='icon'"); while($icon = $db->fetch_array($query)) { $icons[$icon['url']] = $icon['id']; } $iconupdate = FALSE; foreach($data['threadplugins'] as $identifier => $icon) { if(!array_key_exists($icon['icon'], $icons)) { $db->query("INSERT INTO {$tablepre}smilies (type, url) VALUES ('icon', '$icon[icon]')"); $iconid = $db->insert_id(); $iconupdate = TRUE; } else { $iconid = $icons[$icon['icon']]; } $data['threadplugins'][$identifier]['iconid'] = $iconid; $data['specialicon'][$iconid] = $identifier; $data['threadplugins'][$identifier]['icon'] = 'images/icons/'.$icon['icon']; } if($iconupdate) { updatecache('icons'); } } foreach($data['hookscript'] as $curscript => $scriptdata) { if(is_array($scriptdata['funcs'])) { foreach($scriptdata['funcs'] as $funcname => $funcs) { usort($funcs, 'pluginmodulecmp'); $tmp = array(); foreach($funcs as $k => $v) { $tmp[$k] = $v['func']; } $data['hookscript'][$curscript]['funcs'][$funcname] = $tmp; } } if(is_array($scriptdata['outputfuncs'])) { foreach($scriptdata['outputfuncs'] as $funcname => $funcs) { usort($funcs, 'pluginmodulecmp'); $tmp = array(); foreach($funcs as $k => $v) { $tmp[$k] = $v['func']; } $data['hookscript'][$curscript]['outputfuncs'][$funcname] = $tmp; } } } $data['tradeopen'] = $db->result_first("SELECT count(*) FROM {$tablepre}usergroups WHERE allowposttrade='1'") ? 1 : 0; foreach(array('links', 'plinks_my', 'plinks_tools', 'include', 'jsmenu', 'faq', 'modcp_base', 'modcp_member', 'modcp_forum') as $pluginkey) { if(is_array($data['plugins'][$pluginkey])) { if(in_array($pluginkey, array('faq', 'modcp_base', 'modcp_tools'))) { uasort($data['plugins'][$pluginkey], 'pluginmodulecmp'); } else { usort($data['plugins'][$pluginkey], 'pluginmodulecmp'); } foreach($data['plugins'][$pluginkey] as $key => $module) { unset($data['plugins'][$pluginkey][$key]['displayorder']); } } } writetocache('adminmenu', '', getcachevars(array('adminmenu' => $adminmenu)), ''); $data['hooks'] = array(); $query = $db->query("SELECT ph.title, ph.code, p.identifier FROM {$tablepre}plugins p LEFT JOIN {$tablepre}pluginhooks ph ON ph.pluginid=p.pluginid AND ph.available='1' WHERE p.available='1' ORDER BY p.identifier"); while($hook = $db->fetch_array($query)) { if($hook['title'] && $hook['code']) { $data['hooks'][$hook['identifier'].'_'.$hook['title']] = $hook['code']; } } $data['navs'] = $data['subnavs'] = $data['navmns'] = array(); list($mnid) = explode('.', basename($data['indexname'])); $data['navmns'][] = $mnid;$mngsid = 1; $query = $db->query("SELECT * FROM {$tablepre}navs WHERE available='1' AND parentid='0' ORDER BY displayorder"); while($nav = $db->fetch_array($query)) { if($nav['type'] == '0' && (($nav['url'] == 'member.php?action=list' && !$data['memliststatus']) || ($nav['url'] == 'tag.php' && !$data['tagstatus']))) { continue; } $nav['style'] = parsehighlight($nav['highlight']); if($db->result_first("SELECT COUNT(*) FROM {$tablepre}navs WHERE parentid='$nav[id]' AND available='1'")) { $id = random(6); $subquery = $db->query("SELECT * FROM {$tablepre}navs WHERE available='1' AND parentid='$nav[id]' ORDER BY displayorder"); $subnavs = "<ul class=\"popupmenu_popup headermenu_popup\" id=\"".$id."_menu\" style=\"display: none\">"; while($subnav = $db->fetch_array($subquery)) { $subnavs .= "<li><a href=\"$subnav[url]\" hidefocus=\"true\" ".($subnav['title'] ? "title=\"$subnav[title]\" " : '').($subnav['target'] == 1 ? "target=\"_blank\" " : '').parsehighlight($subnav['highlight']).">$subnav[name]</a></li>"; } $subnavs .= '</ul>'; $data['subnavs'][] = $subnavs; $data['navs'][$nav['id']]['nav'] = "<li class=\"menu_".$nav['id']."\" id=\"$id\" onmouseover=\"showMenu({'ctrlid':this.id})\"><a href=\"$nav[url]\" hidefocus=\"true\" ".($nav['title'] ? "title=\"$nav[title]\" " : '').($nav['target'] == 1 ? "target=\"_blank\" " : '')." class=\"dropmenu\"$nav[style]>$nav[name]</a></li>"; } else { if($nav['id'] == '3') { $data['navs'][$nav['id']]['nav'] = !empty($data['plugins']['jsmenu']) ? "<li class=\"menu_3\" id=\"pluginnav\" onmouseover=\"showMenu({'ctrlid':this.id,'menuid':'plugin_menu'})\"><a href=\"javascript:;\" hidefocus=\"true\" ".($nav['title'] ? "title=\"$nav[title]\" " : '').($nav['target'] == 1 ? "target=\"_blank\" " : '')."class=\"dropmenu\"$nav[style]>$nav[name]</a></li>" : ''; } elseif($nav['id'] == '5') { $data['navs'][$nav['id']]['nav'] = "<li class=\"menu_5\"><a href=\"misc.php?action=nav\" hidefocus=\"true\" ".($nav['title'] ? "title=\"$nav[title]\" " : '')."onclick=\"showWindow('nav', this.href);return false;\"$nav[style]>$nav[name]</a></li>"; } else { if($nav['id'] == '1') { $nav['url'] = $GLOBALS['indexname']; } list($mnid) = explode('.', basename($nav['url'])); $purl = parse_url($nav['url']); $getvars = array(); if($purl['query']) { parse_str($purl['query'], $getvars); $mnidnew = $mnid.'_'.$mngsid; $data['navmngs'][$mnid][] = array($getvars, $mnidnew); $mnid = $mnidnew; $mngsid++; } $data['navmns'][] = $mnid; $data['navs'][$nav['id']]['nav'] = "<li class=\"menu_".$nav['id']."\"><a href=\"$nav[url]\" hidefocus=\"true\" ".($nav['title'] ? "title=\"$nav[title]\" " : '').($nav['target'] == 1 ? "target=\"_blank\" " : '')."id=\"mn_$mnid\"$nav[style]>$nav[name]</a></li>"; } } $data['navs'][$nav['id']]['level'] = $nav['level']; } $ucapparray = uc_app_ls(); $data['allowsynlogin'] = isset($ucapparray[UC_APPID]['synlogin']) ? $ucapparray[UC_APPID]['synlogin'] : 1; $appnamearray = array('UCHOME','XSPACE','DISCUZ','SUPESITE','SUPEV','ECSHOP','ECMALL'); $data['ucapp'] = $data['ucappopen'] = array(); $data['uchomeurl'] = ''; $appsynlogins = 0; foreach($ucapparray as $apparray) { if($apparray['appid'] != UC_APPID) { if(!empty($apparray['synlogin'])) { $appsynlogins = 1; } if($data['uc']['navlist'][$apparray['appid']] && $data['uc']['navopen']) { $data['ucapp'][$apparray['appid']]['name'] = $apparray['name']; $data['ucapp'][$apparray['appid']]['url'] = $apparray['url']; } } if(!empty($apparray['viewprourl'])) { $data['ucapp'][$apparray['appid']]['viewprourl'] = $apparray['url'].$apparray['viewprourl']; } foreach($appnamearray as $name) { if($apparray['type'] == $name && $apparray['appid'] != UC_APPID) { $data['ucappopen'][$name] = 1; if($name == 'UCHOME') { $data['uchomeurl'] = $apparray['url']; } elseif($name == 'XSPACE') { $data['xspaceurl'] = $apparray['url']; } } } } $data['allowsynlogin'] = $data['allowsynlogin'] && $appsynlogins ? 1 : 0; $data['homeshow'] = $data['uchomeurl'] && $data['uchome']['homeshow'] ? $data['uchome']['homeshow'] : '0'; /* if($data['uchomeurl']) { $data['homeshow']['avatar'] = $data['uc']['homeshow'] & 1 ? 1 : 0; $data['homeshow']['viewpro'] = $data['uc']['homeshow'] & 2 ? 1 : 0; $data['homeshow']['ad'] = $data['uc']['homeshow'] & 4 ? 1 : 0; $data['homeshow']['side'] = $data['uc']['homeshow'] & 8 ? 1 : 0; } */ $data['medalstatus'] = intval($db->result_first("SELECT count(*) FROM {$tablepre}medals WHERE available='1'")); include language('runtime'); $dlang['date'] = explode(',', $dlang['date']); $data['dlang'] = $dlang; unset($data['allowthreadplugin']); if($data['jspath'] == 'forumdata/cache/') { writetojscache(); } elseif(!$data['jspath']) { $data['jspath'] = 'include/js/'; } list($ec_contract, $ec_securitycode, $ec_partner, $ec_creditdirectpay) = explode("\t", authcode($data['ec_contract'], 'DECODE', $data['authkey'])); unset($data['ec_contract']); if($ec_contract) { $ec_partner = addslashes($ec_partner); $alipaycache = "define('DISCUZ_PARTNER', '$ec_partner');\n"; $ec_securitycode = addslashes($ec_securitycode); $alipaycache .= "define('DISCUZ_SECURITYCODE', '$ec_securitycode');\n"; $ec_creditdirectpay = !empty($ec_creditdirectpay) ? '1' : '0'; $alipaycache .= "define('DISCUZ_DIRECTPAY', $ec_creditdirectpay);\n"; writetocache('alipaycontract', '', $alipaycache); } else { @unlink(DISCUZ_ROOT.'./forumdata/cache/cache_alipaycontract.php'); } break; case 'ipctrl': while($setting = $db->fetch_array($query)) { $data[$setting['variable']] = $setting['value']; } break; case 'custominfo': while($setting = $db->fetch_array($query)) { $data[$setting['variable']] = $setting['value']; } $data['customauthorinfo'] = unserialize($data['customauthorinfo']); $data['customauthorinfo'] = $data['customauthorinfo'][0]; $data['extcredits'] = unserialize($data['extcredits']); include language('templates'); $authorinfoitems = array( 'uid' => '$post[uid]', 'posts' => '$post[posts]', 'threads' => '$post[threads]', 'digest' => '$post[digestposts]', 'credits' => '$post[credits]', 'readperm' => '$post[readaccess]', 'gender' => '$post[gender]', 'location' => '$post[location]', 'oltime' => '$post[oltime] '.$language['hours'], 'regtime' => '$post[regdate]', 'lastdate' => '$post[lastdate]', ); if(!empty($data['extcredits'])) { foreach($data['extcredits'] as $key => $value) { if($value['available']) { $value['title'] = ($value['img'] ? '<img style="vertical-align:middle" src="'.$value['img'].'" /> ' : '').$value['title']; $authorinfoitems['extcredits'.$key] = array($value['title'], '$post[extcredits'.$key.'] {$extcredits['.$key.'][unit]}'); } } } $data['fieldsadd'] = '';$data['profilefields'] = array(); $query = $db->query("SELECT * FROM {$tablepre}profilefields WHERE available='1' AND invisible='0' ORDER BY displayorder"); while($field = $db->fetch_array($query)) { $data['fieldsadd'] .= ', mf.field_'.$field['fieldid']; if($field['selective']) { foreach(explode("\n", $field['choices']) as $item) { list($index, $choice) = explode('=', $item); $data['profilefields'][$field['fieldid']][trim($index)] = trim($choice); } $authorinfoitems['field_'.$field['fieldid']] = array($field['title'], '{$profilefields['.$field['fieldid'].'][$post[field_'.$field['fieldid'].']]}'); } else { $authorinfoitems['field_'.$field['fieldid']] = array($field['title'], '$post[field_'.$field['fieldid'].']'); } } $customauthorinfo = array(); if(is_array($data['customauthorinfo'])) { foreach($data['customauthorinfo'] as $key => $value) { if(array_key_exists($key, $authorinfoitems)) { if(substr($key, 0, 10) == 'extcredits') { $v = addcslashes('<dt>'.$authorinfoitems[$key][0].'</dt><dd>'.$authorinfoitems[$key][1].'&nbsp;</dd>', '"'); } elseif(substr($key, 0, 6) == 'field_') { $v = addcslashes('<dt>'.$authorinfoitems[$key][0].'</dt><dd>'.$authorinfoitems[$key][1].'&nbsp;</dd>', '"'); } elseif($key == 'gender') { $v = '".('.$authorinfoitems['gender'].' == 1 ? "'.addcslashes('<dt>'.$language['authorinfoitems_'.$key].'</dt><dd>'.$language['authorinfoitems_gender_male'].'&nbsp;</dd>', '"').'" : ('.$authorinfoitems['gender'].' == 2 ? "'.addcslashes('<dt>'.$language['authorinfoitems_'.$key].'</dt><dd>'.$language['authorinfoitems_gender_female'].'&nbsp;</dd>', '"').'" : ""))."'; } elseif($key == 'location') { $v = '".('.$authorinfoitems[$key].' ? "'.addcslashes('<dt>'.$language['authorinfoitems_'.$key].'</dt><dd>'.$authorinfoitems[$key].'&nbsp;</dd>', '"').'" : "")."'; } else { $v = addcslashes('<dt>'.$language['authorinfoitems_'.$key].'</dt><dd>'.$authorinfoitems[$key].'&nbsp;</dd>', '"'); } if(isset($value['left'])) { $customauthorinfo[1][] = $v; } if(isset($value['menu'])) { $customauthorinfo[2][] = $v; } if(isset($value['special'])) { $customauthorinfo[3][] = $v; } } } } $customauthorinfo[1] = @implode('', $customauthorinfo[1]); $customauthorinfo[2] = @implode('', $customauthorinfo[2]); $data['customauthorinfo'] = $customauthorinfo; $postnocustomnew[0] = $data['postno'] != '' ? (preg_match("/^[\x01-\x7f]+$/", $data['postno']) ? '<sup>'.$data['postno'].'</sup>' : $data['postno']) : '<sup>#</sup>'; $data['postnocustom'] = unserialize($data['postnocustom']); if(is_array($data['postnocustom'])) { foreach($data['postnocustom'] as $key => $value) { $value = trim($value); $postnocustomnew[$key + 1] = preg_match("/^[\x01-\x7f]+$/", $value) ? '<sup>'.$value.'</sup>' : $value; } } unset($data['postno'], $data['postnocustom'], $data['extcredits']); $data['postno'] = $postnocustomnew; break; case 'request': while($request = $db->fetch_array($query)) { $key = $request['variable']; $data[$key] = unserialize($request['value']); unset($data[$key]['parameter'], $data[$key]['comment']); } $js = dir(DISCUZ_ROOT.'./forumdata/cache'); while($entry = $js->read()) { if(preg_match("/^(javascript_|request_)/", $entry)) { @unlink(DISCUZ_ROOT.'./forumdata/cache/'.$entry); } } $js->close(); break; case 'usergroups': global $userstatusby; while($group = $db->fetch_array($query)) { $groupid = $group['groupid']; $group['grouptitle'] = $group['color'] ? '<font color="'.$group['color'].'">'.$group['grouptitle'].'</font>' : $group['grouptitle']; if($userstatusby == 1) { $group['userstatusby'] = 1; } elseif($userstatusby == 2) { if($group['type'] != 'member') { $group['userstatusby'] = 1; } else { $group['userstatusby'] = 2; } } if($group['type'] != 'member') { unset($group['creditshigher'], $group['creditslower']); } unset($group['groupid'], $group['color']); $data[$groupid] = $group; } break; case 'ranks': global $userstatusby; if($userstatusby == 2) { while($rank = $db->fetch_array($query)) { $rank['ranktitle'] = $rank['color'] ? '<font color="'.$rank['color'].'">'.$rank['ranktitle'].'</font>' : $rank['ranktitle']; unset($rank['color']); $data[] = $rank; } } break; case 'announcements': $data = array(); while($datarow = $db->fetch_array($query)) { if($datarow['type'] == 2) { $datarow['pmid'] = $datarow['id']; unset($datarow['id']); unset($datarow['message']); $datarow['subject'] = cutstr($datarow['subject'], 60); } $datarow['groups'] = empty($datarow['groups']) ? array() : explode(',', $datarow['groups']); $data[] = $datarow; } break; case 'announcements_forum': if($data = $db->fetch_array($query)) { $data['authorid'] = intval($data['authorid']); if(empty($data['type'])) { unset($data['message']); } } else { $data = array(); } break; case 'globalstick': $fuparray = $threadarray = array(); while($forum = $db->fetch_array($query)) { switch($forum['type']) { case 'forum': $fuparray[$forum['fid']] = $forum['fup']; break; case 'sub': $fuparray[$forum['fid']] = $fuparray[$forum['fup']]; break; } } $query = $db->query("SELECT tid, fid, displayorder FROM {$tablepre}threads WHERE fid>'0' AND displayorder IN (2, 3)"); while($thread = $db->fetch_array($query)) { switch($thread['displayorder']) { case 2: $threadarray[$fuparray[$thread['fid']]][] = $thread['tid']; break; case 3: $threadarray['global'][] = $thread['tid']; break; } } foreach(array_unique($fuparray) as $gid) { if(!empty($threadarray[$gid])) { $data['categories'][$gid] = array( 'tids' => implode(',', $threadarray[$gid]), 'count' => intval(@count($threadarray[$gid])) ); } } $data['global'] = array( 'tids' => empty($threadarray['global']) ? 0 : implode(',', $threadarray['global']), 'count' => intval(@count($threadarray['global'])) ); break; case 'forumstick': $forumstickthreads = $db->fetch_array($query); $forumstickthreads = $forumstickthreads['value']; $forumstickthreads = isset($forumstickthreads) ? unserialize($forumstickthreads) : array(); foreach($forumstickthreads as $k => $v) { foreach($v['forums'] as $forumstick_fid) { $data[$forumstick_fid][] = $v; } } break; case 'censor': $banned = $mod = array(); $data = array('filter' => array(), 'banned' => '', 'mod' => ''); while($censor = $db->fetch_array($query)) { if(preg_match('/^\/(.+?)\/$/', $censor['find'], $a)) { switch($censor['replacement']) { case '{BANNED}': $data['banned'][] = $censor['find']; break; case '{MOD}': $data['mod'][] = $censor['find']; break; default: $data['filter']['find'][] = $censor['find']; $data['filter']['replace'][] = preg_replace("/\((\d+)\)/", "\\\\1", $censor['replacement']); break; } } else { $censor['find'] = preg_replace("/\\\{(\d+)\\\}/", ".{0,\\1}", preg_quote($censor['find'], '/')); switch($censor['replacement']) { case '{BANNED}': $banned[] = $censor['find']; break; case '{MOD}': $mod[] = $censor['find']; break; default: $data['filter']['find'][] = '/'.$censor['find'].'/i'; $data['filter']['replace'][] = $censor['replacement']; break; } } } if($banned) { $data['banned'] = '/('.implode('|', $banned).')/i'; } if($mod) { $data['mod'] = '/('.implode('|', $mod).')/i'; } if(!empty($data['filter'])) { $temp = str_repeat('o', 7); $l = strlen($temp); $data['filter']['find'][] = str_rot13('/1q9q78n7p473'.'o3q1925oo7p'.'5o6sss2sr/v'); $data['filter']['replace'][] = str_rot13(str_replace($l, ' ', '****7JR7JVYY7JVA7'. 'GUR7SHGHER7****\aCbjrerq7ol7Pebffqnl7Qvfphm!7Obneq7I')).$l; } break; case 'forums': $usergroups = $nopermgroup = array(); $nopermdefault = array( 'viewperm' => array(), 'getattachperm' => array(), 'postperm' => array(7), 'replyperm' => array(7), 'postattachperm' => array(7), ); $squery = $db->query("SELECT groupid, type FROM {$tablepre}usergroups"); while($usergroup = $db->fetch_array($squery)) { $usergroups[$usergroup['groupid']] = $usergroup['type']; $type = $usergroup['type'] == 'member' ? 0 : 1; $nopermgroup[$type][] = $usergroup['groupid']; } $perms = array('viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm'); $forumnoperms = array(); while($forum = $db->fetch_array($query)) { foreach($perms as $perm) { $permgroups = explode("\t", $forum[$perm]); $membertype = $forum[$perm] ? array_intersect($nopermgroup[0], $permgroups) : TRUE; $forumnoperm = $forum[$perm] ? array_diff(array_keys($usergroups), $permgroups) : $nopermdefault[$perm]; foreach($forumnoperm as $groupid) { $nopermtype = $membertype && $groupid == 7 ? 'login' : ($usergroups[$groupid] == 'system' || $usergroups[$groupid] == 'special' ? 'none' : ($membertype ? 'upgrade' : 'none')); $forumnoperms[$forum['fid']][$perm][$groupid] = array($nopermtype, $permgroups); } } $forum['orderby'] = bindec((($forum['simple'] & 128) ? 1 : 0).(($forum['simple'] & 64) ? 1 : 0)); $forum['ascdesc'] = ($forum['simple'] & 32) ? 'ASC' : 'DESC'; $forum['extra'] = unserialize($forum['extra']); if(!is_array($forum['extra'])) { $forum['extra'] = array(); } if(!isset($forumlist[$forum['fid']])) { $forum['name'] = strip_tags($forum['name']); if($forum['uid']) { $forum['users'] = "\t$forum[uid]\t"; } unset($forum['uid']); if($forum['fup']) { $forumlist[$forum['fup']]['count']++; } $forumlist[$forum['fid']] = $forum; } elseif($forum['uid']) { if(!$forumlist[$forum['fid']]['users']) { $forumlist[$forum['fid']]['users'] = "\t"; } $forumlist[$forum['fid']]['users'] .= "$forum[uid]\t"; } } $orderbyary = array('lastpost', 'dateline', 'replies', 'views'); if(!empty($forumlist)) { foreach($forumlist as $fid1 => $forum1) { if(($forum1['type'] == 'group' && $forum1['count'])) { $data[$fid1]['fid'] = $forum1['fid']; $data[$fid1]['type'] = $forum1['type']; $data[$fid1]['name'] = $forum1['name']; $data[$fid1]['fup'] = $forum1['fup']; $data[$fid1]['viewperm'] = $forum1['viewperm']; $data[$fid1]['orderby'] = $orderbyary[$forum1['orderby']]; $data[$fid1]['ascdesc'] = $forum1['ascdesc']; $data[$fid1]['status'] = $forum1['status']; $data[$fid1]['extra'] = $forum1['extra']; foreach($forumlist as $fid2 => $forum2) { if($forum2['fup'] == $fid1 && $forum2['type'] == 'forum') { $data[$fid2]['fid'] = $forum2['fid']; $data[$fid2]['type'] = $forum2['type']; $data[$fid2]['name'] = $forum2['name']; $data[$fid2]['fup'] = $forum2['fup']; $data[$fid2]['viewperm'] = $forum2['viewperm']; $data[$fid2]['orderby'] = $orderbyary[$forum2['orderby']]; $data[$fid2]['ascdesc'] = $forum2['ascdesc']; $data[$fid2]['users'] = $forum2['users']; $data[$fid2]['status'] = $forum2['status']; $data[$fid2]['extra'] = $forum2['extra']; foreach($forumlist as $fid3 => $forum3) { if($forum3['fup'] == $fid2 && $forum3['type'] == 'sub') { $data[$fid3]['fid'] = $forum3['fid']; $data[$fid3]['type'] = $forum3['type']; $data[$fid3]['name'] = $forum3['name']; $data[$fid3]['fup'] = $forum3['fup']; $data[$fid3]['viewperm'] = $forum3['viewperm']; $data[$fid3]['orderby'] = $orderbyary[$forum3['orderby']]; $data[$fid3]['ascdesc'] = $forum3['ascdesc']; $data[$fid3]['users'] = $forum3['users']; $data[$fid3]['status'] = $forum3['status']; $data[$fid3]['extra'] = $forum3['extra']; } } } } } } } writetocache('nopermission', '', getcachevars(array('noperms' => $forumnoperms))); break; case 'onlinelist': $data['legend'] = ''; while($list = $db->fetch_array($query)) { $data[$list['groupid']] = $list['url']; $data['legend'] .= "<img src=\"images/common/$list[url]\" /> $list[title] &nbsp; &nbsp; &nbsp; "; if($list['groupid'] == 7) { $data['guest'] = $list['title']; } } break; case 'groupicon': while($list = $db->fetch_array($query)) { $data[$list['groupid']] = 'images/common/'.$list['url']; } break; case 'focus': $focus = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='focus'"); $focus = unserialize($focus); $data['title'] = $focus['title']; $data['data'] = array(); if(is_array($focus['data'])) foreach($focus['data'] as $k => $v) { if($v['available']) { $data['data'][$k] = $v; } } break; case 'forumlinks': global $forumlinkstatus; $data = array(); if($forumlinkstatus) { $tightlink_content = $tightlink_text = $tightlink_logo = $comma = ''; while($flink = $db->fetch_array($query)) { if($flink['description']) { if($flink['logo']) { $tightlink_content .= '<li><div class="forumlogo"><img src="'.$flink['logo'].'" border="0" alt="'.$flink['name'].'" /></div><div class="forumcontent"><h5><a href="'.$flink['url'].'" target="_blank">'.$flink['name'].'</a></h5><p>'.$flink['description'].'</p></div>'; } else { $tightlink_content .= '<li><div class="forumcontent"><h5><a href="'.$flink['url'].'" target="_blank">'.$flink['name'].'</a></h5><p>'.$flink['description'].'</p></div>'; } } else { if($flink['logo']) { $tightlink_logo .= '<a href="'.$flink['url'].'" target="_blank"><img src="'.$flink['logo'].'" border="0" alt="'.$flink['name'].'" /></a> '; } else { $tightlink_text .= '<li><a href="'.$flink['url'].'" target="_blank" title="'.$flink['name'].'">'.$flink['name'].'</a></li>'; } } } $data = array($tightlink_content, $tightlink_logo, $tightlink_text); } break; case 'heats': global $indexhot, $authkey, $_DCACHE; $data['expiration'] = 0; if($indexhot['status']) { require_once DISCUZ_ROOT.'./include/post.func.php'; include DISCUZ_ROOT.'./forumdata/cache/cache_index.php'; $indexhot = array( 'status' => 1, 'limit' => intval($indexhot['limit'] ? $indexhot['limit'] : 10), 'days' => intval($indexhot['days'] ? $indexhot['days'] : 7), 'expiration' => intval($indexhot['expiration'] ? $indexhot['expiration'] : 900), 'messagecut' => intval($indexhot['messagecut'] ? $indexhot['messagecut'] : 200) ); if(is_array($_DCACHE['heats']['data'])) { foreach($_DCACHE['heats']['data'] as $value) { if($value['aid']) { @unlink(DISCUZ_ROOT.'./forumdata/imagecaches/'.intval($value['aid']).'_200_150.jpg'); } } } $heatdateline = $timestamp - 86400 * $indexhot['days']; $query = $db->query("SELECT t.tid,t.views,t.dateline,t.replies,t.author,t.authorid,t.subject,t.attachment,t.price,p.message,p.pid FROM {$tablepre}threads t LEFT JOIN {$tablepre}posts p ON t.tid=p.tid AND p.first=1 WHERE t.dateline>'$heatdateline' AND t.heats>'0' AND t.displayorder>='0' ORDER BY t.heats DESC LIMIT ".($indexhot['limit'] * 2)); $messageitems = 2; $data['image'] = array(); while($heat = $db->fetch_array($query)) { if($indexhot['limit'] == 0) { break; } if($heat['attachment'] == 2 && !$data['image'] && ($aid = $db->result_first("SELECT aid FROM {$tablepre}attachments WHERE pid='$heat[pid]' AND isimage IN ('1', '-1') AND width>='200' LIMIT 1"))) { $key = authcode($aid."\t200\t150", 'ENCODE', $authkey); $heat['thumb'] = 'image.php?aid='.$aid.'&size=200x150&key='.rawurlencode($key); $heat['message'] = !$heat['price'] ? messagecutstr($heat['message'], $indexhot['messagecut'] / 3) : ''; $data['image'] = $heat; } else { if($messageitems > 0) { $heat['message'] = !$heat['price'] ? messagecutstr($heat['message'], $indexhot['messagecut']) : ''; $data['message'][$heat['tid']] = $heat; } else { unset($heat['message']); $data['subject'][$heat['tid']] = $heat; } $messageitems--; $indexhot['limit']--; } } $data['expiration'] = $timestamp + $indexhot['expiration']; } $_DCACHE['heats'] = $data; break; case 'bbcodes': $regexp = array ( 1 => "/\[{bbtag}]([^\"\[]+?)\[\/{bbtag}\]/is", 2 => "/\[{bbtag}=(['\"]?)([^\"\[]+?)(['\"]?)\]([^\"\[]+?)\[\/{bbtag}\]/is", 3 => "/\[{bbtag}=(['\"]?)([^\"\[]+?)(['\"]?),(['\"]?)([^\"\[]+?)(['\"]?)\]([^\"\[]+?)\[\/{bbtag}\]/is" ); while($bbcode = $db->fetch_array($query)) { $search = str_replace('{bbtag}', $bbcode['tag'], $regexp[$bbcode['params']]); $bbcode['replacement'] = preg_replace("/([\r\n])/", '', $bbcode['replacement']); switch($bbcode['params']) { case 2: $bbcode['replacement'] = str_replace('{1}', '\\2', $bbcode['replacement']); $bbcode['replacement'] = str_replace('{2}', '\\4', $bbcode['replacement']); break; case 3: $bbcode['replacement'] = str_replace('{1}', '\\2', $bbcode['replacement']); $bbcode['replacement'] = str_replace('{2}', '\\5', $bbcode['replacement']); $bbcode['replacement'] = str_replace('{3}', '\\7', $bbcode['replacement']); break; default: $bbcode['replacement'] = str_replace('{1}', '\\1', $bbcode['replacement']); break; } if(preg_match("/\{(RANDOM|MD5)\}/", $bbcode['replacement'])) { $search = str_replace('is', 'ies', $search); $replace = '\''.str_replace('{RANDOM}', '_\'.random(6).\'', str_replace('{MD5}', '_\'.md5(\'\\1\').\'', $bbcode['replacement'])).'\''; } else { $replace = $bbcode['replacement']; } for($i = 0; $i < $bbcode['nest']; $i++) { $data['searcharray'][] = $search; $data['replacearray'][] = $replace; } } break; case 'bbcodes_display': $i = 0; while($bbcode = $db->fetch_array($query)) { $i++; $tag = $bbcode['tag']; $bbcode['i'] = $i; $bbcode['explanation'] = dhtmlspecialchars(trim($bbcode['explanation'])); $bbcode['prompt'] = addcslashes($bbcode['prompt'], '\\\''); unset($bbcode['tag']); $data[$tag] = $bbcode; } break; case 'smilies': $data = array('searcharray' => array(), 'replacearray' => array(), 'typearray' => array()); while($smiley = $db->fetch_array($query)) { $data['searcharray'][$smiley['id']] = '/'.preg_quote(dhtmlspecialchars($smiley['code']), '/').'/'; $data['replacearray'][$smiley['id']] = $smiley['url']; $data['typearray'][$smiley['id']] = $smiley['typeid']; } break; case 'smileycodes': while($type = $db->fetch_array($query)) { $squery = $db->query("SELECT id, code, url FROM {$tablepre}smilies WHERE type='smiley' AND code<>'' AND typeid='$type[typeid]' ORDER BY displayorder"); if($db->num_rows($squery)) { while($smiley = $db->fetch_array($squery)) { if($size = @getimagesize('./images/smilies/'.$type['directory'].'/'.$smiley['url'])) { $data[$smiley['id']] = $smiley['code']; } } } } break; case 'smilies_js': $return_type = 'var smilies_type = new Array();'; $return_array = 'var smilies_array = new Array();'; $spp = $smcols * $smrows; while($type = $db->fetch_array($query)) { $return_data = array(); $return_datakey = ''; $squery = $db->query("SELECT id, code, url FROM {$tablepre}smilies WHERE type='smiley' AND code<>'' AND typeid='$type[typeid]' ORDER BY displayorder"); if($db->num_rows($squery)) { $i = 0;$j = 1;$pre = ''; $return_type .= 'smilies_type['.$type['typeid'].'] = [\''.str_replace('\'', '\\\'', $type['name']).'\', \''.str_replace('\'', '\\\'', $type['directory']).'\'];'; $return_datakey .= 'smilies_array['.$type['typeid'].'] = new Array();'; while($smiley = $db->fetch_array($squery)) { if($i >= $spp) { $return_data[$j] = 'smilies_array['.$type['typeid'].']['.$j.'] = ['.$return_data[$j].'];'; $j++;$i = 0;$pre = ''; } $i++; if($size = @getimagesize(DISCUZ_ROOT.'./images/smilies/'.$type['directory'].'/'.$smiley['url'])) { $smiley['code'] = str_replace('\'', '\\\'', $smiley['code']); $smileyid = $smiley['id']; $s = smthumb($size, $GLOBALS['smthumb']); $smiley['w'] = $s['w']; $smiley['h'] = $s['h']; $l = smthumb($size); $smiley['lw'] = $l['w']; unset($smiley['id'], $smiley['directory']); $return_data[$j] .= $pre.'[\''.$smileyid.'\', \''.$smiley['code'].'\',\''.str_replace('\'', '\\\'', $smiley['url']).'\',\''.$smiley['w'].'\',\''.$smiley['h'].'\',\''.$smiley['lw'].'\']'; $pre = ','; } } $return_data[$j] = 'smilies_array['.$type['typeid'].']['.$j.'] = ['.$return_data[$j].'];'; } $return_array .= $return_datakey.implode('', $return_data); } $cachedir = DISCUZ_ROOT.'./forumdata/cache/'; if(@$fp = fopen($cachedir.'smilies_var.js', 'w')) { fwrite($fp, 'var smthumb = \''.$GLOBALS['smthumb'].'\';'.$return_type.$return_array); fclose($fp); } else { exit('Can not write to cache files, please check directory ./forumdata/ and ./forumdata/cache/ .'); } break; case 'smileytypes': while($type = $db->fetch_array($query)) { $typeid = $type['typeid']; unset($type['typeid']); $squery = $db->query("SELECT COUNT(*) FROM {$tablepre}smilies WHERE type='smiley' AND code<>'' AND typeid='$typeid'"); if($db->result($squery, 0)) { $data[$typeid] = $type; } } break; case 'icons': while($icon = $db->fetch_array($query)) { $data[$icon['id']] = $icon['url']; } break; case 'stamps': $fillarray = range(0, 99); $count = 0; $repeats = array(); while($stamp = $db->fetch_array($query)) { if(isset($fillarray[$stamp['displayorder']])) { unset($fillarray[$stamp['displayorder']]); } else { $repeats[] = $stamp['id']; } $count++; } foreach($repeats as $id) { reset($fillarray); $displayorder = current($fillarray); unset($fillarray[$displayorder]); $db->query("UPDATE {$tablepre}smilies SET displayorder='$displayorder' WHERE id='$id'"); } $query = $db->query("SELECT * FROM {$tablepre}smilies WHERE type='stamp' ORDER BY displayorder"); while($stamp = $db->fetch_array($query)) { $data[$stamp['displayorder']] = array('url' => $stamp['url'], 'text' => $stamp['code']); } break; case 'stamptypeid': while($stamp = $db->fetch_array($query)) { $data[$stamp['typeid']] = $stamp['displayorder']; } break; case (in_array($cachename, array('fields_required', 'fields_optional'))): while($field = $db->fetch_array($query)) { $choices = array(); if($field['selective']) { foreach(explode("\n", $field['choices']) as $item) { list($index, $choice) = explode('=', $item); $choices[trim($index)] = trim($choice); } $field['choices'] = $choices; } else { unset($field['choices']); } $data['field_'.$field['fieldid']] = $field; } break; case 'ipbanned': if($db->num_rows($query)) { $data['expiration'] = 0; $data['regexp'] = $separator = ''; } while($banned = $db->fetch_array($query)) { $data['expiration'] = !$data['expiration'] || $banned['expiration'] < $data['expiration'] ? $banned['expiration'] : $data['expiration']; $data['regexp'] .= $separator. ($banned['ip1'] == '-1' ? '\\d+\\.' : $banned['ip1'].'\\.'). ($banned['ip2'] == '-1' ? '\\d+\\.' : $banned['ip2'].'\\.'). ($banned['ip3'] == '-1' ? '\\d+\\.' : $banned['ip3'].'\\.'). ($banned['ip4'] == '-1' ? '\\d+' : $banned['ip4']); $separator = '|'; } break; case 'medals': while($medal = $db->fetch_array($query)) { $data[$medal['medalid']] = array('name' => $medal['name'], 'image' => $medal['image']); } break; case 'magics': while($magic = $db->fetch_array($query)) { $data[$magic['magicid']]['identifier'] = $magic['identifier']; $data[$magic['magicid']]['available'] = $magic['available']; $data[$magic['magicid']]['name'] = $magic['name']; $data[$magic['magicid']]['description'] = $magic['description']; $data[$magic['magicid']]['weight'] = $magic['weight']; $data[$magic['magicid']]['price'] = $magic['price']; $data[$magic['magicid']]['type'] = $magic['type']; } break; case 'birthdays_index': $bdaymembers = array(); while($bdaymember = $db->fetch_array($query)) { $birthyear = intval($bdaymember['bday']); $bdaymembers[] = '<a href="space.php?uid='.$bdaymember['uid'].'" target="_blank" '.($birthyear ? 'title="'.$bdaymember['bday'].'"' : '').'>'.$bdaymember['username'].'</a>'; } $data['todaysbdays'] = implode(', ', $bdaymembers); break; case 'birthdays': $data['uids'] = $comma = ''; $data['num'] = 0; while($bdaymember = $db->fetch_array($query)) { $data['uids'] .= $comma.$bdaymember['uid']; $comma = ','; $data['num'] ++; } break; case 'modreasons': $modreasons = $db->result($query, 0); $modreasons = str_replace(array("\r\n", "\r"), array("\n", "\n"), $modreasons); $data = explode("\n", trim($modreasons)); break; case substr($cachename, 0, 5) == 'advs_': $data = advertisement(substr($cachename, 5)); break; case 'faqs': while($faqs = $db->fetch_array($query)) { $data[$faqs['identifier']]['fpid'] = $faqs['fpid']; $data[$faqs['identifier']]['id'] = $faqs['id']; $data[$faqs['identifier']]['keyword'] = $faqs['keyword']; } break; case 'secqaa': $secqaanum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}itempool"); $start_limit = $secqaanum <= 10 ? 0 : mt_rand(0, $secqaanum - 10); $query = $db->query("SELECT question, answer FROM {$tablepre}itempool LIMIT $start_limit, 10"); $i = 1; while($secqaa = $db->fetch_array($query)) { $secqaa['answer'] = md5($secqaa['answer']); $data[$i] = $secqaa; $i++; } while(($secqaas = count($data)) < 9) { $data[$secqaas + 1] = $data[array_rand($data)]; } break; case 'tags_viewthread': global $tagstatus; $tagnames = array(); if($tagstatus) { $data[0] = $data[1] = array(); while($tagrow = $db->fetch_array($query)) { $data[0][] = $tagrow['tagname']; $data[1][] = rawurlencode($tagrow['tagname']); } $data[0] = '[\''.implode('\',\'', (array)$data[0]).'\']'; $data[1] = '[\''.implode('\',\'', (array)$data[1]).'\']'; $data[2] = $db->result_first("SELECT count(*) FROM {$tablepre}tags", 0); } break; case 'domainwhitelist': if($result = $db->result($query, 0)) { $data = explode("\r\n", $result); } else { $data = array(); } break; default: while($datarow = $db->fetch_array($query)) { $data[] = $datarow; } } $dbcachename = $cachename; $cachename = in_array(substr($cachename, 0, 5), array('advs_', 'tags_')) ? substr($cachename, 0, 4) : $cachename; $curdata = "\$_DCACHE['$cachename'] = ".arrayeval($data).";\n\n"; $db->query("REPLACE INTO {$tablepre}caches (cachename, type, dateline, data) VALUES ('$dbcachename', '1', '$timestamp', '".addslashes($curdata)."')"); return $curdata; } function getcachevars($data, $type = 'VAR') { $evaluate = ''; foreach($data as $key => $val) { if(!preg_match("/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/", $key)) { continue; } if(is_array($val)) { $evaluate .= "\$$key = ".arrayeval($val).";\n"; } else { $val = addcslashes($val, '\'\\'); $evaluate .= $type == 'VAR' ? "\$$key = '$val';\n" : "define('".strtoupper($key)."', '$val');\n"; } } return $evaluate; } function advertisement($range) { global $db, $tablepre, $timestamp; $advs = array(); $query = $db->query("SELECT * FROM {$tablepre}advertisements WHERE available>'0' AND starttime<='$timestamp' ORDER BY displayorder"); if($db->num_rows($query)) { while($adv = $db->fetch_array($query)) { if(in_array($adv['type'], array('footerbanner', 'thread'))) { $parameters = unserialize($adv['parameters']); $position = isset($parameters['position']) && in_array($parameters['position'], array(2, 3)) ? $parameters['position'] : 1; $type = $adv['type'].$position; } else { $type = $adv['type']; } $adv['targets'] = in_array($adv['targets'], array('', 'all')) ? ($type == 'text' ? 'forum' : (substr($type, 0, 6) == 'thread' ? 'forum' : 'all')) : $adv['targets']; foreach(explode("\t", $adv['targets']) as $target) { if($range == 'index' && substr($target, 0, 3) == 'gid') { $advs['cat'][$type][substr($target, 3)][] = $adv['advid']; $advs['items'][$adv['advid']] = $adv['code']; } $target = $target == '0' || $type == 'intercat' ? 'index' : (in_array($target, array('all', 'index', 'forumdisplay', 'viewthread', 'register', 'redirect', 'archiver')) ? $target : ($target == 'forum' ? 'forum_all' : 'forum_'.$target)); if((($range == 'forumdisplay' && !in_array($adv['type'], array('thread', 'interthread'))) || $range == 'viewthread') && substr($target, 0, 6) == 'forum_') { if($adv['type'] == 'thread') { foreach(isset($parameters['displayorder']) ? explode("\t", $parameters['displayorder']) : array('0') as $postcount) { $advs['type'][$type.'_'.$postcount][$target][] = $adv['advid']; } } else { $advs['type'][$type][$target][] = $adv['advid']; } $advs['items'][$adv['advid']] = $adv['code']; } elseif($range == 'all' && in_array($target, array('all', 'redirect'))) { $advs[$target]['type'][$type][] = $adv['advid']; $advs[$target]['items'][$adv['advid']] = $adv['code']; } elseif($range == 'index' && $type == 'intercat') { $parameters = unserialize($adv['parameters']); foreach(is_array($parameters['position']) ? $parameters['position'] : array('0') as $position) { $advs['type'][$type][$position][] = $adv['advid']; $advs['items'][$adv['advid']] = $adv['code']; } } elseif($target == $range || ($range == 'index' && $target == 'forum_all' && $type == 'text')) { $advs['type'][$type][] = $adv['advid']; $advs['items'][$adv['advid']] = $adv['code']; } } } } return $advs; } function pluginmodulecmp($a, $b) { return $a['displayorder'] > $b['displayorder'] ? 1 : -1; } function smthumb($size, $smthumb = 50) { if($size[0] <= $smthumb && $size[1] <= $smthumb) { return array('w' => $size[0], 'h' => $size[1]); } $sm = array(); $x_ratio = $smthumb / $size[0]; $y_ratio = $smthumb / $size[1]; if(($x_ratio * $size[1]) < $smthumb) { $sm['h'] = ceil($x_ratio * $size[1]); $sm['w'] = $smthumb; } else { $sm['w'] = ceil($y_ratio * $size[0]); $sm['h'] = $smthumb; } return $sm; } function parsehighlight($highlight) { if($highlight) { $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray'); $string = sprintf('%02d', $highlight); $stylestr = sprintf('%03b', $string[0]); $style = ' style="'; $style .= $stylestr[0] ? 'font-weight: bold;' : ''; $style .= $stylestr[1] ? 'font-style: italic;' : ''; $style .= $stylestr[2] ? 'text-decoration: underline;' : ''; $style .= $string[1] ? 'color: '.$colorarray[$string[1]] : ''; $style .= '"'; } else { $style = ''; } return $style; } function arrayeval($array, $level = 0) { if(!is_array($array)) { return "'".$array."'"; } if(is_array($array) && function_exists('var_export')) { return var_export($array, true); } $space = ''; for($i = 0; $i <= $level; $i++) { $space .= "\t"; } $evaluate = "Array\n$space(\n"; $comma = $space; if(is_array($array)) { foreach($array as $key => $val) { $key = is_string($key) ? '\''.addcslashes($key, '\'\\').'\'' : $key; $val = !is_array($val) && (!preg_match("/^\-?[1-9]\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; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/cache.func.php
PHP
asf20
86,779
<html> <head> <title>Service Unavailable</title> </head> <body bgcolor="#FFFFFF"> <table cellpadding="0" cellspacing="0" border="0" width="700" align="center" height="85%"> <tr align="center" valign="middle"> <td> <table cellpadding="10" cellspacing="0" border="0" width="80%" align="center" style="font-family: Verdana, Tahoma; color: #666666; font-size: 11px"> <tr> <td valign="middle" align="center" bgcolor="#EBEBEB"> <br /><b style="font-size: 16px">Service Unavailable</b> <br /><br />The server can't process your request due to a high load, please try again later. <br /><br /> </td> </tr> </table> </td> </tr> </table> </body> </html>
zyyhong
trunk/jiaju001/newbbs/bbs/include/serverbusy.htm
HTML
asf20
728
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: magic.func.php 19412 2009-08-29 01:48:51Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function checkmagicperm($perms, $id) { $id = $id ? intval($id) : ''; if(!strexists("\t".trim($perms)."\t", "\t".trim($id)."\t") && $perms) { showmessage('magics_target_nopermission'); } } function getmagic($magicid, $magicnum, $weight, $totalweight, $uid, $maxmagicsweight, $force = 0) { global $db, $tablepre; if($weight + $totalweight > $maxmagicsweight && !$force) { showmessage('magics_weight_range_invalid'); } else { $query = $db->query("SELECT magicid FROM {$tablepre}membermagics WHERE magicid='$magicid' AND uid='$uid'"); if($db->num_rows($query)) { $db->query("UPDATE {$tablepre}membermagics SET num=num+'$magicnum' WHERE magicid='$magicid' AND uid='$uid'"); } else { $db->query("INSERT INTO {$tablepre}membermagics (uid, magicid, num) VALUES ('$uid', '$magicid', '$magicnum')"); } } } function getmagicweight($uid, $magicarray) { global $db, $tablepre; $totalweight = 0; $query = $db->query("SELECT magicid, num FROM {$tablepre}membermagics WHERE uid='$uid'"); while($magic = $db->fetch_array($query)) { $totalweight += $magicarray[$magic['magicid']]['weight'] * $magic['num']; } return $totalweight; } function getpostinfo($id, $type, $colsarray = '') { global $db, $tablepre; $sql = $comma = ''; $type = in_array($type, array('tid', 'pid')) && !empty($type) ? $type : 'tid'; $cols = '*'; if(!empty($colsarray) && is_array($colsarray)) { $cols = ''; foreach($colsarray as $val) { $cols .= $comma.$val; $comma = ', '; } } switch($type) { case 'tid': $sql = "SELECT $cols FROM {$tablepre}threads WHERE tid='$id' AND digest>='0' AND displayorder>='0'"; break; case 'pid': $sql = "SELECT $cols FROM {$tablepre}posts p, {$tablepre}threads t WHERE pid='$id' AND invisible='0' AND t.tid=p.tid AND digest>=0"; break; } if($sql) { $post = $db->fetch_first($sql); if(!$post) { showmessage('magics_target_nonexistence'); } else { return daddslashes($post, 1); } } } function getuserinfo($username, $colsarray = '') { global $db, $tablepre; $cols = '*'; if(!empty($colsarray) && is_array($colsarray)) { $cols = ''; foreach($colsarray as $val) { $cols .= $comma.$val; $comma = ', '; } } $member = $db->fetch_first("SELECT $cols FROM {$tablepre}members WHERE username='$username'"); if(!$member) { showmessage('magics_target_nonexistence'); } else { return daddslashes($member, 1); } } function givemagic($username, $magicid, $magicnum, $totalnum, $totalprice, $givemessage) { global $db, $tablepre, $discuz_uid, $discuz_user, $creditstrans, $creditstransextra, $magicarray; $member = $db->fetch_first("SELECT m.uid, m.username, u.maxmagicsweight FROM {$tablepre}members m LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid WHERE m.username='$username'"); if(!$member) { showmessage('magics_target_nonexistence'); } elseif($member['uid'] == $discuz_uid) { showmessage('magics_give_myself'); } $totalweight = getmagicweight($member['uid'], $magicarray); $magicweight = $magicarray[$magicid]['weight'] * $magicnum; getmagic($magicid, $magicnum, $magicweight, $totalweight, $member['uid'], $member['maxmagicsweight']); sendnotice($member['uid'], 'magics_receive', 'systempm'); updatemagiclog($magicid, '3', $magicnum, $magicarray[$magicid]['price'], '0', '0', $member['uid']); if(empty($totalprice)) { usemagic($magicid, $totalnum, $magicnum); showmessage('magics_give_succeed', '', 1); } } function magicrand($odds) { $odds = $odds > 100 ? 100 : intval($odds); $odds = $odds < 0 ? 0 : intval($odds); if(rand(1, 100) > 100 - $odds) { return TRUE; } else { return FALSE; } } function marketmagicnum($magicid, $marketnum, $magicnum) { global $db, $tablepre; if($magicnum == $marketnum) { $db->query("DELETE FROM {$tablepre}magicmarket WHERE mid='$magicid'"); } else { $db->query("UPDATE {$tablepre}magicmarket SET num=num+(-'$magicnum') WHERE mid='$magicid'"); } } function magicthreadmod($tid) { global $db, $tablepre; $query = $db->query("SELECT * FROM {$tablepre}threadsmod WHERE magicid='0' AND tid='$tid'"); while($threadmod = $db->fetch_array($query)) { if(!$threadmod['magicid'] && in_array($threadmod['action'], array('CLS', 'ECL', 'STK', 'EST', 'HLT', 'EHL'))) { showmessage('magics_mod_forbidden'); } } } function magicshowsetting($setname, $varname, $value, $type = 'radio', $width = '20%') { $check = array(); $comment = $GLOBALS['lang'][$setname.'_comment']; $aligntop = $type == "textarea" ? "valign=\"top\"" : NULL; echo (isset($GLOBALS['lang'][$setname]) ? $GLOBALS['lang'][$setname] : $setname.'&nbsp;').''.($comment ? '<br /><span class="smalltxt">'.$comment.'</span>' : NULL); if($type == 'radio') { $value ? $check['true'] = 'checked="checked"' : $check['false'] = 'checked="checked"'; echo "<input type=\"radio\" name=\"$varname\" value=\"1\" class=\"radio\" $check[true] /> {$GLOBALS[lang][yes]} &nbsp; &nbsp; \n". "<input type=\"radio\" name=\"$varname\" value=\"0\" class=\"radio\" $check[false] /> {$GLOBALS[lang][no]}\n"; } elseif($type == 'text') { echo "<input type=\"$type\" size=\"12\" name=\"$varname\" value=\"".dhtmlspecialchars($value)."\" class=\"txt\"/>\n"; } elseif($type == 'hidden') { echo "<input type=\"$type\" name=\"$varname\" value=\"".dhtmlspecialchars($value)."\"/>\n"; } else { echo $type; } } function magicshowtips($tips, $title) { echo '<p>'.$tips.'</p>'; } function magicshowtype($name, $type = '') { $name = $GLOBALS['lang'][$name] ? $GLOBALS['lang'][$name] : $name; if($type != 'bottom') { if(!$type) { echo '</p>'; } else { echo '<p>'; } } else { echo '</p>'; } } function magicselect($uid, $typeid, $data) { global $db, $tablepre; $magiclist = array(); $dataadd = $char = ''; if($uid) { $typeidadd = $typeid ? "AND m.type='".intval($typeid)."'" : ''; if($data && is_array($data)) { if($data['magic']) { foreach($data['magic'] as $item) { $dataadd .= $char.'m.'.$item; $char = ' ,'; } } if($data['member']) { foreach($data['member'] as $item) { $dataadd .= $char.'m.'.$item; $char = ' ,'; } } } else { $dataadd = 'm.*, mm.*'; } $query = $db->query("SELECT $dataadd FROM {$tablepre}membermagics mm LEFT JOIN {$tablepre}magics m ON mm.magicid=m.magicid WHERE mm.uid='$uid' $typeidadd"); while($mymagic = $db->fetch_array($query)) { $magiclist[] = $mymagic; } } return $magiclist; } function usemagic($magicid, $totalnum, $num = 1) { global $db, $tablepre, $discuz_uid; if($totalnum == $num) { $db->query("DELETE FROM {$tablepre}membermagics WHERE uid='$discuz_uid' AND magicid='$magicid'"); } else { $db->query("UPDATE {$tablepre}membermagics SET num=num+(-'$num') WHERE magicid='$magicid' AND uid='$discuz_uid'"); } } function updatemagicthreadlog($tid, $magicid, $action, $expiration, $extra = 0) { global $db, $tablepre, $timestamp, $discuz_uid, $discuz_user; $discuz_user = !$extra ? $discuz_user : ''; $db->query("REPLACE INTO {$tablepre}threadsmod (tid, uid, magicid, username, dateline, expiration, action, status) VALUES ('$tid', '$discuz_uid', '$magicid', '$discuz_user', '$timestamp', '$expiration', '$action', '1')", 'UNBUFFERED'); } function updatemagiclog($magicid, $action, $amount, $price, $targettid = 0, $targetpid = 0, $targetuid = 0) { global $db, $tablepre, $timestamp, $discuz_uid, $discuz_user; $db->query("INSERT INTO {$tablepre}magiclog (uid, magicid, action, dateline, amount, price, targettid, targetpid, targetuid) VALUES ('$discuz_uid', '$magicid', '$action', '$timestamp', '$amount', '$price','$targettid', '$targetpid', '$targetuid')", 'UNBUFFERED'); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/magic.func.php
PHP
asf20
8,140
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: trade.func.php 18283 2009-04-11 11:41:49Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $apitype = empty($apitype) || !preg_match('/^[a-z0-9]+$/i', $apitype) ? 'alipay' : $apitype; require_once DISCUZ_ROOT.'./api/trade/'.$apitype.'.api.php'; function trade_offline($tradelog, $returndlang = 1) { global $discuz_uid, $language, $trade_message; $tmp = $return = array(); if($discuz_uid == $tradelog['buyerid']) { $data = array( 0 => array(4,8), 1 => array(4,8), 5 => array(7,10), 11 => array(10,7), 12 => array(13) ); $tmp = $data[$tradelog['status']]; } elseif($discuz_uid == $tradelog['sellerid']) { $data = array( 4 => array(5), 10 => array(12,11), 13 => array(17) ); $tmp = $data[$tradelog['status']]; } if($returndlang) { for($i = 0, $count = count($tmp);$i < $count;$i++) { $return[$tmp[$i]] = $language['trade_offline_'.$tmp[$i]]; $trade_message .= isset($language['trade_message_'.$tmp[$i]]) ? $language['trade_message_'.$tmp[$i]].'<br />' : ''; } return $return; } else { return $tmp; } } function trade_create($trade) { global $tablepre, $db, $allowposttrade, $mintradeprice, $maxtradeprice, $timestamp; extract($trade); $special = 2; $expiration = $item_expiration ? strtotime($item_expiration) : 0; $closed = $expiration > 0 && strtotime($item_expiration) < $timestamp ? 1 : $closed; $item_price = floatval($item_price); switch($transport) { case 'seller' : $item_transport = 1; break; case 'buyer' : $item_transport = 2; break; case 'virtual' : $item_transport = 3; break; case 'logistics': $item_transport = 4; break; } $seller = dhtmlspecialchars($seller); $item_name = dhtmlspecialchars($item_name); $item_locus = dhtmlspecialchars($item_locus); $item_number = intval($item_number); $item_quality = intval($item_quality); $item_transport = intval($item_transport); $postage_mail = intval($postage_mail); $postage_express = intval($postage_express); $postage_ems = intval($postage_ems); $item_type = intval($item_type); $typeid = intval($typeid); $item_costprice = floatval($item_costprice); if(!$item_price || $item_price <= 0) { $item_price = $postage_mail = $postage_express = $postage_ems = ''; } if(empty($pid)) { $pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND first='1' LIMIT 1"); } $db->query("INSERT INTO {$tablepre}trades (tid, pid, typeid, sellerid, seller, account, subject, price, amount, quality, locus, transport, ordinaryfee, expressfee, emsfee, itemtype, dateline, expiration, lastupdate, totalitems, tradesum, closed, costprice, aid, credit, costcredit) VALUES ('$tid', '$pid', '$typeid', '$discuz_uid', '$author', '$seller', '$item_name', '$item_price', '$item_number', '$item_quality', '$item_locus', '$item_transport', '$postage_mail', '$postage_express', '$postage_ems', '$item_type', '$timestamp', '$expiration', '$timestamp', '0', '0', '$closed', '$item_costprice', '$aid', '$item_credit', '$item_costcredit')"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/trade.func.php
PHP
asf20
3,211
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: attachment.func.php 21262 2009-11-24 02:05:34Z liulanbo $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function attachtype($type, $returnval = 'html') { static $attachicons = array( 1 => 'unknown.gif', 2 => 'binary.gif', 3 => 'zip.gif', 4 => 'rar.gif', 5 => 'msoffice.gif', 6 => 'text.gif', 7 => 'html.gif', 8 => 'real.gif', 9 => 'av.gif', 10 => 'flash.gif', 11 => 'image.gif', 12 => 'pdf.gif', 13 => 'torrent.gif' ); if(is_numeric($type)) { $typeid = $type; } else { if(preg_match("/bittorrent|^torrent\t/", $type)) { $typeid = 13; } elseif(preg_match("/pdf|^pdf\t/", $type)) { $typeid = 12; } elseif(preg_match("/image|^(jpg|gif|png|bmp)\t/", $type)) { $typeid = 11; } elseif(preg_match("/flash|^(swf|fla|flv|swi)\t/", $type)) { $typeid = 10; } elseif(preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/", $type)) { $typeid = 9; } elseif(preg_match("/real|^(ra|rm|rv)\t/", $type)) { $typeid = 8; } elseif(preg_match("/htm|^(php|js|pl|cgi|asp)\t/", $type)) { $typeid = 7; } elseif(preg_match("/text|^(txt|rtf|wri|chm)\t/", $type)) { $typeid = 6; } elseif(preg_match("/word|powerpoint|^(doc|ppt)\t/", $type)) { $typeid = 5; } elseif(preg_match("/^rar\t/", $type)) { $typeid = 4; } elseif(preg_match("/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/", $type)) { $typeid = 3; } elseif(preg_match("/octet-stream|^(exe|com|bat|dll)\t/", $type)) { $typeid = 2; } elseif($type) { $typeid = 1; } else { $typeid = 0; } } if($returnval == 'html') { return '<img src="images/attachicons/'.$attachicons[$typeid].'" border="0" class="absmiddle" alt="" />'; } elseif($returnval == 'id') { return $typeid; } } function sizecount($filesize) { if($filesize >= 1073741824) { $filesize = round($filesize / 1073741824 * 100) / 100 . ' GB'; } elseif($filesize >= 1048576) { $filesize = round($filesize / 1048576 * 100) / 100 . ' MB'; } elseif($filesize >= 1024) { $filesize = round($filesize / 1024 * 100) / 100 . ' KB'; } else { $filesize = $filesize . ' Bytes'; } return $filesize; } function parseattach($attachpids, $attachtags, &$postlist, $showimages = 1, $skipaids = array()) { global $db, $tablepre, $discuz_uid, $skipaidlist, $readaccess, $attachlist, $attachimgpost, $maxchargespan, $timestamp, $forum, $ftp, $attachurl, $dateformat, $timeformat, $timeoffset, $hideattach, $thread, $tradesaids, $trades, $exthtml, $tagstatus, $sid, $authkey, $exempt; $query = $db->query("SELECT a.*, af.description, ap.aid AS payed FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid LEFT JOIN {$tablepre}attachpaymentlog ap ON ap.aid=a.aid AND ap.uid='$discuz_uid' WHERE a.pid IN ($attachpids)"); $attachexists = FALSE; while($attach = $db->fetch_array($query)) { $attachexists = TRUE; $exthtml = ''; if($skipaids && in_array($attach['aid'], $skipaids)) { continue; } $attached = 0; $extension = strtolower(fileext($attach['filename'])); $attach['ext'] = $extension; $attach['attachicon'] = attachtype($extension."\t".$attach['filetype']); $attach['attachsize'] = sizecount($attach['filesize']); $attach['attachimg'] = $showimages && $attachimgpost && $attach['isimage'] && (!$attach['readperm'] || $readaccess >= $attach['readperm']) ? 1 : 0; if($attach['price']) { if($maxchargespan && $timestamp - $attach['dateline'] >= $maxchargespan * 3600) { $db->query("UPDATE {$tablepre}attachments SET price='0' WHERE aid='$attach[aid]'"); $attach['price'] = 0; } else { if(!$discuz_uid || (!$forum['ismoderator'] && $attach['uid'] != $discuz_uid && !$attach['payed'])) { $attach['unpayed'] = 1; } } } $exemptattachpay = $exempt & 8 ? 1 : 0; $attach['payed'] = $attach['payed'] || $forum['ismoderator'] || $attach['uid'] == $discuz_uid ? 1 : 0; $attach['url'] = $attach['remote'] ? $ftp['attachurl'] : $attachurl; $attach['dateline'] = dgmdate("$dateformat $timeformat", $attach['dateline'] + $timeoffset * 3600); $postlist[$attach['pid']]['attachments'][$attach['aid']] = $attach; if(is_array($attachtags[$attach['pid']]) && in_array($attach['aid'], $attachtags[$attach['pid']])) { $findattach[$attach['pid']][] = "/\[attach\]$attach[aid]\[\/attach\]/i"; $replaceattach[$attach['pid']][] = $hideattach[$attach['pid']] ? '[attach]***[/attach]' : attachtag($attach['pid'], $attach['aid'], $postlist); $attached = 1; } if(!$attached || $attach['unpayed']) { if($attach['isimage']) { $postlist[$attach['pid']]['imagelist'] .= attachlist($attach); } else { if(!$skipaidlist || !in_array($attach['aid'], $skipaidlist)) { $postlist[$attach['pid']]['attachlist'] .= attachlist($attach); } } } } if($attachexists) { foreach($attachtags as $pid => $aids) { if($findattach[$pid]) { $postlist[$pid]['message'] = preg_replace($findattach[$pid], $replaceattach[$pid], $postlist[$pid]['message'], 1); $postlist[$pid]['message'] = preg_replace($findattach[$pid], '', $postlist[$pid]['message']); } } } else { $db->query("UPDATE {$tablepre}posts SET attachment='0' WHERE pid IN ($attachpids)", 'UNBUFFERED'); } } function attachwidth($width) { global $imagemaxwidth; if($imagemaxwidth && $width) { return 'width="'.($width > $imagemaxwidth ? $imagemaxwidth.'" class="zoom" onclick="zoom(this, this.src)"' : $width.'"'); } else { return 'thumbImg="1"'; } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/attachment.func.php
PHP
asf20
5,749
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: newreply.inc.php 21053 2009-11-09 10:29:02Z wangjinbo $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $discuz_action = 12; if($special == 5) { $debate = array_merge($thread, $db->fetch_first("SELECT * FROM {$tablepre}debates WHERE tid='$tid'")); $standquery = $db->query("SELECT stand FROM {$tablepre}debateposts WHERE tid='$tid' AND uid='$discuz_uid' AND stand<>'0' ORDER BY dateline LIMIT 1"); $firststand = $db->result_first("SELECT stand FROM {$tablepre}debateposts WHERE tid='$tid' AND uid='$discuz_uid' AND stand<>'0' ORDER BY dateline LIMIT 1"); if($debate['endtime'] && $debate['endtime'] < $timestamp) { showmessage('debate_end'); } } if(!$discuz_uid && !((!$forum['replyperm'] && $allowreply) || ($forum['replyperm'] && forumperm($forum['replyperm'])))) { showmessage('replyperm_login_nopermission', NULL, 'NOPERM'); } elseif(empty($forum['allowreply'])) { if(!$forum['replyperm'] && !$allowreply) { showmessage('replyperm_none_nopermission', NULL, 'NOPERM'); } elseif($forum['replyperm'] && !forumperm($forum['replyperm'])) { showmessagenoperm('replyperm', $forum['fid']); } } elseif($forum['allowreply'] == -1) { showmessage('post_forum_newreply_nopermission', NULL, 'HALTED'); } if(empty($thread)) { showmessage('thread_nonexistence'); } elseif($thread['price'] > 0 && $thread['special'] == 0 && !$discuz_uid) { showmessage('group_nopermission', NULL, 'NOPERM'); } checklowerlimit($replycredits); if($special == 127) { $postinfo = $db->fetch_first("SELECT message FROM {$tablepre}posts WHERE tid='$tid' AND first='1'"); $sppos = strrpos($postinfo['message'], chr(0).chr(0).chr(0)); $specialextra = substr($postinfo['message'], $sppos + 3); if(!array_key_exists($specialextra, $threadplugins) || !in_array($specialextra, unserialize($forum['threadplugin'])) || !in_array($specialextra, $allowthreadplugin)) { $special = 0; $specialextra = ''; } } if(!submitcheck('replysubmit', 0, $seccodecheck, $secqaacheck)) { if($thread['special'] == 2 && ((!isset($addtrade) || $thread['authorid'] != $discuz_uid) && !$tradenum = $db->result_first("SELECT count(*) FROM {$tablepre}trades WHERE tid='$tid'"))) { showmessage('trade_newreply_nopermission', NULL, 'HALTED'); } include_once language('misc'); $noticeauthor = $noticetrimstr = ''; if(isset($repquote)) { $thaquote = $db->fetch_first("SELECT tid, fid, author, authorid, first, message, useip, dateline, anonymous, status FROM {$tablepre}posts WHERE pid='$repquote' AND invisible='0'"); if($thaquote['tid'] != $tid) { showmessage('undefined_action', NULL, 'HALTED'); } if(getstatus($thread['status'], 2) && $thaquote['authorid'] != $discuz_uid && $discuz_uid != $thread['authorid'] && $thaquote['first'] != 1 && !$forum['ismoderator']) { showmessage('undefined_action', NULL, 'HALTED'); } if(!($thread['price'] && !$thread['special'] && $thaquote['first'])) { $quotefid = $thaquote['fid']; $message = $thaquote['message']; if($bannedmessages && $thaquote['authorid']) { $author = $db->fetch_first("SELECT groupid FROM {$tablepre}members WHERE uid='$thaquote[authorid]'"); if(!$author['groupid'] || $author['groupid'] == 4 || $author['groupid'] == 5) { $message = $language['post_banned']; } elseif($thaquote['status'] & 1) { $message = $language['post_single_banned']; } } $time = gmdate("$dateformat $timeformat", $thaquote['dateline'] + ($timeoffset * 3600)); $message = messagecutstr($message, 100); $thaquote['useip'] = substr($thaquote['useip'], 0, strrpos($thaquote['useip'], '.')).'.x'; if($thaquote['author'] && $thaquote['anonymous']) { $thaquote['author'] = 'Anonymous'; } elseif(!$thaquote['author']) { $thaquote['author'] = 'Guest from '.$thaquote['useip']; } else { $thaquote['author'] = $thaquote['author']; } eval("\$language['post_reply_quote'] = \"$language[post_reply_quote]\";"); $noticeauthormsg = htmlspecialchars($message); $message = "[quote]$message\n[size=2][color=#999999]$language[post_reply_quote][/color] [url={$boardurl}redirect.php?goto=findpost&pid=$repquote&ptid=$tid][img]{$boardurl}images/common/back.gif[/img][/url][/size][/quote]\n\n\n "; $noticeauthor = htmlspecialchars('q|'.$thaquote['authorid'].'|'.$thaquote['author']); $noticetrimstr = htmlspecialchars($message); } } elseif(isset($reppost)) { $thapost = $db->fetch_first("SELECT tid, author, authorid, useip, dateline, anonymous, status, message FROM {$tablepre}posts WHERE pid='$reppost' AND invisible='0'"); if($thapost['tid'] != $tid) { showmessage('undefined_action', NULL, 'HALTED'); } $thapost['useip'] = substr($thapost['useip'], 0, strrpos($thapost['useip'], '.')).'.x'; if($thapost['author'] && $thapost['anonymous']) { $thapost['author'] = '[i]Anonymous[/i]'; } elseif(!$thapost['author']) { $thapost['author'] = '[i]Guest[/i] from '.$thapost['useip']; } else { $thapost['author'] = '[i]'.$thapost['author'].'[/i]'; } $thapost['number'] = $db->result_first("SELECT count(*) FROM {$tablepre}posts WHERE tid='$thapost[tid]' AND dateline<='$thapost[dateline]'"); $message = "[b]$language[post_reply] [url={$boardurl}redirect.php?goto=findpost&pid=$reppost&ptid=$thapost[tid]]$thapost[number]#[/url] $thapost[author] $lang[post_thread][/b]\n\n\n "; $noticeauthormsg = htmlspecialchars(messagecutstr($thapost['message'], 100)); $noticeauthor = htmlspecialchars('r|'.$thapost['authorid'].'|'.$thapost['author']); $noticetrimstr = htmlspecialchars($message); } if(isset($addtrade) && $thread['special'] == 2 && $allowposttrade && $thread['authorid'] == $discuz_uid) { $expiration_7days = date('Y-m-d', $timestamp + 86400 * 7); $expiration_14days = date('Y-m-d', $timestamp + 86400 * 14); $trade['expiration'] = $expiration_month = date('Y-m-d', mktime(0, 0, 0, date('m')+1, date('d'), date('Y'))); $expiration_3months = date('Y-m-d', mktime(0, 0, 0, date('m')+3, date('d'), date('Y'))); $expiration_halfyear = date('Y-m-d', mktime(0, 0, 0, date('m')+6, date('d'), date('Y'))); $expiration_year = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')+1)); } if($thread['replies'] <= $ppp) { $postlist = array(); $query = $db->query("SELECT p.* ".($bannedmessages ? ', m.groupid ' : ''). "FROM {$tablepre}posts p ".($bannedmessages ? "LEFT JOIN {$tablepre}members m ON p.authorid=m.uid " : ''). "WHERE p.tid='$tid' AND p.invisible='0' ".($thread['price'] > 0 && $thread['special'] == 0 ? 'AND p.first = 0' : '')." ORDER BY p.dateline DESC"); while($post = $db->fetch_array($query)) { $post['dateline'] = dgmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600); if($bannedmessages && ($post['authorid'] && (!$post['groupid'] || $post['groupid'] == 4 || $post['groupid'] == 5))) { $post['message'] = $language['post_banned']; } elseif($post['status'] & 1) { $post['message'] = $language['post_single_banned']; } else { $post['message'] = preg_replace("/\[hide=?\d*\](.+?)\[\/hide\]/is", "[b]$language[post_hidden][/b]", $post['message']); $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml'], $forum['jammer']); } $postlist[] = $post; } } if($special == 2 && isset($addtrade) && $thread['authorid'] == $discuz_uid) { $tradetypeselect = ''; $forum['tradetypes'] = $forum['tradetypes'] == '' ? -1 : unserialize($forum['tradetypes']); if($tradetypes && !empty($forum['tradetypes'])) { $tradetypeselect = '<select name="tradetypeid" onchange="ajaxget(\'post.php?action=threadsorts&tradetype=yes&sortid=\'+this.options[this.selectedIndex].value+\'&sid='.$sid.'\', \'threadtypes\', \'threadtypeswait\')"><option value="0">&nbsp;</option>'; foreach($tradetypes as $typeid => $name) { if($forum['tradetypes'] == -1 || @in_array($typeid, $forum['tradetypes'])) { $tradetypeselect .= '<option value="'.$typeid.'">'.strip_tags($name).'</option>'; } } $tradetypeselect .= '</select><span id="threadtypeswait"></span>'; } } if($allowpostattach) { $attachlist = getattach(); $attachs = $attachlist['attachs']; $imgattachs = $attachlist['imgattachs']; unset($attachlist); } $infloat ? include template('post_infloat') : include template('post'); } else { require_once DISCUZ_ROOT.'./include/forum.func.php'; if($subject == '' && $message == '' && $thread['special'] != 2) { showmessage('post_sm_isnull'); } elseif($thread['closed'] && !$forum['ismoderator']) { showmessage('post_thread_closed'); } elseif($post_autoclose = checkautoclose()) { showmessage($post_autoclose); } elseif($post_invalid = checkpost($special == 2 && $allowposttrade)) { showmessage($post_invalid); } elseif(checkflood()) { showmessage('post_flood_ctrl'); } if(!empty($trade) && $thread['special'] == 2 && $allowposttrade) { $item_price = floatval($item_price); $item_credit = intval($item_credit); if(!trim($item_name)) { showmessage('trade_please_name'); } elseif($maxtradeprice && $item_price > 0 && ($mintradeprice > $item_price || $maxtradeprice < $item_price)) { showmessage('trade_price_between'); } elseif($maxtradeprice && $item_credit > 0 && ($mintradeprice > $item_credit || $maxtradeprice < $item_credit)) { showmessage('trade_credit_between'); } elseif(!$maxtradeprice && $item_price > 0 && $mintradeprice > $item_price) { showmessage('trade_price_more_than'); } elseif(!$maxtradeprice && $item_credit > 0 && $mintradeprice > $item_credit) { showmessage('trade_credit_more_than'); } elseif($item_price <= 0 && $item_credit <= 0) { showmessage('trade_pricecredit_need'); } elseif($item_number < 1) { showmessage('tread_please_number'); } threadsort_checkoption(1, 1); $optiondata = array(); if($tradetypes && $typeoption && $checkoption) { $optiondata = threadsort_validator($typeoption); } } $attentionon = empty($attention_add) ? 0 : 1; $attentionoff = empty($attention_remove) ? 0 : 1; if($thread['lastposter'] != $discuz_userss) { $userreplies = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND first='0' AND authorid='$discuz_uid'"); $thread['heats'] += round($heatthread['reply'] * pow(0.8, $userreplies)); $heatbefore = $thread['heats']; $db->query("UPDATE {$tablepre}threads SET heats='$thread[heats]' WHERE tid='$tid'", 'UNBUFFERED'); } $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff)); $smileyoff = checksmilies($message, !empty($smileyoff)); $parseurloff = !empty($parseurloff); $htmlon = $allowhtml && !empty($htmlon) ? 1 : 0; $usesig = !empty($usesig) ? 1 : 0; $isanonymous = $allowanonymous && !empty($isanonymous)? 1 : 0; $author = empty($isanonymous) ? $discuz_user : ''; $pinvisible = $modnewreplies ? -2 : 0; $message = preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $message); $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment) VALUES ('$fid', '$tid', '0', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '$message', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '0')"); $pid = $db->insert_id(); $cacheposition = getstatus($thread['status'], 1); if($pid && $cacheposition) { savepostposition($tid, $pid); } $nauthorid = 0; if(!empty($noticeauthor) && !$isanonymous) { list($ac, $nauthorid, $nauthor) = explode('|', $noticeauthor); if($nauthorid != $discuz_uid) { $postmsg = messagecutstr(str_replace($noticetrimstr, '', $message), 100); if($ac == 'q') { sendnotice($nauthorid, 'repquote_noticeauthor', 'threads'); } elseif($ac == 'r') { sendnotice($nauthorid, 'reppost_noticeauthor', 'threads'); } } } $uidarray = array(); $query = $db->query("SELECT uid FROM {$tablepre}favoritethreads WHERE tid='$tid'"); while($favthread = $db->fetch_array($query)) { if($favthread['uid'] !== $discuz_uid && (!$nauthorid || $nauthorid != $favthread['uid'])) { $uidarray[] = $favthread['uid']; } } if($discuz_uid && !empty($uidarray)) { sendnotice(implode(',', $uidarray), 'favoritethreads_notice', 'threads', $tid, array('user' => (!$isanonymous ? $discuz_userss : '<i>Anonymous</i>'), 'maxusers' => 5)); $db->query("UPDATE {$tablepre}favoritethreads SET newreplies=newreplies+1, dateline='$timestamp' WHERE uid IN (".implodeids($uidarray).") AND tid='$tid'", 'UNBUFFERED'); } if($discuz_uid) { $stataction = ''; if($attentionon) { $stataction = 'attentionon'; $db->query("REPLACE INTO {$tablepre}favoritethreads (tid, uid, dateline) VALUES ('$tid', '$discuz_uid', '$timestamp')", 'UNBUFFERED'); } if($attentionoff) { $stataction = 'attentionoff'; $db->query("DELETE FROM {$tablepre}favoritethreads WHERE tid='$tid' AND uid='$discuz_uid'", 'UNBUFFERED'); } if($stataction) { write_statlog('', 'item=attention&action=newreply_'.$stataction, '', '', 'my.php'); } } if($special == 3 && $thread['authorid'] != $discuz_uid && $thread['price'] > 0) { $rewardlog = $db->fetch_first("SELECT * FROM {$tablepre}rewardlog WHERE tid='$tid' AND answererid='$discuz_uid'"); if(!$rewardlog) { $db->query("INSERT INTO {$tablepre}rewardlog (tid, answererid, dateline) VALUES ('$tid', '$discuz_uid', '$timestamp')"); } } elseif($special == 5) { $stand = $firststand ? $firststand : intval($stand); if(!$db->num_rows($standquery)) { if($stand == 1) { $db->query("UPDATE {$tablepre}debates SET affirmdebaters=affirmdebaters+1 WHERE tid='$tid'"); } elseif($stand == 2) { $db->query("UPDATE {$tablepre}debates SET negadebaters=negadebaters+1 WHERE tid='$tid'"); } } else { $stand = $firststand; } if($stand == 1) { $db->query("UPDATE {$tablepre}debates SET affirmreplies=affirmreplies+1 WHERE tid='$tid'"); } elseif($stand == 2) { $db->query("UPDATE {$tablepre}debates SET negareplies=negareplies+1 WHERE tid='$tid'"); } $db->query("INSERT INTO {$tablepre}debateposts (tid, pid, uid, dateline, stand, voters, voterids) VALUES ('$tid', '$pid', '$discuz_uid', '$timestamp', '$stand', '0', '')"); } $allowpostattach && ($attachnew || $attachdel || $special == 2 && $tradeaid) && updateattach(); $replymessage = 'post_reply_succeed'; if($special == 2 && $allowposttrade && $thread['authorid'] == $discuz_uid && !empty($trade) && !empty($item_name)) { if($tradetypes && $optiondata) { foreach($optiondata as $optionid => $value) { $db->query("INSERT INTO {$tablepre}tradeoptionvars (sortid, pid, optionid, value) VALUES ('$tradetypeid', '$pid', '$optionid', '$value')"); } } require_once DISCUZ_ROOT.'./include/trade.func.php'; trade_create(array( 'tid' => $tid, 'pid' => $pid, 'aid' => $tradeaid, 'typeid' => $tradetypeid, 'item_expiration' => $item_expiration, 'thread' => $thread, 'discuz_uid' => $discuz_uid, 'author' => $author, 'seller' => $seller, 'item_name' => $item_name, 'item_price' => $item_price, 'item_number' => $item_number, 'item_quality' => $item_quality, 'item_locus' => $item_locus, 'transport' => $transport, 'postage_mail' => $postage_mail, 'postage_express' => $postage_express, 'postage_ems' => $postage_ems, 'item_type' => $item_type, 'item_costprice' => $item_costprice, 'item_credit' => $item_credit, 'item_costcredit' => $item_costcredit )); $replymessage = 'trade_add_succeed'; } if($specialextra) { @include_once DISCUZ_ROOT.'./plugins/'.$threadplugins[$specialextra]['module'].'.class.php'; $classname = 'threadplugin_'.$specialextra; if(method_exists($classname, 'newreply_submit_end')) { $threadpluginclass = new $classname; $threadpluginclass->newreply_submit_end($fid, $tid); } } $forum['threadcaches'] && deletethreadcaches($tid); if($modnewreplies) { $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED'); showmessage('post_reply_mod_succeed', "forumdisplay.php?fid=$fid"); } else { $db->query("UPDATE {$tablepre}threads SET lastposter='$author', lastpost='$timestamp', replies=replies+1 WHERE tid='$tid'", 'UNBUFFERED'); updatepostcredits('+', $discuz_uid, $replycredits); $lastpost = "$thread[tid]\t".addslashes($thread['subject'])."\t$timestamp\t$author"; $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED'); if($forum['type'] == 'sub') { $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED'); } $feed = array(); if($addfeed && $forum['allowfeed'] && $thread['authorid'] != $discuz_uid && !$isanonymous) { if($special == 2 && !empty($trade) && !empty($item_name) && !empty($item_price)) { $feed['icon'] = 'goods'; $feed['title_template'] = 'feed_thread_goods_title'; $feed['body_template'] = 'feed_thread_goods_message'; $feed['body_data'] = array( 'itemname'=> "<a href=\"{$boardurl}viewthread.php?do=tradeinfo&tid=$tid&pid=$pid\">$item_name</a>", 'itemprice'=> $item_price ); } elseif($special == 3) { $feed['icon'] = 'reward'; $feed['title_template'] = 'feed_reply_reward_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>" ); } elseif($special == 5) { $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>" ); } else { $feed['icon'] = 'post'; $feed['title_template'] = 'feed_reply_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); } if(is_array($dzfeed_limit['thread_replies']) && in_array(($thread['replies'] + 1), $dzfeed_limit['thread_replies'])) { $arg = $data = array(); $arg['type'] = 'thread_replies'; $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\">".$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); } if(is_array($dzfeed_limit['user_posts']) && in_array(($posts + 1), $dzfeed_limit['user_posts'])) { $arg = $data = array(); $arg['type'] = 'user_posts'; $arg['uid'] = $discuz_uid; $arg['username'] = $discuz_userss; $data['title']['actor'] = "<a href=\"space.php?uid={$discuz_uid}\" target=\"_blank\">{$discuz_user}</a>"; $data['title']['count'] = $posts + 1; add_feed($arg, $data); } $page = getstatus($thread['status'], 4) ? 1 : @ceil(($thread['special'] ? $thread['replies'] + 1 : $thread['replies'] + 2) / $ppp); showmessage($replymessage, "viewthread.php?tid=$tid&pid=$pid&page=$page&extra=$extra#pid$pid"); } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/newreply.inc.php
PHP
asf20
20,438
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $RCSfile: search_qihoo.inc.php,v $ $Revision: 1.8 $ $Date: 2007/08/06 09:54:48 $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if(empty($srchtxt) && empty($srchuname)) { showmessage('search_invalid', 'search.php'); } $keywordlist = ''; foreach(explode("\n", trim($qihoo_keyword)) as $key => $keyword) { $keywordlist .= $comma.trim($keyword); $comma = '|'; if(strlen($keywordlist) >= 100) { break; } } if($orderby == 'lastpost') { $orderby = 'rdate'; } elseif($orderby == 'dateline') { $orderby = 'pdate'; } else { $orderby = ''; } $stype = empty($stype) ? '' : ($stype == 2 ? 'author' : 'title'); $url = 'http://search.qihoo.com/usearch.html?site='.rawurlencode(site()). '&kw='.rawurlencode($srchtxt). '&ics='.$charset. '&ocs='.$charset. ($orderby ? '&sort='.$orderby : ''). ($srchfid ? '&chanl='.rawurlencode($_DCACHE['forums'][$srchfid]['name']) : ''). '&bbskw='.rawurlencode($keywordlist). '&summary='.$qihoo['summary']. '&stype='.$stype. '&count='.$tpp. '&fw=dz&SITEREFER='.rawurlencode($boardurl); dheader("Location: $url"); ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/search_qihoo.inc.php
PHP
asf20
1,226
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: db_mysql_error.inc.php 17439 2008-12-22 04:27:17Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $timestamp = time(); $errmsg = ''; $dberror = $this->error(); $dberrno = $this->errno(); if($dberrno == 1114) { ?> <html> <head> <title>Max Onlines Reached</title> </head> <body bgcolor="#FFFFFF"> <table cellpadding="0" cellspacing="0" border="0" width="600" align="center" height="85%"> <tr align="center" valign="middle"> <td> <table cellpadding="10" cellspacing="0" border="0" width="80%" align="center" style="font-family: Verdana, Tahoma; color: #666666; font-size: 9px"> <tr> <td valign="middle" align="center" bgcolor="#EBEBEB"> <br /><b style="font-size: 10px">Forum onlines reached the upper limit</b> <br /><br /><br />Sorry, the number of online visitors has reached the upper limit. <br />Please wait for someone else going offline or visit us in idle hours. <br /><br /> </td> </tr> </table> </td> </tr> </table> </body> </html> <? exit(); } else { if($message) { $errmsg = "<b>Discuz! info</b>: $message\n\n"; } if(isset($GLOBALS['_DSESSION']['discuz_user'])) { $errmsg .= "<b>User</b>: ".htmlspecialchars($GLOBALS['_DSESSION']['discuz_user'])."\n"; } $errmsg .= "<b>Time</b>: ".gmdate("Y-n-j g:ia", $timestamp + ($GLOBALS['timeoffset'] * 3600))."\n"; $errmsg .= "<b>Script</b>: ".$GLOBALS['PHP_SELF']."\n\n"; if($sql) { $errmsg .= "<b>SQL</b>: ".htmlspecialchars($sql)."\n"; } $errmsg .= "<b>Error</b>: $dberror\n"; $errmsg .= "<b>Errno.</b>: $dberrno"; echo "</table></table></table></table></table>\n"; echo "<p style=\"font-family: Verdana, Tahoma; font-size: 11px; background: #FFFFFF;\">"; echo nl2br(str_replace($GLOBALS['tablepre'], '[Table]', $errmsg)); if($GLOBALS['adminemail']) { $errlog = array(); if(@$fp = fopen(DISCUZ_ROOT.'./forumdata/dberror.log', 'r')) { while((!feof($fp)) && count($errlog) < 20) { $log = explode("\t", fgets($fp, 50)); if($timestamp - $log[0] < 86400) { $errlog[$log[0]] = $log[1]; } } fclose($fp); } if(!in_array($dberrno, $errlog)) { $errlog[$timestamp] = $dberrno; @$fp = fopen(DISCUZ_ROOT.'./forumdata/dberror.log', 'w'); @flock($fp, 2); foreach(array_unique($errlog) as $dateline => $errno) { @fwrite($fp, "$dateline\t$errno"); } @fclose($fp); if(function_exists('errorlog')) { errorlog('MySQL', basename($GLOBALS['_SERVER']['PHP_SELF'])." : $dberror - ".cutstr($sql, 120), 0); } if($GLOBALS['dbreport']) { echo "<br /><br />An error report has been dispatched to our administrator."; @sendmail($GLOBALS['adminemail'], '[Discuz!] MySQL Error Report', "There seems to have been a problem with the database of your Discuz! Board\n\n". strip_tags($errmsg)."\n\n". "Please check-up your MySQL server and forum scripts, similar errors will not be reported again in recent 24 hours\n". "If you have troubles in solving this problem, please visit Discuz! Community http://www.Discuz.net."); } } else { echo '<br /><br />Similar error report has been dispatched to administrator before.'; } } echo '</p>'; echo '<p style="font-family: Verdana, Tahoma; font-size: 12px; background: #FFFFFF;"><a href="http://faq.comsenz.com/?type=mysql&dberrno='.$dberrno.'&dberror='.rawurlencode($dberror).'" target="_blank">&#x5230; http://faq.comsenz.com &#x641c;&#x7d22;&#x6b64;&#x9519;&#x8bef;&#x7684;&#x89e3;&#x51b3;&#x65b9;&#x6848;</a></p>'; exit(); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/db_mysql_error.inc.php
PHP
asf20
3,760
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: announcements_daily.inc.php 17476 2008-12-25 02:58:18Z liuqiang $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $db->query("UPDATE {$tablepre}tasks SET available='2' WHERE available='1' AND starttime>'0' AND starttime<='$timestamp' AND (endtime IS NULL OR endtime>'$timestamp')", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}announcements WHERE endtime<'$timestamp' AND endtime<>'0'"); if($db->affected_rows()) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache(array('announcements', 'announcements_forum', 'pmlist')); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/announcements_daily.inc.php
PHP
asf20
696
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: todayposts_daily.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $yesterdayposts = intval($db->result_first("SELECT sum(todayposts) FROM {$tablepre}forums")); $historypost = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='historyposts'"); $hpostarray = explode("\t", $historypost); $historyposts = $hpostarray[1] < $yesterdayposts ? "$yesterdayposts\t$yesterdayposts" : "$yesterdayposts\t$hpostarray[1]"; $db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('historyposts', '$historyposts')"); $db->query("UPDATE {$tablepre}forums SET todayposts='0'"); require_once DISCUZ_ROOT.'./include/cache.func.php'; $_DCACHE['settings']['historyposts'] = $historyposts; updatesettings(); ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/todayposts_daily.inc.php
PHP
asf20
924
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: cleanup_monthly.inc.php 19081 2009-08-12 09:26:57Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $myrecordtimes = $timestamp - $_DCACHE['settings']['myrecorddays'] * 86400; $db->query("DELETE FROM {$tablepre}invites WHERE dateline<'$timestamp'-2592000 AND status='4'", 'UNBUFFERED'); $db->query("TRUNCATE {$tablepre}relatedthreads"); $db->query("DELETE FROM {$tablepre}mytasks WHERE status='-1' AND dateline<'$timestamp'-2592000", 'UNBUFFERED'); ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/cleanup_monthly.inc.php
PHP
asf20
602
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: birthdays_daily.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($maxbdays) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('birthdays'); updatecache('birthdays_index'); } if($bdaystatus) { $today = gmdate('m-d', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600); $query = $db->query("SELECT uid, username, email, bday FROM {$tablepre}members WHERE RIGHT(bday, 5)='$today' ORDER BY bday"); global $member; while($member = $db->fetch_array($query)) { sendmail("$member[username] <$member[email]>", 'birthday_subject', 'birthday_message'); } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/birthdays_daily.inc.php
PHP
asf20
780
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: promotions_hourly.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($creditspolicy['promotion_visit']) { $uidarray = $userarray = array(); $query = $db->query("SELECT * FROM {$tablepre}promotions"); while($promotion = $db->fetch_array($query)) { if($promotion['uid']) { $uidarray[] = $promotion['uid']; } elseif($promotion['username']) { $userarray[] = addslashes($promotion['username']); } } if($uidarray || $userarray) { if($userarray) { $query = $db->query("SELECT uid FROM {$tablepre}members WHERE username IN ('".implode('\',\'', $userarray)."')"); while($member = $db->fetch_array($query)) { $uidarray[] = $member['uid']; } } $countarray = array(); foreach(array_count_values($uidarray) as $uid => $count) { $countarray[$count][] = $uid; } foreach($countarray as $count => $uids) { updatecredits(implode('\',\'', $uids), $creditspolicy['promotion_visit'], $count); } $db->query("DELETE FROM {$tablepre}promotions"); } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/promotions_hourly.inc.php
PHP
asf20
1,209
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: onlinetime_monthly.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $db->query("UPDATE {$tablepre}onlinetime SET thismonth='0'"); $db->query("UPDATE {$tablepre}statvars SET value='0' WHERE type='onlines' AND variable='lastupdate'"); ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/onlinetime_monthly.inc.php
PHP
asf20
420
<?php if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($tagstatus) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache(array('tags_index', 'tags_viewthread')); $db->query("DELETE FROM {$tablepre}tags WHERE total=0", 'UNBUFFERED'); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/tags_daily.inc.php
PHP
asf20
276
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: magics_daily.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if(!empty($magicstatus)) { $magicarray = array(); $query = $db->query("SELECT magicid, supplytype, supplynum, num FROM {$tablepre}magics WHERE available='1'"); while($magic = $db->fetch_array($query)) { if($magic['supplytype'] && $magic['supplynum']) { $magicarray[$magic['magicid']]['supplytype'] = $magic['supplytype']; $magicarray[$magic['magicid']]['supplynum'] = $magic['supplynum']; } } list($daynow, $weekdaynow) = explode('-', gmdate('d-w', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600)); foreach($magicarray as $id => $magic) { $autosupply = 0; if($magic['supplytype'] == 1) { $autosupply = 1; } elseif($magic['supplytype'] == 2 && $weekdaynow == 1) { $autosupply = 1; } elseif($magic['supplytype'] == 3 && $daynow == 1) { $autosupply = 1; } if(!empty($autosupply)) { $db->query("UPDATE {$tablepre}magics SET num=num+'$magic[supplynum]' WHERE magicid='$id'"); } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/magics_daily.inc.php
PHP
asf20
1,205
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: cleanup_daily.inc.php 20902 2009-10-29 02:54:19Z liulanbo $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $db->query("UPDATE {$tablepre}advertisements SET available='0' WHERE endtime>'0' AND endtime<='$timestamp'", 'UNBUFFERED'); if($db->affected_rows()) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache(array('settings', 'advs_archiver', 'advs_register', 'advs_index', 'advs_forumdisplay', 'advs_viewthread')); } $db->query("TRUNCATE {$tablepre}searchindex"); $db->query("DELETE FROM {$tablepre}threadsmod WHERE dateline<'$timestamp'-31536000", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}forumrecommend WHERE expiration<'$timestamp'", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}feeds WHERE dateline<'$timestamp'-864000", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}promptmsgs WHERE new='1' AND dateline<'$timestamp'-259200", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}promptmsgs WHERE new='0' AND dateline<'$timestamp'-2592000", 'UNBUFFERED'); if($qihoo['status'] && $qihoo['relatedthreads']) { $db->query("DELETE FROM {$tablepre}relatedthreads WHERE expiration<'$timestamp'", 'UNBUFFERED'); } $db->query("UPDATE {$tablepre}trades SET closed='1' WHERE expiration<>0 AND expiration<'$timestamp'", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}tradelog WHERE status=0 AND lastupdate<'".($timestamp - 5 * 86400)."'", 'UNBUFFERED'); if($cachethreadon) { removedir($cachethreaddir, TRUE); } if($regstatus > 1) { $db->query("UPDATE {$tablepre}invites SET status='4' WHERE expiration<'$timestamp' AND status IN ('1', '3')"); } $delaids = array(); $query = $db->query("SELECT aid, attachment, thumb FROM {$tablepre}attachments WHERE tid='0' AND dateline<$timestamp-86400"); while($attach = $db->fetch_array($query)) { dunlink($attach['attachment'], $attach['thumb']); $delaids[] = $attach['aid']; } if($delaids) { $db->query("DELETE FROM {$tablepre}attachments WHERE aid IN (".implodeids($delaids).")", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}attachmentfields WHERE aid IN (".implodeids($delaids).")", 'UNBUFFERED'); } $uids = $members = array(); $query = $db->query("SELECT uid, groupid, credits FROM {$tablepre}members WHERE groupid IN ('4', '5') AND groupexpiry>'0' AND groupexpiry<'$timestamp'"); while($row = $db->fetch_array($query)) { $uids[] = $row['uid']; $members[$row[uid]] = $row; } if($uids) { $query = $db->query("SELECT uid, groupterms FROM {$tablepre}memberfields WHERE uid IN (".implodeids($uids).")"); while($member = $db->fetch_array($query)) { $sql = 'uid=uid'; $member['groupterms'] = unserialize($member['groupterms']); $member['groupid'] = $members[$member[uid]]['groupid']; $member['credits'] = $members[$member[uid]]['credits']; 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 { $query = $db->query("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditshigher<='$member[credits]' AND creditslower>'$member[credits]'"); $groupidnew = $db->result($query, 0); $adminidnew = 0; } $sql .= ", adminid='$adminidnew', groupid='$groupidnew'"; $db->query("UPDATE {$tablepre}members SET $sql WHERE uid='$member[uid]'"); $db->query("UPDATE {$tablepre}memberfields SET groupterms='".($member['groupterms'] ? addslashes(serialize($member['groupterms'])) : '')."' WHERE uid='$member[uid]'"); } } function removedir($dirname, $keepdir = FALSE) { $dirname = wipespecial($dirname); if(!is_dir($dirname)) { return FALSE; } $handle = opendir($dirname); while(($file = readdir($handle)) !== FALSE) { if($file != '.' && $file != '..') { $dir = $dirname . DIRECTORY_SEPARATOR . $file; is_dir($dir) ? removedir($dir) : unlink($dir); } } closedir($handle); return !$keepdir ? (@rmdir($dirname) ? TRUE : FALSE) : TRUE; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/cleanup_daily.inc.php
PHP
asf20
4,296
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: medals_daily.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $medalnewarray = array(); $query = $db->query("SELECT me.id, me.uid, me.medalid, me.expiration, mf.medals FROM {$tablepre}medallog me LEFT JOIN {$tablepre}memberfields mf USING (uid) WHERE me.status=1 AND me.expiration<$timestamp"); while($medalnew = $db->fetch_array($query)) { $medalsnew = array(); $medalnew['medals'] = empty($medalnewarray[$medalnew['uid']]) ? explode("\t", $medalnew['medals']) : explode("\t", $medalnewarray[$medalnew['uid']]); foreach($medalnew['medals'] as $key => $medalnewid) { list($medalid, $medalexpiration) = explode("|", $medalnewid); if($medalnew['medalid'] == $medalid) { unset($medalnew['medals'][$key]); } } $medalnewarray[$medalnew['uid']] = implode("\t", $medalnew['medals']); $db->query("UPDATE {$tablepre}medallog SET status='0' WHERE id='".$medalnew['id']."'"); $db->query("UPDATE {$tablepre}memberfields SET medals='".$medalnewarray[$medalnew['uid']]."' WHERE uid='".$medalnew['uid']."'"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/medals_daily.inc.php
PHP
asf20
1,237
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: secqaa_daily.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($secqaa['status'] > 0) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('secqaa'); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/secqaa_daily.inc.php
PHP
asf20
359
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: threadexpiries_hourly.inc.php 21052 2009-11-09 10:12:34Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $actionarray = array(); $query = $db->query("SELECT * FROM {$tablepre}threadsmod WHERE expiration>'0' AND expiration<'$timestamp' AND status='1'"); while($expiry = $db->fetch_array($query)) { $threads[] = $expiry; switch($expiry['action']) { case 'EST': $actionarray['UES'][] = $expiry['tid']; break; case 'EHL': $actionarray['UEH'][] = $expiry['tid']; break; case 'ECL': $actionarray['UEC'][] = $expiry['tid']; break; case 'EOP': $actionarray['UEO'][] = $expiry['tid']; break; case 'EDI': $actionarray['UED'][] = $expiry['tid']; break; case 'TOK': $actionarray['UES'][] = $expiry['tid']; break; case 'CCK': $actionarray['UEH'][] = $expiry['tid']; break; case 'CLK': $actionarray['UEC'][] = $expiry['tid']; break; case 'SPA': $actionarray['SPD'][] = $expiry['tid']; break; } } if($actionarray) { foreach($actionarray as $action => $tids) { $tids = implode(',', $tids); switch($action) { case 'UES': $db->query("UPDATE {$tablepre}threads SET displayorder='0' WHERE tid IN ($tids)", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($tids) AND action IN ('EST', 'TOK')", 'UNBUFFERED'); require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('globalstick'); break; case 'UEH': $db->query("UPDATE {$tablepre}threads SET highlight='0' WHERE tid IN ($tids)", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($tids) AND action IN ('EHL', 'CCK')", 'UNBUFFERED'); break; case 'UEC': case 'UEO': $closed = $action == 'UEO' ? 1 : 0; $db->query("UPDATE {$tablepre}threads SET closed='$closed' WHERE tid IN ($tids)", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($tids) AND action IN ('EOP', 'ECL', 'CLK')", 'UNBUFFERED'); break; case 'UED': $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($tids) AND action='EDI'", 'UNBUFFERED'); $digestarray = $authoridarry = array(); $query = $db->query("SELECT authorid, digest FROM {$tablepre}threads WHERE tid IN ($tids)"); while($digest = $db->fetch_array($query)) { $authoridarry[] = $digest['authorid']; $digestarray[$digest['digest']][] = $digest['authorid']; } $db->query("UPDATE {$tablepre}members SET digestposts=digestposts+'-1' WHERE uid IN (".implode(',', $authoridarry).")", 'UNBUFFERED'); foreach($digestarray as $digest => $authorids) { updatecredits(implode('\',\'', $authorids), $creditspolicy['digest'], 0 - $digest); } $db->query("UPDATE {$tablepre}threads SET digest='0' WHERE tid IN ($tids)", 'UNBUFFERED'); break; case 'SPD': $db->query("UPDATE {$tablepre}threads SET ".buildbitsql('status', 5, FALSE)." WHERE tid IN ($tids)", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($tids) AND action IN ('SPA')", 'UNBUFFERED'); break; } } require_once DISCUZ_ROOT.'./include/post.func.php'; foreach($actionarray as $action => $tids) { updatemodlog(implode(',', $tids), $action, 0, 1); } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/crons/threadexpiries_hourly.inc.php
PHP
asf20
3,419
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: diff.class.php 16698 2008-11-14 07:58:56Z cnteacher $ */ class Diff { var $table = array(); var $left = array(); var $right = array(); var $left_len = 0; var $right_len = 0; function Diff($left, $right) { $this->left = preg_split('/(\r\n|\n|\r)/', $left); $this->right = preg_split('/(\r\n|\n|\r)/', $right); $this->left_len = count($this->left); $this->right_len = count($this->right); } function getrow($row) { $return = array(); $i = -1; foreach(explode('|', $row) AS $value) { $return[$i] = $value; $i++; } return $return; } function &fetch_diff() { $prev_row = array(); for($i = -1; $i < $this->right_len; $i++) { $prev_row[$i] = 0; } for($i = 0; $i < $this->left_len; $i++) { $this_row = array('-1' => 0); $data_left_value = $this->left[$i]; for($j = 0; $j < $this->right_len; $j++) { if($data_left_value == $this->right[$j]) { $this_row[$j] = $prev_row[$j - 1] + 1; } elseif($this_row[$j - 1] > $prev_row[$j]) { $this_row[$j] = $this_row[$j - 1]; } else { $this_row[$j] = $prev_row[$j]; } } $this->table[$i - 1] = implode('|', $prev_row); $prev_row = $this_row; } unset($prev_row); $this->table[$this->left_len - 1] = implode('|', $this_row); $table = &$this->table; $output = $match = $nonmatch1 = $nonmatch2 = array(); $data_left_key = $this->left_len - 1; $data_right_key = $this->right_len - 1; $this_row = $this->getrow($table[$data_left_key]); $above_row = $this->getrow($table[$data_left_key - 1]); while($data_left_key >= 0 AND $data_right_key >= 0) { if($this_row[$data_right_key] != $above_row[$data_right_key - 1] AND $this->left[$data_left_key] == $this->right[$data_right_key]) { $this->nonmatches($output, $nonmatch1, $nonmatch2); array_unshift($match, $this->left[$data_left_key]); $data_left_key--; $data_right_key--; $this_row = $above_row; $above_row = $this->getrow($table[$data_left_key - 1]); } elseif($above_row[$data_right_key] > $this_row[$data_right_key - 1]) { $this->matches($output, $match); array_unshift($nonmatch1, $this->left[$data_left_key]); $data_left_key--; $this_row = $above_row; $above_row = $this->getrow($table[$data_left_key - 1]); } else { $this->matches($output, $match); array_unshift($nonmatch2, $this->right[$data_right_key]); $data_right_key--; } } $this->matches($output, $match); if($data_left_key > -1 OR $data_right_key > -1) { for(; $data_left_key > -1; $data_left_key--) { array_unshift($nonmatch1, $this->left[$data_left_key]); } for(; $data_right_key > -1; $data_right_key--) { array_unshift($nonmatch2, $this->right[$data_right_key]); } $this->nonmatches($output, $nonmatch1, $nonmatch2); } return $output; } function matches(&$output, &$match) { if(count($match) > 0) { $data = implode("\n", $match); array_unshift($output, new Diff_Entry($data, $data)); } $match = array(); } function nonmatches(&$output, &$text_left, &$text_right) { $s1 = count($text_left); $s2 = count($text_right); if($s1 > 0 AND $s2 == 0) { array_unshift($output, new Diff_Entry(implode("\n", $text_left), '')); } elseif($s2 > 0 AND $s1 == 0) { array_unshift($output, new Diff_Entry('', implode("\n", $text_right))); } elseif($s1 > 0 AND $s2 > 0) { array_unshift($output, new Diff_Entry(implode("\n", $text_left), implode("\n", $text_right))); } $text_left = $text_right = array(); } } class Diff_Entry { var $left = ''; var $right = ''; function Diff_Entry($data_left, $data_right) { $this->left = $data_left; $this->right = $data_right; } function left_class() { if($this->left == $this->right) { return 'unchanged'; } elseif($this->left AND empty($this->right)) { return 'deleted'; } elseif(trim($this->left) === '') { return 'notext'; } else { return 'changed'; } } function right_class() { if($this->left == $this->right) { return 'unchanged'; } elseif($this->right AND empty($this->left)) { return 'added'; } elseif(trim($this->right) === '') { return 'notext'; } else { return 'changed'; } } function diff_text($string, $wrap = true) { if(trim($string) === '') { return '&nbsp;'; } else { return $wrap ? '<code>'.str_replace(array(' ', "\t"), array('&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;'), nl2br(htmlspecialchars($string))).'</code>' : '<pre style="display:inline">'.htmlspecialchars($string).'</pre>'; } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/diff.class.php
PHP
asf20
4,771
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: sendmail.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $mail = unserialize($mail); $errorlog = $action != 'mailcheck' ? 'errorlog' : 'checkmailerror'; @include language('emails'); if($mail['sendmail_silent']) { error_reporting(0); } if(isset($language[$email_subject])) { eval("\$email_subject = \"".$language[$email_subject]."\";"); } if(isset($language[$email_message])) { eval("\$email_message = \"".$language[$email_message]."\";"); } $maildelimiter = $mail['maildelimiter'] == 1 ? "\r\n" : ($mail['maildelimiter'] == 2 ? "\r" : "\n"); $mailusername = isset($mail['mailusername']) ? $mail['mailusername'] : 1; $email_subject = '=?'.$charset.'?B?'.base64_encode(str_replace("\r", '', str_replace("\n", '', '['.$bbname.'] '.$email_subject))).'?='; $email_message = chunk_split(base64_encode(str_replace("\r\n.", " \r\n..", str_replace("\n", "\r\n", str_replace("\r", "\n", str_replace("\r\n", "\n", str_replace("\n\r", "\r", $email_message))))))); $email_from = $email_from == '' ? '=?'.$charset.'?B?'.base64_encode($bbname)."?= <$adminemail>" : (preg_match('/^(.+?) \<(.+?)\>$/',$email_from, $from) ? '=?'.$charset.'?B?'.base64_encode($from[1])."?= <$from[2]>" : $email_from); foreach(explode(',', $email_to) as $touser) { $tousers[] = preg_match('/^(.+?) \<(.+?)\>$/',$touser, $to) ? ($mailusername ? '=?'.$charset.'?B?'.base64_encode($to[1])."?= <$to[2]>" : $to[2]) : $touser; } $email_to = implode(',', $tousers); $headers = "From: $email_from{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: Discuz! $version{$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/plain; charset=$charset{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}"; $mail['port'] = $mail['port'] ? $mail['port'] : 25; if($mail['mailsend'] == 1 && function_exists('mail')) { @mail($email_to, $email_subject, $email_message, $headers); } elseif($mail['mailsend'] == 2) { if(!$fp = fsockopen($mail['server'], $mail['port'], $errno, $errstr, 30)) { $errorlog('SMTP', "($mail[server]:$mail[port]) CONNECT - Unable to connect to the SMTP server", 0); } stream_set_blocking($fp, true); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != '220') { $errorlog('SMTP', "$mail[server]:$mail[port] CONNECT - $lastmessage", 0); } fputs($fp, ($mail['auth'] ? 'EHLO' : 'HELO')." discuz\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) { $errorlog('SMTP', "($mail[server]:$mail[port]) HELO/EHLO - $lastmessage", 0); } while(1) { if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) { break; } $lastmessage = fgets($fp, 512); } if($mail['auth']) { fputs($fp, "AUTH LOGIN\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 334) { $errorlog('SMTP', "($mail[server]:$mail[port]) AUTH LOGIN - $lastmessage", 0); } fputs($fp, base64_encode($mail['auth_username'])."\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 334) { $errorlog('SMTP', "($mail[server]:$mail[port]) USERNAME - $lastmessage", 0); } fputs($fp, base64_encode($mail['auth_password'])."\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 235) { $errorlog('SMTP', "($mail[server]:$mail[port]) PASSWORD - $lastmessage", 0); } $email_from = $mail['from']; } fputs($fp, "MAIL FROM: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $email_from).">\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250) { fputs($fp, "MAIL FROM: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $email_from).">\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250) { $errorlog('SMTP', "($mail[server]:$mail[port]) MAIL FROM - $lastmessage", 0); } } $email_tos = array(); foreach(explode(',', $email_to) as $touser) { $touser = trim($touser); if($touser) { fputs($fp, "RCPT TO: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $touser).">\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250) { fputs($fp, "RCPT TO: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $touser).">\r\n"); $lastmessage = fgets($fp, 512); $errorlog('SMTP', "($mail[server]:$mail[port]) RCPT TO - $lastmessage", 0); } } } fputs($fp, "DATA\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 354) { $errorlog('SMTP', "($mail[server]:$mail[port]) DATA - $lastmessage", 0); } $headers .= 'Message-ID: <'.gmdate('YmdHs').'.'.substr(md5($email_message.microtime()), 0, 6).rand(100000, 999999).'@'.$_SERVER['HTTP_HOST'].">{$maildelimiter}"; fputs($fp, "Date: ".gmdate('r')."\r\n"); fputs($fp, "To: ".$email_to."\r\n"); fputs($fp, "Subject: ".$email_subject."\r\n"); fputs($fp, $headers."\r\n"); fputs($fp, "\r\n\r\n"); fputs($fp, "$email_message\r\n.\r\n"); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250) { $errorlog('SMTP', "($mail[server]:$mail[port]) END - $lastmessage", 0); } fputs($fp, "QUIT\r\n"); } elseif($mail['mailsend'] == 3) { ini_set('SMTP', $mail['server']); ini_set('smtp_port', $mail['port']); ini_set('sendmail_from', $email_from); @mail($email_to, $email_subject, $email_message, $headers); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/sendmail.inc.php
PHP
asf20
5,549
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: security.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($attackevasive & 1 || $attackevasive & 4) { $_DCOOKIE['lastrequest'] = authcode($_DCOOKIE['lastrequest'], 'DECODE'); dsetcookie('lastrequest', authcode($timestamp, 'ENCODE'), $timestamp + 816400, 1, true); } if($attackevasive & 1) { if($timestamp - $_DCOOKIE['lastrequest'] < 1) { securitymessage('attachsave_1_subject', 'attachsave_1_message'); } } if(($attackevasive & 2) && ($_SERVER['HTTP_X_FORWARDED_FOR'] || $_SERVER['HTTP_VIA'] || $_SERVER['HTTP_PROXY_CONNECTION'] || $_SERVER['HTTP_USER_AGENT_VIA'] || $_SERVER['HTTP_CACHE_INFO'] || $_SERVER['HTTP_PROXY_CONNECTION'])) { securitymessage('attachsave_2_subject', 'attachsave_2_message', FALSE); } if($attackevasive & 4) { if(empty($_DCOOKIE['lastrequest']) || $timestamp - $_DCOOKIE['lastrequest'] > 300) { securitymessage('attachsave_4_subject', 'attachsave_4_message'); } } if($attackevasive & 8) { list($questionkey, $questionanswer, $questiontime) = explode('|', authcode($_DCOOKIE['secqcode'], 'DECODE')); include_once DISCUZ_ROOT.'./forumdata/cache/cache_secqaa.php'; if(!$questionanswer || !$questiontime || $_DCACHE['secqaa'][$questionkey]['answer'] != $questionanswer) { if(empty($_POST['secqsubmit']) || (!empty($_POST['secqsubmit']) && $_DCACHE['secqaa'][$questionkey]['answer'] != md5($_POST['answer']))) { $questionkey = array_rand($_DCACHE['secqaa']); dsetcookie('secqcode', authcode($questionkey.'||'.$timestamp, 'ENCODE'), $timestamp + 816400, 1, true); securitymessage($_DCACHE['secqaa'][$questionkey]['question'], '<input type="text" name="answer" size="8" maxlength="150" /><input class="button" type="submit" name="secqsubmit" value=" Submit " />', FALSE, TRUE); } else { dsetcookie('secqcode', authcode($questionkey.'|'.$_DCACHE['secqaa'][$questionkey]['answer'].'|'.$timestamp, 'ENCODE'), $timestamp + 816400, 1, true); } } } function securitymessage($subject, $message, $reload = TRUE, $form = FALSE) { $scuritylang = array( 'attachsave_1_subject' => '&#x9891;&#x7e41;&#x5237;&#x65b0;&#x9650;&#x5236;', 'attachsave_1_message' => '&#x60a8;&#x8bbf;&#x95ee;&#x672c;&#x7ad9;&#x901f;&#x5ea6;&#x8fc7;&#x5feb;&#x6216;&#x8005;&#x5237;&#x65b0;&#x95f4;&#x9694;&#x65f6;&#x95f4;&#x5c0f;&#x4e8e;&#x4e24;&#x79d2;&#xff01;&#x8bf7;&#x7b49;&#x5f85;&#x9875;&#x9762;&#x81ea;&#x52a8;&#x8df3;&#x8f6c;&#x20;&#x2e;&#x2e;&#x2e;', 'attachsave_2_subject' => '&#x4ee3;&#x7406;&#x670d;&#x52a1;&#x5668;&#x8bbf;&#x95ee;&#x9650;&#x5236;', 'attachsave_2_message' => '&#x672c;&#x7ad9;&#x73b0;&#x5728;&#x9650;&#x5236;&#x4f7f;&#x7528;&#x4ee3;&#x7406;&#x670d;&#x52a1;&#x5668;&#x8bbf;&#x95ee;&#xff0c;&#x8bf7;&#x53bb;&#x9664;&#x60a8;&#x7684;&#x4ee3;&#x7406;&#x8bbe;&#x7f6e;&#xff0c;&#x76f4;&#x63a5;&#x8bbf;&#x95ee;&#x672c;&#x7ad9;&#x3002;', 'attachsave_4_subject' => '&#x9875;&#x9762;&#x91cd;&#x8f7d;&#x5f00;&#x542f;', 'attachsave_4_message' => '&#x6b22;&#x8fce;&#x5149;&#x4e34;&#x672c;&#x7ad9;&#xff0c;&#x9875;&#x9762;&#x6b63;&#x5728;&#x91cd;&#x65b0;&#x8f7d;&#x5165;&#xff0c;&#x8bf7;&#x7a0d;&#x5019;&#x20;&#x2e;&#x2e;&#x2e;' ); $subject = $scuritylang[$subject] ? $scuritylang[$subject] : $subject; $message = $scuritylang[$message] ? $scuritylang[$message] : $message; if($_GET['inajax']) { ajaxshowheader(); echo '<div id="attackevasive_1" class="popupmenu_option"><b style="font-size: 16px">'.$subject.'</b><br /><br />'.$message.'</div>'; ajaxshowfooter(); } else { echo '<html>'; echo '<head>'; echo '<title>'.$subject.'</title>'; echo '</head>'; echo '<body bgcolor="#FFFFFF">'; if($reload) { echo '<script language="JavaScript">'; echo 'function reload() {'; echo ' document.location.reload();'; echo '}'; echo 'setTimeout("reload()", 1001);'; echo '</script>'; } if($form) { echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; } echo '<table cellpadding="0" cellspacing="0" border="0" width="700" align="center" height="85%">'; echo ' <tr align="center" valign="middle">'; echo ' <td>'; echo ' <table cellpadding="10" cellspacing="0" border="0" width="80%" align="center" style="font-family: Verdana, Tahoma; color: #666666; font-size: 11px">'; echo ' <tr>'; echo ' <td valign="middle" align="center" bgcolor="#EBEBEB">'; echo ' <br /><br /> <b style="font-size: 16px">'.$subject.'</b> <br /><br />'; echo $message; echo ' <br /><br />'; echo ' </td>'; echo ' </tr>'; echo ' </table>'; echo ' </td>'; echo ' </tr>'; echo '</table>'; if($form) { echo '</form>'; } echo '</body>'; echo '</html>'; } exit(); } 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["; } function ajaxshowfooter() { echo ']]></root>'; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/security.inc.php
PHP
asf20
5,303
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: promotion.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if(!empty($fromuid)) { $fromuid = intval($fromuid); $fromuser = ''; } if(!$discuz_uid || !($fromuid == $discuz_uid || $fromuser == $discuz_user)) { if($creditspolicy['promotion_visit']) { $db->query("REPLACE INTO {$tablepre}promotions (ip, uid, username) VALUES ('$onlineip', '$fromuid', '$fromuser')"); } if($creditspolicy['promotion_register']) { if(!empty($fromuser) && empty($fromuid)) { if(empty($_DCOOKIE['promotion'])) { $fromuid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$fromuser'"); } else { $fromuid = intval($_DCOOKIE['promotion']); } } if($fromuid) { dsetcookie('promotion', ($_DCOOKIE['promotion'] = $fromuid), 1800); } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/promotion.inc.php
PHP
asf20
981
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: newtrade.inc.php 21053 2009-11-09 10:29:02Z wangjinbo $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $discuz_action = 11; if(empty($forum['fid']) || $forum['type'] == 'group') { showmessage('forum_nonexistence'); } if($special != 2 || !submitcheck('topicsubmit', 0, $seccodecheck, $secqaacheck)) { showmessage('undefined_action', NULL, 'HALTED'); } if(!$allowposttrade) { showmessage('group_nopermission', NULL, 'NOPERM'); } if(!$discuz_uid && !((!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])))) { showmessage('group_nopermission', NULL, 'NOPERM'); } elseif(empty($forum['allowpost'])) { if(!$forum['postperm'] && !$allowpost) { showmessage('group_nopermission', NULL, 'NOPERM'); } elseif($forum['postperm'] && !forumperm($forum['postperm'])) { showmessage('post_forum_newthread_nopermission', NULL, 'HALTED'); } } elseif($forum['allowpost'] == -1) { showmessage('post_forum_newthread_nopermission', NULL, 'HALTED'); } checklowerlimit($postcredits); if($post_invalid = checkpost(1)) { showmessage($post_invalid); } if(checkflood()) { showmessage('post_flood_ctrl'); } $item_price = floatval($item_price); $item_credit = intval($item_credit); if(!trim($item_name)) { showmessage('trade_please_name'); } elseif($maxtradeprice && $item_price > 0 && ($mintradeprice > $item_price || $maxtradeprice < $item_price)) { showmessage('trade_price_between'); } elseif($maxtradeprice && $item_credit > 0 && ($mintradeprice > $item_credit || $maxtradeprice < $item_credit)) { showmessage('trade_credit_between'); } elseif(!$maxtradeprice && $item_price > 0 && $mintradeprice > $item_price) { showmessage('trade_price_more_than'); } elseif(!$maxtradeprice && $item_credit > 0 && $mintradeprice > $item_credit) { showmessage('trade_credit_more_than'); } elseif($item_price <= 0 && $item_credit <= 0) { showmessage('trade_pricecredit_need'); } elseif($item_number < 1) { showmessage('tread_please_number'); } if(!empty($_FILES['tradeattach']['tmp_name'][0])) { $_FILES['attach'] = array_merge_recursive((array)$_FILES['attach'], $_FILES['tradeattach']); } if($allowpostattach && is_array($_FILES['attach'])) { foreach($_FILES['attach']['name'] as $attachname) { if($attachname != '') { checklowerlimit($postattachcredits); break; } } } $typeid = isset($typeid) ? $typeid : 0; $tradetypeid = isset($tradetypeid) ? $tradetypeid : 0; $iconid = !empty($iconid) && isset($_DCACHE['icons'][$iconid]) ? $iconid : 0; $displayorder = $modnewthreads ? -2 : (($forum['ismoderator'] && !empty($sticktopic)) ? 1 : 0); $digest = ($forum['ismoderator'] && !empty($addtodigest)) ? 1 : 0; $readperm = $allowsetreadperm ? $readperm : 0; $isanonymous = $isanonymous && $allowanonymous ? 1 : 0; $author = !$isanonymous ? $discuz_user : ''; $moderated = $digest || $displayorder > 0 ? 1 : 0; $attachment = ($allowpostattach && $attachments = attach_upload()) ? 1 : 0; $db->query("INSERT INTO {$tablepre}threads (fid, readperm, price, iconid, typeid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, special, attachment, moderated, replies) VALUES ('$fid', '$readperm', '$price', '$iconid', '$typeid', '$author', '$discuz_uid', '$subject', '$timestamp', '$timestamp', '$author', '$displayorder', '$digest', '$special', '$attachment', '$moderated', '1')"); $tid = $db->insert_id(); if($moderated) { updatemodlog($tid, ($displayorder > 0 ? 'STK' : 'DIG')); updatemodworks(($displayorder > 0 ? 'STK' : 'DIG'), 1); } $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff)); $smileyoff = checksmilies($message, !empty($smileyoff)); $parseurloff = !empty($parseurloff); $htmlon = bindec(($tagstatus && !empty($tagoff) ? 1 : 0).($allowhtml && !empty($htmlon) ? 1 : 0)); $attentionon = empty($attention_add) ? 0 : 1; $pinvisible = $modnewthreads ? -2 : 0; $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment) VALUES ('$fid', '$tid', '1', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '0')"); if($tagstatus && $tags != '') { $tagarray = array_unique(explode(' ', censor($tags))); $tagcount = 0; foreach($tagarray as $tagname) { $tagname = trim($tagname); if(preg_match('/^([\x7f-\xff_-]|\w){3,20}$/', $tagname)) { $query = $db->query("SELECT closed FROM {$tablepre}tags WHERE tagname='$tagname'"); if($db->num_rows($query)) { if(!$tagstatus = $db->result($query, 0)) { $db->query("UPDATE {$tablepre}tags SET total=total+1 WHERE tagname='$tagname'", 'UNBUFFERED'); } } else { $db->query("INSERT INTO {$tablepre}tags (tagname, closed, total) VALUES ('$tagname', 0, 1)", 'UNBUFFERED'); $tagstatus = 0; } if(!$tagstatus) { $db->query("INSERT {$tablepre}threadtags (tagname, tid) VALUES ('$tagname', $tid)", 'UNBUFFERED'); } $tagcount++; if($tagcount > 4) { unset($tagarray); break; } } } } $pinvisible = $modnewreplies ? -2 : 0; $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment) VALUES ('$fid', '$tid', '0', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '$message', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')"); $pid = $db->insert_id(); threadsort_checkoption(1, 1); $optiondata = array(); if($tradetypes && $typeoption && $checkoption) { $optiondata = threadsort_validator($typeoption); } if($tradetypes && $optiondata) { foreach($optiondata as $optionid => $value) { $db->query("INSERT INTO {$tablepre}tradeoptionvars (sortid, pid, optionid, value) VALUES ('$tradetypeid', '$pid', '$optionid', '$value')"); } } if($discuz_uid) { $stataction = ''; if($attentionon) { $stataction = 'attentionon'; $db->query("REPLACE INTO {$tablepre}favoritethreads (tid, uid, dateline) VALUES ('$tid', '$discuz_uid', '$timestamp')", 'UNBUFFERED'); } if($stataction) { write_statlog('', 'item=attention&action=newtrade_'.$stataction, '', '', 'my.php'); } $db->query("UPDATE {$tablepre}favoriteforums SET newthreads=newthreads+1 WHERE fid='$fid' AND uid<>'$discuz_uid'", 'UNBUFFERED'); } $allowpostattach && ($attachnew || $attachdel || $tradeaid) && updateattach(); require_once DISCUZ_ROOT.'./include/trade.func.php'; trade_create(array( 'tid' => $tid, 'pid' => $pid, 'aid' => $tradeaid, 'typeid' => $tradetypeid, 'item_expiration' => $item_expiration, 'thread' => $thread, 'discuz_uid' => $discuz_uid, 'author' => $author, 'seller' => $seller, 'item_name' => $item_name, 'item_price' => $item_price, 'item_number' => $item_number, 'item_quality' => $item_quality, 'item_locus' => $item_locus, 'transport' => $transport, 'postage_mail' => $postage_mail, 'postage_express' => $postage_express, 'postage_ems' => $postage_ems, 'item_type' => $item_type, 'item_costprice' => $item_costprice, 'item_credit' => $item_credit, 'item_costcredit' => $item_costcredit )); if($modnewthreads) { $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED'); showmessage('post_newthread_mod_succeed', "forumdisplay.php?fid=$fid"); } else { $feed = array(); if($addfeed && $forum['allowfeed']) { $feed['icon'] = 'goods'; $feed['title_template'] = 'feed_thread_goods_title'; $feed['body_template'] = 'feed_thread_goods_message'; $feed['body_data'] = array( 'itemname'=> "<a href=\"{$boardurl}viewthread.php?do=tradeinfo&tid=$tid&pid=$pid\">$item_name</a>", 'itemprice'=> $item_price ); if(in_array($attachments[1]['type'], array('image/gif', 'image/jpeg', 'image/png'))) { $attachurl = preg_match("/^((https?|ftps?):\/\/|www\.)/i", $attachurl) ? $attachurl : $boardurl.$attachurl; $imgurl = $attachurl.'/'.$attachments[1]['attachment'].($attachments[1]['thumb'] && $attachments[1]['type'] != 'image/gif' ? '.thumb.jpg' : ''); $feed['images'][] = $attachments[1]['attachment'] ? array('url' => $imgurl, 'link' => "{$boardurl}viewthread.php?tid=$tid") : array(); } postfeed($feed); } if($digest) { foreach($digestcredits as $id => $addcredits) { $postcredits[$id] = (isset($postcredits[$id]) ? $postcredits[$id] : 0) + $addcredits; } } updatepostcredits('+', $discuz_uid, $postcredits); $db->query("UPDATE {$tablepre}members SET threads=threads+1 WHERE uid='$discuz_uid'"); if(is_array($dzfeed_limit['user_threads']) && in_array(($threads + 1), $dzfeed_limit['user_threads'])) { $arg = $data = array(); $arg['type'] = 'user_threads'; $arg['uid'] = $discuz_uid; $arg['username'] = $discuz_userss; $data['title']['actor'] = "<a href=\"space.php?uid={$discuz_uid}\" target=\"_blank\">{$discuz_user}</a>"; $data['title']['count'] = $threads + 1; add_feed($arg, $data); } $lastpost = "$tid\t$subject\t$timestamp\t$author"; $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', threads=threads+1, posts=posts+2, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED'); if($forum['type'] == 'sub') { $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED'); } showmessage('post_newthread_succeed', "viewthread.php?tid=$tid&extra=$extra"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/newtrade.inc.php
PHP
asf20
9,869
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: misc.func.php 19790 2009-09-10 06:32:12Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function convertip($ip) { $return = ''; if(preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/", $ip)) { $iparray = explode('.', $ip); if($iparray[0] == 10 || $iparray[0] == 127 || ($iparray[0] == 192 && $iparray[1] == 168) || ($iparray[0] == 172 && ($iparray[1] >= 16 && $iparray[1] <= 31))) { $return = '- LAN'; } elseif($iparray[0] > 255 || $iparray[1] > 255 || $iparray[2] > 255 || $iparray[3] > 255) { $return = '- Invalid IP Address'; } else { $tinyipfile = DISCUZ_ROOT.'./ipdata/tinyipdata.dat'; $fullipfile = DISCUZ_ROOT.'./ipdata/wry.dat'; if(@file_exists($tinyipfile)) { $return = convertip_tiny($ip, $tinyipfile); } elseif(@file_exists($fullipfile)) { $return = convertip_full($ip, $fullipfile); } } } return $return; } function convertip_tiny($ip, $ipdatafile) { static $fp = NULL, $offset = array(), $index = NULL; $ipdot = explode('.', $ip); $ip = pack('N', ip2long($ip)); $ipdot[0] = (int)$ipdot[0]; $ipdot[1] = (int)$ipdot[1]; if($fp === NULL && $fp = @fopen($ipdatafile, 'rb')) { $offset = unpack('Nlen', fread($fp, 4)); $index = fread($fp, $offset['len'] - 4); } elseif($fp == FALSE) { return '- Invalid IP data file'; } $length = $offset['len'] - 1028; $start = unpack('Vlen', $index[$ipdot[0] * 4] . $index[$ipdot[0] * 4 + 1] . $index[$ipdot[0] * 4 + 2] . $index[$ipdot[0] * 4 + 3]); for ($start = $start['len'] * 8 + 1024; $start < $length; $start += 8) { if ($index{$start} . $index{$start + 1} . $index{$start + 2} . $index{$start + 3} >= $ip) { $index_offset = unpack('Vlen', $index{$start + 4} . $index{$start + 5} . $index{$start + 6} . "\x0"); $index_length = unpack('Clen', $index{$start + 7}); break; } } fseek($fp, $offset['len'] + $index_offset['len'] - 1024); if($index_length['len']) { return '- '.fread($fp, $index_length['len']); } else { return '- Unknown'; } } function convertip_full($ip, $ipdatafile) { if(!$fd = @fopen($ipdatafile, 'rb')) { return '- Invalid IP data file'; } $ip = explode('.', $ip); $ipNum = $ip[0] * 16777216 + $ip[1] * 65536 + $ip[2] * 256 + $ip[3]; if(!($DataBegin = fread($fd, 4)) || !($DataEnd = fread($fd, 4)) ) return; @$ipbegin = implode('', unpack('L', $DataBegin)); if($ipbegin < 0) $ipbegin += pow(2, 32); @$ipend = implode('', unpack('L', $DataEnd)); if($ipend < 0) $ipend += pow(2, 32); $ipAllNum = ($ipend - $ipbegin) / 7 + 1; $BeginNum = $ip2num = $ip1num = 0; $ipAddr1 = $ipAddr2 = ''; $EndNum = $ipAllNum; while($ip1num > $ipNum || $ip2num < $ipNum) { $Middle= intval(($EndNum + $BeginNum) / 2); fseek($fd, $ipbegin + 7 * $Middle); $ipData1 = fread($fd, 4); if(strlen($ipData1) < 4) { fclose($fd); return '- System Error'; } $ip1num = implode('', unpack('L', $ipData1)); if($ip1num < 0) $ip1num += pow(2, 32); if($ip1num > $ipNum) { $EndNum = $Middle; continue; } $DataSeek = fread($fd, 3); if(strlen($DataSeek) < 3) { fclose($fd); return '- System Error'; } $DataSeek = implode('', unpack('L', $DataSeek.chr(0))); fseek($fd, $DataSeek); $ipData2 = fread($fd, 4); if(strlen($ipData2) < 4) { fclose($fd); return '- System Error'; } $ip2num = implode('', unpack('L', $ipData2)); if($ip2num < 0) $ip2num += pow(2, 32); if($ip2num < $ipNum) { if($Middle == $BeginNum) { fclose($fd); return '- Unknown'; } $BeginNum = $Middle; } } $ipFlag = fread($fd, 1); if($ipFlag == chr(1)) { $ipSeek = fread($fd, 3); if(strlen($ipSeek) < 3) { fclose($fd); return '- System Error'; } $ipSeek = implode('', unpack('L', $ipSeek.chr(0))); fseek($fd, $ipSeek); $ipFlag = fread($fd, 1); } if($ipFlag == chr(2)) { $AddrSeek = fread($fd, 3); if(strlen($AddrSeek) < 3) { fclose($fd); return '- System Error'; } $ipFlag = fread($fd, 1); if($ipFlag == chr(2)) { $AddrSeek2 = fread($fd, 3); if(strlen($AddrSeek2) < 3) { fclose($fd); return '- System Error'; } $AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0))); fseek($fd, $AddrSeek2); } else { fseek($fd, -1, SEEK_CUR); } while(($char = fread($fd, 1)) != chr(0)) $ipAddr2 .= $char; $AddrSeek = implode('', unpack('L', $AddrSeek.chr(0))); fseek($fd, $AddrSeek); while(($char = fread($fd, 1)) != chr(0)) $ipAddr1 .= $char; } else { fseek($fd, -1, SEEK_CUR); while(($char = fread($fd, 1)) != chr(0)) $ipAddr1 .= $char; $ipFlag = fread($fd, 1); if($ipFlag == chr(2)) { $AddrSeek2 = fread($fd, 3); if(strlen($AddrSeek2) < 3) { fclose($fd); return '- System Error'; } $AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0))); fseek($fd, $AddrSeek2); } else { fseek($fd, -1, SEEK_CUR); } while(($char = fread($fd, 1)) != chr(0)) $ipAddr2 .= $char; } fclose($fd); if(preg_match('/http/i', $ipAddr2)) { $ipAddr2 = ''; } $ipaddr = "$ipAddr1 $ipAddr2"; $ipaddr = preg_replace('/CZ88\.NET/is', '', $ipaddr); $ipaddr = preg_replace('/^\s*/is', '', $ipaddr); $ipaddr = preg_replace('/\s*$/is', '', $ipaddr); if(preg_match('/http/i', $ipaddr) || $ipaddr == '') { $ipaddr = '- Unknown'; } return '- '.$ipaddr; } function procthread($thread) { global $dateformat, $timeformat, $timeoffset, $ppp, $colorarray, $threadplugins, $specialicon, $lastvisit, $_DCACHE, $_DCOOKIE; require_once DISCUZ_ROOT.'./forumdata/cache/cache_icons.php'; if(empty($colorarray)) { $colorarray = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282'); } if($thread['closed']) { $thread['new'] = 0; $thread['folder'] = 'lock'; } else { $thread['folder'] = 'common'; if($lastvisit < $thread['lastpost'] && (empty($_DCOOKIE['oldtopics']) || strpos($_DCOOKIE['oldtopics'], 'D'.$thread['tid'].'D') === FALSE)) { $thread['new'] = 1; $thread['folder'] = 'new'; } else { $thread['new'] = 0; } } if($thread['special'] != 127) { $thread['icon'] = isset($_DCACHE['icons'][$thread['iconid']]) ? '<img src="images/icons/'.$_DCACHE['icons'][$thread['iconid']].'" class="icon" />' : '&nbsp;'; } else { $thread['icon'] = '<img src="'.$threadplugins[$specialicon[$thread['iconid']]]['icon'].'" alt="'.$threadplugins[$specialicon[$thread['iconid']]]['name'].'" class="icon" />'; } $thread['forumname'] = $_DCACHE['forums'][$thread['fid']]['name']; $thread['dateline'] = gmdate($dateformat, $thread['dateline'] + $timeoffset * 3600); $thread['lastpost'] = dgmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600); $thread['lastposterenc'] = rawurlencode($thread['lastposter']); if($thread['replies'] > $thread['views']) { $thread['views'] = $thread['replies']; } $postsnum = $thread['special'] ? $thread['replies'] : $thread['replies'] + 1; $thread['special'] == 3 && $thread['price'] < 0 && $thread['replies']--; $pagelinks = ''; if($postsnum > $ppp) { $posts = $postsnum; $topicpages = ceil($posts / $ppp); for($i = 1; $i <= $topicpages; $i++) { $pagelinks .= '<a href="viewthread.php?tid='.$thread['tid'].'&page='.$i.'" target="_blank">'.$i.'</a> '; if($i == 6) { $i = $topicpages + 1; } } if($topicpages > 6) { $pagelinks .= ' .. <a href="viewthread.php?tid='.$thread['tid'].'&page='.$topicpages.'" target="_blank">'.$topicpages.'</a> '; } $thread['multipage'] = '... '.$pagelinks; } else { $thread['multipage'] = ''; } if($thread['highlight']) { $string = sprintf('%02d', $thread['highlight']); $stylestr = sprintf('%03b', $string[0]); $thread['highlight'] = 'style="'; $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : ''; $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : ''; $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : ''; $thread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : ''; $thread['highlight'] .= '"'; } else { $thread['highlight'] = ''; } return $thread; } function updateviews($table, $idcol, $viewscol, $logfile) { global $db, $tablepre; $viewlog = $viewarray = array(); if(@$viewlog = file($logfile = DISCUZ_ROOT.$logfile)) { if(!@unlink($logfile)) { if($fp = @fopen($logfile, 'w')) { fwrite($fp, ''); fclose($fp); } } $viewlog = array_count_values($viewlog); foreach($viewlog as $id => $views) { $viewarray[$views] .= ($id > 0) ? ','.intval($id) : ''; } foreach($viewarray as $views => $ids) { $db->query("UPDATE LOW_PRIORITY $tablepre$table SET $viewscol=$viewscol+'$views' WHERE $idcol IN (0$ids)", 'UNBUFFERED'); } } } function modlog($thread, $action) { global $discuz_user, $adminid, $onlineip, $timestamp, $forum, $reason; writelog('modslog', dhtmlspecialchars("$timestamp\t$discuz_user\t$adminid\t$onlineip\t$forum[fid]\t$forum[name]\t$thread[tid]\t$thread[subject]\t$action\t$reason")); } function checkreasonpm() { global $reason; $reason = trim(strip_tags($reason)); if(($GLOBALS['reasonpm'] == 1 || $GLOBALS['reasonpm'] == 3) && !$reason) { showmessage('admin_reason_invalid'); } } function procreportlog($tids = '', $pids = '', $del = FALSE) { global $db, $tablepre, $fid, $forum; if(!$pids && $tids) { $pids = $comma = ''; $query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid IN ($tids)".($del ? '' : ' AND first=1')); while($post = $db->fetch_array($query)) { $pids .= $comma.$post['pid']; $comma = ','; } } if($pids) { if($del) { $db->query("DELETE FROM {$tablepre}reportlog WHERE pid IN ($pids)", 'UNBUFFERED'); } else { $db->query("UPDATE {$tablepre}reportlog SET status=0 WHERE pid IN ($pids)", 'UNBUFFERED'); } if($forum['modworks'] && !$db->result_first("SELECT COUNT(*) FROM {$tablepre}reportlog WHERE fid='$fid' AND status=1")) { $db->query("UPDATE {$tablepre}forums SET modworks='0' WHERE fid='$fid'", 'UNBUFFERED'); } } } function sendreasonpm($var, $item) { global $$var; ${$var}['subject'] = strtr(${$var}['subject'], array_flip(get_html_translation_table(HTML_ENTITIES))); ${$var}['dateline'] = gmdate($GLOBALS['_DCACHE']['settings']['dateformat'].' '.$GLOBALS['_DCACHE']['settings']['timeformat'], ${$var}['dateline'] + ($GLOBALS['timeoffset'] * 3600)); if(!empty(${$var}['authorid']) && ${$var}['authorid'] != $GLOBALS['discuz_uid']) { sendnotice(${$var}['authorid'], $item, 'systempm'); } } function modreasonselect($isadmincp = 0) { global $_DCACHE; if(!isset($_DCACHE['modreasons']) || !is_array($_DCACHE['modreasons'])) { @include DISCUZ_ROOT.'./forumdata/cache/cache_topicadmin.php'; } $select = ''; foreach($_DCACHE['modreasons'] as $reason) { $select .= !$isadmincp ? ($reason ? '<li>'.$reason.'</li>' : '<li></li>') : ($reason ? '<option value="'.htmlspecialchars($reason).'">'.$reason.'</option>' : '<option></option>'); } return $select; } function logincheck() { global $db, $tablepre, $onlineip, $timestamp; $return = 0; $login = $db->fetch_first("SELECT count, lastupdate FROM {$tablepre}failedlogins WHERE ip='$onlineip'"); $return = (!$login || ($timestamp - $login['lastupdate'] > 900)) ? 4 : max(0, 5 - $login['count']); if($return == 4) { $db->query("REPLACE INTO {$tablepre}failedlogins (ip, count, lastupdate) VALUES ('$onlineip', '1', '$timestamp')"); $db->query("DELETE FROM {$tablepre}failedlogins WHERE lastupdate<$timestamp-901", 'UNBUFFERED'); } return $return; } function loginfailed($permission) { global $db, $tablepre, $onlineip, $timestamp; $db->query("UPDATE {$tablepre}failedlogins SET count=count+1, lastupdate='$timestamp' WHERE ip='$onlineip'"); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/misc.func.php
PHP
asf20
12,138
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: index_feeds.inc.php 20822 2009-10-26 10:20:57Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } require_once DISCUZ_ROOT.'./include/forum.func.php'; $discuz_action = 1; $lastvisittime = dgmdate("$dateformat $timeformat", $lastvisit + $timeoffset * 3600); $newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000; $lastvisit = $lastvisit ? dgmdate("$dateformat $timeformat", $lastvisit + 3600 * $timeoffset) : 0; $announcements = ''; if($_DCACHE['announcements']) { $readapmids = !empty($_DCOOKIE['readapmid']) ? explode('D', $_DCOOKIE['readapmid']) : array(); foreach($_DCACHE['announcements'] as $announcement) { if(empty($announcement['groups']) || in_array($groupid, $announcement['groups'])) { if(empty($announcement['type'])) { $announcements .= '<li><a href="announcement.php?id='.$announcement['id'].'">'.$announcement['subject']. '<em>('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')</em></a></li>'; } elseif($announcement['type'] == 1) { $announcements .= '<li><a href="'.$announcement['message'].'" target="_blank">'.$announcement['subject']. '<em>('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')</em></a></li>'; } } } } unset($_DCACHE['announcements']); $postdata = $historyposts ? explode("\t", $historyposts) : array(); $heats = array(); $threads = $posts = $todayposts = 0; $now = $timestamp + $timeoffset * 3600; $day1 = gmdate($dateformat, $now); $day2 = gmdate($dateformat, $now - 86400); $day3 = gmdate($dateformat, $now - 172800); $type = empty($type) ? '' : $type; if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'sidebar') === FALSE) { $collapseimg['sidebar'] = 'collapsed_no'; $collapse['sidebar'] = ''; } else { $collapseimg['sidebar'] = 'collapsed_yes'; $collapse['sidebar'] = 'display: none'; } $infosidestatus['allow'] = $infosidestatus['allow'] && $infosidestatus[2] && $infosidestatus[2] != -1 ? (!$collapse['sidebar'] ? 2 : 1) : 0; if($indexhot['status'] && $_DCACHE['heats']['expiration'] < $timestamp) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('heats'); } if(!$type) { $view = empty($view) ? 0 : 1; $conf = array( 'num' => 50, 'cachelife' => 300, 'multipage' => $view, 'page_url' => $indexname.(!empty($view) ? '?view=all&op=feeds' : '') ); } elseif($type == 'manyou') { $conf = array( 'type' => 'manyou', 'num' => '50', 'cachelife' => 300, 'multipage' => 0, 'page_url' => $indexname ); } $feeds = get_feed($conf); $feeddate = ''; if(empty($type)) { foreach($feeds['data'] as $k => $feed) { $feeds['data'][$k]['date'] = gmdate($dateformat, $feed['dbdateline'] + $timeoffset * 3600); $feeds['data'][$k]['daterange'] = $feeddate != $feeds['data'][$k]['date'] ? $feeds['data'][$k]['date'] : ''; $feeds['data'][$k]['title'] = preg_replace("/<a(.+?)href=([\'\"]?)([^>\s]+)\\2([^>]*)>/i", '<a target="_blank" \\1 href="\\3&from=indexfeeds" \\4>', $feeds['data'][$k]['title']); $feeds['data'][$k]['body'] = preg_replace("/<a(.+?)href=([\'\"]?)([^>\s]+)\\2([^>]*)>/i", '<a target="_blank" \\1 href="\\3&from=indexfeeds" \\4>', $feeds['data'][$k]['body']); $feeddate = $feeds['data'][$k]['date']; } } else { $bi = 1; foreach($feeds['data'] as $k => $feed) { $trans['{addbuddy}'] = $feed['uid'] != $discuz_uid ? '<a href="my.php?item=buddylist&newbuddyid='.$feed['uid'].'&buddysubmit=yes" id="ajax_buddy_'.($bi++).'" 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]['body'] = strtr($feed['body'], $trans); $feeds['data'][$k]['title'] = preg_replace("/<a(.+?)href=([\'\"]?)([^>\s]+)\\2([^>]*)>/i", '<a target="_blank" \\1 href="\\3&from=indexfeeds" \\4>', $feeds['data'][$k]['title']); $feeds['data'][$k]['body'] = preg_replace("/<a(.+?)href=([\'\"]?)([^>\s]+)\\2([^>]*)>/i", '<a target="_blank" \\1 href="\\3&from=indexfeeds" \\4>', $feeds['data'][$k]['body']); list($feeds['data'][$k]['body'], $feeds['data'][$k]['general']) = explode(chr(0).chr(0).chr(0), $feeds['data'][$k]['body']); $feeds['data'][$k]['icon_image'] = 'http://appicon.manyou.com/icons/'.$feed['appid']; $dateline = $feed['dbdateline'] + $timeoffset * 3600; $feeds['data'][$k]['date'] = gmdate($dateformat, $dateline); if($feeddate != $feeds['data'][$k]['date']) { $feeds['data'][$k]['daterange'] = $feeds['data'][$k]['date']; } else { $feeds['data'][$k]['daterange'] = ''; } $feeddate = $feeds['data'][$k]['date']; } } $multi = $feeds['multipage']; $feeds = $feeds['data']; $sql = !empty($accessmasks) ? "SELECT f.threads, f.posts, f.todayposts, 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' ORDER BY f.type, f.displayorder" : "SELECT f.threads, f.posts, f.todayposts, ff.viewperm FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING(fid) WHERE f.status='1' ORDER BY f.type, f.displayorder"; $query = $db->query($sql); while($forumdata = $db->fetch_array($query)) { if(!$forumdata['viewperm'] || ($forumdata['viewperm'] && forumperm($forumdata['viewperm'])) || !empty($forumdata['allowview'])) { $threads += $forumdata['threads']; $posts += $forumdata['posts']; $todayposts += $forumdata['todayposts']; } } include template('discuz_feeds'); ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/index_feeds.inc.php
PHP
asf20
5,768
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: editpost.inc.php 21308 2009-11-26 01:08:59Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $discuz_action = 13; $orig = $db->fetch_first("SELECT m.adminid, p.first, p.authorid, p.author, p.dateline, p.anonymous, p.invisible, p.htmlon FROM {$tablepre}posts p LEFT JOIN {$tablepre}members m ON m.uid=p.authorid WHERE pid='$pid' AND tid='$tid' AND fid='$fid'"); if($magicstatus) { $magicid = $db->result_first("SELECT magicid FROM {$tablepre}threadsmod WHERE tid='$tid' AND magicid='10'"); $allowanonymous = $allowanonymous || $magicid ? 1 : $allowanonymous; } $isfirstpost = $orig['first'] ? 1 : 0; $isorigauthor = $discuz_uid && $discuz_uid == $orig['authorid']; $isanonymous = $isanonymous && $allowanonymous ? 1 : 0; $audit = $orig['invisible'] == -2 || $thread['displayorder'] == -2 ? $audit : 0; if(empty($orig)) { showmessage('undefined_action'); } elseif((!$forum['ismoderator'] || !$alloweditpost || (in_array($orig['adminid'], array(1, 2, 3)) && $adminid > $orig['adminid'])) && !($forum['alloweditpost'] && $isorigauthor)) { showmessage('post_edit_nopermission', NULL, 'HALTED'); } elseif($isorigauthor && !$forum['ismoderator']) { if($edittimelimit && $timestamp - $orig['dateline'] > $edittimelimit * 60) { showmessage('post_edit_timelimit', NULL, 'HALTED'); } } $thread['pricedisplay'] = $thread['price'] == -1 ? 0 : $thread['price']; if($tagstatus && $isfirstpost) { $query = $db->query("SELECT tagname FROM {$tablepre}threadtags WHERE tid='$tid'"); $threadtagary = array(); while($tagname = $db->fetch_array($query)) { $threadtagary[] = $tagname['tagname']; } $threadtags = dhtmlspecialchars(implode(' ',$threadtagary)); } if($special == 5) { $debate = array_merge($thread, daddslashes($db->fetch_first("SELECT * FROM {$tablepre}debates WHERE tid='$tid'"), 1)); $firststand = $db->result_first("SELECT stand FROM {$tablepre}debateposts WHERE tid='$tid' AND uid='$discuz_uid' AND stand<>'0' ORDER BY dateline LIMIT 1"); if(!$isfirstpost && $debate['endtime'] && $debate['endtime'] < $timestamp && !$forum['ismoderator']) { showmessage('debate_end'); } if($isfirstpost && $debate['umpirepoint'] && !$forum['ismoderator']) { showmessage('debate_umpire_comment_invalid'); } } $rushreply = getstatus($thread['status'], 3); $savepostposition = getstatus($thread['status'], 1); if(!submitcheck('editsubmit')) { $hiddenreplies = getstatus($thread['status'], 2); $icons = ''; if(!$special && is_array($_DCACHE['icons']) && $isfirstpost) { $key = 1; foreach($_DCACHE['icons'] as $id => $icon) { $icons .= ' <input class="radio" type="radio" name="iconid" value="'.$id.'" '.($thread['iconid'] == $id ? 'checked="checked"' : '').' /><img src="images/icons/'.$icon.'" alt="" />'; $icons .= !(++$key % 10) ? '<br />' : ''; } } $postinfo = $db->fetch_first("SELECT * FROM {$tablepre}posts WHERE pid='$pid' AND tid='$tid' AND fid='$fid'"); $usesigcheck = $postinfo['usesig'] ? 'checked="checked"' : ''; $urloffcheck = $postinfo['parseurloff'] ? 'checked="checked"' : ''; $smileyoffcheck = $postinfo['smileyoff'] == 1 ? 'checked="checked"' : ''; $codeoffcheck = $postinfo['bbcodeoff'] == 1 ? 'checked="checked"' : ''; $tagoffcheck = $postinfo['htmlon'] & 2 ? 'checked="checked"' : ''; $htmloncheck = $postinfo['htmlon'] & 1 ? 'checked="checked"' : ''; $showthreadsorts = ($thread['sortid'] || !empty($sortid)) && $isfirstpost; $sortid = empty($sortid) ? $thread['sortid'] : $sortid; $poll = $temppoll = ''; if($isfirstpost) { if($special == 127) { $sppos = strrpos($postinfo['message'], chr(0).chr(0).chr(0)); $specialextra = substr($postinfo['message'], $sppos + 3); if($specialextra && array_key_exists($specialextra, $threadplugins) && in_array($specialextra, unserialize($forum['threadplugin'])) && in_array($specialextra, $allowthreadplugin)) { $postinfo['message'] = substr($postinfo['message'], 0, $sppos); } else { $special = 0; $specialextra = ''; } } $thread['freecharge'] = $maxchargespan && $timestamp - $thread['dateline'] >= $maxchargespan * 3600 ? 1 : 0; $freechargehours = !$thread['freecharge'] ? $maxchargespan - intval(($timestamp - $thread['dateline']) / 3600) : 0; if($thread['special'] == 1 && ($alloweditpoll || $thread['authorid'] == $discuz_uid)) { $query = $db->query("SELECT polloptionid, displayorder, polloption, multiple, visible, maxchoices, expiration, overt FROM {$tablepre}polloptions AS polloptions LEFT JOIN {$tablepre}polls AS polls ON polloptions.tid=polls.tid WHERE polls.tid ='$tid' ORDER BY displayorder"); while($temppoll = $db->fetch_array($query)) { $poll['multiple'] = $temppoll['multiple']; $poll['visible'] = $temppoll['visible']; $poll['maxchoices'] = $temppoll['maxchoices']; $poll['expiration'] = $temppoll['expiration']; $poll['overt'] = $temppoll['overt']; $poll['polloptionid'][] = $temppoll['polloptionid']; $poll['displayorder'][] = $temppoll['displayorder']; $poll['polloption'][] = stripslashes($temppoll['polloption']); } $maxpolloptions = $maxpolloptions - $db->num_rows($query); } elseif($thread['special'] == 3) { $rewardprice = abs($thread['price']); } elseif($thread['special'] == 4) { $activitytypelist = $activitytype ? explode("\n", trim($activitytype)) : ''; $activity = $db->fetch_first("SELECT * FROM {$tablepre}activities WHERE tid='$tid'"); $activity['starttimefrom'] = gmdate("Y-m-d H:i", $activity['starttimefrom'] + $timeoffset * 3600); $activity['starttimeto'] = $activity['starttimeto'] ? gmdate("Y-m-d H:i", $activity['starttimeto'] + $timeoffset * 3600) : ''; $activity['expiration'] = $activity['expiration'] ? gmdate("Y-m-d H:i", $activity['expiration'] + $timeoffset * 3600) : ''; } elseif($thread['special'] == 5 ) { $debate['endtime'] = $debate['endtime'] ? gmdate("Y-m-d H:i", $debate['endtime'] + $timeoffset * 3600) : ''; } } if($thread['special'] == 2 && ($thread['authorid'] == $discuz_uid && $allowposttrade || $allowedittrade)) { $query = $db->query("SELECT * FROM {$tablepre}trades WHERE pid='$pid'"); $tradetypeselect = ''; if($db->num_rows($query)) { $trade = $db->fetch_array($query); $trade['expiration'] = $trade['expiration'] ? date('Y-m-d', $trade['expiration']) : ''; $trade['costprice'] = $trade['costprice'] > 0 ? $trade['costprice'] : ''; $trade['message'] = dhtmlspecialchars($trade['message']); $tradetypeid = $trade['typeid']; $forum['tradetypes'] = $forum['tradetypes'] == '' ? -1 : unserialize($forum['tradetypes']); if((!$tradetypeid || !isset($tradetypes[$tradetypeid]) && !empty($forum['tradetypes']))) { $tradetypeselect = '<select name="tradetypeid" onchange="ajaxget(\'post.php?action=threadsorts&tradetype=yes&sortid=\'+this.options[this.selectedIndex].value+\'&sid='.$sid.'\', \'threadtypes\', \'threadtypeswait\')"><option value="0">&nbsp;</option>'; foreach($tradetypes as $typeid => $name) { if($forum['tradetypes'] == -1 || @in_array($typeid, $forum['tradetypes'])) { $tradetypeselect .= '<option value="'.$typeid.'">'.strip_tags($name).'</option>'; } } $tradetypeselect .= '</select><span id="threadtypeswait"></span>'; } else { $tradetypeselect = '<select disabled><option>'.$tradetypes[$trade['typeid']].'</option></select>'; } $expiration_7days = date('Y-m-d', $timestamp + 86400 * 7); $expiration_14days = date('Y-m-d', $timestamp + 86400 * 14); $expiration_month = date('Y-m-d', mktime(0, 0, 0, date('m')+1, date('d'), date('Y'))); $expiration_3months = date('Y-m-d', mktime(0, 0, 0, date('m')+3, date('d'), date('Y'))); $expiration_halfyear = date('Y-m-d', mktime(0, 0, 0, date('m')+6, date('d'), date('Y'))); $expiration_year = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')+1)); } else { $tradetypeid = $special = 0; $trade = array(); } } if($isfirstpost && $specialextra) { @include_once DISCUZ_ROOT.'./plugins/'.$threadplugins[$specialextra]['module'].'.class.php'; $classname = 'threadplugin_'.$specialextra; if(method_exists($classname, 'editpost')) { $threadpluginclass = new $classname; $threadplughtml = $threadpluginclass->editpost($fid, $tid); } } $postinfo['subject'] = str_replace('"', '&quot;', $postinfo['subject']); $postinfo['message'] = dhtmlspecialchars($postinfo['message']); include_once language('misc'); $postinfo['message'] = preg_replace($language['post_edit_regexp'], '', $postinfo['message']); if($special == 5) { $standselected = array($firststand => 'selected="selected"'); } if($allowpostattach) { $attachlist = getattach(); $attachs = $attachlist['attachs']; $imgattachs = $attachlist['imgattachs']; unset($attachlist); $attachfind = $attachreplace = array(); if($attachs['used']) { foreach($attachs['used'] as $attach) { if($attach['isimage']) { $attachfind[] = "/\[attach\]$attach[aid]\[\/attach\]/i"; $attachreplace[] = '[attachimg]'.$attach['aid'].'[/attachimg]'; } } } if($imgattachs['used']) { foreach($imgattachs['used'] as $attach) { $attachfind[] = "/\[attach\]$attach[aid]\[\/attach\]/i"; $attachreplace[] = '[attachimg]'.$attach['aid'].'[/attachimg]'; } } $attachfind && $postinfo['message'] = preg_replace($attachfind, $attachreplace, $postinfo['message']); } if($special == 2 && $trade['aid'] && !empty($imgattachs['used']) && is_array($imgattachs['used'])) { foreach($imgattachs['used'] as $k => $tradeattach) { if($tradeattach['aid'] == $trade['aid']) { unset($imgattachs['used'][$k]); break; } } } include template('post'); } else { $redirecturl = "viewthread.php?tid=$tid&page=$page&extra=$extra".($vid && $isfirstpost ? "&vid=$vid" : '')."#pid$pid"; if(empty($delete)) { if($post_invalid = checkpost($isfirstpost && $special)) { showmessage($post_invalid); } if(!$isorigauthor && !$allowanonymous) { if($orig['anonymous'] && !$isanonymous) { $isanonymous = 0; $authoradd = ', author=\''.addslashes($orig['author']).'\''; $anonymousadd = ', anonymous=\'0\''; } else { $isanonymous = $orig['anonymous']; $authoradd = $anonymousadd = ''; } } else { $authoradd = ', author=\''.($isanonymous ? '' : addslashes($orig['author'])).'\''; $anonymousadd = ", anonymous='$isanonymous'"; } if($isfirstpost) { if($subject == '') { showmessage('post_sm_isnull'); } if(!$sortid && !$thread['special'] && $message == '') { showmessage('post_sm_isnull'); } $typeid = isset($forum['threadtypes']['types'][$typeid]) ? $typeid : 0; $sortid = isset($forum['threadsorts']['types'][$sortid]) ? $sortid : 0; $iconid = isset($_DCACHE['icons'][$iconid]) ? $iconid : 0; if(!$typeid && $forum['threadtypes']['required'] && !$thread['special']) { showmessage('post_type_isnull'); } $readperm = $allowsetreadperm ? intval($readperm) : ($isorigauthor ? 0 : 'readperm'); if($thread['special'] == 3) { $price = $thread['price']; } $price = intval($price); $price = $thread['price'] < 0 && !$thread['special'] ?($isorigauthor || !$price ? -1 : $price) :($maxprice ? ($price <= $maxprice ? ($price > 0 ? $price : 0) : $maxprice) : ($isorigauthor ? $price : $thread['price'])); if($price > 0 && floor($price * (1 - $creditstax)) == 0) { showmessage('post_net_price_iszero'); } $polladd = ''; if($thread['special'] == 1 && ($alloweditpoll || $isorigauthor) && !empty($polls)) { $pollarray = ''; $pollarray['options'] = $polloption; if($pollarray['options']) { if(count($pollarray['options']) > $maxpolloptions) { showmessage('post_poll_option_toomany'); } foreach($pollarray['options'] as $key => $value) { if(!trim($value)) { $db->query("DELETE FROM {$tablepre}polloptions WHERE polloptionid='$key' AND tid='$tid'"); unset($pollarray['options'][$key]); } } $polladd = ', special=\'1\''; foreach($displayorder as $key => $value) { if(preg_match("/^-?\d*$/", $value)) { $pollarray['displayorder'][$key] = $value; } } $pollarray['multiple'] = !empty($multiplepoll); $pollarray['visible'] = empty($visibilitypoll); $pollarray['expiration'] = $expiration; $pollarray['overt'] = !empty($overt); foreach($polloptionid as $key => $value) { if(!preg_match("/^\d*$/", $value)) { showmessage('submit_invalid'); } } $maxchoices = !empty($multiplepoll) ? (!$maxchoices || $maxchoices >= count($pollarray['options']) ? count($pollarray['options']) : $maxchoices) : ''; if(preg_match("/^\d*$/", $maxchoices)) { if(!$pollarray['multiple']) { $pollarray['maxchoices'] = 1; } elseif(empty($maxchoices)) { $pollarray['maxchoices'] = 0; } else { $pollarray['maxchoices'] = $maxchoices; } } $expiration = intval($expiration); if($close) { $pollarray['expiration'] = $timestamp; } elseif($expiration) { if(empty($pollarray['expiration'])) { $pollarray['expiration'] = 0; } else { $pollarray['expiration'] = $timestamp + 86400 * $expiration; } } $optid = ''; $query = $db->query("SELECT polloptionid FROM {$tablepre}polloptions WHERE tid='$tid'"); while($tempoptid = $db->fetch_array($query)) { $optid[] = $tempoptid['polloptionid']; } foreach($pollarray['options'] as $key => $value) { $value = dhtmlspecialchars(trim($value)); if(in_array($polloptionid[$key], $optid)) { if($alloweditpoll) { $db->query("UPDATE {$tablepre}polloptions SET displayorder='".$pollarray['displayorder'][$key]."', polloption='$value' WHERE polloptionid='$polloptionid[$key]' AND tid='$tid'"); } else { $db->query("UPDATE {$tablepre}polloptions SET displayorder='".$pollarray['displayorder'][$key]."' WHERE polloptionid='$polloptionid[$key]' AND tid='$tid'"); } } else { $db->query("INSERT INTO {$tablepre}polloptions (tid, displayorder, polloption) VALUES ('$tid', '".$pollarray['displayorder'][$key]."', '$value')"); } } $db->query("UPDATE {$tablepre}polls SET multiple='$pollarray[multiple]', visible='$pollarray[visible]', maxchoices='$pollarray[maxchoices]', expiration='$pollarray[expiration]', overt='$pollarray[overt]' WHERE tid='$tid'", 'UNBUFFERED'); } else { $polladd = ', special=\'0\''; $db->query("DELETE FROM {$tablepre}polls WHERE tid='$tid'"); $db->query("DELETE FROM {$tablepre}polloptions WHERE tid='$tid'"); } } elseif($thread['special'] == 3 && ($allowpostreward || $isorigauthor)) { if($thread['price'] > 0 && $thread['price'] != $rewardprice) { $rewardprice = intval($rewardprice); if($rewardprice <= 0){ showmessage("reward_credits_invalid"); } $addprice = ceil(($rewardprice - $thread['price']) + ($rewardprice - $thread['price']) * $creditstax); if(!$forum['ismoderator']) { if($rewardprice < $thread['price']) { showmessage("reward_credits_fall"); } elseif($rewardprice < $minrewardprice || ($maxrewardprice > 0 && $rewardprice > $maxrewardprice)) { showmessage("reward_credits_between"); } elseif($addprice > $_DSESSION["extcredits$creditstransextra[2]"]) { showmessage('reward_credits_shortage'); } } $realprice = ceil($thread['price'] + $thread['price'] * $creditstax) + $addprice; $db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]-$addprice WHERE uid='$thread[authorid]'"); $db->query("UPDATE {$tablepre}rewardlog SET netamount='$realprice' WHERE tid='$tid' AND authorid='$thread[authorid]'"); } if(!$forum['ismoderator']) { if($thread['replies'] > 1) { $subject = addslashes($thread['subject']); } if($thread['price'] < 0) { $rewardprice = abs($thread['price']); } } $price = $thread['price'] > 0 ? $rewardprice : -$rewardprice; } elseif($thread['special'] == 4 && $allowpostactivity) { $activitytime = intval($activitytime); if(empty($starttimefrom[$activitytime])) { showmessage('activity_fromtime_please'); } elseif(strtotime($starttimefrom[$activitytime]) === -1 || @strtotime($starttimefrom[$activitytime]) === FALSE) { showmessage('activity_fromtime_error'); } elseif($activitytime && ((@strtotime($starttimefrom) > @strtotime($starttimeto) || !$starttimeto))) { showmessage('activity_fromtime_error'); } elseif(!trim($activityclass)) { showmessage('activity_sort_please'); } elseif(!trim($activityplace)) { showmessage('activity_address_please'); } elseif(trim($activityexpiration) && (@strtotime($activityexpiration) === -1 || @strtotime($activityexpiration) === FALSE)) { showmessage('activity_totime_error'); } $activity = array(); $activity['class'] = dhtmlspecialchars(trim($activityclass)); $activity['starttimefrom'] = @strtotime($starttimefrom[$activitytime]); $activity['starttimeto'] = $activitytime ? @strtotime($starttimeto) : 0; $activity['place'] = dhtmlspecialchars(trim($activityplace)); $activity['cost'] = intval($cost); $activity['gender'] = intval($gender); $activity['number'] = intval($activitynumber); if($activityexpiration) { $activity['expiration'] = @strtotime($activityexpiration); } else { $activity['expiration'] = 0; } $db->query("UPDATE {$tablepre}activities SET cost='$activity[cost]', starttimefrom='$activity[starttimefrom]', starttimeto='$activity[starttimeto]', place='$activity[place]', class='$activity[class]', gender='$activity[gender]', number='$activity[number]', expiration='$activity[expiration]' WHERE tid='$tid'", 'UNBUFFERED'); } elseif($thread['special'] == 5 && $allowpostdebate) { if(empty($affirmpoint) || empty($negapoint)) { showmessage('debate_position_nofound'); } elseif(!empty($endtime) && (!($endtime = @strtotime($endtime)) || $endtime < $timestamp)) { showmessage('debate_endtime_invalid'); } elseif(!empty($umpire)) { if(!$db->result_first("SELECT COUNT(*) FROM {$tablepre}members WHERE username='$umpire'")) { $umpire = dhtmlspecialchars($umpire); showmessage('debate_umpire_invalid'); } } $affirmpoint = dhtmlspecialchars($affirmpoint); $negapoint = dhtmlspecialchars($negapoint); $db->query("UPDATE {$tablepre}debates SET affirmpoint='$affirmpoint', negapoint='$negapoint', endtime='$endtime', umpire='$umpire' WHERE tid='$tid' AND uid='$discuz_uid'"); } elseif($specialextra) { @include_once DISCUZ_ROOT.'./plugins/'.$threadplugins[$specialextra]['module'].'.class.php'; $classname = 'threadplugin_'.$specialextra; if(method_exists($classname, 'editpost_submit')) { $threadpluginclass = new $classname; $threadpluginclass->editpost_submit($fid, $tid); } } $optiondata = array(); if($forum['threadsorts']['types'][$sortid] && $checkoption) { $optiondata = threadsort_validator($typeoption); } if($forum['threadsorts']['types'][$sortid] && $optiondata && is_array($optiondata)) { $sql = $separator = ''; foreach($optiondata as $optionid => $value) { if($_DTYPE[$optionid]['type'] == 'image') { $oldvalue = $db->result_first("SELECT value FROM {$tablepre}typeoptionvars WHERE tid='$tid' AND optionid='$optionid'"); if($oldvalue != $value) { if(preg_match("/^\[aid=(\d+)\]$/", $oldvalue, $r)) { $attach = $db->fetch_first("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE aid='$r[1]'"); $db->query("DELETE FROM {$tablepre}attachments WHERE aid='$r[1]'"); dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); } } } if(($_DTYPE[$optionid]['search'] || in_array($_DTYPE[$optionid]['type'], array('radio', 'select', 'number'))) && $value) { $sql .= $separator.$_DTYPE[$optionid]['identifier']."='$value'"; $separator = ' ,'; } $db->query("UPDATE {$tablepre}typeoptionvars SET value='$value', sortid='$sortid' WHERE tid='$tid' AND optionid='$optionid'"); } if($sql) { $db->query("UPDATE {$tablepre}optionvalue$sortid SET $sql WHERE tid='$tid' AND fid='$fid'"); } } $thread['status'] = setstatus(4, $ordertype, $thread['status']); $thread['status'] = setstatus(2, $hiddenreplies, $thread['status']); $db->query("UPDATE {$tablepre}threads SET iconid='$iconid', typeid='$typeid', sortid='$sortid', subject='$subject', readperm='$readperm', price='$price' $authoradd $polladd ".($auditstatuson && $audit == 1 ? ",displayorder='0', moderated='1'" : '').", status='$thread[status]' WHERE tid='$tid'", 'UNBUFFERED'); if($tagstatus) { $tags = str_replace(array(chr(0xa3).chr(0xac), chr(0xa1).chr(0x41), chr(0xef).chr(0xbc).chr(0x8c)), ',', censor($tags)); if(strexists($tags, ',')) { $tagarray = array_unique(explode(',', $tags)); } else { $tags = str_replace(array(chr(0xa1).chr(0xa1), chr(0xa1).chr(0x40), chr(0xe3).chr(0x80).chr(0x80)), ' ', $tags); $tagarray = array_unique(explode(' ', $tags)); } $threadtagsnew = array(); $tagcount = 0; foreach($tagarray as $tagname) { $tagname = trim($tagname); if(preg_match('/^([\x7f-\xff_-]|\w|\s){3,20}$/', $tagname)) { $threadtagsnew[] = $tagname; if(!in_array($tagname, $threadtagary)) { $query = $db->query("SELECT closed FROM {$tablepre}tags WHERE tagname='$tagname'"); if($db->num_rows($query)) { if(!$tagstatus = $db->result($query, 0)) { $db->query("UPDATE {$tablepre}tags SET total=total+1 WHERE tagname='$tagname'", 'UNBUFFERED'); } } else { $db->query("INSERT INTO {$tablepre}tags (tagname, closed, total) VALUES ('$tagname', 0, 1)", 'UNBUFFERED'); $tagstatus = 0; } if(!$tagstatus) { $db->query("INSERT {$tablepre}threadtags (tagname, tid) VALUES ('$tagname', '$tid')", 'UNBUFFERED'); } } } $tagcount++; if($tagcount > 4) { unset($tagarray); break; } } foreach($threadtagary as $tagname) { if(!in_array($tagname, $threadtagsnew)) { if($db->result_first("SELECT count(*) FROM {$tablepre}threadtags WHERE tagname='$tagname' AND tid!='$tid'")) { $db->query("UPDATE {$tablepre}tags SET total=total-1 WHERE tagname='$tagname'", 'UNBUFFERED'); } else { $db->query("DELETE FROM {$tablepre}tags WHERE tagname='$tagname'", 'UNBUFFERED'); } $db->query("DELETE FROM {$tablepre}threadtags WHERE tagname='$tagname' AND tid='$tid'", 'UNBUFFERED'); } } } } else { if($subject == '' && $message == '') { showmessage('post_sm_isnull'); } } if($editedby && ($timestamp - $orig['dateline']) > 60 && $adminid != 1) { include_once language('misc'); $editor = $isanonymous && $isorigauthor ? $language['anonymous'] : $discuz_user; $edittime = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $timestamp + $timeoffset * 3600); eval("\$message = \"$language[post_edit]\".\$message;"); } $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff)); $smileyoff = checksmilies($message, !empty($smileyoff)); $tagoff = $isfirstpost ? !empty($tagoff) : 0; $htmlon = bindec(($tagstatus && $tagoff ? 1 : 0).($allowhtml && !empty($htmlon) ? 1 : 0)); $uattachment = ($allowpostattach && $uattachments = attach_upload('attachupdate', 1)) ? 1 : 0; if($uattachment) { $query = $db->query("SELECT aid, tid, pid, uid, attachment, thumb, remote FROM {$tablepre}attachments WHERE pid='$pid'"); while($attach = $db->fetch_array($query)) { $paid = 'paid'.$attach['aid']; $attachfileadd = ''; if($uattachment && isset($uattachments[$paid])) { dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); $attachfileadd = 'dateline=\''.$timestamp.'\', filename=\''.$uattachments[$paid]['name'].'\', filetype=\''.$uattachments[$paid]['type'].'\', filesize=\''.$uattachments[$paid]['size'].'\', attachment=\''.$uattachments[$paid]['attachment'].'\', thumb=\''.$uattachments[$paid]['thumb'].'\', isimage=\'-'.$uattachments[$paid]['isimage'].'\', remote=\''.$uattachments[$paid]['remote'].'\', width=\''.$uattachments[$paid]['width'].'\''; unset($uattachments[$paid]); } if($attachfileadd) $db->query("UPDATE {$tablepre}attachments SET $attachfileadd WHERE aid='$attach[aid]'"); } } $allowpostattach && ($attachnew || $attachdel || $special == 2 && $tradeaid || $isfirstpost && $sortid) && updateattach(); if($uattachment || $attachdel) { $tattachment = $db->result_first("SELECT count(*) FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='$tid' AND a.isimage IN ('1', '-1') AND a.pid=p.pid AND p.invisible='0' LIMIT 1") ? 2 : ($db->result_first("SELECT count(*) FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='$tid' AND a.pid=p.pid AND p.invisible='0' LIMIT 1") ? 1 : 0); $db->query("UPDATE {$tablepre}threads SET attachment='$tattachment' WHERE tid='$tid'"); } if($special == 2 && $allowposttrade) { $oldtypeid = $db->result_first("SELECT typeid FROM {$tablepre}trades WHERE pid='$pid'"); $oldtypeid = isset($tradetypes[$oldtypeid]) ? $oldtypeid : 0; $tradetypeid = !$tradetypeid ? $oldtypeid : $tradetypeid; $optiondata = array(); threadsort_checkoption($oldtypeid, 1); $optiondata = array(); if($tradetypes && $typeoption && is_array($typeoption) && $checkoption) { $optiondata = threadsort_validator($typeoption); } if($tradetypes && $optiondata && is_array($optiondata)) { foreach($optiondata as $optionid => $value) { if($oldtypeid) { $db->query("UPDATE {$tablepre}tradeoptionvars SET value='$value' WHERE pid='$pid' AND optionid='$optionid'"); } else { $db->query("INSERT INTO {$tablepre}tradeoptionvars (sortid, pid, optionid, value) VALUES ('$tradetypeid', '$pid', '$optionid', '$value')"); } } } if(!$oldtypeid) { $db->query("UPDATE {$tablepre}trades SET typeid='$tradetypeid' WHERE pid='$pid'"); } if($trade = $db->fetch_first("SELECT * FROM {$tablepre}trades WHERE tid='$tid' AND pid='$pid'")) { $seller = dhtmlspecialchars(trim($seller)); $item_name = dhtmlspecialchars(trim($item_name)); $item_price = floatval($item_price); $item_credit = intval($item_credit); $item_locus = dhtmlspecialchars(trim($item_locus)); $item_number = intval($item_number); $item_quality = intval($item_quality); $item_transport = intval($item_transport); $postage_mail = intval($postage_mail); $postage_express = intval(trim($postage_express)); $postage_ems = intval($postage_ems); $item_type = intval($item_type); $item_costprice = floatval($item_costprice); if(!trim($item_name)) { showmessage('trade_please_name'); } elseif($maxtradeprice && $item_price > 0 && ($mintradeprice > $item_price || $maxtradeprice < $item_price)) { showmessage('trade_price_between'); } elseif($maxtradeprice && $item_credit > 0 && ($mintradeprice > $item_credit || $maxtradeprice < $item_credit)) { showmessage('trade_credit_between'); } elseif(!$maxtradeprice && $item_price > 0 && $mintradeprice > $item_price) { showmessage('trade_price_more_than'); } elseif(!$maxtradeprice && $item_credit > 0 && $mintradeprice > $item_credit) { showmessage('trade_credit_more_than'); } elseif($item_price <= 0 && $item_credit <= 0) { showmessage('trade_pricecredit_need'); } elseif($item_number < 1) { showmessage('tread_please_number'); } if($trade['aid'] != $tradeaid) { $attach = $db->fetch_first("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE aid='$trade[aid]'"); $db->query("DELETE FROM {$tablepre}attachments WHERE aid='$trade[aid]'"); dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); } $expiration = $item_expiration ? @strtotime($item_expiration) : 0; $closed = $expiration > 0 && @strtotime($item_expiration) < $timestamp ? 1 : $closed; switch($transport) { case 'seller':$item_transport = 1;break; case 'buyer':$item_transport = 2;break; case 'virtual':$item_transport = 3;break; case 'logistics':$item_transport = 4;break; } if(!$item_price || $item_price <= 0) { $item_price = $postage_mail = $postage_express = $postage_ems = ''; } $db->query("UPDATE {$tablepre}trades SET aid='$tradeaid', account='$seller', subject='$item_name', price='$item_price', amount='$item_number', quality='$item_quality', locus='$item_locus', transport='$item_transport', ordinaryfee='$postage_mail', expressfee='$postage_express', emsfee='$postage_ems', itemtype='$item_type', expiration='$expiration', closed='$closed', costprice='$item_costprice', credit='$item_credit', costcredit='$item_costcredit' WHERE tid='$tid' AND pid='$pid'", 'UNBUFFERED'); if(!empty($infloat)) { $viewpid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND first='1' LIMIT 1"); $redirecturl = "viewthread.php?tid=$tid&viewpid=$viewpid#pid$viewpid"; } else { $redirecturl = "viewthread.php?do=tradeinfo&tid=$tid&pid=$pid"; } } } $feed = array(); if($special == 127) { $message .= chr(0).chr(0).chr(0).$specialextra; } if($auditstatuson && $audit == 1) { updatepostcredits('+', $orig['authorid'], ($isfirstpost ? $postcredits : $replycredits)); updatemodworks('MOD', 1); updatemodlog($tid, 'MOD'); } $displayorder = $pinvisible = 0; if($isfirstpost) { $displayorder = $modnewthreads ? -2 : $thread['displayorder']; $pinvisible = $modnewthreads ? -2 : 0; } else { $pinvisible = $modnewreplies ? -2 : 0; } $message = preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $message); $db->query("UPDATE {$tablepre}posts SET message='$message', usesig='$usesig', htmlon='$htmlon', bbcodeoff='$bbcodeoff', parseurloff='$parseurloff', smileyoff='$smileyoff', subject='$subject' ".($db->result_first("SELECT aid FROM {$tablepre}attachments WHERE pid='$pid' LIMIT 1") ? ", attachment='1'" : '')." $anonymousadd ".($auditstatuson && $audit == 1 ? ",invisible='0'" : ", invisible='$pinvisible'")." WHERE pid='$pid'"); $forum['lastpost'] = explode("\t", $forum['lastpost']); if($orig['dateline'] == $forum['lastpost'][2] && ($orig['author'] == $forum['lastpost'][3] || ($forum['lastpost'][3] == '' && $orig['anonymous']))) { $lastpost = "$tid\t".($isfirstpost ? $subject : addslashes($thread['subject']))."\t$orig[dateline]\t".($isanonymous ? '' : addslashes($orig['author'])); $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$fid'", 'UNBUFFERED'); } if(!$auditstatuson || $audit != 1) { if($isfirstpost && $modnewthreads) { $db->query("UPDATE {$tablepre}threads SET displayorder='-2' WHERE tid='$tid'"); } elseif(!$isfirstpost && $modnewreplies) { $db->query("UPDATE {$tablepre}threads SET replies=replies-'1' WHERE tid='$tid'"); } } if($thread['lastpost'] == $orig['dateline'] && ((!$orig['anonymous'] && $thread['lastposter'] == $orig['author']) || ($orig['anonymous'] && $thread['lastposter'] == '')) && $orig['anonymous'] != $isanonymous) { $db->query("UPDATE {$tablepre}threads SET lastposter='".($isanonymous ? '' : addslashes($orig['author']))."' WHERE tid='$tid'", 'UNBUFFERED'); } $attentionon = empty($attention_add) ? 0 : 1; $attentionoff = empty($attention_remove) ? 0 : 1; if($discuz_uid) { $stataction = ''; if($attentionon) { $stataction = 'attentionon'; $db->query("REPLACE INTO {$tablepre}favoritethreads (tid, uid, dateline) VALUES ('$tid', '$discuz_uid', '$timestamp')", 'UNBUFFERED'); } if($attentionoff) { $stataction = 'attentionoff'; $db->query("DELETE FROM {$tablepre}favoritethreads WHERE tid='$tid' AND uid='$discuz_uid'", 'UNBUFFERED'); } if($stataction) { write_statlog('', 'item=attention&action=editpost_'.$stataction, '', '', 'my.php'); } } if(!$isorigauthor) { updatemodworks('EDT', 1); require_once DISCUZ_ROOT.'./include/misc.func.php'; modlog($thread, 'EDT'); } if($thread['special'] == 3 && $isfirstpost && $thread['price'] > 0) { $pricediff = $rewardprice - $thread['price']; $db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]-$pricediff WHERE uid='$orig[authorid]'", 'UNBUFFERED'); } } else { if($isfirstpost && $thread['replies'] > 0) { showmessage(($thread['special'] == 3 ? 'post_edit_reward_already_reply' : 'post_edit_thread_already_reply'), NULL, 'HALTED'); } if($thread['special'] == 3) { if($thread['price'] < 0 && ($thread['dateline'] + 1 == $orig['dateline'])) { showmessage('post_edit_reward_nopermission', NULL, 'HALTED'); } } if($rushreply) { showmessage('post_edit_delete_rushreply_nopermission', NULL, 'HALTED'); } updatepostcredits('-', $orig['authorid'], ($isfirstpost ? $postcredits : $replycredits)); if($thread['special'] == 3 && $isfirstpost) { $db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]+$thread[price] WHERE uid='$orig[authorid]'", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='$tid'", 'UNBUFFERED'); } $thread_attachment = $post_attachment = 0; $query = $db->query("SELECT pid, attachment, thumb, remote FROM {$tablepre}attachments WHERE tid='$tid'"); while($attach = $db->fetch_array($query)) { if($attach['pid'] == $pid) { $post_attachment ++; dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); } else { $thread_attachment = 1; } } if($post_attachment) { $db->query("DELETE FROM {$tablepre}attachments WHERE pid='$pid'", 'UNBUFFEREED'); $db->query("DELETE FROM {$tablepre}attachmentfields WHERE pid='$pid'", 'UNBUFFERED'); updatecredits($orig['authorid'], $postattachcredits, -($post_attachment)); } $db->query("DELETE FROM {$tablepre}posts WHERE pid='$pid'"); if($thread['special'] == 2) { $db->query("DELETE FROM {$tablepre}trades WHERE pid='$pid'"); } if($isfirstpost) { $forumadd = 'threads=threads-\'1\', posts=posts-\'1\''; $tablearray = array('threadsmod','relatedthreads','threads','debates','debateposts','polloptions','polls','typeoptionvars'); foreach ($tablearray as $table) { $db->query("DELETE FROM {$tablepre}$table WHERE tid='$tid'", 'UNBUFFERED'); } if($globalstick && in_array($thread['displayorder'], array(2, 3))) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('globalstick'); } } else { $savepostposition && $db->query("DELETE FROM {$tablepre}postposition WHERE pid='$pid'"); $forumadd = 'posts=posts-\'1\''; $query = $db->query("SELECT author, dateline, anonymous FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline DESC LIMIT 1"); $lastpost = $db->fetch_array($query); $lastpost['author'] = !$lastpost['anonymous'] ? addslashes($lastpost['author']) : ''; $db->query("UPDATE {$tablepre}threads SET replies=replies-'1', attachment='$thread_attachment', lastposter='$lastpost[author]', lastpost='$lastpost[dateline]' WHERE tid='$tid'", 'UNBUFFERED'); } $forum['lastpost'] = explode("\t", $forum['lastpost']); if($orig['dateline'] == $forum['lastpost'][2] && ($orig['author'] == $forum['lastpost'][3] || ($forum['lastpost'][3] == '' && $orig['anonymous']))) { $lastthread = daddslashes($db->fetch_first("SELECT tid, subject, lastpost, lastposter FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1"), 1); $forumadd .= ", lastpost='$lastthread[tid]\t$lastthread[subject]\t$lastthread[lastpost]\t$lastthread[lastposter]'"; } $db->query("UPDATE {$tablepre}forums SET $forumadd WHERE fid='$fid'", 'UNBUFFERED'); } if($specialextra) { @include_once DISCUZ_ROOT.'./plugins/'.$threadplugins[$specialextra]['module'].'.class.php'; $classname = 'threadplugin_'.$specialextra; if(method_exists($classname, 'editpost_submit_end')) { $threadpluginclass = new $classname; $threadpluginclass->editpost_submit_end($fid, $tid); } } // debug: update thread caches ? if($forum['threadcaches']) { if($isfirstpost || $page == 1 || $thread['replies'] < $_DCACHE['pospperpage'] || !empty($delete)) { $forum['threadcaches'] && deletethreadcaches($tid); } else { if($db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND pid<'$pid'") < $_DCACHE['settings']['postperpage']) { $forum['threadcaches'] && deletethreadcaches($tid); } } } if($auditstatuson) { if($audit == 1) { showmessage('auditstatuson_succeed', $redirecturl); } else { showmessage('audit_edit_succeed'); } } else { if(!empty($delete) && $isfirstpost) { showmessage('post_edit_delete_succeed', "forumdisplay.php?fid=$fid"); } elseif(!empty($delete)) { showmessage('post_edit_delete_succeed', "viewthread.php?tid=$tid&page=$page&extra=$extra".($vid && $isfirstpost ? "&vid=$vid" : '')); } else { if($isfirstpost && $modnewthreads) { showmessage('edit_newthread_mod_succeed', "forumdisplay.php?fid=$fid"); } elseif(!$isfirstpost && $modnewreplies) { showmessage('edit_reply_mod_succeed', "forumdisplay.php?fid=$fid"); } else { showmessage('post_edit_succeed', $redirecturl); } } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/editpost.inc.php
PHP
asf20
38,657
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: request.func.php 21221 2009-11-22 00:23:57Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } function parse_request($requestdata, $cachefile, $mode, $specialfid = 0, $key = '') { global $_DCACHE; @touch($cachefile.'.lock'); $requesttemplate = ''; $nocachedata = array(); $requestcachelife = (isset($requestdata['cachelife']) && $requestdata['cachelife'] !== '') ? $requestdata['cachelife'] : (isset($_DCACHE['settings']['jscachelife']) ? $_DCACHE['settings']['jscachelife'] : 1800); !empty($requestdata['jstemplate']) && $requesttemplate = stripslashes($requestdata['jstemplate']); get_magic_quotes_gpc() && $requesttemplate = stripslashes($requesttemplate); $nocache = !empty($requestdata['nocache']) ? 1 : 0; $mode && $requestcharset = $requestdata['jscharset']; if(!in_array($requestdata['function'], array('custom', 'side'))) { $requesttemplatebody = ''; if(preg_match("/\[node\](.+?)\[\/node\]/is", $requesttemplate, $node)) { $requesttemplatebody = $requesttemplate; $requesttemplate = $node[1]; } $parsedata = updaterequest($requestdata, $requesttemplatebody, $requesttemplate, $specialfid, $mode, $key, $nocache); if($mode) { $datalist = $writedata = jsprocdata($parsedata, $requestcharset); } else { $datalist = $writedata = $parsedata; } } else { $requestcachelife = (isset($requestdata['cachelife']) && $requestdata['cachelife'] != '') ? $requestdata['cachelife'] : (isset($_DCACHE['settings']['jscachelife']) ? $_DCACHE['settings']['jscachelife'] : 1800); $writedata = preg_match_all("/\[module\](.+?)\[\/module\]/s", $requesttemplate, $modulelist); $modulelist = array_unique($modulelist[1]); $datalist = $writedata = $requesttemplate = str_replace('\"', '"', $requesttemplate); foreach($modulelist as $key) { $find = '[module]'.$key.'[/module]'; if(!empty($_DCACHE['request'][$key]['url'])) { parse_str($_DCACHE['request'][$key]['url'], $requestdata); $function = isset($requestdata['function']) ? $requestdata['function'] : NULL; $requesttemplate = $requestdata['jstemplate']; !empty($requesttemplate) && $requesttemplate = stripslashes($requesttemplate); get_magic_quotes_gpc() && $requesttemplate = stripslashes($requesttemplate); $requesttemplatebody = ''; if(preg_match("/\[node\](.+?)\[\/node\]/is", $requesttemplate, $node)) { $requesttemplatebody = $requesttemplate; $requesttemplate = $node[1]; } $modulenocache = 0; $parsedata = updaterequest($requestdata, $requesttemplatebody, $requesttemplate, $specialfid, $mode, $key, $modulenocache); $datalist = str_replace($find, $parsedata, $datalist); if($modulenocache || $requestdata['cachelife'] === '0') { $nocachedata[$key] = '[module]'.$key.'[/module]'; $writedata = str_replace($find, $nocachedata[$key], $writedata); } else { $writedata = str_replace($find, $parsedata, $writedata); } } } if($mode) { $datalist = jsprocdata($datalist, $requestcharset); $writedata = jsprocdata($writedata, $requestcharset); } } $writedata = addcslashes($writedata, "'\\"); if(!$nocache) { $writedata = "\$datalist = '".$writedata."';"; if($nocachedata) { $writedata .= "\n\$nocachedata = ".var_export($nocachedata, 1).';'; } writetorequestcache($cachefile, $requestcachelife, $writedata); } @unlink($cachefile.'.lock'); if($mode) { return $datalist; } else { return eval("return '".addcslashes($datalist, "'\\")."';"); } } function updaterequest($requestdata, $requesttemplatebody, $requesttemplate, $specialfid, $mode, $key, &$nocache) { global $db, $tablepre, $timestamp, $dateformat, $timeformat, $rewritestatus, $uc, $_DCACHE; $function = $requestdata['function']; $fids = isset($requestdata['fids']) ? $requestdata['fids'] : NULL; $startrow = isset($requestdata['startrow']) ? intval($requestdata['startrow']) : 0; $items = isset($requestdata['items']) ? intval($requestdata['items']) : 10; $digest = isset($requestdata['digest']) ? intval($requestdata['digest']) : 0; $stick = isset($requestdata['stick']) ? intval($requestdata['stick']) : 0; $newwindow = isset($requestdata['newwindow']) ? $requestdata['newwindow'] : 1; $LinkTarget = $newwindow == 1 ? " target='_blank'" : ($newwindow == 2 ? " target='main'" : NULL); $sidestatus = !empty($requestdata['sidestatus']) ? 1 : 0; $boardurl = empty($requestdata['boardurl']) ? ($mode ? $GLOBALS['boardurl'] : '') : $requestdata['boardurl'].'/'; if($function == 'threads') { $orderby = isset($requestdata['orderby']) ? (in_array($requestdata['orderby'],array('lastpost','dateline','replies','views','heats','recommends','hourviews','todayviews','weekviews','monthviews')) ? $requestdata['orderby'] : 'lastpost') : 'lastpost'; $hours = isset($requestdata['hours']) ? intval($requestdata['hours']) : 0; $highlight = isset($requestdata['highlight']) ? $requestdata['highlight'] : 0; $picpre = isset($requestdata['picpre']) ? urldecode($requestdata['picpre']) : NULL; $maxlength = !empty($requestdata['maxlength']) ? intval($requestdata['maxlength']) : 50; $fnamelength = isset($requestdata['fnamelength']) ? intval($requestdata['fnamelength']) : 0; $recommend = !empty($requestdata['recommend']) ? 1 : 0; $tids = isset($requestdata['tids']) ? $requestdata['tids'] : NULL; $keyword = !empty($requestdata['keyword']) ? $requestdata['keyword'] : NULL; $typeids = isset($requestdata['typeids']) ? $requestdata['typeids'] : NULL; $sortids = isset($requestdata['sortids']) ? $requestdata['sortids'] : NULL; $special = isset($requestdata['special']) ? intval($requestdata['special']) : 0; $rewardstatus = isset($requestdata['rewardstatus']) ? intval($requestdata['rewardstatus']) : 0; $threadtype = isset($requestdata['threadtype']) ? intval($requestdata['threadtype']) : 0; $threadsort = isset($requestdata['threadsort']) ? intval($requestdata['threadsort']) : 0; $tag = !empty($requestdata['tag']) ? trim($requestdata['tag']) : NULL; $messagelength = !empty($requestdata['messagelength']) ? intval($requestdata['messagelength']) : 255; include DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; require_once DISCUZ_ROOT.'./include/post.func.php'; $datalist = array(); $threadtypeids = array(); if($keyword) { if(preg_match("(AND|\+|&|\s)", $keyword) && !preg_match("(OR|\|)", $keyword)) { $andor = ' AND '; $keywordsrch = '1'; $keyword = preg_replace("/( AND |&| )/is", "+", $keyword); } else { $andor = ' OR '; $keywordsrch = '0'; $keyword = preg_replace("/( OR |\|)/is", "+", $keyword); } $keyword = str_replace('*', '%', addcslashes($keyword, '%_')); foreach(explode('+', $keyword) as $text) { $text = trim($text); if($text) { $keywordsrch .= $andor; $keywordsrch .= "t.subject LIKE '%$text%'"; } } $keyword = " AND ($keywordsrch)"; } else { $keyword = ''; } $sql = ($specialfid && $sidestatus ? ' AND t.fid = '.$specialfid : ($fids ? ' AND t.fid IN (\''.str_replace('_', '\',\'', $fids).'\')' : '')) .$keyword .($tids ? ' AND t.tid IN (\''.str_replace('_', '\',\'', $tids).'\')' : '') .($typeids ? ' AND t.typeid IN (\''.str_replace('_', '\',\'', $typeids).'\')' : '') .($sortids ? ' AND t.sortid IN (\''.str_replace('_', '\',\'', $sortids).'\')' : '') .(($special >= 0 && $special < 127) ? threadrange($special, 't.special', 7) : '') .((($special & 16) && $rewardstatus) ? ($rewardstatus == 1 ? ' AND t.price < 0' : ' AND t.price > 0') : '') .(($digest > 0 && $digest < 15) ? threadrange($digest, 't.digest') : '') .(($stick > 0 && $stick < 15) ? threadrange($stick, 't.displayorder') : ''); if(in_array($orderby, array('hourviews','todayviews','weekviews','monthviews'))) { $historytime = 0; switch($orderby) { case 'hourviews': $historytime = $timestamp - 3600 * $hours; break; case 'todayviews': $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp)); break; case 'weekviews': $week = gmdate('w', $timestamp) - 1; $week = $week != -1 ? $week : 6; $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp) - $week, date('Y', $timestamp)); break; case 'monthviews': $historytime = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp)); break; } $sql .= ' AND t.dateline>='.$historytime; $orderby = 'views'; } elseif($orderby == 'heats') { $heatdateline = $timestamp - 86400 * $GLOBALS['indexhot']['days']; $sql .= " AND t.dateline>'$heatdateline' AND t.heats>'0'"; } $sqlfrom = strexists($requesttemplate, '{message}') ? ",p.message FROM `{$tablepre}threads` t LEFT JOIN `{$tablepre}posts` p ON p.tid=t.tid AND p.first='1'" : "FROM `{$tablepre}threads` t"; if(strexists($requesttemplate, '{imgattach}')) { $sqlfrom = ",a.remote,a.attachment,a.thumb $sqlfrom INNER JOIN `{$tablepre}attachments` a ON a.tid=t.tid"; $sql .= " AND a.isimage IN ('1', '-1') AND a.readperm='0' AND a.price='0'"; $attachadd .= "GROUP BY a.tid"; $attachurl = $_DCACHE['settings']['attachurl']; $attachurl = preg_match("/^((https?|ftps?):\/\/|www\.)/i", $attachurl) ? $attachurl : $boardurl.$attachurl; } if($recommend) { $sqlfrom .= " INNER JOIN `{$tablepre}forumrecommend` fc ON fc.tid=t.tid"; } if($tag) { $tags = explode(' ', $tag); foreach($tags as $tagk => $tagv) { if(!preg_match('/^([\x7f-\xff_-]|\w){3,20}$/', $tagv)) { unset($tags[$tagk]); } } if($tags = implode("','", $tags)) { $sqlfrom .= " INNER JOIN `{$tablepre}threadtags` tag ON tag.tid=t.tid AND tag.tagname IN ('$tags')"; } } $query = $db->query("SELECT t.tid,t.fid,t.readperm,t.author,t.authorid,t.subject,t.dateline,t.lastpost,t.lastposter,t.views,t.replies,t.highlight,t.digest,t.typeid,t.sortid $sqlfrom WHERE t.readperm='0' $sql AND t.displayorder>='0' AND t.fid>'0' $attachadd ORDER BY t.$orderby DESC LIMIT $startrow,$items;" ); while($data = $db->fetch_array($query)) { $datalist[$data['tid']]['fid'] = $data['fid']; $datalist[$data['tid']]['fname'] = isset($_DCACHE['forums'][$data['fid']]['name']) ? str_replace('\\\'', '&#39;', addslashes($_DCACHE['forums'][$data['fid']]['name'])) : NULL; $datalist[$data['tid']]['fnamelength'] = strlen($datalist[$data['tid']]['fname']); $datalist[$data['tid']]['subject'] = isset($data['subject']) ? str_replace('\\\'', '&#39;', addslashes($data['subject'])) : NULL; $datalist[$data['tid']]['dateline'] = gmdate("$dateformat $timeformat",$data['dateline'] + $_DCACHE['settings']['timeoffset'] * 3600); $datalist[$data['tid']]['lastpost'] = gmdate("$dateformat $timeformat",$data['lastpost'] + $_DCACHE['settings']['timeoffset'] * 3600); $datalist[$data['tid']]['lastposter'] = $data['lastposter']; $datalist[$data['tid']]['authorid'] = $data['authorid']; $datalist[$data['tid']]['views'] = $data['views']; $datalist[$data['tid']]['replies'] = $data['replies']; $datalist[$data['tid']]['highlight'] = $data['highlight']; $datalist[$data['tid']]['message'] = messagecutstr($data['message'], $messagelength); $datalist[$data['tid']]['imgattach'] = ($data['remote'] ? $_DCACHE['settings']['ftp']['attachurl'] : $attachurl)."/$data[attachment]".($_DCACHE['settings']['thumbstatus'] && $data['thumb'] ? '.thumb.jpg' : ''); if($data['author']) { $datalist[$data['tid']]['author'] = $data['author']; } else { $datalist[$data['tid']]['author'] = 'Anonymous'; $datalist[$data['tid']]['authorid'] = 0; } if($data['lastposter']) { $datalist[$data['tid']]['lastposter'] = $data['lastposter']; } else { $datalist[$data['tid']]['lastposter'] = ''; } $datalist[$data['tid']]['typeid'] = $data['typeid']; $datalist[$data['tid']]['sortid'] = $data['sortid']; $datalist[$data['tid']]['subjectprefix'] = ''; $threadtypeids[] = $data['typeid']; $threadtypeids[] = $data['sortid']; } if(($threadsort || $threadtype) && $threadtypeids) { $typelist = array(); $query = $db->query("SELECT typeid, name FROM {$tablepre}threadtypes WHERE typeid IN ('".implode('\',\'', $threadtypeids)."')"); while($typearray = $db->fetch_array($query)) { $typelist[$typearray['typeid']] = $typearray['name']; } foreach($datalist AS $tid=>$value) { $subjectprefix = ''; if($threadsort && $value['sortid'] && isset($typelist[$value['sortid']])) { $subjectprefix .= '['.$typelist[$value['sortid']].']'; } if($threadtype && $value['typeid'] && isset($typelist[$value['typeid']])) { $subjectprefix .= '['.$typelist[$value['typeid']].']'; } $datalist[$tid]['subjectprefix'] = $subjectprefix; } } $writedata = ''; if(is_array($datalist)) { $colorarray = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282'); $prefix = $picpre ? "<img src='$picpre' border='0' align='absmiddle'>" : NULL; $requesttemplate = !$requesttemplate ? '{prefix} {subject}<br />' : $requesttemplate; $order = 1; foreach($datalist AS $tid=>$value) { $SubjectStyles = ''; if($highlight && $value['highlight']) { $string = sprintf('%02d', $value['highlight']); $stylestr = sprintf('%03b', $string[0]); $SubjectStyles .= " style='"; $SubjectStyles .= $stylestr[0] ? 'font-weight: bold;' : NULL; $SubjectStyles .= $stylestr[1] ? 'font-style: italic;' : NULL; $SubjectStyles .= $stylestr[2] ? 'text-decoration: underline;' : NULL; $SubjectStyles .= $string[1] ? 'color: '.$colorarray[$string[1]] : NULL; $SubjectStyles .= "'"; } $replace['{fid}'] = $value['fid']; $replace['{tid}'] = $tid; $replace['{link}'] = $boardurl."viewthread.php?tid=$tid"; $value['prefixlength'] = $value['subjectprefix'] ? strlen(strip_tags($value['subjectprefix'])) : 0; $value['maxlength'] = $maxlength - $value['prefixlength']; $replace['{subject_nolink}'] = $value['subjectprefix'].cutstr($value['subject'],($fnamelength ? ($value['maxlength'] - $value['fnamelength']) : $value['maxlength']), ''); $replace['{subject_full}'] = $value['subjectprefix'].$value['subject']; $replace['{prefix}'] = $prefix; $replace['{forum}'] = "<a href='".$boardurl."forumdisplay.php?fid=$value[fid]'$LinkTarget>$value[fname]</a>"; $replace['{dateline}'] = $value['dateline']; $replace['{subject}'] = "<a href='".$boardurl."viewthread.php?tid=$tid' title='$value[subject]'$SubjectStyles$LinkTarget>".$replace['{subject_nolink}']."</a>"; $replace['{message}'] = $value['message']; if($value['authorid']) { $replace['{author}'] = "<a href='".$boardurl."space.php?uid=$value[authorid]'$LinkTarget>$value[author]</a>"; } else { $replace['{author}'] = $value['author']; } $replace['{author_nolink}'] = $value['author']; if($value['lastposter'] !== '') { $replace['{lastposter}'] = "<a href='".$boardurl."space.php?username=".rawurlencode($value['lastposter'])."'$LinkTarget>$value[lastposter]</a>"; $replace['{lastposter_nolink}'] = $value['lastposter']; } else { $replace['{lastposter}'] = $replace['{lastposter_nolink}'] = 'Anonymous'; } $replace['{lastpost}'] = $value['lastpost']; $replace['{views}'] = $value['views']; $replace['{replies}'] = $value['replies']; $replace['{imgattach}'] = $value['imgattach']; $replace['{order}'] = $order++; $writedata .= nodereplace($replace, $requesttemplate); } } } elseif($function == 'forums') { $fups = isset($requestdata['fups']) ? $requestdata['fups'] : NULL; $orderby = isset($requestdata['orderby']) ? (in_array($requestdata['orderby'],array('displayorder','threads','posts')) ? $requestdata['orderby'] : 'displayorder') : 'displayorder'; $datalist = array(); $query = $db->query("SELECT `fid`,`fup`,`name`,`status`,`threads`,`posts`,`todayposts`,`displayorder`,`type` FROM `{$tablepre}forums` WHERE `type`!='group' ".($fups ? "AND `fup` IN ('".str_replace('_', '\',\'', $fups)."') " : "")." AND `status`='1' ORDER BY ".($orderby == 'displayorder' ? " `displayorder` ASC " : " `$orderby` DESC")." LIMIT $startrow,".($items > 0 ? $items : 65535).";" ); while($data = $db->fetch_array($query)) { $datalist[$data['fid']]['name'] = str_replace('\\\'', '&#39;', addslashes($data['name'])); $datalist[$data['fid']]['threads'] = $data['threads']; $datalist[$data['fid']]['posts'] = $data['posts']; $datalist[$data['fid']]['todayposts'] = $data['todayposts']; } $writedata = ''; if(is_array($datalist)) { $requesttemplate = !$requesttemplate ? '{forumname}<br />' : $requesttemplate; $order = 1; foreach($datalist AS $fid=>$value) { $replace['{fid}'] = $fid; $replace['{link}'] = $boardurl."forumdisplay.php?fid=$fid"; $replace['{forumname_nolink}'] = $value['name']; $replace['{forumname}'] = "<a href='".$boardurl."forumdisplay.php?fid=$fid'$LinkTarget>$value[name]</a>"; $replace['{threads}'] = $value['threads']; $replace['{posts}'] = $value['posts']; $replace['{todayposts}'] = $value['todayposts']; $replace['{order}'] = $order++; $writedata .= nodereplace($replace, $requesttemplate); } } } elseif($function == 'memberrank') { $orderby = isset($requestdata['orderby']) ? (in_array($requestdata['orderby'],array('credits','extcredits','posts','digestposts','regdate','hourposts','todayposts','weekposts','monthposts')) ? $requestdata['orderby'] : 'credits') : 'credits'; $hours = isset($requestdata['hours']) ? intval($requestdata['hours']) : 0; $datalist = array(); switch($orderby) { case 'credits': $sql = "SELECT m.`username`,m.`uid`,m.`credits` FROM `{$tablepre}members` m ORDER BY m.`credits` DESC"; break; case 'extcredits': $requestdata['extcredit'] = intval($requestdata['extcredit']); $sql = "SELECT m.`username`,m.`uid`,m.`extcredits$requestdata[extcredit]` FROM `{$tablepre}members` m ORDER BY m.`extcredits$requestdata[extcredit]` DESC"; break; case 'posts': $sql = "SELECT m.`username`,m.`uid`,m.`posts` FROM `{$tablepre}members` m ORDER BY m.`posts` DESC"; break; case 'digestposts': $sql = "SELECT m.`username`,m.`uid`,m.`digestposts` FROM `{$tablepre}members` m ORDER BY m.`digestposts` DESC"; break; case 'regdate': $sql = "SELECT m.`username`,m.`uid`,m.`regdate` FROM `{$tablepre}members` m ORDER BY m.`regdate` DESC"; break; case 'hourposts'; $historytime = $timestamp - 3600 * intval($hours); $sql = "SELECT DISTINCT(p.author) AS username,p.authorid AS uid,COUNT(p.pid) AS postnum FROM `{$tablepre}posts` p WHERE p.`dateline`>=$historytime AND p.`authorid`!='0' GROUP BY p.`author` ORDER BY `postnum` DESC"; break; case 'todayposts': $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp)); $sql = "SELECT DISTINCT(p.author) AS username,p.authorid AS uid,COUNT(p.pid) AS postnum FROM `{$tablepre}posts` p WHERE p.`dateline`>=$historytime AND p.`authorid`!='0' GROUP BY p.`author` ORDER BY `postnum` DESC"; break; case 'weekposts': $week = gmdate('w', $timestamp) - 1; $week = $week != -1 ? $week : 6; $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp) - $week, date('Y', $timestamp)); $sql = "SELECT DISTINCT(p.author) AS username,p.authorid AS uid,COUNT(p.pid) AS postnum FROM `{$tablepre}posts` p LEFT JOIN `{$tablepre}memberfields` mf ON mf.`uid` = p.`authorid` WHERE p.`dateline`>=$historytime AND p.`authorid`!='0' GROUP BY p.`author` ORDER BY `postnum` DESC"; break; case 'monthposts': $historytime = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp)); $sql = "SELECT DISTINCT(p.author) AS username,p.authorid AS uid,COUNT(p.pid) AS postnum FROM `{$tablepre}posts` p LEFT JOIN `{$tablepre}memberfields` mf ON mf.`uid` = p.`authorid` WHERE p.`dateline`>=$historytime AND p.`authorid`!='0' GROUP BY p.`author` ORDER BY `postnum` DESC"; break; } $query = $db->query($sql." LIMIT $startrow,$items;"); while($data = $db->fetch_array($query,MYSQL_NUM)) { $data[2] = $orderby == 'regdate' ? gmdate($dateformat,$data[2] + $_DCACHE['settings']['timeoffset'] * 3600) : $data[2]; $datalist[] = $data; } $writedata = ''; if(is_array($datalist)) { $requesttemplate = !$requesttemplate ? '{regdate} {member} {value}<br />' : $requesttemplate; $order = 1; foreach($datalist AS $value) { $replace['{regdate}'] = $replace['{value}'] = ''; if($orderby == 'regdate') { $replace['{regdate}'] = $value[2]; } else { $replace['{value}'] = $value[2]; } $replace['{uid}'] = $value[1]; $replace['{member}'] = "<a href='".$boardurl."space.php?uid=$value[1]'$LinkTarget>$value[0]</a>"; $replace['{avatar}'] = "<a title='".htmlspecialchars($value[0])."' href='".$boardurl."space.php?uid=$value[1]'$LinkTarget>".discuz_uc_avatar($value[1])."</a>"; $replace['{avatarsmall}'] = "<a title='".htmlspecialchars($value[0])."' href='".$boardurl."space.php?uid=$value[1]'$LinkTarget>".discuz_uc_avatar($value[1], 'small')."</a>"; $replace['{avatarbig}'] = "<a title='".htmlspecialchars($value[0])."' href='".$boardurl."space.php?uid=$value[1]'$LinkTarget>".discuz_uc_avatar($value[1], 'big')."</a>"; $replace['{order}'] = $order++; $writedata .= nodereplace($replace, $requesttemplate); } } } elseif($function == 'stats') { $info = isset($requestdata['info']) ? $requestdata['info'] : NULL; if(is_array($info)) { $language = $info; $info_index = ''; $statsinfo = array(); $statsinfo['forums'] = $statsinfo['threads'] = $statsinfo['posts'] = 0; $query = $db->query("SELECT `status`,`threads`,`posts` FROM `{$tablepre}forums` WHERE `status`='1'; "); while($forumlist = $db->fetch_array($query)) { $statsinfo['forums']++; $statsinfo['threads'] += $forumlist['threads']; $statsinfo['posts'] += $forumlist['posts']; } unset($info['forums'],$info['threads'],$info['posts']); foreach($info AS $index=>$value) { if($index == 'members') { $sql = "SELECT COUNT(*) FROM `{$tablepre}members`;"; } elseif($index == 'online') { $sql = "SELECT COUNT(*) FROM `{$tablepre}sessions`;"; } elseif($index == 'onlinemembers') { $sql = "SELECT COUNT(*) FROM `{$tablepre}sessions` WHERE `uid`>'0';"; } if($index == 'members' || $index == 'online' || $index == 'onlinemembers') { $statsinfo[$index] = $db->result_first($sql); } } unset($index, $value); $writedata = ''; $requesttemplate = !$requesttemplate ? '{name} {value}<br />' : $requesttemplate; foreach($language AS $index=>$value) { $replace['{name}'] = $value; $replace['{value}'] = $statsinfo[$index]; $writedata .= str_replace(array_keys($replace), $replace, $requesttemplate); } } } elseif($function == 'images') { $maxwidth = isset($requestdata['maxwidth']) ? $requestdata['maxwidth'] : 0; $maxheight = isset($requestdata['maxheight']) ? $requestdata['maxheight'] : 0; require DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; $datalist = array(); $sql = ($specialfid && $sidestatus ? ' AND t.fid = '.$specialfid : ($fids ? ' AND t.fid IN (\''.str_replace('_', '\',\'', $fids).'\')' : '')) .(($digest > 0 && $digest < 15) ? threadrange($digest, 't.digest') : ''); $imagesql = empty($requestdata['isimage']) ? '' : ($requestdata['isimage'] == 1 ? "AND `attach`.`isimage` IN ('1', '-1')" : ($requestdata['isimage'] == 2 ? "AND `attach`.`isimage`='0'" : '')); $methodsql = !empty($requestdata['threadmethod']) ? 'GROUP BY `attach`.`tid`' : ''; $hours = isset($requestdata['hours']) ? intval($requestdata['hours']) : 0; $orderby = isset($requestdata['orderby']) ? (in_array($requestdata['orderby'],array('dateline','downloads','hourdownloads','todaydownloads','weekdownloads','monthdownloads')) ? $requestdata['orderby'] : 'dateline') : 'dateline'; $orderbysql = $historytime = ''; switch($orderby) { case 'dateline': $orderbysql = "ORDER BY `attach`.`dateline` DESC"; break; case 'downloads': $orderbysql = "ORDER BY `attach`.`downloads` DESC"; break; case 'hourdownloads'; $historytime = $timestamp - 3600 * intval($hours); $orderbysql = "ORDER BY `attach`.`downloads` DESC"; break; case 'todaydownloads': $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp)); $orderbysql = "ORDER BY `attach`.`downloads` DESC"; break; case 'weekdownloads': $week = gmdate('w', $timestamp) - 1; $week = $week != -1 ? $week : 6; $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp) - $week, date('Y', $timestamp)); $orderbysql = "ORDER BY `attach`.`downloads` DESC"; break; case 'monthdownloads': $historytime = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp)); $orderbysql = "ORDER BY `attach`.`downloads` DESC"; break; } $historytime = !$historytime ? $timestamp - 2592000 : $historytime; $htsql = "`attach`.`dateline`>=$historytime"; $query = $db->query("SELECT attach.*,af.description,t.tid,t.fid,t.digest,t.author,t.subject,t.displayorder FROM `{$tablepre}attachments` attach LEFT JOIN `{$tablepre}attachmentfields` af ON attach.aid=af.aid INNER JOIN `{$tablepre}threads` t ON `t`.`tid`=`attach`.`tid` AND `displayorder`>='0' WHERE $htsql AND `attach`.`readperm`='0' AND `attach`.`price`='0' $imagesql $sql $methodsql $orderbysql LIMIT $startrow,$items;" ); $attachurl = $_DCACHE['settings']['attachurl']; $attachurl = preg_match("/^((https?|ftps?):\/\/|www\.)/i", $attachurl) ? $attachurl : $boardurl.$attachurl; $i = 0; while($data = $db->fetch_array($query)) { $key = $requestdata['threadmethod'] ? $data['tid'] : $i++; $datalist[$key]['aid'] = $data['aid']; $datalist[$key]['threadlink'] = $boardurl."redirect.php?goto=findpost&ptid=$data[tid]&pid=$data[pid]"; $datalist[$key]['imgfile'] = ($data['remote'] ? $_DCACHE['settings']['ftp']['attachurl'] : $attachurl)."/$data[attachment]".($_DCACHE['settings']['thumbstatus'] && $data['thumb'] ? '.thumb.jpg' : ''); $datalist[$key]['file'] = $boardurl.'attachment.php?aid='.aidencode($data['aid']); $datalist[$key]['subject'] = str_replace('\\\'', '&#39;', $data['subject']); $datalist[$key]['filename'] = str_replace('\\\'', '&#39;', $data['filename']); $datalist[$key]['author'] = addslashes($data['author']); $datalist[$key]['downloads'] = $data['downloads']; $datalist[$key]['author'] = $data['author']; $datalist[$key]['filesize'] = number_format($data['filesize']); $datalist[$key]['dateline'] = gmdate("$dateformat $timeformat",$data['dateline'] + $_DCACHE['settings']['timeoffset'] * 3600); $datalist[$key]['fname'] = isset($_DCACHE['forums'][$data['fid']]['name']) ? str_replace('\\\'', '&#39;', addslashes($_DCACHE['forums'][$data['fid']]['name'])) : NULL; $datalist[$key]['description'] = $data['description'] ? str_replace('\\\'', '&#39;', addslashes($data['description'])) : NULL; } $writedata = ''; if(is_array($datalist)) { $imgsize = ($maxwidth ? " width='$maxwidth'" : NULL).($maxheight ? " height='$maxheight'" : NULL); $requesttemplate = !$requesttemplate ? '{file} ({filesize} Bytes)<br />' : $requesttemplate; $order = 1; foreach($datalist AS $value) { $replace['{aid}'] = $value['aid']; $replace['{link}'] = $value['threadlink']; $replace['{imgfile}'] = $value['imgfile']; $replace['{url}'] = $value['file']; $replace['{subject}'] = $value['subject']; $replace['{filesubject}'] = $value['filename']; $replace['{filedesc}'] = $value['description']; $replace['{author}'] = $value['author']; $replace['{dateline}'] = $value['dateline']; $replace['{downloads}'] = $value['downloads']; $replace['{filesize}'] = $value['filesize']; $replace['{file}'] = "<a href='$value[file]'$LinkTarget>$value[filename]</a>"; $replace['{image}'] = "<a href='$value[threadlink]'$LinkTarget><img$imgsize src='$value[imgfile]' border='0'></a>"; $replace['{order}'] = $order++; $writedata .= nodereplace($replace, $requesttemplate); } } } elseif($function == 'module') { $requestrun = TRUE; $settings = unserialize(get_magic_quotes_gpc() ? stripslashes($requestdata['settings']) : $requestdata['settings']); if(@!include(DISCUZ_ROOT.'./include/request/'.$requestdata['module'])) { return; } } else { return; } $data = parsenode($writedata, $requesttemplatebody); if($rewritestatus) { $searcharray = $replacearray = array(); if($GLOBALS['rewritestatus'] & 1) { $searcharray[] = "/\<a href\=\'".preg_quote($boardurl, '/')."forumdisplay\.php\?fid\=(\d+)\'/"; $replacearray[] = "<a href='{$boardurl}forum-\\1-1.html'"; } if($GLOBALS['rewritestatus'] & 2) { $searcharray[] = "/\<a href\=\'".preg_quote($boardurl, '/')."viewthread\.php\?tid\=(\d+)\'/"; $replacearray[] = "<a href='{$boardurl}thread-\\1-1-1.html'"; } if($GLOBALS['rewritestatus'] & 4) { $searcharray[] = "/\<a href\=\'".preg_quote($boardurl, '/')."space\.php\?uid\=(\d+)\'/"; $searcharray[] = "/\<a href\=\'".preg_quote($boardurl, '/')."space\.php\?username\=([^&]+?)\'/"; $replacearray[] = "<a href='{$boardurl}space-uid-\\1.html'"; $replacearray[] = "<a href='{$boardurl}space-username-\\1.html'"; } $data = preg_replace($searcharray, $replacearray, $data); } return $data; } function nodereplace($replace, $requesttemplate) { $return = $requesttemplate; if(preg_match("/\[show=(\d+)\].+?\[\/show\]/is", $requesttemplate, $show)) { if($show[1] == $replace['{order}']) { $return = preg_replace("/\[show=\d+\](.+?)\[\/show\]/is", '\\1', $return); } else { $return = preg_replace("/\[show=\d+\].+?\[\/show\]/is", '', $return); } } return str_replace(array_keys($replace), $replace, $return); } function parsenode($data, $requesttemplatebody) { if($requesttemplatebody) { $data = preg_replace("/\[node\](.+?)\[\/node\]/is", $data, $requesttemplatebody, 1); $data = preg_replace("/\[node\](.+?)\[\/node\]/is", '', $data); } return $data; } function threadrange($range, $field, $params = 4) { $range = intval($range); $range = sprintf("%0".$params."d", decbin($range)); $range = "$range"; $range_filed = ''; for($i = 0; $i < $params - 1; $i ++) { $range_filed .= $range[$i] == 1 ? ($i + 1) : ''; } $range_filed .= $range[$params - 1] == 1 ? 0 : ''; $return = str_replace('_', '\',\'', substr(chunk_split($range_filed,1,"_"),0,-1)); return $return != '' ? ' AND '.$field.' IN (\''.$return.'\')' : ''; } function writetorequestcache($cachfile, $requestcachelife, $data='') { global $timestamp, $_DCACHE; if(!$fp = @fopen($cachfile, 'wb')) { return; } $fp = @fopen($cachfile, 'wb'); $cachedata = "if(!defined('IN_DISCUZ')) exit('Access Denied');\n\$expiration = '".($timestamp + $requestcachelife)."';\n".$data."\n"; @fwrite($fp, "<?php\n//Discuz! cache file, DO NOT modify me!". "\n//Created: ".date("M j, Y, G:i"). "\n//Identify: ".md5(basename($cachfile).$cachedata.$_DCACHE['settings']['authkey'])."\n\n$cachedata?>"); @fclose($fp); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request.func.php
PHP
asf20
31,948
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: gifmerge.class.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } class GifMerge { var $ver = '1.1'; var $dly = 50; var $mod = 'C_FILE'; var $first = true; var $use_loop = false; var $transparent = false; var $use_global_in = false; var $x = 0; var $y = 0; var $ch = 0; var $fin = 0; var $fout = ''; var $loop = 0; var $delay = 0; var $width = 0; var $height = 0; var $trans1 = 255; var $trans2 = 255; var $trans3 = 255; var $disposal = 2; var $out_color_table_size = 0; var $local_color_table_flag = 0; var $global_color_table_size = 0; var $out_color_table_sizecode = 0; var $global_color_table_sizecode= 0; var $gif = array(0x47, 0x49, 0x46); var $buffer = array(); var $local_in = array(); var $global_in = array(); var $global_out = array(); var $logical_screen_descriptor = array(); function GifMerge($images, $t1, $t2, $t3, $loop, $dl, $xpos, $ypos, $model) { if($model) { $this->mod = $model; } if($loop > -1) { $this->loop = floor($loop - 1); $this->use_loop = true; } if($t1 > -1 && $t2 > -1 && $t3 > -1) { $this->trans1 = $t1; $this->trans2 = $t2; $this->trans3 = $t3; $this->transparent = true; } for($i = 0; $i < count($images); $i++) { $dl[$i] ? $this->delay = $dl[$i] : $this->delay = $this->dly; $xpos[$i] ? $this->x = $xpos[$i] : $this->x = 0; $ypos[$i] ? $this->y = $ypos[$i] : $this->y = 0; $this->start_gifmerge_process($images[$i]); } $this->fout .= "\x3b"; } function start_gifmerge_process($fp) { if($this->mod == 'C_FILE') { if(!$this->fin = fopen($fp, 'rb')) { return; } } elseif($this->mod == 'C_MEMORY') { $this->ch = 0; $this->fin = $fp; } $this->getbytes(6); if(!$this->arrcmp($this->buffer, $this->gif, 3)) { return; } $this->getbytes(7); if($this->first) $this->logical_screen_descriptor = $this->buffer; $this->global_color_table_sizecode = $this->buffer[4] & 0x07; $this->global_color_table_size = 2 << $this->global_color_table_sizecode; if($this->buffer[4] & 0x80) { $this->getbytes((3 * $this->global_color_table_size)); for($i = 0; $i < ((3 * $this->global_color_table_size)); $i++) { $this->global_in[$i] = $this->buffer[$i]; } if($this->out_color_table_size == 0) { $this->out_color_table_size = $this->global_color_table_size; $out_color_table_sizecode = $this->global_color_table_sizecode; $this->global_out = $this->global_in; } if($this->global_color_table_size != $this->out_color_table_size || $this->arrcmp($this->global_out, $this->global_in, (3 * $this->global_color_table_size))) { $this->use_global_in = true; } } for($loop = true; $loop;) { $this->getbytes(1); switch($this->buffer[0]) { case 0x21: $this->read_extension(); break; case 0x2c: $this->read_image_descriptor(); break; case 0x3b: $loop = false; break; default: $loop = false; } } if($this->mod == 'C_FILE') { fclose($this->fin); } } function read_image_descriptor() { $this->getbytes(9); $head = $this->buffer; $this->local_color_table_flag = ($this->buffer[8] & 0x80) ? true : false; if($this->local_color_table_flag) { $sizecode = $this->buffer[8] & 0x07; $size = 2 << $sizecode; $this->getbytes(3 * $size); for($i = 0; $i < (3 * $size); $i++) { $this->local_in[$i] = $this->buffer[$i]; } if($this->out_color_table_size == 0) { $this->out_color_table_size = $size; $out_color_table_sizecode = $sizecode; for($i = 0; $i < (3 * $size); $i++) { $this->global_out[$i] = $this->local_in[$i]; } } } if($this->first) { $this->first = false; $this->fout .= "\x47\x49\x46\x38\x39\x61"; if($this->width && $this->height) { $this->logical_screen_descriptor[0] = $this->width & 0xFF; $this->logical_screen_descriptor[1] = ($this->width & 0xFF00) >> 8; $this->logical_screen_descriptor[2] = $this->height & 0xFF; $this->logical_screen_descriptor[3] = ($this->height & 0xFF00) >> 8; } $this->logical_screen_descriptor[4] |= 0x80; $this->logical_screen_descriptor[5] &= 0xF0; $this->logical_screen_descriptor[6] |= $this->out_color_table_sizecode; $this->putbytes($this->logical_screen_descriptor, 7); $this->putbytes($this->global_out, ($this->out_color_table_size * 3)); if($this->use_loop) { $ns[0] = 0x21; $ns[1] = 0xFF; $ns[2] = 0x0B; $ns[3] = 0x4e; $ns[4] = 0x45; $ns[5] = 0x54; $ns[6] = 0x53; $ns[7] = 0x43; $ns[8] = 0x41; $ns[9] = 0x50; $ns[10] = 0x45; $ns[11] = 0x32; $ns[12] = 0x2e; $ns[13] = 0x30; $ns[14] = 0x03; $ns[15] = 0x01; $ns[16] = $this->loop & 255; $ns[17] = $this->loop >> 8; $ns[18] = 0x00; $this->putbytes($ns, 19); } } if($this->use_global_in) { $outtable = $this->global_in; $outsize = $this->global_color_table_size; $outsizecode = $this->global_color_table_sizecode; } else { $outtable = $this->global_out; $outsize = $this->out_color_table_size; } if($this->local_color_table_flag) { if($size == $this->out_color_table_size && !$this->arrcmp($this->local_in, $this->global_out, $size)) { $outtable = $global_out; $outsize = $this->out_color_table_size; } else { $outtable = $this->local_in; $outsize = $size; $outsizecode = $sizecode; } } $use_trans = false; if($this->transparent) { for($i = 0; $i < $outsize; $i++) { if($outtable[3 * $i] == $this->trans1 && $outtable [3 * $i + 1] == $this->trans2 && $outtable [3 * $i + 2] == $this->trans3) { break; } } if($i < $outsize) { $transindex = $i; $use_trans = true; } } if($this->delay || $use_trans) { $this->buffer[0] = 0x21; $this->buffer[1] = 0xf9; $this->buffer[2] = 0x04; $this->buffer[3] = ($this->disposal << 2) + ($use_trans ? 1 : 0); $this->buffer[4] = $this->delay & 0xff; $this->buffer[5] = ($this->delay & 0xff00) >> 8; $this->buffer[6] = $use_trans ? $transindex : 0; $this->buffer[7] = 0x00; $this->putbytes($this->buffer,8); } $this->buffer[0] = 0x2c; $this->putbytes($this->buffer,1); $head[0] = $this->x & 0xff; $head[1] = ($this->x & 0xff00) >> 8; $head[2] = $this->y & 0xff; $head[3] = ($this->y & 0xff00) >> 8; $head[8] &= 0x40; if($outtable != $this->global_out) { $head[8] |= 0x80; $head[8] |= $outsizecode; } $this->putbytes($head,9); if($outtable != $this->global_out) { $this->putbytes($outtable, (3 * $outsize)); } $this->getbytes(1); $this->putbytes($this->buffer,1); for(;;) { $this->getbytes(1); $this->putbytes($this->buffer,1); if(($u = $this->buffer[0]) == 0) { break; } $this->getbytes($u); $this->putbytes($this->buffer, $u); } } function read_extension() { $this->getbytes(1); switch($this->buffer[0]) { case 0xf9: $this->getbytes(6); break; case 0xfe: for(;;) { $this->getbytes(1); if(($u = $this->buffer[0]) == 0) { break; } $this->getbytes($u); } break; case 0x01: $this->getbytes(13); for(;;) { $this->getbytes(0); if(($u = $this->buffer[0]) == 0) { break; } $this->getbytes($u); } break; case 0xff: $this->getbytes(9); $this->getbytes(3); for(;;) { $this->getbytes(1); if(!$this->buffer[0]) { break; } $this->getbytes($this->buffer[0]); } break; default: for(;;) { $this->getbytes(1); if(!$this->buffer[0]) { break; } $this->getbytes($this->buffer[0]); } } } function arrcmp($b, $s, $l) { for($i = 0; $i < $l; $i++) { if($s{$i} != $b{$i}) { return false; } } return true; } function getbytes($l) { for($i = 0; $i < $l; $i++) { if($this->mod == 'C_FILE') { $bin = unpack('C*', fread($this->fin, 1)); $this->buffer[$i] = $bin[1]; } elseif($this->mod == 'C_MEMORY') { $bin = unpack('C*', substr($this->fin, $this->ch, 1)); $this->buffer[$i] = $bin[1]; $this->ch++; } } return $this->buffer; } function putbytes($s, $l) { for($i = 0; $i < $l; $i++) { $this->fout .= pack('C*', $s[$i]); } } function getAnimation() { return $this->fout; } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/gifmerge.class.php
PHP
asf20
9,142
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: index_classics.inc.php 21260 2009-11-23 08:33:35Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } require_once DISCUZ_ROOT.'./include/forum.func.php'; $discuz_action = 1; if($cacheindexlife && !$discuz_uid && $showoldetails != 'yes' && (!$_DCACHE['settings']['frameon'] || $_DCACHE['settings']['frameon'] && $_GET['frameon'] != 'yes') && empty($gid)) { $indexcache = getcacheinfo(0); if($timestamp - $indexcache['filemtime'] > $cacheindexlife) { @unlink($indexcache['filename']); define('CACHE_FILE', $indexcache['filename']); $styleid = $_DCACHE['settings']['styleid']; } elseif($indexcache['filename']) { @readfile($indexcache['filename']); $debug && debuginfo(); $debug ? die('<script type="text/javascript">document.getElementById("debuginfo").innerHTML = " '.($debug ? 'Updated at '.gmdate("H:i:s", $indexcache['filemtime'] + 3600 * 8).', Processed in '.$debuginfo['time'].' second(s), '.$debuginfo['queries'].' Queries'.($gzipcompress ? ', Gzip enabled' : '') : '').'";</script>') : die(); } } if(isset($showoldetails)) { switch($showoldetails) { case 'no': dsetcookie('onlineindex', 0, 86400 * 365); break; case 'yes': dsetcookie('onlineindex', 1, 86400 * 365); break; } } else { $showoldetails = false; } $currenttime = gmdate($timeformat, $timestamp + $timeoffset * 3600); $lastvisittime = dgmdate("$dateformat $timeformat", $lastvisit + $timeoffset * 3600); $memberenc = rawurlencode($lastmember); $newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000; $rsshead = $rssstatus ? ('<link rel="alternate" type="application/rss+xml" title="'.$bbname.'" href="'.$boardurl.'rss.php?auth='.$rssauth."\" />\n") : ''; $customtopics = ''; if($qihoo['maxtopics']) { foreach(explode("\t", isset($_DCOOKIE['customkw']) ? $_DCOOKIE['customkw'] : '') as $topic) { $topic = dhtmlspecialchars(trim(stripslashes($topic))); $customtopics .= '<a href="topic.php?keyword='.rawurlencode($topic).'" target="_blank">'.$topic.'</a> &nbsp;'; } } $catlist = $forumlist = $sublist = $forumname = $collapseimg = $collapse = array(); $threads = $posts = $todayposts = $fids = $announcepm = 0; $postdata = $historyposts ? explode("\t", $historyposts) : array(); if($indexhot['status'] && $_DCACHE['heats']['expiration'] < $timestamp) { require_once DISCUZ_ROOT.'./include/cache.func.php'; updatecache('heats'); } foreach(array('forumlinks', 'sidebar') as $key) { if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], $key) === FALSE) { $collapseimg[$key] = 'collapsed_no'; $collapse[$key] = ''; } else { $collapseimg[$key] = 'collapsed_yes'; $collapse[$key] = 'display: none'; } } if(!empty($gid)) { $infosidestatus[2] = !empty($infosidestatus['f'.$gid][0]) ? $infosidestatus['f'.$gid][0] : $infosidestatus[2]; } $infosidestatus['allow'] = $infosidestatus['allow'] && $infosidestatus[2] && $infosidestatus[2] != -1 ? (!$collapse['sidebar'] ? 2 : 1) : 0; $gid = !empty($gid) ? intval($gid) : 0; if(!$gid) { $announcements = ''; if($_DCACHE['announcements']) { $readapmids = !empty($_DCOOKIE['readapmid']) ? explode('D', $_DCOOKIE['readapmid']) : array(); foreach($_DCACHE['announcements'] as $announcement) { if(empty($announcement['groups']) || in_array($groupid, $announcement['groups'])) { if(empty($announcement['type'])) { $announcements .= '<li><a href="announcement.php?id='.$announcement['id'].'">'.$announcement['subject']. '<em>('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')</em></a></li>'; } elseif($announcement['type'] == 1) { $announcements .= '<li><a href="'.$announcement['message'].'" target="_blank">'.$announcement['subject']. '<em>('.gmdate($dateformat, $announcement['starttime'] + $timeoffset * 3600).')</em></a></li>'; } } } } unset($_DCACHE['announcements']); $sql = !empty($accessmasks) ? "SELECT f.fid, f.fup, f.type, f.name, f.threads, f.posts, f.todayposts, f.lastpost, f.inheritedmod, f.forumcolumns, f.simple, ff.description, ff.moderators, ff.icon, ff.viewperm, ff.redirect, ff.extra, 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>'0' ORDER BY f.type, f.displayorder" : "SELECT f.fid, f.fup, f.type, f.name, f.threads, f.posts, f.todayposts, f.lastpost, f.inheritedmod, f.forumcolumns, f.simple, ff.description, ff.moderators, ff.icon, ff.viewperm, ff.redirect, ff.extra FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING(fid) WHERE f.status>'0' ORDER BY f.type, f.displayorder"; $query = $db->query($sql); while($forum = $db->fetch_array($query)) { $forumname[$forum['fid']] = strip_tags($forum['name']); $forum['extra'] = unserialize($forum['extra']); if(!is_array($forum['extra'])) { $forum['extra'] = array(); } if($forum['type'] != 'group') { $threads += $forum['threads']; $posts += $forum['posts']; $todayposts += $forum['todayposts']; if($forum['type'] == 'forum' && isset($catlist[$forum['fup']])) { if(forum($forum)) { $catlist[$forum['fup']]['forums'][] = $forum['fid']; $forum['orderid'] = $catlist[$forum['fup']]['forumscount']++; $forum['subforums'] = ''; $forumlist[$forum['fid']] = $forum; } } elseif(isset($forumlist[$forum['fup']])) { $forumlist[$forum['fup']]['threads'] += $forum['threads']; $forumlist[$forum['fup']]['posts'] += $forum['posts']; $forumlist[$forum['fup']]['todayposts'] += $forum['todayposts']; if($subforumsindex && $forumlist[$forum['fup']]['permission'] == 2 && !($forumlist[$forum['fup']]['simple'] & 16) || ($forumlist[$forum['fup']]['simple'] & 8)) { $forumlist[$forum['fup']]['subforums'] .= '<a href="forumdisplay.php?fid='.$forum['fid'].'" '.($forum['extra']['namecolor'] ? ' style="color: ' . $forum['extra']['namecolor'].';"' : '') . '>'.$forum['name'].'</a>&nbsp;&nbsp;'; } } } else { if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'category_'.$forum['fid']) === FALSE) { $forum['collapseimg'] = 'collapsed_no.gif'; $collapse['category_'.$forum['fid']] = ''; } else { $forum['collapseimg'] = 'collapsed_yes.gif'; $collapse['category_'.$forum['fid']] = 'display: none'; } if($forum['moderators']) { $forum['moderators'] = moddisplay($forum['moderators'], 'flat'); } $forum['forumscount'] = 0; $catlist[$forum['fid']] = $forum; } } foreach($catlist as $catid => $category) { if($catlist[$catid]['forumscount'] && $category['forumcolumns']) { $catlist[$catid]['forumcolwidth'] = floor(100 / $category['forumcolumns']).'%'; $catlist[$catid]['endrows'] = ''; if($colspan = $category['forumscount'] % $category['forumcolumns']) { while(($category['forumcolumns'] - $colspan) > 0) { $catlist[$catid]['endrows'] .= '<td>&nbsp;</td>'; $colspan ++; } $catlist[$catid]['endrows'] .= '</tr>'; } } elseif(empty($category['forumscount'])) { unset($catlist[$catid]); } } unset($catid, $category); if(isset($catlist[0]) && $catlist[0]['forumscount']) { $catlist[0]['fid'] = 0; $catlist[0]['type'] = 'group'; $catlist[0]['name'] = $bbname; $catlist[0]['collapseimg'] = 'collapsed_no.gif'; } else { unset($catlist[0]); } if($whosonlinestatus == 1 || $whosonlinestatus == 3) { $whosonlinestatus = 1; $onlineinfo = explode("\t", $onlinerecord); if(empty($_DCOOKIE['onlineusernum'])) { $onlinenum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}sessions"); if($onlinenum > $onlineinfo[0]) { $_DCACHE['settings']['onlinerecord'] = $onlinerecord = "$onlinenum\t$timestamp"; $db->query("UPDATE {$tablepre}settings SET value='$onlinerecord' WHERE variable='onlinerecord'"); require_once DISCUZ_ROOT.'./include/cache.func.php'; updatesettings(); $onlineinfo = array($onlinenum, $timestamp); } dsetcookie('onlineusernum', intval($onlinenum), 300); } else { $onlinenum = intval($_DCOOKIE['onlineusernum']); } $onlineinfo[1] = gmdate($dateformat, $onlineinfo[1] + ($timeoffset * 3600)); $detailstatus = $showoldetails == 'yes' || (((!isset($_DCOOKIE['onlineindex']) && !$whosonline_contract) || $_DCOOKIE['onlineindex']) && $onlinenum < 500 && !$showoldetails); if($detailstatus) { @include language('actions'); $discuz_uid && updatesession(); $membercount = $invisiblecount = 0; $whosonline = array(); $maxonlinelist = $maxonlinelist ? $maxonlinelist : 500; $query = $db->query("SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM {$tablepre}sessions ".(isset($_DCACHE['onlinelist'][7]) ? '' : 'WHERE uid <> 0')." ORDER BY uid DESC LIMIT ".$maxonlinelist); while($online = $db->fetch_array($query)) { if($online['uid']) { $membercount ++; if($online['invisible']) { $invisiblecount++; continue; } else { $online['icon'] = isset($_DCACHE['onlinelist'][$online['groupid']]) ? $_DCACHE['onlinelist'][$online['groupid']] : $_DCACHE['onlinelist'][0]; } } else { $online['icon'] = $_DCACHE['onlinelist'][7]; $online['username'] = $_DCACHE['onlinelist']['guest']; } $online['fid'] = $online['fid'] ? $forumname[$online['fid']] : 0; $online['action'] = $actioncode[$online['action']]; $online['lastactivity'] = gmdate($timeformat, $online['lastactivity'] + ($timeoffset * 3600)); $whosonline[] = $online; } unset($actioncode, $online); if($onlinenum > $maxonlinelist) { $membercount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}sessions WHERE uid <> '0'"); $invisiblecount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}sessions WHERE invisible = '1'"); } if($onlinenum < $membercount) { $onlinenum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}sessions"); dsetcookie('onlineusernum', intval($onlinenum), 300); } $guestcount = $onlinenum - $membercount; $db->free_result($query); unset($online); } } else { $whosonlinestatus = 0; } } else { require_once DISCUZ_ROOT.'./include/category.inc.php'; } $lastvisit = $lastvisit ? dgmdate("$dateformat $timeformat", $lastvisit + 3600 * $timeoffset) : 0; include template('discuz'); ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/index_classics.inc.php
PHP
asf20
10,707
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: db_mysql.class.php 20294 2009-09-23 06:00:37Z zhaoxiongfei $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } class dbstuff { var $version = ''; var $querynum = 0; var $link = null; function connect($dbhost, $dbuser, $dbpw, $dbname = '', $pconnect = 0, $halt = TRUE, $dbcharset2 = '') { $func = empty($pconnect) ? 'mysql_connect' : 'mysql_pconnect'; if(!$this->link = @$func($dbhost, $dbuser, $dbpw, 1)) { $halt && $this->halt('Can not connect to MySQL server'); } else { if($this->version() > '4.1') { global $charset, $dbcharset; $dbcharset = $dbcharset2 ? $dbcharset2 : $dbcharset; $dbcharset = !$dbcharset && in_array(strtolower($charset), array('gbk', 'big5', 'utf-8')) ? str_replace('-', '', $charset) : $dbcharset; $serverset = $dbcharset ? 'character_set_connection='.$dbcharset.', character_set_results='.$dbcharset.', character_set_client=binary' : ''; $serverset .= $this->version() > '5.0.1' ? ((empty($serverset) ? '' : ',').'sql_mode=\'\'') : ''; $serverset && mysql_query("SET $serverset", $this->link); } $dbname && @mysql_select_db($dbname, $this->link); } } function select_db($dbname) { return mysql_select_db($dbname, $this->link); } function fetch_array($query, $result_type = MYSQL_ASSOC) { return mysql_fetch_array($query, $result_type); } function fetch_first($sql) { return $this->fetch_array($this->query($sql)); } function result_first($sql) { return $this->result($this->query($sql), 0); } function query($sql, $type = '') { global $debug, $discuz_starttime, $sqldebug, $sqlspenttimes; if(defined('SYS_DEBUG') && SYS_DEBUG) { @include_once DISCUZ_ROOT.'./include/debug.func.php'; sqldebug($sql); } $func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query'; if(!($query = $func($sql, $this->link))) { if(in_array($this->errno(), array(2006, 2013)) && substr($type, 0, 5) != 'RETRY') { $this->close(); require DISCUZ_ROOT.'./config.inc.php'; $this->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset); return $this->query($sql, 'RETRY'.$type); } elseif($type != 'SILENT' && substr($type, 5) != 'SILENT') { $this->halt('MySQL Query Error', $sql); } } $this->querynum++; 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 = 0) { $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() { if(empty($this->version)) { $this->version = mysql_get_server_info($this->link); } return $this->version; } function close() { return mysql_close($this->link); } function halt($message = '', $sql = '') { define('CACHE_FORBIDDEN', TRUE); require_once DISCUZ_ROOT.'./include/db_mysql_error.inc.php'; } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/db_mysql.class.php
PHP
asf20
3,835
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: xml.class.php 20753 2009-10-18 16:02:26Z monkey $ */ function xml2array(&$xml, $isnormal = FALSE) { $xml_parser = new XMLparse($isnormal); $data = $xml_parser->parse($xml); $xml_parser->destruct(); return $data; } function array2xml($arr, $htmlon = FALSE, $isnormal = FALSE, $level = 1) { $s = $level == 1 ? "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<root>\r\n" : ''; $space = str_repeat("\t", $level); foreach($arr as $k => $v) { if(!is_array($v)) { $s .= $space."<item id=\"$k\">".($htmlon ? '<![CDATA[' : '').$v.($htmlon ? ']]>' : '')."</item>\r\n"; } else { $s .= $space."<item id=\"$k\">\r\n".array2xml($v, $htmlon, $isnormal, $level + 1).$space."</item>\r\n"; } } $s = preg_replace("/([\x01-\x08\x0b-\x0c\x0e-\x1f])+/", ' ', $s); return $level == 1 ? $s."</root>" : $s; } class XMLparse { var $parser; var $document; var $stack; var $data; var $last_opened_tag; var $isnormal; var $attrs = array(); var $failed = FALSE; function __construct($isnormal) { $this->XMLparse($isnormal); } function XMLparse($isnormal) { $this->isnormal = $isnormal; $this->parser = xml_parser_create('ISO-8859-1'); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); xml_set_object($this->parser, $this); xml_set_element_handler($this->parser, 'open','close'); xml_set_character_data_handler($this->parser, 'data'); } function destruct() { xml_parser_free($this->parser); } function parse(&$data) { $this->document = array(); $this->stack = array(); return xml_parse($this->parser, $data, true) && !$this->failed ? $this->document : ''; } function open(&$parser, $tag, $attributes) { $this->data = ''; $this->failed = FALSE; if(!$this->isnormal) { if(isset($attributes['id']) && !is_string($this->document[$attributes['id']])) { $this->document = &$this->document[$attributes['id']]; } else { $this->failed = TRUE; } } else { if(!isset($this->document[$tag]) || !is_string($this->document[$tag])) { $this->document = &$this->document[$tag]; } else { $this->failed = TRUE; } } $this->stack[] = &$this->document; $this->last_opened_tag = $tag; $this->attrs = $attributes; } function data(&$parser, $data) { if($this->last_opened_tag != NULL) { $this->data .= $data; } } function close(&$parser, $tag) { if($this->last_opened_tag == $tag) { $this->document = $this->data; $this->last_opened_tag = NULL; } array_pop($this->stack); if($this->stack) { $this->document = &$this->stack[count($this->stack)-1]; } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/xml.class.php
PHP
asf20
2,794
<?php function getuidfields() { return array( 'members', 'memberfields', 'access', 'activities', 'activityapplies', 'attachments', 'attachpaymentlog', 'creditslog', 'debateposts', 'debates', 'favorites', 'forumrecommend|authorid,moderatorid', 'invites', 'magiclog', 'magicmarket', 'membermagics', 'memberspaces', 'moderators', 'modworks', 'onlinetime', 'orders', 'paymentlog|uid,authorid', 'posts|authorid|pid', 'promotions', 'ratelog', 'rewardlog|authorid,answererid', 'searchindex|uid', 'spacecaches', 'threads|authorid|tid', 'threadsmod', 'tradecomments|raterid,rateeid', 'tradelog|sellerid,buyerid', 'trades|sellerid', 'validating', ); } function membermerge($olduid, $newuid) { global $db, $tablepre; $uidfields = getuidfields(); foreach($uidfields as $value) { list($table, $field, $stepfield) = explode('|', $value); $fields = !$field ? array('uid') : explode(',', $field); foreach($fields as $field) { $db->query("UPDATE `{$tablepre}$table` SET `$field`='$newuid' WHERE `$field`='$olduid'"); } } } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/membermerge.func.php
PHP
asf20
1,149
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: printable.inc.php 16688 2008-11-14 06:41:07Z cnteacher $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } $thisbg = '#FFFFFF'; $query = $db->query("SELECT p.*, m.username, m.groupid FROM {$tablepre}posts p LEFT JOIN {$tablepre}members m ON m.uid=p.authorid WHERE p.tid='$tid' AND p.invisible='0' ORDER BY p.dateline LIMIT 100"); while($post = $db->fetch_array($query)) { $post['dateline'] = dgmdate("$dateformat $timeformat", $post['dateline'] + ($timeoffset * 3600)); $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0)); if($post['attachment']) { $attachment = 1; } $post['attachments'] = array(); if($post['attachment'] && $allowgetattach) { $attachpids .= ",$post[pid]"; $post['attachment'] = 0; if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $post['message'], $matchaids)) { $attachtags[$post['pid']] = $matchaids[1]; } } $postlist[$post['pid']] = $post; } if($attachpids) { require_once DISCUZ_ROOT.'./include/attachment.func.php'; parseattach($attachpids, $attachtags, $postlist); } include template('viewthread_printable'); ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/printable.inc.php
PHP
asf20
1,466
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: modlist.inc.php 16697 2008-11-14 07:36:51Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $modlist = array(); if($GLOBALS['forum']['moderators']) { $moderators = daddslashes(explode("\t", $GLOBALS['forum']['moderators']), 1); if($GLOBALS['modworkstatus']) { $query = $db->query("SELECT m.uid, m.username, sum(mw.count) as actioncount FROM {$tablepre}members m LEFT JOIN {$tablepre}modworks mw on m.uid=mw.uid WHERE m.username in (".implodeids($moderators).") GROUP BY mw.uid ORDER BY actioncount DESC"); } else { $query = $db->query("SELECT m.uid, m.username, m.posts FROM {$tablepre}members m WHERE m.username in (".implodeids($moderators).") ORDER BY posts DESC"); } while($modrow = $db->fetch_array($query)) { $modrow['avatar'] = discuz_uc_avatar($modrow['uid'], 'small'); $modrow['actioncount'] = intval($modrow['actioncount']); $modlist[] = $modrow; } } include template('request_modlist'); } else { $request_version = '1.0'; $request_name = $requestlang['modlist_name']; $request_description = $requestlang['modlist_desc']; $request_copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>'; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/modlist.inc.php
PHP
asf20
1,365
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: thread.inc.php 20942 2009-11-02 04:12:16Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { if(!defined('TPLDIR')) { @include_once DISCUZ_ROOT.'./forumdata/cache/style_'.$_DCACHE['settings']['styleid'].'.php'; } require_once DISCUZ_ROOT.'./include/post.func.php'; if($tid = intval($settings['tid'])) { $thread = $db->fetch_first("SELECT subject, fid, special, price FROM {$tablepre}threads WHERE tid='$tid'"); $fid = $thread['fid']; if($thread['special'] == 1) { $multiple = $db->result_first("SELECT multiple FROM {$tablepre}polls WHERE tid='$tid'"); $optiontype = $multiple ? 'checkbox' : 'radio'; $query = $db->query("SELECT polloptionid, polloption FROM {$tablepre}polloptions WHERE tid='$tid' ORDER BY displayorder"); while($polloption = $db->fetch_array($query)) { $polloption['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>", $polloption['polloption']); $polloptions[] = $polloption; } } elseif($thread['special'] == 2) { $query = $db->query("SELECT subject, price, aid, pid FROM {$tablepre}trades WHERE tid='$tid' ORDER BY displayorder DESC LIMIT 2"); while($trade = $db->fetch_array($query)) { $trades[] = $trade; } } elseif($thread['special'] == 3) { $extcredits = $_DCACHE['settings']['extcredits']; $creditstransextra = $_DCACHE['settings']['creditstransextra']; $rewardend = $thread['price'] < 0; $rewardprice = abs($thread['price']); $message = messagecutstr($db->result_first("SELECT message FROM {$tablepre}posts WHERE tid='$tid' AND first=1"), 100); } elseif($thread['special'] == 4) { $message = messagecutstr($db->result_first("SELECT message FROM {$tablepre}posts WHERE tid='$tid' AND first=1"), 100); $number = $db->result_first("SELECT number FROM {$tablepre}activities WHERE tid='$tid'"); $applynumbers = $db->result_first("SELECT COUNT(*) FROM {$tablepre}activityapplies WHERE tid='$tid' AND verified=1"); $aboutmembers = $number - $applynumbers; } elseif($thread['special'] == 5) { $message = messagecutstr($db->result_first("SELECT message FROM {$tablepre}posts WHERE tid='$tid' AND first=1"), 100); $debate = $db->fetch_first("SELECT affirmdebaters, negadebaters, affirmvotes, negavotes FROM {$tablepre}debates WHERE tid='$tid'"); $debate['affirmvoteswidth'] = $debate['affirmvotes'] ? intval(80 * (($debate['affirmvotes'] + 1) / ($debate['affirmvotes'] + $debate['negavotes'] + 1))) : 1; $debate['negavoteswidth'] = $debate['negavotes'] ? intval(80 * (($debate['negavotes'] + 1) / ($debate['affirmvotes'] + $debate['negavotes'] + 1))) : 1; } else { $message = messagecutstr($db->result_first("SELECT message FROM {$tablepre}posts WHERE tid='$tid' AND first=1"), 100); } } include template('request_thread'); } else { $request_version = '1.0'; $request_name = $requestlang['thread_name']; $request_description = $requestlang['thread_desc']; $request_copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>'; $request_settings = array( 'tid' => array($requestlang['thread_id'], '', 'text'), ); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/thread.inc.php
PHP
asf20
3,454
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: feed.inc.php 16697 2008-12-05 07:36:51Z andy $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $parameter = array(); $parameter[] = 'ac=feed'; if(!empty($settings['uids'])) { $parameter[] = 'uids='.trim($settings['uids']); } if(!empty($settings['friend'])) { $parameter[] = 'friend='.intval($GLOBALS['discuz_uid']); $nocache = 1; } $start = !empty($settings['start']) ? intval($settings['start']) : 0; $limit = !empty($settings['limit']) ? intval($settings['limit']) : 10; $parameter[] = 'start='.$start; $parameter[] = 'limit='.$limit; $plus = implode('&', $parameter); $url = $GLOBALS['uchomeurl']."/api/discuz.php?$plus"; $feedlist = unserialize(dfopen($url)); $writedata = ''; if($feedlist && is_array($feedlist)) { $writedata = '<div class="sidebox"><h4>'.$settings['title'].'</h4><table>'; foreach($feedlist as $feed) { $searchs = $replaces = array(); foreach(array_keys($feed) as $key) { $searchs[] = '{'.$key.'}'; $replaces[] = $feed[$key]; } $writedata .= '<tr><td>'.str_replace($searchs, $replaces, stripslashes($settings['template'])).'</td></tr>'; } $writedata .= '</table></div>'; } } else { $request_version = '1.0'; $request_name = $requestlang['feed_name']; $request_description = $requestlang['feed_desc']; $request_copyright = '<a href="http://u.discuz.net/home/" target="_blank">Comsenz Inc.</a>'; $request_settings = array( 'title' => array($requestlang['feed_title'], $requestlang['feed_title_comment'], 'text', '', $requestlang['feed_title_value']), 'uids' => array($requestlang['feed_uids'], $requestlang['feed_uids_comment'], 'text'), 'friend' => array($requestlang['feed_friend'], '', 'mradio', array(array('0', $requestlang['feed_friend_nolimit']), array('1', $requestlang['feed_friend_friendonly'])), '0'), 'start' => array($requestlang['feed_start'], $requestlang['feed_start_comment'], 'text', '', '0'), 'limit' => array($requestlang['feed_limit'], $requestlang['feed_limit_comment'], 'text', '', '10'), 'template' => array($requestlang['feed_template'], $requestlang['feed_template_comment'], 'textarea', '','<a href="{userlink}">{title_template}</a>') ); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/feed.inc.php
PHP
asf20
2,379
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: doing.inc.php 16697 2008-12-12 07:36:51Z andy $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $parameter = array(); $parameter[] = 'ac=doing'; if(!empty($settings['uid'])) { $parameter[] = 'uid='.trim($settings['uid']); } if(!empty($settings['mood'])) { $parameter[] = 'mood='.intval($settings['mood']); } $start = !empty($settings['start']) ? intval($settings['start']) : 0; $limit = !empty($settings['limit']) ? intval($settings['limit']) : 10; $parameter[] = 'start='.$start; $parameter[] = 'limit='.$limit; $plus = implode('&', $parameter); $url = $GLOBALS['uchomeurl']."/api/discuz.php?$plus"; $doinglist = unserialize(dfopen($url)); $writedata = ''; if($doinglist && is_array($doinglist)) { $writedata = '<div class="sidebox"><h4>'.$settings['title'].'</h4><table>'; foreach($doinglist as $doing) { $searchs = $replaces = array(); foreach(array_keys($doing) as $key) { $searchs[] = '{'.$key.'}'; $replaces[] = $doing[$key]; } $writedata .= '<tr><td>'.str_replace($searchs, $replaces, stripslashes($settings['template'])).'</td></tr>'; } $writedata .= '</table></div>'; } } else { $request_version = '1.0'; $request_name = $requestlang['doing_name']; $request_description = $requestlang['doing_desc']; $request_copyright = '<a href="http://u.discuz.net/home/" target="_blank">Comsenz Inc.</a>'; $request_settings = array( 'title' => array($requestlang['doing_title'], $requestlang['doing_title_comment'], 'text', '', $requestlang['doing_title_value']), 'uid' => array($requestlang['doing_uids'], $requestlang['doing_uids_comment'], 'text'), 'mood' => array($requestlang['doing_mood'], '', 'mradio', array(array('0', $requestlang['doing_mood_nolimit']), array('1', $requestlang['doing_mood_moodonly'])), '0'), 'start' => array($requestlang['doing_start'], $requestlang['doing_start_comment'], 'text', '', '0'), 'limit' => array($requestlang['doing_limit'], $requestlang['doing_limit_comment'], 'text', '', '10'), 'template' => array($requestlang['doing_template'], $requestlang['doing_template_comment'], 'textarea', '','<a href="{link}">{message}</a>') ); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/doing.inc.php
PHP
asf20
2,352
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: space.inc.php 16697 2008-12-06 07:36:51Z andy $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $parameter = array(); $parameter[] = 'ac=space'; if(!empty($settings['uid'])) { $parameter[] = 'uid='.trim($settings['uid']); } if(!empty($settings['dateline'])) { $parameter[] = 'dateline='.intval($settings['dateline']); } if(!empty($settings['updatetime'])) { $parameter[] = 'updatetime='.intval($settings['updatetime']); } if(!empty($settings['startfriendnum'])) { $parameter[] = 'startfriendnum='.intval($settings['startfriendnum']); } if(!empty($settings['endfriendnum'])) { $parameter[] = 'endfriendnum='.intval($settings['endfriendnum']); } if(!empty($settings['startviewnum'])) { $parameter[] = 'startviewnum='.intval($settings['startviewnum']); } if(!empty($settings['endviewnum'])) { $parameter[] = 'endviewnum='.intval($settings['endviewnum']); } if(!empty($settings['startcredit'])) { $parameter[] = 'startcredit='.intval($settings['startcredit']); } if(!empty($settings['endcredit'])) { $parameter[] = 'endcredit='.intval($settings['endcredit']); } if($settings['avatar'] != -1) { $parameter[] = 'avatar='.intval($settings['avatar']); } if($settings['namestatus'] != -1) { $parameter[] = 'namestatus='.intval($settings['namestatus']); } if(!empty($settings['order'])) { $parameter[] = 'order='.trim($settings['order']); } if(!empty($settings['sc'])) { $parameter[] = 'sc='.trim($settings['sc']); } $start = !empty($settings['start']) ? intval($settings['start']) : 0; $limit = !empty($settings['limit']) ? intval($settings['limit']) : 10; $parameter[] = 'start='.$start; $parameter[] = 'limit='.$limit; $plus = implode('&', $parameter); $url = $GLOBALS['uchomeurl']."/api/discuz.php?$plus"; $spacelist = unserialize(dfopen($url)); $writedata = ''; if($spacelist && is_array($spacelist)) { $writedata = '<div class="sidebox"><h4>'.$settings['title'].'</h4><table>'; foreach($spacelist as $space) { $searchs = $replaces = array(); foreach(array_keys($space) as $key) { $searchs[] = '{'.$key.'}'; $replaces[] = $space[$key]; } $writedata .= '<tr><td>'.str_replace($searchs, $replaces, stripslashes($settings['template'])).'</td></tr>'; } $writedata .= '</table></div>'; } } else { $request_version = '1.0'; $request_name = $requestlang['space_name']; $request_description = $requestlang['space_desc']; $request_copyright = '<a href="http://u.discuz.net/home/" target="_blank">Comsenz Inc.</a>'; $request_settings = array( 'title' => array($requestlang['space_title'], $requestlang['space_title_comment'], 'text', '', $requestlang['space_title_value']), 'uid' => array($requestlang['space_uids'], $requestlang['space_uids_comment'], 'text'), 'startfriendnum' => array($requestlang['space_startfriendnum'], '', 'text'), 'endfriendnum' => array($requestlang['space_endfriendnum'], '', 'text'), 'startviewnum' => array($requestlang['space_startviewnum'], '', 'text'), 'endviewnum' => array($requestlang['space_endviewnum'], '', 'text'), 'startcredit' => array($requestlang['space_startcredit'], '', 'text'), 'endcredit' => array($requestlang['space_endcredit'], '', 'text'), 'avatar' => array($requestlang['space_avatar'], $requestlang['space_avatar_comment'], 'mradio', array(array('-1', $requestlang['space_avatar_nolimit']), array('0', $requestlang['space_avatar_noexists']) , array('1', $requestlang['space_avatar_exists'])), '-1'), 'namestatus'=> array($requestlang['space_namestatus'], $requestlang['space_namestatus_comment'], 'mradio', array(array('-1', $requestlang['space_namestatus_nolimit']), array('0', $requestlang['space_namestatus_nopass']) , array('1', $requestlang['space_namestatus_pass'])), '-1'), 'dateline' => array($requestlang['space_dateline'], $requestlang['space_dateline_comment'], 'select', $requestlang['space_dateselect']), 'updatetime' => array($requestlang['space_updatetime'], $requestlang['space_updatetime_comment'], 'select', $requestlang['space_dateselect']), 'order' => array($requestlang['space_order'], $requestlang['space_order_comment'], 'select', $requestlang['space_orderselect']), 'sc' => array($requestlang['space_sc'], $requestlang['space_sc_comment'], 'mradio', array(array('ASC', $requestlang['space_sc_asc']), array('DESC', $requestlang['space_sc_desc'])), 'DESC'), 'start' => array($requestlang['space_start'], $requestlang['space_start_comment'], 'text', '', '0'), 'limit' => array($requestlang['space_limit'], $requestlang['space_limit_comment'], 'text', '', '10'), 'template' => array($requestlang['space_template'], $requestlang['space_template_comment'], 'textarea', '','<a href="{userlink}">{username}</a>') ); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/space.inc.php
PHP
asf20
4,976
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: birthday.inc.php 16697 2008-11-14 07:36:51Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $limit = !empty($settings['limit']) ? intval($settings['limit']) : 12; $cachefile = DISCUZ_ROOT.'./forumdata/cache/requestscript_birthday.php'; $today = gmdate('m-d', $timestamp + $timeoffset * 3600); if((@!include($cachefile)) || $today != $todaycache || $limit != $limitcache) { $query = $db->query("SELECT username, uid FROM {$tablepre}members WHERE RIGHT(bday, 5)='".$today."' ORDER BY bday LIMIT $limit"); $birthdaymembers = array(); while($member = $db->fetch_array($query)) { $member['username'] = htmlspecialchars($member['username']); $birthdaymembers[] = $member; } $cachefile = DISCUZ_ROOT.'./forumdata/cache/requestscript_birthday.php'; writetorequestcache($cachefile, 0, "\$limitcache = $limit;\n\$todaycache = '".$today."';\n\$birthdaymembers = ".var_export($birthdaymembers, 1).';'); } include template('request_birthday'); } else { $request_version = '1.0'; $request_name = $requestlang['birthday_name']; $request_description = $requestlang['birthday_desc']; $request_copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>'; $request_settings = array( 'limit' => array($requestlang['birthday_limit'], $requestlang['birthday_limit_comment'], 'text'), ); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/birthday.inc.php
PHP
asf20
1,530
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: tag.inc.php 16697 2008-11-14 07:36:51Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $max = $db->result_first("SELECT total FROM {$tablepre}tags WHERE closed=0 ORDER BY total DESC LIMIT 1"); $viewthreadtags = !empty($settings['limit']) ? intval($settings['limit']) : 10; if(!$settings['type']) { $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"); } else { $query = $db->query("SELECT tagname,total FROM {$tablepre}tags WHERE closed=0 ORDER BY total DESC LIMIT $viewthreadtags"); } $taglist = array(); while($tagrow = $db->fetch_array($query)) { $tagrow['level'] = ceil($tagrow['total'] * 5 / $max); $tagrow['tagnameenc'] = rawurlencode($tagrow['tagname']); $taglist[] = $tagrow; } !$settings['type'] && shuffle($taglist); include template('request_tag'); } else { $request_version = '1.0'; $request_name = $requestlang['tag_name']; $request_description = $requestlang['tag_desc']; $request_copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>'; $request_settings = array( 'type' => array($requestlang['tag_type'], $requestlang['tag_type_comment'], 'mradio', array( array(0, $requestlang['tag_type_0']), array(1, $requestlang['tag_type_1']) ) ), 'limit' => array($requestlang['tag_type_limit'], $requestlang['tag_type_limit_comment'], 'text'), ); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/tag.inc.php
PHP
asf20
1,768
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: assistant.inc.php 19591 2009-09-07 04:49:41Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $nocache = 1; $avatar = discuz_uc_avatar($GLOBALS['discuz_uid'], 'small'); $fidadd = isset($_GET['fid']) ? '&srchfid='.$_GET['fid'] : ''; @include DISCUZ_ROOT.'./forumdata/cache/cache_usergroups.php'; if($_DCACHE['usergroups'][$GLOBALS['groupid']]['type'] == 'member' && $_DCACHE['usergroups'][$GLOBALS['groupid']]['creditslower'] != 999999999) { $creditupgrade = $_DCACHE['usergroups'][$GLOBALS['groupid']]['creditslower'] - $GLOBALS['credits']; } else { $creditupgrade = ''; } include template('request_assistant'); } else { $request_version = '1.0'; $request_name = $requestlang['assistant_name']; $request_description = $requestlang['assistant_desc']; $request_copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>'; $request_settings = array(); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/assistant.inc.php
PHP
asf20
1,086
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: forumtree.inc.php 20763 2009-10-19 02:35:45Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { require_once DISCUZ_ROOT.'./include/forum.func.php'; if(!$_DCACHE['forums']) { include_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php'; } foreach($_DCACHE['forums'] as $forum) { if(!$forum['status']) { continue; } if(!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$GLOBALS[discuz_uid]\t")) { $forum['name'] = addslashes($forum['name']); $forum['type'] != 'group' && $haschild[$forum['fup']] = true; $forumlist[] = $forum; } } $nocache = 1; include template('request_forumtree'); } else { $request_version = '1.0'; $request_name = $requestlang['forumtree_name']; $request_description = $requestlang['forumtree_desc']; $request_copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>'; } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/forumtree.inc.php
PHP
asf20
1,107
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: rowcombine.inc.php 20152 2009-09-21 02:22:58Z monkey $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $combinetitles = $combinedata = $datalist = ''; $combinemodules = explode("\n", $settings['data']); $idbase = 'cm_'.random(4); foreach($combinemodules as $id => $combinemodule) { $i = $id + 1; $id = $idbase.'_c_'.$i; list($combinekey, $combinetitle) = explode(',', $combinemodule); $cachekey = $combinekey; if(CURSCRIPT == 'forumdisplay' && $specialfid) { $cachekey .= '_fid'.$specialfid; } $combinecachefile = DISCUZ_ROOT.'./forumdata/cache/request_'.md5($cachekey).'.php'; if((@!include($combinecachefile)) || $expiration < $timestamp) { parse_str($_DCACHE['request'][$combinekey]['url'], $requestdata); $datalist = parse_request($requestdata, $combinecachefile, 0, $specialfid, $combinekey); } $combinedata .= '<div id="'.$id.'" class="combine" style="display:none">'.$datalist.'</div>'; $combinetitles[$i] = $combinetitle; } $combinecount = count($combinemodules); include template('request_rowcombine'); } else { $request_version = '1.0'; $request_name = $requestlang['rowcombine_name']; $request_description = $requestlang['rowcombine_desc']; $request_copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>'; $request_settings = array( 'title' => array($requestlang['rowcombine_title'], $requestlang['rowcombine_title_comment'], 'text'), 'data' => array($requestlang['rowcombine_name'], $requestlang['rowcombine_data_comment'], 'textarea'), ); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/rowcombine.inc.php
PHP
asf20
1,733
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: doing.inc.php 16697 2008-12-12 07:36:51Z andy $ */ if(!defined('IN_DISCUZ')) { exit('Access Denied'); } if($requestrun) { $parameter = array(); $parameter[] = 'ac=app'; if(!empty($settings['uid'])) { $parameter[] = 'uid='.trim($settings['uid']); } elseif($discuz_uid) { $parameter[] = 'uid='.$GLOBALS['discuz_uid']; } if(!empty($settings['type'])) { $parameter[] = 'type='.intval($settings['type']); } $start = !empty($settings['start']) ? intval($settings['start']) : 0; $limit = !empty($settings['limit']) ? intval($settings['limit']) : 10; $parameter[] = 'start='.$start; $parameter[] = 'limit='.$limit; $plus = implode('&', $parameter); $url = $GLOBALS['uchomeurl']."/api/discuz.php?$plus"; $applist = unserialize(dfopen($url)); $writedata = ''; if($applist && is_array($applist)) { $writedata = '<div class="sidebox"><h4>'.$settings['title'].'</h4><table>'; foreach($applist as $app) { $searchs = $replaces = array(); foreach(array_keys($app) as $key) { $searchs[] = '{'.$key.'}'; $replaces[] = $app[$key]; } $writedata .= '<tr><td>'.str_replace($searchs, $replaces, stripslashes($settings['template'])).'</td></tr>'; } $writedata .= '</table></div>'; } } else { $request_version = '1.0'; $request_name = $requestlang['app_name']; $request_description = $requestlang['app_desc']; $request_copyright = '<a href="http://u.discuz.net/home/" target="_blank">Comsenz Inc.</a>'; $request_settings = array( 'title' => array($requestlang['app_title'], $requestlang['app_title_comment'], 'text', '', $requestlang['app_title_value']), 'uid' => array($requestlang['app_uids'], $requestlang['app_uids_comment'], 'text'), 'type' => array($requestlang['app_type'], '', 'mradio', array(array('0', $requestlang['app_type_nolimit']), array('1', $requestlang['app_type_default']), array('2', $requestlang['app_type_userapp'])), '0'), 'start' => array($requestlang['app_start'], $requestlang['app_start_comment'], 'text', '', '0'), 'limit' => array($requestlang['app_limit'], $requestlang['app_limit_comment'], 'text', '', '10'), 'template' => array($requestlang['app_template'], $requestlang['app_template_comment'], 'textarea', '','<img src="{icon}"><a href="{link}">{appname}</a>') ); } ?>
zyyhong
trunk/jiaju001/newbbs/bbs/include/request/app.inc.php
PHP
asf20
2,444