public function index() { global $G, $lang; if ($this->checkFormSubmit()) { $delete = $_GET['delete']; if ($delete && is_array($delete)) { $deleteids = implodeids($delete); $photos = $this->t('photo')->where("photoid IN({$deleteids})")->select(); foreach ($photos as $pp) { @unlink(ROOT_PATH . '/' . $pp['thumb']); @unlink(ROOT_PATH . '/' . $pp['picurl']); } $this->t('photo')->where("photoid IN({$deleteids})")->delete(); } $this->showSuccess('delete_succeed'); } else { $pagesize = 20; $totalnum = $this->t('photo')->count(); $pagecount = $totalnum < $pagesize ? 1 : ceil($totalnum / $pagesize); $photolist = $this->t('photo')->page($G['page'], $pagesize)->order('photoid', 'DESC')->select(); if ($photolist) { $newlist = array(); foreach ($photolist as $list) { $list['thumb'] = C('ATTACHURL') . $list['thumb']; $list['size'] = formatsize($list['size']); $list['uptime'] = @date('Y-m-d H:i', $list['uptime']); $newlist[$list['photoid']] = $list; } $photolist = $newlist; unset($newlist); } $pages = $this->showPages($G['page'], $pagecount, $totalnum); include template('photo'); } }
function updatecache($cachename = '') { global $db, $bbname, $tablepre, $maxbdays; static $cachescript = array('settings' => array('settings'), 'usergroups' => array('usergroups'), 'ipbanned' => array('ipbanned')); 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 == 'admingroups') { $query = $db->query("SELECT * FROM {$tablepre}admingroups"); while ($data = $db->fetch_array($query)) { writetocache($data['admingid'], '', getcachevars($data), 'admingroup_'); } } }
function listinfos($where = '', $order = '', $page = 1, $pagesize = 50, $flags = 0) { if (!isset($ACTOR)) { $ACTOR = getcache('actor_' . get_siteid(), 'ask'); } if ($where) { $where = " WHERE {$where}"; } if ($order) { $order = " ORDER BY {$order}"; } $page = max(intval($page), 1); $offset = $pagesize * ($page - 1); $limit = " LIMIT {$offset}, {$pagesize}"; $r = $this->get_one('', ' COUNT(*) AS num'); $number = $r['number']; $this->db->pages; $array = array(); $i = 1; $result = $this->db->query("SELECT * FROM {$this->table_name} {$where} {$order} {$limit}"); $data = $this->fetch_array($result); foreach ($data as $r) { $userids[] = $userid = $r['userid']; $r['orderid'] = $i; $_array[] = $array[$userid] = $r; $i++; } if ($userids != '') { $userids = implodeids($userids); $data = $this->db_m->listinfo("userid IN ({$userids})"); foreach ($data as $r) { $userid = $r['userid']; $credit = $r['point']; $r['lastdate'] = date('Y-m-d H:i', $r['lastdate']); foreach ($ACTOR[$r['actortype']] as $k => $v) { if ($credit >= $v['min'] && $credit <= $v['max']) { $r['grade'] = $v['grade'] . ' ' . $v['actor']; } elseif ($credit > $v['max']) { $r['grade'] = $v['grade'] . ' ' . $v['actor']; } } if ($flags) { $_info[$userid] = $r; } else { $info[] = array_merge($array[$userid], $r); } } if ($flags) { foreach ($_array as $r) { $userid = $r['userid']; $info[] = array_merge($_info[$userid], $r); } } } $info = array_filter($info); $this->number = $this->db_m->page; $this->db->free_result($result); return $info; }
function updatespacecache($uid, $module, $list = FALSE) { global $_DCOOKIE, $db, $mod, $tablepre, $timestamp, $tpp, $page, $multipage, $starttime, $endtime, $spacedata, $lastvisit, $videoopen, $tradetypeid; if (!file_exists(DISCUZ_ROOT . './forumdata/cache/cache_spacesettings.php')) { require_once DISCUZ_ROOT . './include/cache.func.php'; updatespacesettings(); } require DISCUZ_ROOT . './forumdata/cache/cache_spacesettings.php'; if ($list) { $tpp = $mod != 'mytrades' ? $tpp : 15; $page = max(1, intval($page)); $start_limit = ($page - 1) * $tpp; $parms['items'] = "{$start_limit}, {$tpp}"; } else { $parms['items'] = intval($spacedata['limit' . $module]); } $parms['list'] = $list; $parms['conditions'] = $parms['extraquery'] = ''; $parms['cols'] = '*'; $user_func = 'module_' . $module; $user_func($parms); $tids = $datalist = array(); $query = $db->query("SELECT {$parms['cols']} FROM {$tablepre}{$parms['table']} {$parms['conditions']} LIMIT {$parms['items']}"); while ($data = $db->fetch_array($query)) { if (!empty($data['message'])) { $data['message'] = spacecutstr($data['message'], $spacedata['textlength']); $videoopen && ($data['message'] = videocode($data['message'], $data['tid'], $data['pid'])); } if ($data['tid'] && $lastvisit < $data['lastpost'] && (empty($_DCOOKIE['oldtopics']) || strpos($_DCOOKIE['oldtopics'], 'D' . $data['tid'] . 'D') === FALSE)) { $data['subject'] .= ' <a href="redirect.php?tid=' . $data['tid'] . '&goto=newpost#newpost" target="_blank"><img src="' . IMGDIR . '/firstnew.gif" border="0" alt="" /></a>'; } if ($parms['extraquery']) { $tids[] = $data['tid']; $datalist[$data['tid']] = $data; } else { $datalist[] = $data; } } if ($tids) { $query = $db->query($parms['extraquery'] . '(' . implodeids($tids) . ')'); while ($data = $db->fetch_array($query)) { $datalist[$data['tid']] = array_merge($datalist[$data['tid']], $data); } } if (!$list) { $db->query("REPLACE INTO {$tablepre}spacecaches (uid, variable, value, expiration) VALUES ('{$uid}', '{$module}', '" . addslashes(serialize($datalist)) . "', '" . ($timestamp + $spacedata['cachelife']) . "')"); } else { $num = $db->result_first("SELECT count(*) FROM {$tablepre}{$parms['table']} {$parms['conditions']}"); $module = empty($parms['pagemodule']) ? $module : $parms['pagemodule']; $multipage = spacemulti($num, $tpp, $page, "space.php?uid={$uid}&mod={$module}" . ($starttime ? "&starttime={$starttime}" : '') . ($endtime ? "&endtime={$endtime}" : '') . (isset($tradetypeid) ? "&tradetypeid={$tradetypeid}" : '')); } return $datalist; }
function getUpdatedUsers($num) { $logfile = DISCUZ_ROOT.'./forumdata/logs/manyou_user.log'; $totalNum = 0; $result = array(); if(file_exists($logfile) && @rename($logfile, $logfile.'.bak')) { $data = file($logfile.'.bak'); $totalNum = count($data); if($num < $totalNum) { $ldata = array_slice($data, $num); $data = array_slice($data, 0, $num); $newdata = @file($logfile); $writedata = is_array($newdata) ? array_merge($ldata, $newdata) : $ldata; if($fp = @fopen($logfile, 'w')) { @flock($fp, 2); foreach($writedata as $row) { fwrite($fp, trim($row)."\n"); } fclose($fp); } } @unlink($logfile.'.bak'); if($data) { $dataary = $uIds = array(); foreach($data as $row) { list(,, $uid, $action) = explode("\t", $row); $uIds[] = $uid; $dataary[] = array($uid, $action); } $sql = 'SELECT m.*, mf.* FROM %s m LEFT JOIN %s mf ON m.uid = mf.uid WHERE m.uid IN (%s)'; $sql = sprintf($sql, $GLOBALS['tablepre'].'members', $GLOBALS['tablepre'].'memberfields', implodeids(array_unique($uIds))); $query = $GLOBALS['db']->query($sql); $users = array(); while($member = $GLOBALS['db']->fetch_array($query)) { $user = $this->_space2user($member); $users[$user['uId']] = $user; } foreach($dataary as $row) { $users[$row[0]]['action'] = trim($row[1]); $result[] = $users[$row[0]]; } } } $result = array( 'totalNum' => count($data), 'users' => $result ); return new APIResponse($result); }
function getInfo($uIds, $fields = array()) { $result = array(); $query = $GLOBALS['db']->query("SELECT mf.*, m.* FROM ".$GLOBALS['tablepre']."members m LEFT JOIN ".$GLOBALS['tablepre']."memberfields mf ON mf.uid=m.uid WHERE m.uid IN (".implodeids($uIds).")"); while($space = $GLOBALS['db']->fetch_array($query)) { $user = $this->_space2user($space); $tmp = array(); if($fields) { foreach($fields as $field) { $tmp[$field] = $user[$field]; } } else { $tmp = $user; } $result[] = $tmp; } return new APIResponse($result); }
function setFlag($applications, $flag) { $flag = ($flag == 'disabled') ? -1 : ($flag == 'default' ? 1 : 0); $appIds = array(); if ($applications && is_array($applications)) { foreach($applications as $application) { $this->refreshApplication($application['appId'], $application['appName'], null, null, null, $flag, null); $appIds[] = $application['appId']; } } if ($flag == -1) { $sql = sprintf('DELETE FROM %s WHERE appid IN (%s)', $GLOBALS['tablepre'].'myfeed', implodeids($appIds)); $GLOBALS['db']->query($sql); $sql = sprintf('DELETE FROM %s WHERE appid IN (%s)', $GLOBALS['tablepre'].'userapp', implodeids($appIds)); $GLOBALS['db']->query($sql); $sql = sprintf('DELETE FROM %s WHERE appid IN (%s)', $GLOBALS['tablepre'].'myinvite', implodeids($appIds)); $GLOBALS['db']->query($sql); } $result = true; return new APIResponse($result); }
public function index() { global $G, $lang; if ($this->checkFormSubmit()) { $tags = $_GET['tags']; $tagids = implodeids($_GET['tagid']); $delete = intval($_GET['delete']); $newtag = $_GET['newtag']; if (!empty($tags) && is_array($tags)) { foreach ($tags as $key => $value) { M('member_tag')->where(array('tagid' => $key))->update(array('tag' => $value)); } } if ($delete) { if (!empty($tagids)) { M('member_tag')->where("tagid IN({$tagids})")->delete(); } } if (!empty($newtag)) { foreach ($newtag as $key => $tag) { if ($tag) { $this->t('member_tag')->insert(array('tag' => $tag)); } } } $this->showSuccess('update_succeed'); } else { $tags = array(); $pagesize = 30; $totalnum = M('member_tag')->count(); $pagecount = $totalnum < $pagesize ? 1 : ceil($totalnum / $pagesize); $taglist = M('member_tag')->page($G['page'], $pagesize)->select(); $pages = $this->showPages($G['page'], $pagecount, $totalnum); include template('usertag'); } }
if(empty($filter) && empty($sortid)) { $threadcount = $forum['threads']; } else { $threadcount = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid='$fid' $filteradd AND displayorder>='0'"); } $thisgid = $forum['type'] == 'forum' ? $forum['fup'] : $_DCACHE['forums'][$forum['fup']]['fup']; if($globalstick && $forum['allowglobalstick']) { $stickytids = $_DCACHE['globalstick']['global']['tids'].(empty($_DCACHE['globalstick']['categories'][$thisgid]['count']) ? '' : ','.$_DCACHE['globalstick']['categories'][$thisgid]['tids']); $forumstickytids = array(); $_DCACHE['forumstick'][$fid] = is_array($_DCACHE['forumstick'][$fid]) ? $_DCACHE['forumstick'][$fid] : array(); $forumstickycount = count($_DCACHE['forumstick'][$fid]); foreach($_DCACHE['forumstick'][$fid] as $forumstickthread) { $forumstickytids[] = $forumstickthread['tid']; } if(!empty($forumstickytids)) { $forumstickytids = implodeids($forumstickytids); $stickytids .= ", $forumstickytids"; } $stickytids = trim($stickytids, ', '); if ($stickytids === ''){ $stickytids = '0'; } $stickycount = $_DCACHE['globalstick']['global']['count'] + $_DCACHE['globalstick']['categories'][$thisgid]['count'] + $forumstickycount; } else { $forumstickycount = $stickycount = $stickytids = 0; } $filterbool = !empty($filter) && in_array($filter, array('digest', 'recommend', 'type', 'activity', 'poll', 'trade', 'reward', 'debate')); $threadcount += $filterbool ? 0 : $stickycount;
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'); } }
$resultarray = array('redirect' => "forumdisplay.php?fid={$fid}", 'reasonpm' => $sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_copy') : array(), 'modtids' => $thread['tid'], 'modlog' => array($thread, $other)); } } elseif ($action == 'removereward') { $modaction = 'RMR'; if (!is_array($thread) || $thread['special'] != '3' || $thread['price'] >= 0) { showmessage('reward_end'); } $answererid = $db->result_first("SELECT answererid FROM {$tablepre}rewardlog WHERE tid='{$thread['tid']}'"); $thread[price] = abs($thread[price]); $db->query("UPDATE {$tablepre}members SET extcredits{$creditstrans}=extcredits{$creditstrans}+{$thread['price']} WHERE uid='{$thread['authorid']}'", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}members SET extcredits{$creditstrans}=extcredits{$creditstrans}-{$thread['price']} WHERE uid='{$answererid}'", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}threads SET special='0', price='0' WHERE tid='{$thread['tid']}'", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='{$thread['tid']}'", 'UNBUFFERED'); showmessage('admin_succeed', "viewthread.php?tid={$tid}"); } elseif ($action == 'banpost') { if (!($banpids = implodeids($topiclist))) { showmessage('admin_banpost_invalid'); } elseif (!$allowbanpost || !$tid) { showmessage('admin_nopermission', NULL, 'HALTED'); } $posts = array(); $query = $db->query("SELECT first, authorid FROM {$tablepre}posts WHERE pid IN ({$banpids}) AND tid='{$tid}'"); while ($post = $db->fetch_array($query)) { if ($post['first'] && $thread['digest'] == '-1') { showmessage('special_noaction'); } $posts[] = $post; } if (!submitcheck('banpostsubmit')) { $banid = ''; foreach ($topiclist as $id) {
if ($threadtypesnew && $typeids) { $query = DB::query("SELECT * FROM " . DB::table('forum_threadclass') . " WHERE typeid IN ({$typeids}) ORDER BY displayorder"); while ($type = DB::fetch($query)) { if ($threadtypesnew['options']['enable'][$type['typeid']]) { $threadtypesnew['types'][$type['typeid']] = $threadtypesnew['options']['name'][$type['typeid']]; } $threadtypesnew['icons'][$type['typeid']] = trim($threadtypesnew['options']['icon'][$type['typeid']]); } $threadtypesnew = $threadtypesnew['types'] ? addslashes(serialize(array('required' => (bool) $threadtypesnew['required'], 'listable' => (bool) $threadtypesnew['listable'], 'prefix' => $threadtypesnew['prefix'], 'types' => $threadtypesnew['types'], 'icons' => $threadtypesnew['icons']))) : ''; } $forumfielddata['threadtypes'] = $threadtypesnew; $threadsortsnew = $_G['gp_threadsortsnew']; if ($threadsortsnew['status']) { if (is_array($threadsortsnew['options']) && $threadsortsnew['options']) { if (!empty($threadsortsnew['options']['enable'])) { $sortids = implodeids(array_keys($threadsortsnew['options']['enable'])); } else { $sortids = '0'; } $query = DB::query("SELECT * FROM " . DB::table('forum_threadtype') . " WHERE typeid IN ({$sortids}) AND special='1' ORDER BY displayorder"); while ($sort = DB::fetch($query)) { if ($threadsortsnew['options']['enable'][$sort['typeid']]) { $threadsortsnew['types'][$sort['typeid']] = $sort['name']; } $threadsortsnew['expiration'][$sort['typeid']] = $sort['expiration']; $threadsortsnew['show'][$sort['typeid']] = $threadsortsnew['options']['show'][$sort['typeid']] ? 1 : 0; } } if ($threadsortsnew['default'] && !$threadsortsnew['defaultshow']) { cpmsg('forums_edit_threadsort_nonexistence', '', 'error'); }
foreach($directorynew as $id => $directory) { if(!$delete || ($delete && !in_array($id, $delete))) { if(!istpldir($directory)) { cpmsg('templates_directory_invalid'); } elseif($id == 1 && $directory != './templates/default') { cpmsg('templates_default_directory_invalid'); } $db->query("UPDATE {$tablepre}templates SET name='$namenew[$id]', directory='$directorynew[$id]' WHERE templateid='$id'", 'UNBUFFERED'); } } if(is_array($delete)) { if(in_array('1', $delete)) { cpmsg('templates_delete_invalid'); } $ids = implodeids($delete); $db->query("DELETE FROM {$tablepre}templates WHERE templateid IN ($ids) AND templateid<>'1'", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}styles SET templateid='1' WHERE templateid IN ($ids)", 'UNBUFFERED'); } updatecache('styles'); cpmsg('templates_update_succeed', 'admincp.php?action=templates'); } } else { $template = $db->fetch_first("SELECT * FROM {$tablepre}templates WHERE templateid='$edit'"); if(!$template) { cpmsg('undefined_action'); } elseif(!istpldir($template['directory'])) {
while($option = $db->fetch_array($query)) { $classoptions .= "<option value=\"$option[optionid]\">$option[title]</option>"; } $model = $db->fetch_first("SELECT * FROM {$tablepre}typemodels WHERE id='".intval($modelid)."'"); if(!$model) { cpmsg('undefined_action'); } $query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN (".implodeids(explode("\t", $model['customoptions'])).")"); while($modelopt = $db->fetch_array($query)){ $modeloption .= "<option value=\"$modelopt[optionid]\">$modelopt[title]</option>"; } if($model['type']) { $query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN (".implodeids(explode("\t", $model['options'])).")"); while($modelopt = $db->fetch_array($query)){ $sysoption .= "<option value=\"$modelopt[optionid]\">$modelopt[title]</option>"; } $sysoptselect = '<select name="" size="8" multiple="multiple" style="width: 50%">'.$sysoption.'</select>'; } $optselect = '<select name="" size="8" multiple="multiple" style="width: 50%" id="coptselect">'.$classoptions.'</select>'; $hoptselect = '<select name="customoptions[]" size="8" multiple="multiple" style="width: 50%" id="moptselect">'.$modeloption.'</select>'; ?> <script type="text/javascript"> function copyoption(s1, s2) { var s1 = $(s1); var s2 = $(s2);
$del = array(); $query = $db->query("SELECT pid, authorid, status, dateline, tid, anonymous FROM {$tablepre}posts WHERE pid IN($plist) AND invisible='0' AND authorid<>'0'"); while($post = $db->fetch_array($query)){ if(!$post || $post['tid'] != $tid || !$post['authorid']) { showmessage('undefined_action', NULL, 'HALTED'); } elseif(!$forum['ismoderator'] && $karmaratelimit && $timestamp - $post['dateline'] > $karmaratelimit * 3600) { showmessage('thread_rate_timelimit', NULL, 'HALTED'); } elseif($post['authorid'] == $discuz_uid || $post['anonymous'] || $post['status'] & 1) { $del[] = $post['pid']; } $p[] = $post; } $alist = array_diff($awardplist, $del); $plist = implodeids($alist); $ratetimes = ceil($credit / 5); $db->query("UPDATE {$tablepre}posts SET rate=rate+($credit), ratetimes=ratetimes+$ratetimes WHERE pid IN($plist)"); foreach($alist as $id => $aquery) { $db->query("INSERT INTO {$tablepre}ratelog (pid, uid, username, extcredits, dateline, score, reason) VALUES ('$aquery', '$discuz_uid', '$discuz_user', '$credittype', '$timestamp', '$credit', '$rate_msg')", 'UNBUFFERED'); } } if($sendmsg){ $thread = $db->fetch_first("SELECT tid, subject FROM {$tablepre}posts WHERE tid='$tid' AND first='1'"); $awardmsg = "$credit ".$extcredits[$credittype]['title']; eval("\$message = addslashes(\"".$scriptlang['dps_postawards']['pm_message']."\");"); foreach(array_unique($awardulist) as $user){ sendnotice($user, $message, 'systempm', 0, array(), 0); }
} $resultarray = array( 'redirect' => "viewthread.php?tid=$tid&page=$page", 'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_ban_post') : array()), 'modtids' => 0, 'modlog' => $thread ); procreportlog('', $pids); } } elseif($action == 'warn' && $allowwarnpost) { if(!($warnpids = implodeids($topiclist))) { showmessage('admin_warn_invalid'); } elseif(!$allowbanpost || !$tid) { showmessage('admin_nopermission', NULL, 'HALTED'); } $posts = $authors = array(); $authorwarnings = $warningauthor = $warnstatus = ''; $query = $db->query("SELECT p.pid, p.authorid, p.author, p.status, p.dateline, p.message, m.adminid FROM {$tablepre}posts p LEFT JOIN {$tablepre}members m ON p.authorid=m.uid WHERE pid IN ($warnpids) AND p.tid='$tid'"); while($post = $db->fetch_array($query)) { if($post['adminid'] == 0 || $post['adminid'] == -1) { $warnstatus = ($post['status'] & 2) || $warnstatus; $authors[$post['authorid']] = 1; $posts[] = $post; } }
</td></tr> <?php echo $advs; ?> </table> <?php echo $multipage; ?> <br /><center><input class="button" type="submit" name="advsubmit" value="<?php echo $lang['submit']; ?> "></center> </form> <?php } else { if ($advids = implodeids($delete)) { $db->query("DELETE FROM {$tablepre}advertisements WHERE advid IN ({$advids})"); } if (is_array($titlenew)) { foreach ($titlenew as $advid => $title) { $db->query("UPDATE {$tablepre}advertisements SET available='{$availablenew[$advid]}', displayorder='{$displayordernew[$advid]}', title='" . cutstr($titlenew[$advid], 50) . "' WHERE advid='{$advid}'", 'UNBUFFERED'); } } updatecache(array('settings', 'advs_archiver', 'advs_register', 'advs_index', 'advs_forumdisplay', 'advs_viewthread')); cpmsg('advertisements_update_succeed', 'admincp.php?action=adv'); } } elseif ($action == 'advadd' && in_array($type, array('headerbanner', 'footerbanner', 'text', 'thread', 'interthread', 'float', 'couplebanner', 'intercat')) || $action == 'advedit' && $advid) { if (!submitcheck('advsubmit')) { require_once DISCUZ_ROOT . './include/forum.func.php'; shownav('menu_misc_advertisements'); if ($action == 'advedit') {
function deletethreads($tids = array()) { global $db, $tablepre, $losslessdel, $creditspolicy; static $cleartable = array('threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'videos', 'debateposts', 'attachments', 'favorites', 'mythreads', 'myposts', 'subscriptions', 'typeoptionvars', 'forumrecommend'); $threadsdel = 0; if ($tids = implodeids($tids)) { $auidarray = array(); $query = $db->query("SELECT uid, attachment, dateline, thumb, remote FROM {$tablepre}attachments WHERE tid IN ({$tids})"); while ($attach = $db->fetch_array($query)) { dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); if ($attach['dateline'] > $losslessdel) { $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1; } } if ($auidarray) { updateattachcredits('-', $auidarray, $creditspolicy['postattach']); } $videoopen && videodelete($moderate, TRUE); foreach ($cleartable as $tb) { $db->query("DELETE FROM {$tablepre}{$tb} WHERE tid IN ({$tids})", 'UNBUFFERED'); } $db->query("DELETE FROM {$tablepre}threads WHERE tid IN ({$tids})"); $threadsdel = $db->affected_rows(); } return $threadsdel; }
$tag = $db->fetch_first("SELECT * FROM {$tablepre}tags WHERE tagname='{$name}'"); if ($tag['closed']) { showmessage('tag_closed'); } $count = $db->result_first("SELECT count(*) FROM {$tablepre}threadtags WHERE tagname='{$name}'"); $query = $db->query("SELECT t.*,tt.tid as tagtid FROM {$tablepre}threadtags tt LEFT JOIN {$tablepre}threads t ON t.tid=tt.tid AND t.displayorder>='0' WHERE tt.tagname='{$name}' ORDER BY lastpost DESC LIMIT {$start_limit}, {$tpp}"); $cleantid = $threadlist = array(); while ($tagthread = $db->fetch_array($query)) { if ($tagthread['tid']) { $threadlist[] = procthread($tagthread); } else { $cleantid[] = $tagthread['tagtid']; } } if ($cleantid) { $db->query("DELETE FROM {$tablepre}threadtags WHERE tagname='{$name}' AND tid IN (" . implodeids($cleantid) . ")", 'UNBUFFERED'); $cleancount = count($cleantid); if ($count > $cleancount) { $db->query("UPDATE {$tablepre}tags SET total=total-'{$cleancount}' WHERE tagname='{$name}'", 'UNBUFFERED'); } else { $db->query("DELETE FROM {$tablepre}tags WHERE tagname='{$name}'", 'UNBUFFERED'); } } $tagnameenc = rawurlencode($name); $navtitle = $name . ' - '; $multipage = multi($count, $tpp, $page, "tag.php?name={$tagnameenc}"); include template('tag_threads'); } else { $viewthreadtags = intval($viewthreadtags); $query = $db->query("SELECT tagname,total FROM {$tablepre}tags WHERE closed=0 ORDER BY total DESC LIMIT {$viewthreadtags}"); $hottaglist = array();
$filters .= '<select onchange="window.location=\'' . $BASESCRIPT . '?action=logs&operation=invite&status=\'+this.options[this.selectedIndex].value"><option value="">' . $lang['action'] . '</option><option value="">' . $lang['all'] . '</option>'; foreach (array(1, 2, 3, 4) as $s) { $filters .= '<option value="' . $s . '" ' . (!empty($status) && $s == $status ? 'selected="selected"' : '') . '>' . lang('logs_invite_status_' . $s) . '</option>'; } $filters .= '</select>'; $query = $db->query("SELECT i.*, m.username FROM {$tablepre}invites i, {$tablepre}members m\r\n\t\t\t\tWHERE i.uid=m.uid {$addstatus}\r\n\t\t\t\tORDER BY i.dateline LIMIT {$start_limit},{$tpp}"); while ($invite = $db->fetch_array($query)) { $invite['statuslog'] = $lang['logs_invite_status_' . $invite['status']]; $username = "******"space.php?uid={$invite['uid']}\">{$invite['username']}</a>"; $invite['dateline'] = gmdate('Y-n-j H:i', $invite['dateline'] + $timeoffset * 3600); $invite['expiration'] = gmdate('Y-n-j H:i', $invite['expiration'] + $timeoffset * 3600); $stats = $invite['statuslog'] . ($invite['status'] == 2 ? ' [<a href="space.php?uid=' . $invite['reguid'] . '">' . $lang['logs_invite_target'] . '</a>]' : ''); showtablerow('', array('', 'class="bold"'), array('<input type="checkbox" class="checkbox" name="delete[]" value="' . $invite[invitecode] . '" />', $username, $invite['dateline'], $invite['expiration'], $invite['inviteip'], $invite['invitecode'], $stats)); } } else { if ($deletelist = implodeids($delete)) { $db->query("DELETE FROM {$tablepre}invites WHERE invitecode IN ({$deletelist})"); } header("Location: {$boardurl}{$BASESCRIPT}?action=logs&operation=invite"); } } elseif ($operation == 'magic') { require_once DISCUZ_ROOT . './forumdata/cache/cache_magics.php'; $lpp = empty($lpp) ? 50 : $lpp; $page = max(1, intval($page)); $start_limit = ($page - 1) * $lpp; $mpurl = "{$BASESCRIPT}?action=logs&operation=magic&lpp={$lpp}"; if (in_array($opt, array('1', '2', '3', '4', '5'))) { $optadd = "AND ma.action='{$opt}'"; $mpurl .= '&opt=' . $opt; } else { $optadd = '';
if ($text) { $sqltxtsrch .= $andor; $sqltxtsrch .= $srchtype == 'fulltext' ? "(p.message LIKE '%" . str_replace('_', '\\_', $text) . "%' OR p.subject LIKE '%{$text}%')" : "t.subject LIKE '%{$text}%'"; } } $sqlsrch .= " AND ({$sqltxtsrch})"; } if ($srchuid) { $sqlsrch .= ' AND ' . ($srchtype == 'fulltext' ? 'p' : 't') . ".authorid IN ({$srchuid})"; } if (!empty($srchfrom)) { $searchfrom = ($before ? '<=' : '>=') . ($timestamp - $srchfrom); $sqlsrch .= " AND t.lastpost{$searchfrom}"; } if (!empty($specials)) { $sqlsrch .= " AND special IN (" . implodeids($special) . ")"; } $keywords = str_replace('%', '+', $srchtxt) . (trim($srchuname) ? '+' . str_replace('%', '+', $srchuname) : ''); $expiration = $timestamp + $cachelife_text; } $threads = $tids = 0; $maxsearchresults = $maxsearchresults ? intval($maxsearchresults) : 500; $query = $db->query("SELECT " . ($srchtype == 'fulltext' ? 'DISTINCT' : '') . " t.tid, t.closed, t.author {$sqlsrch} ORDER BY tid DESC LIMIT {$maxsearchresults}"); while ($thread = $db->fetch_array($query)) { if ($thread['closed'] <= 1 && $thread['author']) { $tids .= ',' . $thread['tid']; $threads++; } } $db->free_result($query); $db->query("INSERT INTO {$tablepre}searchindex (keywords, searchstring, useip, uid, dateline, expiration, threads, tids)\r\n\t\t\t\t\tVALUES ('{$keywords}', '{$searchstring}', '{$onlineip}', '{$discuz_uid}', '{$timestamp}', '{$expiration}', '{$threads}', '{$tids}')");
if($singleprem && in_array(stripslashes($usernamenew), $permusers) || !$singleprem) { $usernamenew = strip_tags($usernamenew); $logindata = addslashes(authcode($passwordnew."\t".$questionidnew."\t".$answernew, 'ENCODE', $_DCACHE['settings']['authkey'])); if($db->result_first("SELECT COUNT(*) FROM {$tablepre}myrepeats WHERE uid='$discuz_uid' AND username='******'")) { $db->query("UPDATE {$tablepre}myrepeats SET logindata='$logindata' WHERE uid='$discuz_uid' AND username='******'"); } else { $db->query("INSERT INTO {$tablepre}myrepeats (uid, username, logindata, comment) VALUES ('$discuz_uid', '$usernamenew', '$logindata', '".strip_tags($commentnew)."')"); } dsetcookie('mrn', '', -1); dsetcookie('mrd', '', -1); $usernamenew = stripslashes($usernamenew); showmessage('myrepeats:adduser_succeed', 'plugin.php?id=myrepeats:memcp'); } } elseif($op == 'update' && submitcheck('updateuser')) { if(!empty($delete)) { $db->query("DELETE FROM {$tablepre}myrepeats WHERE uid='$discuz_uid' AND username IN (".implodeids($delete).")"); } foreach($comment as $user => $v) { $db->query("UPDATE {$tablepre}myrepeats SET comment='".strip_tags($v)."' WHERE uid='$discuz_uid' AND username='******'"); } dsetcookie('mrn', '', -1); dsetcookie('mrd', '', -1); showmessage('myrepeats:updateuser_succeed', 'plugin.php?id=myrepeats:memcp'); } $username = empty($username) ? '' : htmlspecialchars(stripslashes($username)); $repeatusers = array(); $query = $db->query("SELECT * FROM {$tablepre}myrepeats WHERE uid='$discuz_uid'"); while($myrepeat = $db->fetch_array($query)) { $myrepeat['lastswitch'] = $myrepeat['lastswitch'] ? dgmdate("$dateformat $timeformat", $myrepeat['lastswitch'] + $timeoffset * 3600) : '';
$starttasks[] = $task['taskid']; } $checked = $task['available'] ? ' checked="checked"' : ''; if ($task['starttime'] && $task['endtime']) { $task['time'] = gmdate('y-m-d', $task['starttime'] + $timeoffset * 3600) . ' ~ ' . gmdate('y-m-d', $task['endtime'] + $timeoffset * 3600); } elseif ($task['starttime'] && !$task['endtime']) { $task['time'] = gmdate('y-m-d', $task['starttime'] + $timeoffset * 3600) . ' ' . lang('tasks_online'); } elseif (!$task['starttime'] && $task['endtime']) { $task['time'] = gmdate('y-m-d', $task['endtime'] + $timeoffset * 3600) . ' ' . lang('tasks_offline'); } else { $task['time'] = lang('nolimit'); } showtablerow('', array('', 'class="td25"'), array("<input type=\"text\" class=\"txt\" name=\"namenew[{$task['taskid']}]\" size=\"20\" value=\"{$task['name']}\"><input type=\"hidden\" name=\"nameold[{$task['taskid']}]\" value=\"{$task['name']}\">", "<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[{$task['taskid']}]\" value=\"1\"{$checked}><input type=\"hidden\" name=\"availableold[{$task['taskid']}]\" value=\"{$task['available']}\">", '<input type="text" class="txt" name="displayordernew[' . $task['taskid'] . ']" value="' . $task['displayorder'] . '" size="3" />', $task['newbietask'] == '1' ? lang('tasks_newbie_task') : (in_array($task['scriptname'], $custom_scripts) ? $custom_types[$task['scriptname']]['name'] : lang('nav_task_' . $task['scriptname'])), $reward, $task['time'] . '<input type="hidden" name="newbietasknew[' . $task['taskid'] . ']" value="' . $task['newbietask'] . '"><input type="hidden" name="scriptnamenew[' . $task['taskid'] . ']" value="' . $task['scriptname'] . '">', "<a href=\"{$BASESCRIPT}?action=tasks&operation=edit&id={$task['taskid']}\" class=\"act\">{$lang['edit']}</a>", $task['newbietask'] == '1' ? '' : "<a href=\"{$BASESCRIPT}?action=tasks&operation=delete&id={$task['taskid']}\" class=\"act\">{$lang['delete']}</a>")); } if ($starttasks) { $db->query("UPDATE {$tablepre}tasks SET available='2' WHERE taskid IN (" . implodeids($starttasks) . ")", 'UNBUFFERED'); } showsubmit('tasksubmit', 'submit'); showtablefooter(); showformfooter(); } else { $checksettingsok = TRUE; if (is_array($namenew)) { foreach ($namenew as $id => $name) { $availablenew[$id] = $availablenew[$id] && (!$starttimenew[$id] || $starttimenew[$id] <= $timestamp) && (!$endtimenew[$id] || $endtimenew[$id] > $timestamp) ? 2 : $availablenew[$id]; if ($newbietasknew[$id] && $availablenew[$id]) { switch (substr($scriptnamenew[$id], 7)) { case 'post_reply': $checkid = 'threadid'; break; case 'post_newthread':
updatemodworks('MOD', $db->affected_rows()); $db->query("UPDATE {$tablepre}posts SET invisible='-1' WHERE tid IN ({$recyclebintids})"); updatemodlog($recyclebintids, 'DEL'); } $query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ({$deletetids})"); while ($attach = $db->fetch_array($query)) { dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); } $db->query("DELETE FROM {$tablepre}threads WHERE tid IN ({$deletetids})", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}posts WHERE tid IN ({$deletetids})", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ({$deletetids})"); $db->query("DELETE FROM {$tablepre}polls WHERE tid IN ({$deletetids})", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}trades WHERE tid IN ({$deletetids})", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ({$deletetids})", 'UNBUFFERED'); } if ($validatetids = implodeids($moderation['validate'])) { $tids = $comma = $comma2 = ''; $authoridarray = $moderatedthread = array(); $query = $db->query("SELECT t.fid, t.tid, t.authorid, t.subject, t.author, t.dateline FROM {$tablepre}threads t\r\n\t\t\t\tWHERE t.tid IN ({$validatetids}) AND t.displayorder='{$pstat}' AND " . ($modfidsadd ? "t.{$modfidsadd}" : '1')); while ($thread = $db->fetch_array($query)) { $tids .= $comma . $thread['tid']; $comma = ','; if ($thread['postcredits']) { updatepostcredits('+', $thread['authorid'], $forum['postcredits']); } else { $authoridarray[] = $thread['authorid']; } $validatedthreads[] = $thread; if ($reason != '' && $thread['authorid']) { $pmlist[] = array('act' => 'modthreads_validate_', 'authorid' => $thread['authorid'], 'tid' => $thread['tid'], 'thread' => $thread['subject'], 'reason' => dhtmlspecialchars($reason)); }
function checkmasks($return = FALSE) { global $insenz, $db, $tablepre, $admins, $members, $noneexistusers, $member; if (!($admins = trim($admins))) { $return ? cpmsg('insenz_require_one_admin') : insenz_alert('insenz_require_one_admin', 'admins'); } else { $admins = array_unique(explode("\n", str_replace(array("\r\n", "\r"), array("\n", "\n"), $admins))); } $admin_masks = $member_masks = array(); $query = $db->query("SELECT uid, username, adminid FROM {$tablepre}members WHERE username IN ('" . implode("','", $admins) . "')"); while ($member = $db->fetch_array($query)) { if ($member['adminid'] <= 0) { $return ? cpmsg('insenz_illegal_admin') : insenz_alert('insenz_illegal_admin', 'admins'); } $admin_masks[$member['uid']] = addslashes($member['username']); } if ($noneexistusers = array_diff($admins, $admin_masks)) { $noneexistusers = stripslashes(implode(', ', $noneexistusers)); $return ? cpmsg('insenz_user_not_exists') : insenz_alert('insenz_user_not_exists', 'admins'); } $members = array_unique(explode("\n", str_replace(array("\r\n", "\r"), array("\n", "\n"), trim($members)))); if (count($members) < 2) { $return ? cpmsg('insenz_require_two_normal_poster') : insenz_alert('insenz_require_two_normal_poster', 'members'); } $query = $db->query("SELECT uid, username, adminid FROM {$tablepre}members WHERE username IN ('" . implode("','", $members) . "')"); while ($member = $db->fetch_array($query)) { if ($member['adminid'] > 0) { $return ? cpmsg('insenz_not_normal_user') : insenz_alert('insenz_not_normal_user', 'members'); } $member_masks[$member['uid']] = addslashes($member['username']); } if ($noneexistusers = array_diff($members, $member_masks)) { $noneexistusers = stripslashes(implode(', ', $noneexistusers)); $return ? cpmsg('insenz_user_not_exists') : insenz_alert('insenz_user_not_exists', 'members'); } $modified = $insenz['admin_masks'] != $admin_masks || $insenz['member_masks'] != $member_masks; if (INSENZ_SAFEMODE && $insenz['member_masks'] != $member_masks) { if (!empty($insenz['groupid'])) { $query = $db->query("SELECT COUNT(*) FROM {$tablepre}usergroups WHERE groupid='{$insenz['groupid']}'"); if (!$db->result($query, 0)) { unset($insenz['groupid']); } } if (empty($insenz['groupid'])) { $query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type='member' ORDER BY creditslower DESC LIMIT 5"); $groups = array(); while ($group = $db->fetch_array($query)) { $groups[$group['groupid']] = $group['grouptitle']; } $randgid = array_rand($groups); $grouptitle = $groups[$randgid] ? $groups[$randgid] : 'Member'; $query = $db->query("SELECT * FROM {$tablepre}usergroups WHERE groupid='{$randgid}'"); $fieldnums = mysql_num_fields($query); $group = $db->fetch_array($query); $fields = ''; for ($i = 0; $i < $fieldnums; $i++) { $field = mysql_field_name($query, $i); if (!in_array($field, array('groupid', 'type', 'grouptitle', 'allowpost', 'allowreply'))) { $fields .= ", {$field}='{$group[$field]}'"; } } $db->query("INSERT INTO {$tablepre}usergroups SET type='special', grouptitle='{$grouptitle}', allowpost='1', allowreply='1' {$fields}"); $insenz['groupid'] = $db->insert_id(); require_once DISCUZ_ROOT . './include/cache.func.php'; updatecache('usergroups'); } $db->query("UPDATE {$tablepre}members SET adminid=-1, groupid='{$insenz['groupid']}' WHERE uid IN (" . implodeids(array_keys($member_masks)) . ")"); } $insenz['admin_masks'] = $admin_masks; $insenz['member_masks'] = $member_masks; if ($return) { return $modified; } }
} updateprompt('myinvite', $discuz_uid, 0); $multi = multi($count, $tpp, $page, "userapp.php?script=notice&action=invite"); } else { $page = isset($page) ? max(1, intval($page)) : 1; $start_limit = ($page - 1) * $tpp; $noticeids = array(); $count = $db->result_first("SELECT count(*) FROM {$tablepre}mynotice WHERE uid='$discuz_uid'"); $query = $db->query("SELECT * FROM {$tablepre}mynotice WHERE uid='$discuz_uid' ORDER BY dateline DESC LIMIT $start_limit,$tpp"); while($value = $db->fetch_array($query)) { $value['dateline'] = dgmdate("$dateformat $timeformat", $value['dateline'] + $timeoffset * 3600); $list[] = $value; $noticeids[] = $value['id']; } if($noticeids) { $db->query("UPDATE {$tablepre}mynotice SET new='0' WHERE id IN (".implodeids($noticeids).")"); updateprompt('mynotice', $discuz_uid, 0); } $multi = multi($count, $tpp, $page, "userapp.php?script=notice"); } include template('manyou_notice'); ?>
showformheader('attach', '', 'attachmentforum'); showhiddenfields(array('page' => $page, 'nomatched' => $nomatched, 'inforum' => $inforum, 'sizeless' => $sizeless, 'sizemore' => $sizemore, 'dlcountless' => $dlcountless, 'dlcountmore' => $dlcountmore, 'daysold' => $daysold, 'filename' => $filename, 'keywords' => $keywords, 'author' => $author)); echo '<input type="submit" name="searchsubmit" value="' . lang('submit') . '" class="btn" style="display: none" />'; showformfooter(); showformheader('attach&frame=no', 'target="attachmentframe"'); showtableheader(); showsubtitle(array('', 'filename', 'attach_path', 'author', 'attach_thread', 'size', 'attach_downloadnums', '')); echo $attachments; showsubmit('deletesubmit', 'submit', 'del', '<a href="###" onclick="$(\'admin\').style.display=\'none\';$(\'search\').style.display=\'\';" class="act lightlink normal">' . lang('research') . '</a>', $multipage); showtablefooter(); showformfooter(); echo '<iframe name="attachmentframe" style="display:none"></iframe>'; showtagfooter('div'); } } else { if ($ids = implodeids($delete)) { $tids = $pids = 0; $query = $db->query("SELECT tid, pid, attachment, thumb, remote FROM {$tablepre}attachments WHERE aid IN ({$ids})"); while ($attach = $db->fetch_array($query)) { dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); $tids .= ',' . $attach['tid']; $pids .= ',' . $attach['pid']; } $db->query("DELETE FROM {$tablepre}attachments WHERE aid IN ({$ids})"); $db->query("DELETE FROM {$tablepre}attachmentfields WHERE aid IN ({$ids})"); $attachtids = 0; $query = $db->query("SELECT tid FROM {$tablepre}attachments WHERE tid IN ({$tids}) GROUP BY tid ORDER BY pid DESC"); while ($attach = $db->fetch_array($query)) { $attachtids .= ',' . $attach['tid']; } $db->query("UPDATE {$tablepre}threads SET attachment='0' WHERE tid IN ({$tids})" . ($attachtids ? " AND tid NOT IN ({$attachtids})" : NULL));
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\r\n\t\t\t\tINNER JOIN {$tablepre}attachments a ON a.pid=p.pid AND a.isimage IN ('1', '-1') AND a.width>='{$imgw}'\r\n\t\t\t\tWHERE 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 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); } } }
$settingsnew['seccodedata']['width'] = $settingsnew['seccodedata']['width'] < 100 ? 100 : ($settingsnew['seccodedata']['width'] > 200 ? 200 : $settingsnew['seccodedata']['width']); $settingsnew['seccodedata']['height'] = $settingsnew['seccodedata']['height'] < 50 ? 50 : ($settingsnew['seccodedata']['height'] > 80 ? 80 : $settingsnew['seccodedata']['height']); } else { $settingsnew['seccodedata']['width'] = 85; $settingsnew['seccodedata']['height'] = 25; } $settingsnew['seccodedata']['loginfailedcount'] = !empty($settingsnew['seccodedata']['loginfailedcount']) ? 3 : 0; $settingsnew['seccodedata'] = addslashes(serialize($settingsnew['seccodedata'])); } if (isset($settingsnew['allowviewuserthread'])) { $settingsnew['allowviewuserthread'] = addslashes(serialize($settingsnew['allowviewuserthread'])); } if ($operation == 'sec') { $settingsnew['seccodestatus'] = bindec(intval($settingsnew['seccodestatus'][5]) . intval($settingsnew['seccodestatus'][4]) . intval($settingsnew['seccodestatus'][3]) . intval($settingsnew['seccodestatus'][2]) . intval($settingsnew['seccodestatus'][1])); if (is_array($delete)) { $db->query("DELETE FROM\t{$tablepre}itempool WHERE id IN (" . implodeids($delete) . ")"); } if (is_array($question)) { foreach ($question as $key => $q) { $q = trim($q); $a = cutstr(dhtmlspecialchars(trim($answer[$key])), 50); if ($q !== '' && $a !== '') { $db->query("UPDATE {$tablepre}itempool SET question='{$q}', answer='{$a}' WHERE id='{$key}'"); } } } if (is_array($newquestion) && is_array($newanswer)) { foreach ($newquestion as $key => $q) { $q = trim($q); $a = cutstr(dhtmlspecialchars(trim($newanswer[$key])), 50); if ($q !== '' && $a !== '') {