コード例 #1
0
 function apiGetNewPost($uid, $limit = 10)
 {
     $FTParams = array('numid_id' => $uid, 'num_limit' => $limit);
     if ($this->_FTHelper($FTParams)) {
         $Query = "SELECT `pid`,`fid`,`tid`,`author`,`authorid`,`subject`,`message` FROM " . DB::table(getposttable('p')) . " WHERE `authorid`='" . $uid . "' AND `first`=1 ORDER BY `pid` DESC LIMIT " . $limit;
         $RS = $this->_DBHelper($Query, 3);
         if ($RS) {
             //去除同步提示信息
             foreach ($RS as $key => $row) {
                 $RS[$key]['message'] = preg_replace("|(\n\n)?\\[size=2\\]\\[color=gray\\] \\[img\\](.*?)\\[/url\\]\\[/color\\]\\[/size\\]\$|", '', $row['message']);
             }
             $this->rst = $RS;
         }
     }
     $this->_LogHelper($this->apiRoute . '/apiGetNewPost');
     return array('rst' => $this->rst, 'errno' => $this->errno, 'err' => $this->err);
 }
コード例 #2
0
 function csc($task = array())
 {
     global $_G;
     $taskvars = array('num' => 0);
     $query = DB::query("SELECT variable, value FROM " . DB::table('common_taskvar') . " WHERE taskid='{$task['taskid']}'");
     while ($taskvar = DB::fetch($query)) {
         if ($taskvar['value']) {
             $taskvars[$taskvar['variable']] = $taskvar['value'];
         }
     }
     $taskvars['num'] = $taskvars['num'] ? $taskvars['num'] : 1;
     $tbladd = $sqladd = '';
     if ($taskvars['act'] == 'newreply' && $taskvars['threadid']) {
         $sqladd .= " AND p.tid='{$taskvars['threadid']}'";
     } else {
         if ($taskvars['forumid']) {
             $sqladd .= " AND p.fid='{$taskvars['forumid']}'";
         }
         if ($taskvars['author']) {
             $taskvars['authorid'] = DB::result_first("SELECT uid FROM " . DB::table('common_member') . " WHERE username='******'author']) . "'");
             $tbladd .= ", " . DB::table('forum_thread') . " 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 " . DB::table(getposttable()) . " p {$tbladd} WHERE p.authorid='{$_G['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);
     }
 }
コード例 #3
0
    $allposttalbe[] = 'forum_post_' . $i;
    $i++;
}
loadcache('threadtableids');
foreach ($_G['cache']['threadtableids'] as $value) {
    $allthreadtalbe[] = 'forum_thread_' . $value;
}
showtipss($toolslang['cleardbtips']);
if (submitcheck('clearpostsubmit', 1)) {
    $id = getmaxmin(getposttable('primary'), 'pid');
    if ($_G['gp_start'] == 0) {
        $_G['gp_start'] = $id['min'];
    }
    $start = $_G['gp_start'];
    $end = $_G['gp_start'] + $rpp;
    $posttable = getposttable('primary');
    $query = DB::query("SELECT pid,tid FROM " . DB::table($posttable) . " WHERE pid >= {$start} AND pid < {$end}");
    //note
    while ($post = DB::fetch($query)) {
        $tid = DB::result_first("SELECT tid FROM " . DB::table('forum_thread') . " WHERE tid='" . $post['tid'] . "'");
        foreach ($allthreadtalbe as $value) {
            $tid = $tid || DB::result_first("SELECT tid FROM " . DB::table($value) . " WHERE tid='" . $post['tid'] . "'");
        }
        if (!$tid) {
            $rows++;
            DB::delete($posttable, "pid = {$post['pid']}");
        }
    }
    $nextlink = "action=plugins&cp=aboutdb&pmod=maintain&identifier=tools&operation={$operation}&do={$do}&start={$end}&rows={$rows}&clearpostsubmit=yes&rpp={$rpp}";
    if ($end <= $id['max'] + 1) {
        cpmsg("{$lang['counter_forum']}: " . cplang('counter_processing', array('current' => $start, 'next' => $end)), $nextlink, 'loading');
コード例 #4
0
ファイル: table_forum_thread.php プロジェクト: renning/html
 private function make_special_condition($special, $authorid = 0, $replies = 0, $displayorder = null, $subject = '', $join = 0, $tableid = 0)
 {
     $wherearr = $condition = array();
     $parameter = array($this->get_table_name($tableid));
     if ($authorid && !$join) {
         $authorid = dintval($authorid, true);
         $parameter[] = $authorid;
         $wherearr[] = is_array($authorid) && $authorid ? 't.authorid IN(%n)' : 't.authorid=%d';
     }
     $parameter[] = $special;
     $wherearr[] = 't.special=%d';
     if ($replies) {
         $parameter[] = $replies;
         $wherearr[] = 't.replies>=%d';
     }
     if ($displayorder !== null) {
         $parameter[] = $displayorder;
         $wherearr[] = 't.displayorder>=%d';
     }
     if (!empty($subject)) {
         $parameter[] = '%' . $subject . '%';
         $wherearr[] = "subject LIKE %s";
     }
     if ($join) {
         if ($special == 1) {
             $parameter[] = $authorid;
             $wherearr[] = 'p.uid=%d';
             $wherearr[] = 'p.tid = t.tid';
             $condition['jointable'] = ', ' . DB::table('forum_pollvoter') . ' p ';
         } elseif ($special == 5) {
             $parameter[] = $authorid;
             $wherearr[] = 'p.authorid=%d';
             $wherearr[] = 'p.first=0';
             $wherearr[] = 'p.tid = t.tid';
             $posttable = getposttable();
             $condition['jointable'] = ', ' . DB::table($posttable) . ' p ';
         }
     }
     $condition['parameter'] = $parameter;
     $condition['where'] = ' WHERE ' . implode(' AND ', $wherearr);
     return $condition;
 }
コード例 #5
0
ファイル: misc_ranklist.php プロジェクト: pan289091315/Discuz
function getranklist_member_post($num, $orderby)
{
    global $_G;
    $timestamp = TIMESTAMP;
    $posts = array();
    $timelimit = 0;
    if ($orderby == 'digestposts') {
        $sql = "SELECT m.username, m.uid, mc.digestposts AS posts\n\t\tFROM " . DB::table('common_member') . " m\n\t\tLEFT JOIN " . DB::table('common_member_count') . " mc ON mc.uid=m.uid WHERE mc.digestposts>0\n\t\tORDER BY mc.digestposts DESC LIMIT 0, {$num}";
    } elseif ($orderby == 'thismonth') {
        $timelimit = $timestamp - 86400 * 30;
    } elseif ($orderby == 'today') {
        $timelimit = $timestamp - 86400;
    } else {
        $sql = "SELECT m.username, m.uid, mc.posts\n\t\tFROM " . DB::table('common_member') . " m\n\t\tLEFT JOIN " . DB::table('common_member_count') . " mc ON mc.uid=m.uid WHERE\tmc.posts>0\n\t\tORDER BY mc.posts DESC LIMIT 0, {$num}";
    }
    if ($timelimit) {
        $sql = "SELECT DISTINCT(author) AS username, authorid AS uid, COUNT(pid) AS posts\n\t\tFROM " . DB::table(getposttable()) . " WHERE dateline>='{$timelimit}' AND invisible='0' AND authorid>'0'\n\t\tGROUP BY author\n\t\tORDER BY posts DESC LIMIT 0, {$num}";
    }
    $query = DB::query($sql);
    while ($result = DB::fetch($query)) {
        $posts[] = $result;
    }
    return $posts;
}
コード例 #6
0
ファイル: post_editpost.php プロジェクト: kleitz/sports
     }
     if ($threadimageaid) {
         if (!$threadimage) {
             $threadimage = DB::fetch_first("SELECT attachment, remote FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE tid='{$_G['tid']}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1");
         }
         DB::delete('forum_threadimage', "tid='{$_G['tid']}'");
         $threadimage = daddslashes($threadimage);
         DB::insert('forum_threadimage', array('tid' => $_G['tid'], 'attachment' => $threadimage['attachment'], 'remote' => $threadimage['remote']));
     }
 }
 $feed = array();
 if ($special == 127) {
     $message .= chr(0) . chr(0) . chr(0) . $specialextra;
 }
 if ($_G['forum_auditstatuson'] && $audit == 1) {
     DB::query("UPDATE " . DB::table(getposttable($thread['posttableid'])) . " SET status='4' WHERE pid='{$pid}' AND status='0' AND invisible='-2'");
     updatepostcredits('+', $orig['authorid'], $isfirstpost ? 'post' : 'reply', $_G['fid']);
     updatemodworks('MOD', 1);
     updatemodlog($_G['tid'], 'MOD');
 }
 $displayorder = $pinvisible = 0;
 if ($isfirstpost) {
     $displayorder = $modnewthreads ? -2 : $thread['displayorder'];
     $pinvisible = $modnewthreads ? -2 : (empty($_G['gp_save']) ? 0 : -3);
     if ($thread['displayorder'] == -4 && empty($_G['gp_save'])) {
         DB::query("UPDATE " . DB::table($posttable) . " SET dateline='{$_G['timestamp']}', invisible='0' WHERE tid='{$thread['tid']}'");
         DB::query("UPDATE " . DB::table('forum_thread') . " SET dateline='{$_G['timestamp']}', lastpost='{$_G['timestamp']}' WHERE tid='{$thread['tid']}'");
         $posts = $thread['replies'] + 1;
         if ($thread['replies']) {
             $dateline = $_G['timestamp'];
             $query = DB::query("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$thread['tid']}' AND first='0'");
コード例 #7
0
         my_thread_log('validate', array('tid' => $thread['tid']));
         if (getstatus($poststatus, 3) == 0) {
             updatepostcredits('+', $thread['authorid'], 'post', $thread['fid']);
             $attachcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($thread['tid'])) . " WHERE tid='{$thread['tid']}'");
             updatecreditbyaction('postattach', $thread['authorid'], array(), '', $attachcount, 1, $thread['fid']);
         }
         $forums[] = $thread['fid'];
         $validatedthreads[] = $thread;
         $pm = 'pm_' . $thread['tid'];
         if (isset($_G['gp_' . $pm]) && $_G['gp_' . $pm] != '' && $thread['authorid']) {
             $pmlist[] = array('action' => 'modthreads_validate', 'notevar' => array('tid' => $thread['tid'], 'threadsubject' => $thread['subject'], 'reason' => dhtmlspecialchars($_G['gp_' . $pm])), 'authorid' => $thread['authorid']);
         }
     }
     if ($tids) {
         $tidstr = dimplode($tids);
         $validates = DB::query("UPDATE " . DB::table(getposttable()) . " SET status='4' WHERE tid IN ({$tidstr}) AND status='0' AND invisible='-2'");
         updatepost(array('invisible' => '0'), "tid IN ({$tidstr}) AND first='1'");
         DB::query("UPDATE " . DB::table('forum_thread') . " SET displayorder='0', moderated='1' WHERE tid IN ({$tidstr})");
         $validates = DB::affected_rows();
         foreach (array_unique($forums) as $fid) {
             updateforumcount($fid);
         }
         updatemodworks('MOD', $validates);
         updatemodlog($tidstr, 'MOD');
         updatemoderate('tid', $tids, 2);
     }
 }
 if ($pmlist) {
     foreach ($pmlist as $pm) {
         notification_add($pm['authorid'], 'system', $pm['action'], $pm['notevar'], 1);
     }
コード例 #8
0
ファイル: google.php プロジェクト: vuchannguyen/vuchan
	function on_gts() {
		$xmlcontent = '';
		$threads = C::t('forum_thread')->count();

		$posts = 0;
		loadcache('posttableids');
		if($_G['cache']['posttableids']) {
			foreach($_G['cache']['posttableids'] AS $tableid) {
				$posts += DB::result_first("SELECT COUNT(*) FROM ".DB::table(getposttable($tableid))." LIMIT 1");
			}
		}
		$members = C::t('common_member')->count();
		$settings = C::t('common_setting')->fetch_all(array('bbname', 'historyposts'));
		$bbname = $settings['bbname'];
		$yesterdayposts = $settings['historyposts'];
		if(!empty($yesterdayposts)) {
			$yesterdayposts = explode("\t", $yesterdayposts);
			$yestoday = intval($yesterdayposts[0]);
			$mostpost = intval($yesterdayposts[1]);
		} else {
			$yestoday = $mostpost = 0;
		}

		$xmlcontent .= "<sitedata>\n".
		"	<bbname>".dhtmlspecialchars($bbname)."</bbname>\n".
		"	<threads>$threads</threads>\n".
		"	<posts>$posts</posts>\n".
		"	<members>$members</members>\n".
		"	<yesterdayposts>$yestoday</yesterdayposts>\n".
		"	<mostposts>$mostpost</mostposts>\n".
		"</sitedata>\n";
		echo $xmlcontent;

		echo "<forumdata>\n";
		$query = C::t('forum_forum')->fetch_all_forum_ignore_access();
		foreach($query as $forum) {
			echo "	<$forum[type]>\n".
			"		<fid>$forum[fid]</fid>\n".
			"		<fup>$forum[fup]</fup>\n".
			"		<name>".dhtmlspecialchars($forum['name'])."</name>\n".
			"		<description>".dhtmlspecialchars($forum['description'])."</description>\n".
			"		<threads>$forum[threads]</threads>\n".
			"		<posts>$forum[posts]</posts>\n".
			"		<todayposts>$forum[todayposts]</todayposts>\n".
			"	</$forum[type]>\n";
		}

		echo "</forumdata>";

	}
コード例 #9
0
ファイル: modcp_thread.php プロジェクト: v998/discuzx-en
 }
 $page = max(1, intval($_G['page']));
 $total = 0;
 $query = $multipage = '';
 if ($do == 'list') {
     $postarray = array();
     $result = $modsession->get($cachekey);
     $threadoptionselect[$result['threadoption']] = 'selected';
     if ($result['fid'] == $_G['fid']) {
         $total = $result['count'];
         $tpage = ceil($total / $_G['tpp']);
         $page = min($tpage, $page);
         $multipage = multi($total, $_G['tpp'], $page, "{$cpscript}?mod=modcp&amp;action={$_G['gp_action']}&amp;op={$op}&amp;fid={$_G['fid']}&amp;do={$do}");
         if ($total && $result['pids']) {
             $start = ($page - 1) * $_G['tpp'];
             $query = DB::query('SELECT p.*, t.subject as tsubject ' . 'FROM ' . DB::table(getposttable($result['posttableid'])) . " p LEFT JOIN " . DB::table('forum_thread') . " t USING(tid) " . "WHERE pid IN ({$result['pids']}) " . 'ORDER BY dateline DESC ' . "LIMIT {$start}, {$_G['tpp']}");
             while ($value = DB::fetch($query)) {
                 $postarray[] = $value;
             }
         }
     }
 }
 $postlist = array();
 if ($postarray) {
     require_once libfile('function/post');
     foreach ($postarray as $post) {
         $post['dateline'] = dgmdate($post['dateline']);
         $post['message'] = messagecutstr($post['message'], 200);
         $post['forum'] = $modforums['list'][$post['fid']];
         $post['modthreadkey'] = modauthkey($post['tid']);
         $postlist[] = $post;
コード例 #10
0
function deletethread($tids, $membercount = false, $credit = false, $ponly = false)
{
    global $_G;
    if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
        $_G['deletethreadtids'] =& $tids;
        $hookparam = func_get_args();
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'deletethread');
    }
    if (!$tids) {
        return 0;
    }
    require_once libfile('function/forum');
    foreach ($tids as $tid) {
        my_post_log('delete', array('tid' => $tid));
    }
    $count = count($tids);
    $tids = dimplode($tids);
    loadcache(array('threadtableids', 'posttableids'));
    $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
    $posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array('0');
    if (!in_array(0, $threadtableids)) {
        $threadtableids = array_merge(array(0), $threadtableids);
    }
    DB::delete('common_moderate', "id IN ({$tids}) AND idtype='tid'");
    $atids = $fids = $postids = $threadtables = array();
    foreach ($threadtableids as $tableid) {
        $threadtable = !$tableid ? "forum_thread" : "forum_thread_{$tableid}";
        $query = DB::query("SELECT cover, tid, fid, posttableid FROM " . DB::table($threadtable) . " WHERE tid IN ({$tids})");
        while ($row = DB::fetch($query)) {
            $atids[] = $row['tid'];
            $row['posttableid'] = !empty($row['posttableid']) && in_array($row['posttableid'], $posttableids) ? $row['posttableid'] : '0';
            $postids[$row['posttableid']][$row['tid']] = $row['tid'];
            if ($tableid) {
                $fids[$row['fid']][] = $tableid;
            }
        }
        if (!$tableid && !$ponly) {
            $threadtables[] = $threadtable;
        }
    }
    if ($credit || $membercount) {
        $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
        $postlist = $uidarray = $tuidarray = $ruidarray = array();
        foreach ($postids as $posttableid => $posttabletids) {
            $query = DB::query('SELECT tid, first, authorid, dateline, replycredit, invisible FROM ' . DB::table(getposttable($posttableid)) . ' WHERE tid IN (' . dimplode($posttabletids) . ')');
            while ($post = DB::fetch($query)) {
                if ($post['invisible'] != -1 && $post['invisible'] != -5) {
                    $postlist[] = $post;
                }
            }
        }
        $query = DB::query("SELECT tid, extcreditstype FROM " . DB::table('forum_replycredit') . " WHERE tid IN ({$tids})");
        while ($rule = DB::fetch($query)) {
            $rule['extcreditstype'] = $rule['extcreditstype'] ? $rule['extcreditstype'] : $_G['setting']['creditstransextra'][10];
            $replycredit_rule[$rule['tid']] = $rule;
        }
        foreach ($postlist as $post) {
            if ($post['dateline'] < $losslessdel) {
                if ($membercount) {
                    if ($post['first']) {
                        updatemembercount($post['authorid'], array('threads' => -1, 'post' => -1), false);
                    } else {
                        updatemembercount($post['authorid'], array('posts' => -1), false);
                    }
                }
            } else {
                if ($credit) {
                    if ($post['first']) {
                        $tuidarray[] = $post['authorid'];
                    } else {
                        $ruidarray[] = $post['authorid'];
                    }
                }
            }
            if ($credit || $membercount) {
                if ($post['authorid'] > 0 && $post['replycredit'] > 0) {
                    if ($replycredit_rule[$post['tid']]['extcreditstype']) {
                        updatemembercount($post['authorid'], array($replycredit_rule[$post['tid']]['extcreditstype'] => (int) ('-' . $post['replycredit'])));
                    }
                }
            }
        }
        if ($credit) {
            if ($tuidarray || $ruidarray) {
                require_once libfile('function/post');
            }
            if ($tuidarray) {
                updatepostcredits('-', $tuidarray, 'post', $_G['forum']['fid']);
            }
            if ($ruidarray) {
                updatepostcredits('-', $ruidarray, 'reply', $_G['forum']['fid']);
            }
            $auidarray = $attachtables = array();
            foreach ($atids as $tid) {
                $attachtables[getattachtablebytid($tid)][] = $tid;
            }
            foreach ($attachtables as $attachtable => $attachtids) {
                $query = DB::query("SELECT uid, dateline FROM " . DB::table($attachtable) . " WHERE tid IN (" . dimplode($attachtids) . ")");
                while ($attach = DB::fetch($query)) {
                    if ($attach['dateline'] > $losslessdel) {
                        $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
                    }
                }
            }
            if ($auidarray) {
                $postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach'];
                updateattachcredits('-', $auidarray, $postattachcredits);
            }
        }
    }
    if ($ponly) {
        if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
            hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
        }
        return $count;
    }
    DB::delete('forum_replycredit', "tid IN ({$tids})");
    DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN ({$tids})");
    deletethreadcover($tids);
    foreach ($threadtables as $threadtable) {
        DB::delete($threadtable, "tid IN ({$tids})");
    }
    if ($atids) {
        foreach ($postids as $posttableid => $oneposttids) {
            deletepost($oneposttids, 'tid', false, $posttableid);
        }
        deleteattach($atids, 'tid');
    }
    if ($fids) {
        foreach ($fids as $fid => $tableids) {
            $tableids = array_unique($tableids);
            foreach ($tableids as $tableid) {
                $query = DB::query("SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM " . DB::table("forum_thread_{$tableid}") . " WHERE fid='{$fid}'");
                while ($row = DB::fetch($query)) {
                    DB::insert('forum_forum_threadtable', array('fid' => $fid, 'threadtableid' => $tableid, 'threads' => intval($row['threads']), 'posts' => intval($row['posts'])), false, true);
                }
            }
        }
    }
    foreach (array('forum_forumrecommend', 'forum_polloption', 'forum_poll', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_typeoptionvar', 'forum_postposition', 'forum_poststick', 'forum_pollvoter', 'forum_threadimage') as $table) {
        DB::delete($table, "tid IN ({$tids})");
    }
    DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN ({$tids}) AND idtype='tid'", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_tagitem') . " WHERE idtype='tid' AND itemid IN ({$tids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('forum_threadrush') . " WHERE tid IN ({$tids})", 'UNBUFFERED');
    if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
    }
    return $count;
}
コード例 #11
0
         $threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ? ", lastpost='{$post['dateline']}', lastposter='" . ($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author])) . "'" : '';
         $threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : '';
         $pm = 'pm_' . $post['pid'];
         if (isset($_G['gp_' . $pm]) && $_G['gp_' . $pm] != '' && $post['authorid']) {
             $pmlist[] = array('action' => 'modreplies_validate', 'notevar' => array('pid' => $post['pid'], 'tid' => $post['tid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars($_G['gp_' . $pm])), 'authorid' => $post['authorid']);
         }
     }
     foreach ($threads as $tid => $thread) {
         DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies+{$thread['posts']} {$thread['lastpostadd']} {$thread['attachadd']} WHERE tid='{$tid}'", 'UNBUFFERED');
     }
     foreach (array_unique($forums) as $fid) {
         updateforumcount($fid);
     }
     if (!empty($pidarray)) {
         DB::query("UPDATE " . DB::table(getposttable($posttable)) . " SET status='4' WHERE pid IN (0," . implode(',', $pidarray) . ") AND status='0' AND invisible='-2'");
         DB::query("UPDATE " . DB::table(getposttable($posttable)) . " SET invisible='0' WHERE pid IN (0," . implode(',', $pidarray) . ")");
         $validates = DB::affected_rows();
         updatemodworks('MOD', $validates);
         updatemoderate('pid', $pidarray, 2);
     } else {
         updatemodworks('MOD', 1);
     }
 }
 if ($pmlist) {
     foreach ($pmlist as $pm) {
         notification_add($pm['authorid'], 'system', $pm['action'], $pm['notevar'], 1);
     }
 }
 if ($_G['gp_fast']) {
     echo callback_js($_G['gp_pid']);
     exit;
コード例 #12
0
function recommendupdate($fid, &$modrecommend, $force = '', $position = 0)
{
    global $_G;
    $recommendlist = $recommendimagelist = $modedtids = array();
    $num = $modrecommend['num'] ? intval($modrecommend['num']) : 10;
    $imagenum = $modrecommend['imagenum'] = $modrecommend['imagenum'] ? intval($modrecommend['imagenum']) : 0;
    $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 " . DB::table('forum_forumrecommend') . " WHERE fid='{$fid}'");
        while ($row = DB::fetch($query)) {
            if ($modrecommend['sort'] == 2 && $row['moderatorid']) {
                $modedtids[] = $row['tid'];
            }
        }
        DB::query("DELETE FROM " . DB::table('forum_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 " . DB::table('forum_thread') . " WHERE fid='{$fid}' AND displayorder>='0' {$conditions} ORDER BY {$orderby} DESC LIMIT 0, {$num}");
        while ($thread = DB::fetch($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 && $imagenum) {
            $attachtables = array();
            foreach ($tids as $tid) {
                $attachtables[getattachtablebytid($tid)][] = $tid;
            }
            foreach ($attachtables as $attachtable => $tids) {
                $query = DB::query('SELECT p.fid, p.tid, a.aid
							FROM ' . DB::table(getposttable()) . " p\n\t\t\t\t\t\t\tINNER JOIN " . DB::table($attachtable) . " a\n\t\t\t\t\t\t\tON a.pid=p.pid AND a.isimage IN ('1', '-1') AND a.width>='{$imgw}'" . "\n\t\t\t\t\t\t\tWHERE p.tid IN (" . dimplode($tids) . ") AND p.first='1'");
                while ($attachment = DB::fetch($query)) {
                    if (isset($recommendimagelist[$attachment['tid']])) {
                        continue;
                    }
                    $key = md5($attachment['aid'] . '|' . $imgw . '|' . $imgh);
                    $recommendlist[$attachment['tid']]['filename'] = $attachment['aid'] . "\t" . $imgw . "\t" . $imgh . "\t" . $key;
                    $recommendimagelist[$attachment['tid']] = $recommendlist[$attachment['tid']];
                    $addimg[$attachment['tid']] = ",'', '" . 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 " . DB::table('forum_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 " . DB::table('forum_forumfield') . " SET modrecommend='{$modrecommendnew}' WHERE fid='{$fid}'");
        }
    }
    $recommendlists = $recommendlist = array();
    $position = $position ? "AND position IN ('0','{$position}')" : '';
    $query = DB::query("SELECT * FROM " . DB::table('forum_forumrecommend') . " WHERE fid='{$fid}' {$position} ORDER BY displayorder");
    while ($recommend = DB::fetch($query)) {
        if ($recommend['expiration'] && $recommend['expiration'] > TIMESTAMP || !$recommend['expiration']) {
            if ($recommend['filename'] && strexists($recommend['filename'], "\t")) {
                $imgd = explode("\t", $recommend['filename']);
                if ($imgd[0] && $imgd[3]) {
                    $recommend['filename'] = 'forum.php?mod=image&aid=' . $imgd[0] . '&size=' . $imgd[1] . 'x' . $imgd[2] . '&key=' . rawurlencode($imgd[3]);
                }
            }
            $recommendlist[] = $recommend;
            if ($recommend['typeid'] && count($recommendimagelist) < $imagenum) {
                $recommendimagelist[] = $recommend;
            }
        }
        if (count($recommendlist) == $num) {
            break;
        }
    }
    if ($recommendlist) {
        $_G['forum_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: ' . $_G['forum_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;
}
コード例 #13
0
ファイル: admincp_group.php プロジェクト: pan289091315/Discuz
     DB::query("UPDATE " . DB::table('forum_forumfield') . " SET groupnum = groupnum+'-{$num}' WHERE fid='{$fup}'");
 }
 $query = DB::query("SELECT tid FROM " . DB::table('forum_thread') . " WHERE fid IN(" . dimplode($fidarray) . ") ORDER BY tid LIMIT {$start}, {$pp}");
 while ($thread = DB::fetch($query)) {
     $tids[] = $thread['tid'];
 }
 require_once libfile('function/delete');
 if ($tids) {
     deletepost($tids, 'tid');
     deletethread($tids);
     cpmsg('group_thread_removing', 'action=group&operation=managetype&optype=delete&submit=yes&confirmed=yes&fidarray=' . $_G['gp_fidarray'] . '&start=' . ($start + $pp));
 }
 loadcache('posttable_info');
 if (!empty($_G['cache']['posttable_info']) && is_array($_G['cache']['posttable_info'])) {
     foreach ($_G['cache']['posttable_info'] as $key => $value) {
         DB::query("DELETE FROM " . DB::table(getposttable($key)) . " WHERE fid IN(" . dimplode($fidarray) . ")", 'UNBUFFERED');
     }
 }
 loadcache('threadtableids');
 $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array('0');
 foreach ($threadtableids as $tableid) {
     if (!$tableid) {
         $threadtable = "forum_thread";
     } else {
         $threadtable = "forum_thread_{$tableid}";
     }
     DB::query("DELETE FROM " . DB::table($threadtable) . " WHERE fid IN(" . dimplode($fidarray) . ")", 'UNBUFFERED');
 }
 DB::query("DELETE FROM " . DB::table('forum_forumrecommend') . " WHERE fid IN(" . dimplode($fidarray) . ")", 'UNBUFFERED');
 DB::query("DELETE FROM " . DB::table('forum_forum') . " WHERE fid IN(" . dimplode($fidarray) . ")");
 DB::query("DELETE FROM " . DB::table('forum_forumfield') . " WHERE fid IN(" . dimplode($fidarray) . ")");
コード例 #14
0
ファイル: update.php プロジェクト: vuchannguyen/vuchan
		if(!$modcount) {
			$query = DB::query("SELECT tid FROM ".DB::table('forum_thread')." WHERE displayorder='-2'");
			while($row = DB::fetch($query)) {
				updatemoderate('tid', $row['tid']);
			}
			loadcache('posttable_info');
			$posttables = array();
			if(!empty($_G['cache']['posttable_info']) && is_array($_G['cache']['posttable_info'])) {
				foreach($_G['cache']['posttable_info'] as $posttableid => $data) {
					$posttables[] = $posttableid;
				}
			} else {
				$posttables[] = 0;
			}
			foreach($posttables as $postableid) {
				$query = DB::query("SELECT pid FROM ".DB::table(getposttable($postableid))." WHERE invisible='-2' AND first='0'");
				while($row = DB::fetch($query)) {
					updatemoderate('pid', $row['pid']);
				}
			}

			$query = DB::query("SELECT blogid FROM ".DB::table('home_blog')." WHERE status='1'");
			while($row = DB::fetch($query)) {
				updatemoderate('blogid', $row['blogid']);
			}
			$query = DB::query("SELECT doid FROM ".DB::table('home_doing')." WHERE status='1'");
			while($row = DB::fetch($query)) {
				updatemoderate('doid', $row['doid']);
			}
			$query = DB::query("SELECT picid FROM ".DB::table('home_pic')." WHERE status='1'");
			while($row = DB::fetch($query)) {
コード例 #15
0
ファイル: function_core.php プロジェクト: Kingson4Wu/php_demo
function getallwithposts($sqlstruct, $onlyprimarytable = false)
{
    $ptable = getposttable('p');
    $atable = getposttable('a');
    $result = array();
    $from_clause = str_replace(DB::table('forum_post'), DB::table($ptable), $sqlstruct['from']);
    $sql = "SELECT {$sqlstruct['select']} FROM {$from_clause} WHERE {$sqlstruct['where']}";
    $sqladd = '';
    if (!empty($sqlstruct['order'])) {
        $sqladd .= " ORDER BY {$sqlstruct['order']}";
    }
    if (!empty($sqlstruct['limit'])) {
        $sqladd .= " LIMIT {$sqlstruct['limit']}";
    }
    $sql = $sql . $sqladd;
    $query = DB::query($sql);
    while ($row = DB::fetch($query)) {
        $result[] = $row;
    }
    if (!$onlyprimarytable && $atable !== NULL) {
        $from_clause = str_replace(DB::table('forum_post'), DB::table($atable), $sqlstruct['from']);
        $sql = "SELECT {$sqlstruct['select']} FROM {$from_clause} WHERE {$sqlstruct['where']}";
        $sql = $sql . $sqladd;
        $query = DB::query($sql);
        while ($row = DB::fetch($query)) {
            $result[] = $row;
        }
    }
    return $result;
}
コード例 #16
0
    }
    include template('forum/topicadmin');
} else {
    $moderatetids = dimplode(array_keys($threadlist));
    $reason = checkreasonpm();
    $stampstatus = 0;
    $stampaction = 'SPA';
    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)) {
                    foreach ($posttablearr as $posttableid => $ids) {
                        $query = DB::query('SELECT * FROM ' . DB::table(getposttable($posttableid)) . ' WHERE tid IN (' . dimplode($ids) . ')');
                        while ($post = DB::fetch($query)) {
                            $post['message'] = messagecutstr($post['message'], 200);
                            $posts[$post['tid']] = $post;
                        }
                    }
                }
            }
            $updatemodlog = TRUE;
            if ($operation == 'stick') {
                $sticklevel = intval($_G['gp_sticklevel']);
                if ($sticklevel < 0 || $sticklevel > 3 || $sticklevel > $_G['group']['allowstickthread']) {
                    showmessage('no_privilege_stickthread');
                }
                $expiration = checkexpiration($_G['gp_expirationstick'], $operation);
                $expirationstick = $sticklevel ? $_G['gp_expirationstick'] : 0;
コード例 #17
0
function recyclebinpostshowpostlist($sql, $start_limit, $lpp)
{
    global $_G, $lang, $posttableid;
    $tids = $fids = array();
    $query = DB::query("SELECT message, useip, attachment, htmlon, smileyoff, bbcodeoff, pid, tid, fid, author, dateline, subject, authorid, anonymous FROM " . DB::table(getposttable($posttableid)) . "\r\n\t\tWHERE invisible='-5' {$sql} ORDER BY dateline DESC LIMIT {$start_limit}, {$lpp}");
    while ($post = DB::fetch($query)) {
        $postlist[] = $post;
    }
    if (empty($postlist)) {
        return false;
    }
    foreach ($postlist as $key => $post) {
        $tids[$post['tid']] = $post['tid'];
        $fids[$post['fid']] = $post['fid'];
    }
    $query = DB::query("SELECT tid, subject as tsubject FROM " . DB::table('forum_thread') . " WHERE tid IN (" . dimplode($tids) . ")");
    while ($thread = DB::fetch($query)) {
        $threadlist[$thread['tid']] = $thread;
    }
    $query = DB::query("SELECT fid, name AS forumname, allowsmilies, allowhtml, allowbbcode, allowimgcode FROM " . DB::table('forum_forum') . " WHERE fid IN (" . dimplode($fids) . ")");
    while ($forum = DB::fetch($query)) {
        $forumlist[$forum['fid']] = $forum;
    }
    foreach ($postlist as $key => $post) {
        $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $forumlist[$post['fid']]['allowsmilies'], $forumlist[$post['fid']]['allowbbcode'], $forumlist[$post['fid']]['allowimgcode'], $forumlist[$post['fid']]['allowhtml']);
        $post['dateline'] = dgmdate($post['dateline']);
        if ($post['attachment']) {
            require_once libfile('function/attachment');
            $queryattach = DB::query("SELECT aid, filename, filesize, attachment, isimage, remote FROM " . DB::table(getattachtablebytid($post['tid'])) . " WHERE pid='{$post['pid']}'");
            while ($attach = DB::fetch($queryattach)) {
                $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
                $attach['url'] = $attach['isimage'] ? " {$attach['filename']} (" . sizecount($attach['filesize']) . ")<br /><br /><img src=\"" . $_G['setting']['attachurl'] . "forum/{$attach['attachment']}\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">" : "<a href=\"" . $_G['setting']['attachurl'] . "forum/{$attach['attachment']}\" target=\"_blank\">{$attach['filename']}</a> (" . sizecount($attach['filesize']) . ")";
                $post['message'] .= "<br /><br />{$lang['attachment']}: " . attachtype(fileext($attach['filename']) . "\t") . $attach['url'];
            }
        }
        showtablerow("id=\"mod_{$post['pid']}_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array("<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$post['pid']}]\" id=\"mod_{$post['pid']}_1\" value=\"delete\" checked=\"checked\" /><label for=\"mod_{$post['pid']}_1\">{$lang['delete']}</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$post['pid']}]\" id=\"mod_{$post['pid']}_2\" value=\"undelete\" /><label for=\"mod_{$post['pid']}_2\">{$lang['undelete']}</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$post['pid']}]\" id=\"mod_{$post['pid']}_3\" value=\"ignore\" /><label for=\"mod_{$post['pid']}_3\">{$lang['ignore']}</label></li></ul>", "<h3><a href=\"forum.php?mod=forumdisplay&fid={$post['fid']}\" target=\"_blank\">" . $forumlist[$post['fid']]['forumname'] . "</a> &raquo; <a href=\"forum.php?mod=viewthread&tid={$post['tid']}\" target=\"_blank\">" . $threadlist[$post['tid']]['tsubject'] . "</a>" . ($post['subject'] ? ' &raquo; ' . $post['subject'] : '') . "</h3><p><span class=\"bold\">{$lang['author']}:</span> <a href=\"home.php?mod=space&uid={$post['authorid']}\" target=\"_blank\">{$post['author']}</a> &nbsp;&nbsp; <span class=\"bold\">{$lang['time']}:</span> {$post['dateline']} &nbsp;&nbsp; IP: {$post['useip']}</p>"));
        showtablerow("id=\"mod_{$post['pid']}_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:120px; word-break: break-all;">' . $post['message'] . '</div>');
        showtablerow("id=\"mod_{$post['pid']}_row3\"", 'class="threadopt threadtitle" colspan="2"', "{$lang['isanonymous']}: " . ($post['anonymous'] ? $lang['yes'] : $lang['no']) . " &nbsp;&nbsp; {$lang['ishtmlon']}: " . ($post['htmlon'] ? $lang['yes'] : $lang['no']));
    }
    return true;
}
コード例 #18
0
ファイル: search_group.php プロジェクト: v998/discuzx-en
 $index['ids'] = unserialize($index['ids']);
 $searchstring = explode('|', $index['searchstring']);
 $srchfid = $searchstring[2];
 $threadlist = $grouplist = $posttables = array();
 if ($index['ids']['thread'] && ($searchstring[2] || empty($viewgroup))) {
     require_once libfile('function/misc');
     $query = DB::query("SELECT t.*, f.name AS forumname FROM " . DB::table('forum_thread') . " t LEFT JOIN " . DB::table('forum_forum') . " f ON t.fid=f.fid WHERE t.tid IN ({$index[ids][thread]}) AND t.displayorder>='0' ORDER BY {$orderby} {$ascdesc} LIMIT {$start_limit}, {$_G['tpp']}");
     while ($thread = DB::fetch($query)) {
         $thread['subject'] = bat_highlight($thread['subject'], $keyword);
         $thread['realtid'] = $thread['tid'];
         $threadlist[$thread['tid']] = procthread($thread);
         $posttables[$thread['posttableid']][] = $thread['tid'];
     }
     if ($threadlist) {
         foreach ($posttables as $tableid => $tids) {
             $query = DB::query("SELECT tid, message FROM " . DB::table(getposttable($tableid)) . " WHERE tid IN (" . dimplode($tids) . ") AND first='1'");
             while ($post = DB::fetch($query)) {
                 $threadlist[$post['tid']]['message'] = bat_highlight(messagecutstr($post['message'], 200), $keyword);
             }
         }
     }
 }
 $groupnum = !empty($index['ids']['group']) ? count(explode(',', $index['ids']['group'])) - 1 : 0;
 if ($index['ids']['group'] && ($viewgroup || empty($searchstring[2]))) {
     if (empty($viewgroup)) {
         $index['ids']['group'] = implode(',', array_slice(explode(',', $index['ids']['group']), 0, 9));
     }
     $query = DB::query("SELECT f.*, ff.description, ff.membernum, ff.icon, ff.gviewperm, ff.jointype, ff.dateline FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON f.fid=ff.fid WHERE f.fid IN ({$index[ids][group]}) AND f.status='3' AND `type`='sub'" . ($viewgroup ? " LIMIT {$start_limit}, {$_G['tpp']}" : ''));
     while ($group = DB::fetch($query)) {
         $group['icon'] = get_groupimg($group['icon'], 'icon');
         $group['name'] = bat_highlight($group['name'], $keyword);
コード例 #19
0
ファイル: function_forum.php プロジェクト: v998/discuzx-en
function updatepost($data, $condition, $unbuffered = false, $posttableid = false)
{
    global $_G;
    loadcache('posttableids');
    $affected_rows = 0;
    if (!empty($_G['cache']['posttableids'])) {
        $posttableids = $posttableid !== false && in_array($posttableid, $_G['cache']['posttableids']) ? array($posttableid) : $_G['cache']['posttableids'];
    } else {
        $posttableids = array('0');
    }
    foreach ($posttableids as $id) {
        DB::update(getposttable($id), $data, $condition, $unbuffered);
        $affected_rows += DB::affected_rows();
    }
    return $affected_rows;
}
コード例 #20
0
ファイル: space_debate.php プロジェクト: v998/discuzx-en
     if ($_GET['view'] == 'me' && $_GET['type'] == 'reply' && $page == 1 && count($special) < 2) {
         $value['message'] = messagecutstr($value['message'], 200);
         $special[$value['tid']] = $value;
     } else {
         if ($page == 1 && count($special) < 2) {
             $tids[$value['posttableid']][$value['tid']] = $value['tid'];
             $special[$value['tid']] = $value;
         } else {
             $list[$value['tid']] = $value;
         }
     }
     $dids[$value['tid']] = $value['tid'];
 }
 if ($tids) {
     foreach ($tids as $postid => $tid) {
         $posttable = getposttable('p');
         $query = DB::query("SELECT tid, message FROM " . DB::table($posttable) . " WHERE tid IN(" . dimplode($tid) . ")");
         while ($value = DB::fetch($query)) {
             $special[$value['tid']]['message'] = messagecutstr($value['message'], 200);
         }
     }
 }
 if ($dids) {
     $query = DB::query("SELECT * FROM " . DB::table('forum_debate') . " WHERE tid IN(" . dimplode($dids) . ")");
     while ($value = DB::fetch($query)) {
         $value['negavotesheight'] = $value['affirmvotesheight'] = '8px';
         if ($value['affirmvotes'] || $value['negavotes']) {
             $allvotes = $value['affirmvotes'] + $value['negavotes'];
             $value['negavotesheight'] = round($value['negavotes'] / $allvotes * 100, 2) . '%';
             $value['affirmvotesheight'] = round($value['affirmvotes'] / $allvotes * 100, 2) . '%';
         }
コード例 #21
0
ファイル: search_forum.php プロジェクト: pan289091315/Discuz
         $num = 0;
     } else {
         $ids = implode(",", $tids);
         $num = $result['total_found'];
     }
 } else {
     $digestltd = $srchfilter == 'digest' ? "t.digest>'0' AND" : '';
     $topltd = $srchfilter == 'top' ? "AND t.displayorder>'0'" : "AND t.displayorder>='0'";
     if (!empty($srchfrom) && empty($srchtxt) && empty($srchuid) && empty($srchuname)) {
         $searchfrom = $before ? '<=' : '>=';
         $searchfrom .= TIMESTAMP - $srchfrom;
         $sqlsrch = "FROM " . DB::table('forum_thread') . " t WHERE {$digestltd} t.fid IN ({$fids}) {$topltd} AND t.lastpost{$searchfrom}";
         $expiration = TIMESTAMP + $cachelife_time;
         $keywords = '';
     } else {
         $sqlsrch = $srchtype == 'fulltext' ? "FROM " . DB::table(getposttable($seltableid)) . " p, " . DB::table('forum_thread') . " t WHERE {$digestltd} t.fid IN ({$fids}) {$topltd} AND p.tid=t.tid AND p.invisible='0'" : "FROM " . DB::table('forum_thread') . " t WHERE {$digestltd} t.fid IN ({$fids}) {$topltd}";
         if ($srchuname) {
             $srchuid = $comma = '';
             $srchuname = str_replace('*', '%', addcslashes($srchuname, '%_'));
             $query = DB::query("SELECT uid FROM " . DB::table('common_member') . " WHERE username LIKE '" . str_replace('_', '\\_', $srchuname) . "' LIMIT 50");
             while ($member = DB::fetch($query)) {
                 $srchuid .= "{$comma}'{$member['uid']}'";
                 $comma = ', ';
             }
             if (!$srchuid) {
                 $sqlsrch .= ' AND 0';
             }
         } elseif ($srchuid) {
             $srchuid = "'{$srchuid}'";
         }
         if ($srchtxt) {
コード例 #22
0
             while ($row = DB::fetch($query)) {
                 $groupsname[$row[fid]] = $row['name'];
             }
         }
         if ($postlist) {
             foreach ($postlist as $post) {
                 $posts .= showtablerow('', '', array("<input class=\"checkbox\" type=\"checkbox\" name=\"pidarray[]\" value=\"{$post['pid']}\" checked />", "<a href=\"forum.php?mod=redirect&goto=findpost&pid={$post['pid']}&ptid={$post['tid']}\" target=\"_blank\">{$post['subject']}</a>", $post['message'], "<a href=\"forum.php?mod=forumdisplay&fid={$post['fid']}\" target=\"_blank\">" . (empty($post['isgroup']) ? $_G['cache']['forums'][$post[fid]]['name'] : $groupsname[$post[fid]]) . "</a>", "<a href=\"home.php?mod=space&uid={$post['authorid']}\" target=\"_blank\">{$post['author']}</a>", $post['dateline']), TRUE);
             }
         }
         $postcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getposttable($posttable)) . " p LEFT JOIN " . DB::table('forum_thread') . " t USING(tid) WHERE 1 {$sql}");
         $multi = multi($postcount, $perpage, $page, ADMINSCRIPT . "?action=prune");
         $multi = preg_replace("/href=\"" . ADMINSCRIPT . "\\?action=prune&amp;page=(\\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
         $multi = str_replace("window.location='" . ADMINSCRIPT . "?action=prune&amp;page='+this.value", "page(this.value)", $multi);
     } else {
         $postcount = 0;
         $query = DB::query('SELECT pid FROM ' . DB::table(getposttable($posttable)) . " p LEFT JOIN " . DB::table('forum_thread') . " t USING(tid) WHERE 1 {$sql}");
         while ($post = DB::fetch($query)) {
             $pids .= ',' . $post['pid'];
             $postcount++;
         }
         $multi = '';
     }
     if (!$postcount) {
         $error = 'prune_post_nonexistence';
     }
 }
 showtagheader('div', 'postlist', $searchsubmit);
 showformheader('prune&frame=no' . ($operation ? '&operation=' . $operation : ''), 'target="pruneframe"');
 showhiddenfields(array('pids' => authcode($pids, 'ENCODE'), 'posttableid' => $posttable));
 showtableheader(cplang('prune_result') . ' ' . $postcount . ' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';$(\'pruneforum\').pp.value=\'\';$(\'pruneforum\').page.value=\'\';" class="act lightlink normal">' . cplang('research') . '</a>', 'fixpadding');
 if ($error) {
コード例 #23
0
ファイル: modcp_moderate.php プロジェクト: tang86/discuz-utf8
            }
        }
    }
    if (submitcheck('modsubmit')) {
        $updatestat = $op == 'replies' ? 1 : 2;
        $modpost = array('ignore' => count($moderation['ignore']), 'delete' => count($moderation['delete']), 'validate' => count($moderation['validate']));
    } elseif (submitcheck('dosubmit', 1)) {
        $_GET['handlekey'] = 'mods';
        $list = $moderation[$modact];
        include template('forum/modcp_moderate_float');
        dexit();
    }
}
if ($op == 'replies') {
    $posttableid = intval($_GET['posttableid']);
    $posttable = getposttable($posttableid);
    $posttableselect = getposttableselect();
    if (submitcheck('modsubmit')) {
        $pmlist = array();
        if ($ignorepids = dimplode($moderation['ignore'])) {
            C::t('forum_post')->update($posttableid, $moderation['ignore'], array('invisible' => -3), true, false, 0, -2, $modfids ? explode(',', $modfids) : null);
            updatemoderate('pid', $moderation['ignore'], 1);
        }
        if ($deletepids = dimplode($moderation['delete'])) {
            $recyclebinpids = array();
            $pids = array();
            foreach (C::t('forum_post')->fetch_all($posttableid, $moderation['delete']) as $post) {
                if ($post['invisible'] != $pstat || $post['first'] != 0 || ($modfids ? !in_array($post['fid'], explode(',', $modfids)) : 0)) {
                    continue;
                }
                if ($modforums['recyclebins'][$post['fid']]) {
コード例 #24
0
function recyclebinpostundelete($undeletepids, $posttableid = false)
{
    global $_G;
    $postsundel = 0;
    if (empty($undeletepids)) {
        return $postsundel;
    }
    foreach ($undeletepids as $pid) {
        my_post_log('restore', array('pid' => $pid));
    }
    $undeletepids = dimplode($undeletepids);
    loadcache('posttableids');
    $posttableids = !empty($_G['cache']['posttableids']) ? $posttableid !== false && in_array($posttableid, $_G['cache']['posttableids']) ? array($posttableid) : $_G['cache']['posttableids'] : array('0');
    $postarray = $ruidarray = $fidarray = $tidarray = array();
    foreach ($posttableids as $ptid) {
        $query = DB::query('SELECT fid, tid, first, authorid FROM ' . DB::table(getposttable($ptid)) . " WHERE pid IN ({$undeletepids})");
        while ($post = DB::fetch($query)) {
            $postarray[] = $post;
        }
    }
    if (empty($postarray)) {
        return $postsundel;
    }
    foreach ($postarray as $key => $post) {
        if (!$post['first']) {
            $ruidarray[] = $post['authorid'];
        }
        $fidarray[$post['fid']] = $post['fid'];
        $tidarray[$post['tid']] = $post['tid'];
    }
    $postsundel = updatepost(array('invisible' => '0'), "pid IN ({$undeletepids})", true, $posttableid);
    include_once libfile('function/post');
    if ($ruidarray) {
        updatepostcredits('+', $ruidarray, $creditspolicy['reply']);
    }
    foreach ($tidarray as $tid) {
        updatethreadcount($tid, 1);
    }
    foreach ($fidarray as $fid) {
        updateforumcount($fid);
    }
    return $postsundel;
}
コード例 #25
0
 if ($_G['group']['allowbanuser'] && DB::affected_rows()) {
     banlog($member['username'], $member['groupid'], $groupidnew, $_G['gp_banexpirynew'], $reason, $_G['gp_bannew'] == 'status' ? -1 : 0);
 }
 DB::query("UPDATE " . DB::table('common_member_field_forum') . " SET groupterms='" . ($member['groupterms'] ? addslashes(serialize($member['groupterms'])) : '') . "' WHERE uid='{$member['uid']}'");
 if ($_G['adminid'] == 1 && !empty($_G['gp_clear']) && is_array($_G['gp_clear'])) {
     require_once libfile('function/delete');
     $membercount = array();
     if (in_array('post', $_G['gp_clear'])) {
         if ($member['uid']) {
             require_once libfile('function/post');
             $tidsdelete = array();
             loadcache('posttableids');
             $posttables = empty($_G['cache']['posttableids']) ? array(0) : $_G['cache']['posttableids'];
             foreach ($posttables as $posttableid) {
                 $pidsdelete = array();
                 $query = DB::query('SELECT pid, fid, tid, first FROM ' . DB::table(getposttable($posttableid)) . " WHERE authorid='{$member['uid']}'");
                 while ($post = DB::fetch($query)) {
                     $prune['forums'][] = $post['fid'];
                     $prune['thread'][$post['tid']]++;
                     if ($post['first']) {
                         $tidsdelete[] = $post['tid'];
                     }
                     $pidsdelete[] = $post['pid'];
                 }
                 deletepost($pidsdelete, 'pid', false, $posttableid);
             }
             deletethread($tidsdelete);
             if (!empty($prune)) {
                 foreach ($prune['thread'] as $tid => $decrease) {
                     updatethreadcount($tid);
                 }
コード例 #26
0
ファイル: post_newthread.php プロジェクト: v998/discuzx-en
    if (!$_G['forum']['postperm'] && !$_G['group']['allowpost']) {
        showmessage('postperm_none_nopermission', NULL, array(), array('login' => 1));
    } elseif ($_G['forum']['postperm'] && !forumperm($_G['forum']['postperm'])) {
        showmessagenoperm('postperm', $_G['fid'], $_G['forum']['formulaperm']);
    }
} elseif ($_G['forum']['allowpost'] == -1) {
    showmessage('post_forum_newthread_nopermission', NULL);
}
if (!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum'])) {
    showmessage('postperm_login_nopermission', NULL, array(), array('login' => 1));
}
checklowerlimit('post', 0, 1, $_G['forum']['fid']);
if (!submitcheck('topicsubmit', 0, $seccodecheck, $secqaacheck)) {
    $savethreads = array();
    $savethreadothers = array();
    $query = DB::query("SELECT dateline, fid, tid, pid, subject FROM " . DB::table(getposttable()) . " WHERE authorid='{$_G['uid']}' AND invisible='-3' AND first='1'");
    while ($savethread = DB::fetch($query)) {
        $savethread['dateline'] = dgmdate($savethread['dateline'], 'u');
        if ($_G['fid'] == $savethread['fid']) {
            $savethreads[] = $savethread;
        } else {
            $savethreadothers[] = $savethread;
        }
    }
    $savethreadcount = count($savethreads);
    $savethreadothercount = count($savethreadothers);
    if ($savethreadothercount) {
        loadcache('forums');
    }
    $savecount = $savethreadcount + $savethreadothercount;
    unset($savethread);
コード例 #27
0
ファイル: space_thread.php プロジェクト: tang86/discuz-utf8
     } elseif ($filter == 'aduit') {
         $displayorder = -2;
     } elseif ($filter == 'ignored') {
         $displayorder = -3;
     } elseif ($filter == 'save') {
         $displayorder = -4;
     } elseif ($filter == 'close') {
         $closed = 1;
     } elseif ($filter == 'common') {
         $closed = 0;
         $displayorder = 0;
         $dglue = '>=';
     }
     $ordersql = 't.tid DESC';
 } elseif ($viewtype == 'postcomment') {
     $posttable = getposttable();
     require_once libfile('function/post');
     $pids = $tids = array();
     $postcommentarr = C::t('forum_postcomment')->fetch_all_by_authorid($_G['uid'], $start, $perpage);
     foreach ($postcommentarr as $value) {
         $pids[] = $value['pid'];
         $tids[] = $value['tid'];
     }
     $pids = C::t('forum_post')->fetch_all(0, $pids);
     $tids = C::t('forum_thread')->fetch_all($tids);
     $list = $fids = array();
     foreach ($postcommentarr as $value) {
         $value['authorid'] = $pids[$value['pid']]['authorid'];
         $value['fid'] = $pids[$value['pid']]['fid'];
         $value['invisible'] = $pids[$value['pid']]['invisible'];
         $value['dateline'] = $pids[$value['pid']]['dateline'];
コード例 #28
0
ファイル: uc.php プロジェクト: imnpc/discuzx-php7-patch
 function renameuser($get, $post)
 {
     global $_G;
     if (!API_RENAMEUSER) {
         return API_RETURN_FORBIDDEN;
     }
     $tables = array('common_block' => array('id' => 'uid', 'name' => 'username'), 'common_invite' => array('id' => 'fuid', 'name' => 'fusername'), 'common_member_verify_info' => array('id' => 'uid', 'name' => 'username'), 'common_mytask' => array('id' => 'uid', 'name' => 'username'), 'common_report' => array('id' => 'uid', 'name' => 'username'), 'forum_thread' => array('id' => 'authorid', 'name' => 'author'), 'forum_activityapply' => array('id' => 'uid', 'name' => 'username'), 'forum_groupuser' => array('id' => 'uid', 'name' => 'username'), 'forum_pollvoter' => array('id' => 'uid', 'name' => 'username'), 'forum_post' => array('id' => 'authorid', 'name' => 'author'), 'forum_postcomment' => array('id' => 'authorid', 'name' => 'author'), 'forum_ratelog' => array('id' => 'uid', 'name' => 'username'), 'home_album' => array('id' => 'uid', 'name' => 'username'), 'home_blog' => array('id' => 'uid', 'name' => 'username'), 'home_clickuser' => array('id' => 'uid', 'name' => 'username'), 'home_docomment' => array('id' => 'uid', 'name' => 'username'), 'home_doing' => array('id' => 'uid', 'name' => 'username'), 'home_feed' => array('id' => 'uid', 'name' => 'username'), 'home_feed_app' => array('id' => 'uid', 'name' => 'username'), 'home_friend' => array('id' => 'fuid', 'name' => 'fusername'), 'home_friend_request' => array('id' => 'fuid', 'name' => 'fusername'), 'home_notification' => array('id' => 'authorid', 'name' => 'author'), 'home_pic' => array('id' => 'uid', 'name' => 'username'), 'home_poke' => array('id' => 'fromuid', 'name' => 'fromusername'), 'home_share' => array('id' => 'uid', 'name' => 'username'), 'home_show' => array('id' => 'uid', 'name' => 'username'), 'home_specialuser' => array('id' => 'uid', 'name' => 'username'), 'home_visitor' => array('id' => 'vuid', 'name' => 'vusername'), 'portal_article_title' => array('id' => 'uid', 'name' => 'username'), 'portal_comment' => array('id' => 'uid', 'name' => 'username'), 'portal_topic' => array('id' => 'uid', 'name' => 'username'), 'portal_topic_pic' => array('id' => 'uid', 'name' => 'username'));
     if (!C::t('common_member')->update($get['uid'], array('username' => $get[newusername])) && isset($_G['setting']['membersplit'])) {
         C::t('common_member_archive')->update($get['uid'], array('username' => $get[newusername]));
     }
     loadcache("posttableids");
     if ($_G['cache']['posttableids']) {
         foreach ($_G['cache']['posttableids'] as $tableid) {
             $tables[getposttable($tableid)] = array('id' => 'authorid', 'name' => 'author');
         }
     }
     foreach ($tables as $table => $conf) {
         DB::query("UPDATE " . DB::table($table) . " SET `{$conf['name']}`='{$get['newusername']}' WHERE `{$conf['id']}`='{$get['uid']}'");
     }
     return API_RETURN_SUCCEED;
 }
コード例 #29
0
ファイル: admincp_postsplit.php プロジェクト: v998/discuzx-en
function movedate($query)
{
    global $sourcesize, $tableid, $movesize, $targettableid, $hash, $tableindex, $threadtableids, $fieldstr, $fromtableid, $posttable_info;
    $tids = array();
    while ($value = DB::fetch($query)) {
        $tids[$value['tid']] = $value['tid'];
    }
    $fromtable = getposttable($fromtableid, true);
    $condition = " tid IN(" . dimplode($tids) . ")";
    DB::query("INSERT INTO " . DB::table(getposttable($targettableid)) . " ({$fieldstr}) SELECT {$fieldstr} FROM {$fromtable} WHERE {$condition}", 'SILENT');
    if (DB::errno()) {
        DB::delete(getposttable($targettableid), $condition);
    } else {
        foreach ($threadtableids as $threadtableid) {
            $table = $threadtableid ? "forum_thread_{$threadtableid}" : 'forum_thread';
            DB::update($table, array('posttableid' => $targettableid), $condition);
            if (DB::affected_rows() == count($tids)) {
                break;
            }
        }
        DB::delete(getposttable($fromtableid), $condition);
    }
    $status = gettablestatus(DB::table(getposttable($targettableid)), false);
    $targetsize = $sourcesize + $movesize * 1048576;
    $nowdatasize = $targetsize - $status['Data_length'];
    if ($status['Data_length'] >= $targetsize) {
        cpmsg('postsplit_done', 'action=postsplit&operation=optimize&tableid=' . $fromtableid, 'form');
    }
    cpmsg('postsplit_doing', 'action=postsplit&operation=movepost&fromtable=' . $tableid . '&movesize=' . $movesize . '&targettable=' . $targettableid . '&hash=' . $hash . '&tindex=' . $tableindex, 'loadingform', array('datalength' => sizecount($status['Data_length']), 'nowdatalength' => sizecount($nowdatasize)));
}
コード例 #30
0
function getotherinfo($aids, $pids, $tids, $taskids, $uids)
{
    global $_G;
    $otherinfo = array('attachs' => array(), 'threads' => array(), 'tasks' => array(), 'users' => array());
    if (!empty($aids)) {
        $query = DB::query("SELECT * FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($aids) . ")");
        while ($value = DB::fetch($query)) {
            $value['tableid'] = intval($value['tableid']);
            $attachtable[$value['tableid']][] = $value['aid'];
            $tids[$value['tid']] = $value['tid'];
        }
        foreach ($attachtable as $id => $value) {
            $query = DB::query("SELECT * FROM " . DB::table('forum_attachment_' . $id) . " WHERE aid IN (" . dimplode($value) . ")");
            while ($value = DB::fetch($query)) {
                $otherinfo['attachs'][$value['aid']] = $value;
            }
        }
    }
    if (!empty($pids)) {
        $query = DB::query("SELECT * FROM " . DB::table(getposttable()) . " WHERE pid IN (" . dimplode($pids) . ")");
        while ($value = DB::fetch($query)) {
            $tids[$value['tid']] = $value['tid'];
            $otherinfo['post'][$value['pid']] = $value['tid'];
        }
    }
    if (!empty($tids)) {
        $query = DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid IN (" . dimplode($tids) . ")");
        while ($value = DB::fetch($query)) {
            $otherinfo['threads'][$value['tid']] = $value;
        }
    }
    if (!empty($taskids)) {
        $query = DB::query("SELECT taskid,name FROM " . DB::table('common_task') . " WHERE taskid IN (" . dimplode($taskids) . ")");
        while ($value = DB::fetch($query)) {
            $otherinfo['tasks'][$value['taskid']] = $value['name'];
        }
    }
    if (!empty($uids)) {
        $query = DB::query("SELECT uid,username FROM " . DB::table('common_member') . " WHERE uid IN (" . dimplode($uids) . ")");
        while ($value = DB::fetch($query)) {
            $otherinfo['users'][$value['uid']] = $value['username'];
        }
    }
    return $otherinfo;
}