function getpostinfo($id, $type, $colsarray = '')
{
    global $_G;
    $sql = $comma = '';
    $type = in_array($type, array('tid', 'pid', 'blogid')) && !empty($type) ? $type : 'tid';
    $cols = '*';
    if (!empty($colsarray) && is_array($colsarray)) {
        $cols = '';
        foreach ($colsarray as $val) {
            $cols .= $comma . $val;
            $comma = ', ';
        }
    }
    switch ($type) {
        case 'tid':
            $sql = "SELECT {$cols} FROM " . DB::table('forum_thread') . " WHERE tid='{$id}' AND displayorder>='0'";
            break;
        case 'pid':
            $posttable = getposttablebytid($_G['tid']);
            $sql = "SELECT {$cols} FROM " . DB::table($posttable) . " p, " . DB::table('forum_thread') . " t WHERE p.pid='{$id}' AND p.invisible='0' AND t.tid=p.tid";
            break;
        case 'blogid':
            $sql = "SELECT {$cols} FROM " . DB::table('home_blog') . " WHERE blogid='{$id}' AND status='0'";
            break;
    }
    if ($sql) {
        $info = DB::fetch_first($sql);
        if (!$info) {
            showmessage('magics_target_nonexistence');
        } else {
            return daddslashes($info, 1);
        }
    }
}
Exemple #2
0
 function usesubmit()
 {
     global $_G;
     if (empty($_G['gp_pid'])) {
         showmessage(lang('magic/namepost', 'namepost_info_nonexistence'));
     }
     $_G['tid'] = $_G['gp_ptid'];
     $post = getpostinfo($_G['gp_pid'], 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.dateline', 'p.anonymous'));
     $this->_check($post);
     $query = DB::query("SELECT username FROM " . DB::table('common_member') . " WHERE uid='{$post['authorid']}'");
     $author = daddslashes(DB::result($query, 0), 1);
     $thread = getpostinfo($post['tid'], 'tid', array('tid', 'subject', 'author', 'replies', 'lastposter'));
     $posttable = getposttablebytid($post['tid']);
     if ($post['first']) {
         $lastposter = $thread['replies'] > 0 ? $thread['lastposter'] : $author;
         DB::query("UPDATE " . DB::table($posttable) . " SET anonymous='0' WHERE tid='{$post['tid']}' AND first='1'");
     } else {
         $lastposter = $author;
         $author = $thread['author'];
         DB::query("UPDATE " . DB::table($posttable) . " SET anonymous='0' WHERE pid='{$_G['gp_pid']}'");
     }
     $forum['lastpost'] = explode("\t", DB::result_first("SELECT lastpost FROM " . DB::table('forum_forum') . " WHERE fid='{$post['fid']}'"));
     if ($thread['subject'] == $forum['lastpost'][1] && ($forum['lastpost'][3] == '' && $post['anonymous'])) {
         $lastpost = "{$thread['tid']}\t{$thread['subject']}\t{$_G['timestamp']}\t{$lastposter}";
         DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}' WHERE fid='{$post['fid']}'", 'UNBUFFERED');
     }
     DB::query("UPDATE " . DB::table('forum_thread') . " SET author='{$author}', lastposter='{$lastposter}' WHERE tid='{$post['tid']}'");
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['gp_tid']);
     if ($post['authorid'] != $_G['uid']) {
         notification_add($post['authorid'], 'magic', lang('magic/namepost', 'namepost_notification'), array('pid' => $_G['gp_pid'], 'tid' => $_G['gp_tid'], 'subject' => $thread['subject'], 'magicname' => $this->magic['name']));
     }
     showmessage(lang('magic/namepost', 'namepost_succeed'), dreferer(), array(), array('showdialog' => 1, 'locationtime' => true));
 }
Exemple #3
0
function updatersscache($num)
{
    global $_G;
    DB::query("DELETE FROM " . DB::table('forum_rsscache') . "");
    require_once libfile('function/post');
    foreach ($_G['cache']['forums'] as $fid => $forum) {
        if ($forum['type'] != 'group') {
            $query = DB::query("SELECT tid, readperm, author, dateline, subject\r\n\t\t\t\tFROM " . DB::table('forum_thread') . "\r\n\t\t\t\tWHERE fid='{$fid}' AND displayorder>='0'\r\n\t\t\t\tORDER BY tid DESC LIMIT {$num}");
            $forum['name'] = addslashes($forum['name']);
            while ($thread = DB::fetch($query)) {
                $thread['author'] = $thread['author'] != '' ? addslashes($thread['author']) : 'Anonymous';
                $thread['subject'] = addslashes($thread['subject']);
                $posttable = getposttablebytid($thread['tid']);
                $post = DB::fetch_first("SELECT pid, attachment, message, status FROM " . DB::table($posttable) . " WHERE tid='{$thread['tid']}' AND first='1'");
                $attachdata = '';
                if ($post['attachment'] == 2) {
                    $attach = DB::fetch_first("SELECT remote, attachment, filesize FROM " . DB::table('forum_attachment') . " WHERE pid='{$post['pid']}' AND isimage='1' ORDER BY dateline LIMIT 1");
                    $attachdata = "\t" . $attach['remote'] . "\t" . $attach['attachment'] . "\t" . $attach['filesize'];
                }
                $thread['message'] = $post['message'];
                $thread['status'] = $post['status'];
                $thread['description'] = $thread['readperm'] > 0 || $thread['price'] > 0 || $thread['status'] & 1 ? '' : addslashes(messagecutstr($thread['message'], 250 - strlen($attachdata)) . $attachdata);
                DB::query("REPLACE INTO " . DB::table('forum_rsscache') . " (lastupdate, fid, tid, dateline, forum, author, subject, description)\r\n\t\t\t\t\tVALUES ('{$_G['timestamp']}', '{$fid}', '{$thread['tid']}', '{$thread['dateline']}', '{$forum['name']}', '{$thread['author']}', '{$thread['subject']}', '{$thread['description']}')");
            }
        }
    }
}
 function post_mobile_message($message, $url_forward, $values, $extraparam, $custom)
 {
     if ($message == 'comment_add_succeed') {
         showmessage($message);
     }
     if ($values['tid'] && $values['pid']) {
         global $_G;
         $threadstatus = DB::result_first("SELECT status FROM " . DB::table('forum_thread') . " WHERE tid='{$values['tid']}'");
         $setstatusold = base_convert(getstatus($threadstatus, 13) . getstatus($threadstatus, 12) . getstatus($threadstatus, 11), 2, 10);
         $updatestatus = false;
         if (!empty($_POST['allowsound'])) {
             $setstatus = array(1, 0, 0);
             $updatestatus = $setstatusold < 4;
         } elseif (!empty($_POST['allowphoto'])) {
             $setstatus = array(0, 1, 1);
             $updatestatus = $setstatusold < 3;
         } elseif (!empty($_POST['allowlocal'])) {
             $setstatus = array(0, 1, 0);
             $updatestatus = $setstatusold < 2;
         } else {
             $setstatus = array(0, 0, 1);
         }
         if ($updatestatus) {
             foreach ($setstatus as $i => $bit) {
                 $threadstatus = setstatus(13 - $i, $bit, $threadstatus);
             }
             //note DB::update('forum_thread', array('status' => $threadstatus), "tid='$values[tid]'");
             C::t('forum_thread')->update($values['tid'], array('status' => $threadstatus));
         }
         $posttable = getposttablebytid($values['tid']);
         $poststatus = DB::result_first("SELECT status FROM " . DB::table($posttable) . " WHERE pid='{$values['pid']}'");
         $poststatus = setstatus(4, 1, $poststatus);
         if (!empty($_POST['allowlocal'])) {
             $poststatus = setstatus(6, 1, $poststatus);
         }
         if (!empty($_POST['allowsound'])) {
             $poststatus = setstatus(7, 1, $poststatus);
         }
         if (!empty($_POST['mobiletype']) && $_POST['mobiletype'] < 8) {
             $mobiletype = base_convert($_POST['mobiletype'], 10, 2);
             $mobiletype = sprintf('%03d', $mobiletype);
             for ($i = 0; $i < 3; $i++) {
                 $poststatus = setstatus(10 - $i, $mobiletype[$i], $poststatus);
             }
         }
         //note DB::update($posttable, array('status' => $poststatus), "pid='$values[pid]'");
         C::t('forum_post')->update('tid:' . $values['tid'], $values['pid'], array('status' => $poststatus));
         if ($_POST['location']) {
             list($mapx, $mapy, $location) = explode('|', dhtmlspecialchars($_POST['location']));
             C::t('forum_post_location')->insert(array('pid' => $values['pid'], 'tid' => $values['tid'], 'uid' => $_G['uid'], 'mapx' => $mapx, 'mapy' => $mapy, 'location' => $location));
         }
     }
 }
function trade_create($trade)
{
    global $_G;
    extract($trade);
    $special = 2;
    $expiration = $item_expiration ? strtotime($item_expiration) : 0;
    $closed = $expiration > 0 && strtotime($item_expiration) < TIMESTAMP ? 1 : $closed;
    $item_price = floatval($item_price);
    switch ($transport) {
        case 'offline':
            $item_transport = 0;
            break;
        case 'seller':
            $item_transport = 1;
            break;
        case 'buyer':
            $item_transport = 2;
            break;
        case 'virtual':
            $item_transport = 3;
            break;
        case 'logistics':
            $item_transport = 4;
            break;
    }
    $seller = dhtmlspecialchars($seller);
    $item_name = dhtmlspecialchars($item_name);
    $item_locus = dhtmlspecialchars($item_locus);
    $item_number = intval($item_number);
    $item_quality = intval($item_quality);
    $item_transport = intval($item_transport);
    $postage_mail = intval($postage_mail);
    $postage_express = intval($postage_express);
    $postage_ems = intval($postage_ems);
    $item_type = intval($item_type);
    $typeid = intval($typeid);
    $item_costprice = floatval($item_costprice);
    if (!$item_price || $item_price <= 0) {
        $item_price = $postage_mail = $postage_express = $postage_ems = '';
    }
    if (empty($pid)) {
        $posttable = getposttablebytid($tid);
        $pid = DB::result_first("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND first='1' LIMIT 1");
    }
    if (!$item_price && $item_credit) {
        $seller == '';
    }
    DB::insert('forum_trade', array('tid' => $tid, 'pid' => $pid, 'typeid' => $typeid, 'sellerid' => $_G['uid'], 'seller' => $author, 'tenpayaccount' => $tenpayaccount, 'account' => $seller, 'subject' => $item_name, 'price' => $item_price, 'amount' => $item_number, 'quality' => $item_quality, 'locus' => $item_locus, 'transport' => $item_transport, 'ordinaryfee' => $postage_mail, 'expressfee' => $postage_express, 'emsfee' => $postage_ems, 'itemtype' => $item_type, 'dateline' => $_G['timestamp'], 'expiration' => $expiration, 'lastupdate' => $_G['timestamp'], 'totalitems' => '0', 'tradesum' => '0', 'closed' => $closed, 'costprice' => $item_costprice, 'aid' => $aid, 'credit' => $item_credit, 'costcredit' => $item_costcredit));
}
 function usesubmit()
 {
     global $_G;
     $id = intval($_G['gp_id']);
     if (empty($id)) {
         showmessage(lang('magic/anonymouspost', 'anonymouspost_info_nonexistence'));
     }
     $idtype = !empty($_G['gp_idtype']) ? htmlspecialchars($_G['gp_idtype']) : '';
     if (!in_array($idtype, array('pid', 'cid'))) {
         showmessage(lang('magic/anonymouspost', 'anonymouspost_use_error'));
     }
     if ($idtype == 'pid') {
         $_G['tid'] = $_G['gp_ptid'];
         $post = getpostinfo($id, 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.author', 'p.dateline', 'p.anonymous'));
         $this->_check($post);
         if ($post['authorid'] != $_G['uid']) {
             showmessage('magics_operation_nopermission');
         }
         $thread = getpostinfo($post['tid'], 'tid', array('tid', 'subject', 'author', 'replies', 'lastposter'));
         $posttable = getposttablebytid($post['tid']);
         if ($post['first']) {
             $author = '';
             $lastposter = $thread['replies'] > 0 ? $thread['lastposter'] : '';
         } else {
             $author = $thread['author'];
             $lastposter = '';
         }
         DB::query("UPDATE " . DB::table($posttable) . " SET anonymous='1' WHERE pid='{$id}'");
         $forum['lastpost'] = explode("\t", DB::result_first("SELECT lastpost FROM " . DB::table('forum_forum') . " WHERE fid='{$post['fid']}'"));
         if ($post['dateline'] == $forum['lastpost'][2] && ($post['author'] == $forum['lastpost'][3] || $forum['lastpost'][3] == '' && $post['anonymous'])) {
             $lastpost = "{$thread['tid']}\t{$thread['subject']}\t{$_G['timestamp']}\t{$lastposter}";
             DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}' WHERE fid='{$post['fid']}'", 'UNBUFFERED');
         }
         DB::query("UPDATE " . DB::table('forum_thread') . " SET author='{$author}', lastposter='{$lastposter}' WHERE tid='{$post['tid']}'");
     } elseif ($idtype == 'cid') {
         $value = DB::fetch_first('SELECT * FROM ' . DB::table('home_comment') . " WHERE cid = '{$id}' AND authorid = '{$_G['uid']}'");
         if (empty($value)) {
             showmessage('anonymouspost_use_error');
         } elseif ($value['author'] == '') {
             showmessage('anonymouspost_once_limit');
         }
         DB::query("UPDATE " . DB::table('home_comment') . " SET author='' WHERE cid='{$id}' AND authorid='{$_G['uid']}'");
     }
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, $idtype, $id);
     showmessage(lang('magic/anonymouspost', 'anonymouspost_succeed'), dreferer(), array(), array('showdialog' => 1, 'locationtime' => true));
 }
Exemple #7
0
function updatethreadcount($tid, $updateattach = 0)
{
    $posttable = getposttablebytid($tid);
    $replycount = DB::result_first("SELECT COUNT(*) FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND invisible='0'") - 1;
    $lastpost = DB::fetch_first("SELECT author, anonymous, dateline FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND invisible='0' ORDER BY dateline DESC LIMIT 1");
    $lastpost['author'] = $lastpost['anonymous'] ? lang('forum/misc', 'anonymous') : addslashes($lastpost['author']);
    $lastpost['dateline'] = !empty($lastpost['dateline']) ? $lastpost['dateline'] : TIMESTAMP;
    if ($updateattach) {
        $attach = DB::result_first("SELECT attachment FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND invisible='0' AND attachment>0 LIMIT 1");
        $attachadd = ', attachment=\'' . ($attach ? 1 : 0) . '\'';
    } else {
        $attachadd = '';
    }
    DB::query("UPDATE " . DB::table('forum_thread') . " SET replies='{$replycount}', lastposter='{$lastpost['author']}', lastpost='{$lastpost['dateline']}' {$attachadd} WHERE tid='{$tid}'", 'UNBUFFERED');
}
 *      $Id: topicadmin_merge.php 31741 2012-09-26 08:12:08Z zhangjie $
 */
if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
if (!$_G['group']['allowmergethread']) {
    showmessage('no_privilege_mergethread');
}
if (!submitcheck('modsubmit')) {
    include template('forum/topicadmin_action');
} else {
    //删除缓存
    memory('rm', 'forumdisplay_' . $_G['fid']);
    $posttable = getposttablebytid($_G['tid']);
    $othertid = intval($_GET['othertid']);
    $otherposttable = getposttablebytid($othertid);
    $modaction = 'MRG';
    $reason = checkreasonpm();
    $other = C::t('forum_thread')->fetch_by_tid_displayorder($othertid, 0);
    if (!$other) {
        showmessage('admin_merge_nonexistence');
    } elseif ($other['special']) {
        showmessage('special_noaction');
    }
    if ($othertid == $_G['tid'] || $_G['adminid'] == 3 && $other['fid'] != $_G['forum']['fid']) {
        showmessage('admin_merge_invalid');
    }
    $other['views'] = intval($other['views']);
    $other['replies']++;
    if (!$other['maxposition']) {
        $other['maxposition'] = C::t('forum_post')->fetch_maxposition_by_tid($other['posttableid'], $othertid);
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $allowmediacode = '0', $pid = 0)
{
    global $_G;
    static $authorreplyexist;
    if ($parsetype != 1 && !$bbcodeoff && $allowbbcode && (strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) {
        $message = preg_replace("/\\s?\\[code\\](.+?)\\[\\/code\\]\\s?/ies", "codedisp('\\1')", $message);
    }
    $msglower = strtolower($message);
    $htmlon = $htmlon && $allowhtml ? 1 : 0;
    if (!$htmlon) {
        $message = dhtmlspecialchars($message);
    }
    if (!$smileyoff && $allowsmilies) {
        $message = parsesmiles($message);
    }
    if ($_G['setting']['allowattachurl'] && strpos($msglower, 'attach://') !== FALSE) {
        $message = preg_replace("/attach:\\/\\/(\\d+)\\.?(\\w*)/ie", "parseattachurl('\\1', '\\2')", $message);
    }
    if ($allowbbcode) {
        if (strpos($msglower, 'ed2k://') !== FALSE) {
            $message = preg_replace("/ed2k:\\/\\/(.+?)\\//e", "parseed2k('\\1')", $message);
        }
    }
    if (!$bbcodeoff && $allowbbcode) {
        if (strpos($msglower, '[/url]') !== FALSE) {
            $message = preg_replace("/\\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|synacast){1}:\\/\\/|www\\.|mailto:)?([^\\s\\[\"']+?))?\\](.+?)\\[\\/url\\]/ies", "parseurl('\\1', '\\5', '\\2')", $message);
        }
        if (strpos($msglower, '[/email]') !== FALSE) {
            $message = preg_replace("/\\[email(=([a-z0-9\\-_.+]+)@([a-z0-9\\-_]+[.][a-z0-9\\-_.]+))?\\](.+?)\\[\\/email\\]/ies", "parseemail('\\1', '\\4')", $message);
        }
        $nest = 0;
        while (strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE) {
            $message = preg_replace("/\\[table(?:=(\\d{1,4}%?)(?:,([\\(\\)%,#\\w ]+))?)?\\]\\s*(.+?)\\s*\\[\\/table\\]/ies", "parsetable('\\1', '\\2', '\\3')", $message);
            if (++$nest > 4) {
                break;
            }
        }
        $message = str_replace(array('[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]', '[/p]', '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]', '[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'), array('</font>', '</font>', '</font>', '</p>', '<strong>', '</strong>', '<strike>', '</strike>', '<hr class="l" />', '</p>', '<i class="pstatus">', '<i>', '</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">', '<ul type="A" class="litype_3">', '<li>', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'), preg_replace(array("/\\[color=([#\\w]+?)\\]/i", "/\\[color=(rgb\\([\\d\\s,]+?\\))\\]/i", "/\\[size=(\\d{1,2}?)\\]/i", "/\\[size=(\\d{1,2}(\\.\\d{1,2}+)?(px|pt)+?)\\]/i", "/\\[font=([^\\[\\<]+?)\\]/i", "/\\[align=(left|center|right)\\]/i", "/\\[p=(\\d{1,2}|null), (\\d{1,2}), (left|center|right)\\]/i", "/\\[float=(left|right)\\]/i"), array("<font color=\"\\1\">", "<font style=\"color:\\1\">", "<font size=\"\\1\">", "<font style=\"font-size: \\1\">", "<font face=\"\\1 \">", "<p align=\"\\1\">", "<p style=\"line-height: \\1px; text-indent: \\2em; text-align: \\3;\">", "<span style=\"float: \\1;\">"), $message));
        if ($parsetype != 1) {
            if (strpos($msglower, '[/quote]') !== FALSE) {
                $message = preg_replace("/\\s?\\[quote\\][\n\r]*(.+?)[\n\r]*\\[\\/quote\\]\\s?/is", tpl_quote(), $message);
            }
            if (strpos($msglower, '[/free]') !== FALSE) {
                $message = preg_replace("/\\s*\\[free\\][\n\r]*(.+?)[\n\r]*\\[\\/free\\]\\s*/is", tpl_free(), $message);
            }
        }
        if (strpos($msglower, '[/media]') !== FALSE) {
            $message = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", $allowmediacode ? "parsemedia('\\1', '\\2')" : "bbcodeurl('\\2', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message);
        }
        if (strpos($msglower, '[/audio]') !== FALSE) {
            $message = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/ies", $allowmediacode ? "parseaudio('\\2', 400, '\\1')" : "bbcodeurl('\\2', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message);
        }
        if (strpos($msglower, '[/flash]') !== FALSE) {
            $message = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/ies", $allowmediacode ? "parseflash('\\2', '\\3', '\\4');" : "bbcodeurl('\\4', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", $message);
        }
        if ($parsetype != 1 && $allowbbcode < 0 && isset($_G['cache']['bbcodes'][-$allowbbcode])) {
            $message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], $_G['cache']['bbcodes'][-$allowbbcode]['replacearray'], $message);
        }
        if ($parsetype != 1 && strpos($msglower, '[/hide]') !== FALSE && $pid) {
            if (strpos($msglower, '[hide]') !== FALSE) {
                if ($authorreplyexist === null) {
                    $posttable = getposttablebytid($_G['tid']);
                    $authorreplyexist = !$_G['forum']['ismoderator'] ? DB::result_first("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$_G['tid']}' AND " . ($_G['uid'] ? "authorid='{$_G['uid']}'" : "authorid=0 AND useip='{$_G['clientip']}'") . " LIMIT 1") : TRUE;
                }
                if ($authorreplyexist) {
                    $message = preg_replace("/\\[hide\\]\\s*(.+?)\\s*\\[\\/hide\\]/is", tpl_hide_reply(), $message);
                } else {
                    $message = preg_replace("/\\[hide\\](.+?)\\[\\/hide\\]/is", tpl_hide_reply_hidden(), $message);
                    $message .= '<script type="text/javascript">replyreload += \',\' + ' . $pid . ';</script>';
                }
            }
            if (strpos($msglower, '[hide=') !== FALSE) {
                $message = preg_replace("/\\[hide=(\\d+)\\]\\s*(.+?)\\s*\\[\\/hide\\]/ies", "creditshide(\\1,'\\2', {$pid})", $message);
            }
        }
    }
    if (!$bbcodeoff) {
        if ($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) {
            $message = preg_replace("/\\[swf\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/swf\\]/ies", "bbcodeurl('\\1', ' <img src=\"'.STATICURL.'image/filetype/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"{url}\" target=\"_blank\">Flash: {url}</a> ')", $message);
        }
        if (strpos($msglower, '[/img]') !== FALSE) {
            $message = preg_replace(array("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies", "/\\[img=(\\d{1,4})[x|\\,](\\d{1,4})\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies"), $allowimgcode ? array("bbcodeurl('\\1', '<img src=\"{url}\" onload=\"thumbImg(this)\" alt=\"\" />')", "parseimg('\\1', '\\2', '\\3')") : array("bbcodeurl('\\1', '<a href=\"{url}\" target=\"_blank\">{url}</a>')", "bbcodeurl('\\3', '<a href=\"{url}\" target=\"_blank\">{url}</a>')"), $message);
        }
    }
    for ($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
        $message = str_replace("[\tDISCUZ_CODE_{$i}\t]", $_G['forum_discuzcode']['codehtml'][$i], $message);
    }
    if (!empty($_G['gp_highlight'])) {
        $highlightarray = explode('+', $_G['gp_highlight']);
        $sppos = strrpos($message, chr(0) . chr(0) . chr(0));
        if ($sppos !== FALSE) {
            $specialextra = substr($message, $sppos + 3);
            $message = substr($message, 0, $sppos);
        }
        $message = preg_replace(array("/(^|>)([^<]+)(?=<|\$)/sUe", "/<highlight>(.*)<\\/highlight>/siU"), array("highlight('\\2', \$highlightarray, '\\1')", "<strong><font color=\"#FF0000\">\\1</font></strong>"), $message);
        if ($sppos !== FALSE) {
            $message = $message . chr(0) . chr(0) . chr(0) . $specialextra;
        }
    }
    unset($msglower);
    if ($jammer) {
        $message = preg_replace("/\r\n|\n|\r/e", "jammer()", $message);
    }
    return $htmlon ? $message : nl2br(str_replace(array("\t", '   ', '  '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $message));
}
Exemple #10
0
$commentlist = $org = array();
if ($article['id'] && $article['idtype']) {
    if ($article['idtype'] == 'blogid') {
        $org = db::fetch_first("SELECT * FROM " . db::table('home_blog') . " WHERE blogid='{$article['id']}'");
        $common_url = "home.php?mod=space&uid={$org['uid']}&do=blog&id={$article['id']}";
        $form_url = "home.php?mod=spacecp&ac=comment";
        $article['commentnum'] = getcount('home_comment', array('id' => $article['id'], 'idtype' => 'blogid'));
        $query = DB::query("SELECT authorid AS uid, author AS username, dateline, message\n\t\t\tFROM " . DB::table('home_comment') . " WHERE id='{$article['id']}' AND idtype='blogid' ORDER BY dateline DESC LIMIT 0,20");
        while ($value = DB::fetch($query)) {
            $commentlist[] = $value;
        }
    } else {
        $common_url = "forum.php?mod=viewthread&tid={$article['id']}";
        $form_url = "forum.php?mod=post&action=reply&tid={$article['id']}&replysubmit=yes&infloat=yes&handlekey=fastpost";
        require_once libfile('function/discuzcode');
        $posttable = getposttablebytid($article['id']);
        $article['commentnum'] = getcount($posttable, array('tid' => $article['id'], 'first' => '0'));
        $firstpost = DB::fetch_first("SELECT first, authorid AS uid, author AS username, dateline, message, smileyoff, bbcodeoff, htmlon, attachment, pid\n\t\t\tFROM " . DB::table($posttable) . " WHERE tid='{$article['id']}' AND first='1'");
        if (!($org = $firstpost)) {
            db::update('portal_article_title', array('id' => 0, 'idtype' => ''), array('aid' => $aid));
            header("location: portal.php?mod=view&aid={$aid}");
            exit;
        }
        $attachpids = -1;
        $attachtags = $aimgs = array();
        $firstpost['message'] = $content['content'];
        if ($firstpost['attachment']) {
            if ($_G['group']['allowgetattach']) {
                $attachpids .= ",{$firstpost['pid']}";
                if (preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $firstpost['message'], $matchaids)) {
                    $attachtags[$firstpost['pid']] = $matchaids[1];
 }
 $moderate = array();
 $toforumallowspecial = array(1 => $toforum['allowpostspecial'] & 1, 2 => $toforum['allowpostspecial'] & 2, 3 => isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && $toforum['allowpostspecial'] & 4, 4 => $toforum['allowpostspecial'] & 8, 5 => $toforum['allowpostspecial'] & 16, 127 => $_G['setting']['threadplugins'] ? unserialize($toforum['threadplugin']) : array());
 foreach ($threadlist as $tid => $thread) {
     $allowmove = 0;
     if ($thread['closed']) {
         continue;
     }
     if (!$thread['special']) {
         $allowmove = 1;
     } else {
         if ($thread['special'] != 127) {
             $allowmove = $toforum['allowpostspecial'] ? $toforumallowspecial[$thread['special']] : 0;
         } else {
             if ($toforumallowspecial[127]) {
                 $posttable = getposttablebytid($thread['tid']);
                 $message = DB::result_first("SELECT message FROM " . DB::table($posttable) . " WHERE tid='{$thread['tid']}' AND first='1'");
                 $sppos = strrpos($message, chr(0) . chr(0) . chr(0));
                 $specialextra = substr($message, $sppos + 3);
                 $allowmove = in_array($specialextra, $toforumallowspecial[127]);
             } else {
                 $allowmove = 0;
             }
         }
     }
     if ($allowmove) {
         $moderate[] = $tid;
         $thread = daddslashes($thread, 1);
         DB::query("INSERT INTO " . DB::table('forum_thread') . " (fid, readperm, author, authorid, subject, dateline, lastpost, lastposter, views, replies, displayorder, digest, closed, special, attachment, isgroup)\r\n\t\t\t\t\t\t\tVALUES ('{$moveto}', '{$thread['readperm']}', '" . addslashes($thread['author']) . "', '{$thread['authorid']}', '" . addslashes($thread['subject']) . "', '{$thread['dateline']}', '" . TIMESTAMP . "', '" . addslashes($thread['lastposter']) . "', '{$thread['views']}', '{$thread['replies']}', '0', '{$thread['digest']}', '{$thread['tid']}', '{$thread['special']}', '{$thread['attachment']}', '{$thread['isgroup']}')");
         $newtid = DB::insert_id();
         DB::query("UPDATE " . DB::table('forum_thread') . " SET closed='{$newtid}' WHERE tid='{$thread['tid']}'");
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: topicadmin_getip.php 20099 2011-02-15 01:55:29Z monkey $
 */
if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
if (!$_G['group']['allowviewip']) {
    showmessage('no_privilege_viewip');
}
$pid = $_G['gp_pid'];
$posttable = getposttablebytid($_G['tid']);
$member = DB::fetch_first("SELECT m.adminid, p.first, p.useip FROM " . DB::table($posttable) . " p\r\n\t\t\tLEFT JOIN " . DB::table('common_member') . " m ON m.uid=p.authorid\r\n\t\t\tWHERE p.pid='{$pid}' AND p.tid='{$_G['tid']}'");
if (!$member) {
    showmessage('thread_nonexistence', NULL);
} elseif ($member['adminid'] == 1 && $_G['adminid'] > 1 || $member['adminid'] == 2 && $_G['adminid'] > 2) {
    showmessage('admin_getip_nopermission', NULL);
}
$member['iplocation'] = convertip($member['useip']);
include template('forum/topicadmin_getip');
Exemple #13
0
    $_G['connect']['is_oauth_user'] = true;
    if (empty($_G['member']['conuinsecret'])) {
        $_G['connect']['is_oauth_user'] = false;
    }
    $referer = str_replace($_G['siteurl'], '', dreferer());
    if (!empty($_G['gp_connect_autoshare'])) {
        if (strpos($referer, '?') !== false) {
            $referer .= '&connect_autoshare=1';
        } else {
            $referer .= '?connect_autoshare=1';
        }
    }
    $_G['connect']['loginbind_url'] = $_G['siteurl'] . 'connect.php?mod=login&op=init&type=loginbind&referer=' . urlencode($_G['connect']['referer'] ? $_G['connect']['referer'] : 'index.php');
} elseif ($pluginop == 'share') {
    $_G['gp_share_url'] = $_G['connect']['discuz_new_share_url'];
    $posttable = getposttablebytid($tid);
    $post = DB::fetch_first("SELECT * FROM " . DB::table($posttable) . " WHERE tid = '{$tid}' AND first='1' AND invisible='0'");
    $thread = DB::fetch_first("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid = '{$tid}' AND displayorder >= 0");
    if ($_G['group']['allowgetimage'] && $thread['price'] == 0) {
        connect_parse_bbcode($post['message'], $thread['fid'], $post['pid'], $post['htmlon'], $attach_images);
        if ($attach_images && is_array($attach_images)) {
            $_G['gp_share_images'] = array_slice($attach_images, 0, 3);
            $attach_images = array();
            foreach ($_G['gp_share_images'] as $image) {
                $attach_images[] = $image['big'];
            }
            $_G['gp_attach_image'] = implode('|', $attach_images);
            unset($attach_images);
        }
    }
} elseif ($pluginop == 'new') {
function create_position(&$select, $lastpid = 0)
{
    if (empty($select) || !is_array($select)) {
        return 0;
    }
    $tid = $select[0];
    if (empty($lastpid)) {
        $check = DB::result_first("SELECT tid FROM " . DB::table('forum_postposition') . " WHERE tid='{$tid}' LIMIT 1");
        if ($check) {
            unset($select[0]);
            return 0;
        }
    }
    $round = 500;
    $posttable = getposttablebytid($tid);
    $query = DB::query("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND pid>'{$lastpid}' ORDER BY pid ASC LIMIT 0, {$round}");
    while ($post = DB::fetch($query)) {
        if (empty($post) || empty($post['pid'])) {
            continue;
        }
        savepostposition($tid, $post['pid']);
        $lastid = $post['pid'];
    }
    if (DB::num_rows($query) < $round) {
        DB::query("UPDATE " . DB::table('forum_thread') . " SET status=status | '1' WHERE tid='{$tid}'");
        unset($select[0]);
        return 0;
    } else {
        return $lastid;
    }
}
Exemple #15
0
} elseif ($_G['gp_action'] == 'getimage') {
    $_G['gp_aid'] = intval($_G['gp_aid']);
    $image = DB::fetch_first('SELECT * FROM ' . DB::table(getattachtablebyaid($_G['gp_aid'])) . " WHERE aid='{$_G['gp_aid']}' AND isimage='1'");
    include template('common/header_ajax');
    if ($image['aid']) {
        echo '<img src="' . getforumimg($image['aid'], 1, 300, 300, 'fixnone') . '" id="image_' . $image['aid'] . '" onclick="insertAttachimgTag(\'' . $image['aid'] . '\')" width="' . ($image['width'] < 110 ? $image['width'] : 110) . '" cwidth="' . ($image['width'] < 300 ? $image['width'] : 300) . '" />';
    }
    include template('common/footer_ajax');
    dexit();
} elseif ($_G['gp_action'] == 'setthreadcover') {
    $aid = intval($_G['gp_aid']);
    require_once libfile('function/post');
    if ($_G['forum'] && $aid) {
        $threadimage = DB::fetch_first("SELECT tid, pid, attachment, remote FROM " . DB::table(getattachtablebyaid($aid)) . " WHERE aid='{$aid}'");
        if ($threadimage['tid'] && $threadimage['pid']) {
            $firstpost = DB::result_first("SELECT first FROM " . DB::table(getposttablebytid($threadimage['tid'])) . " WHERE pid='{$threadimage['pid']}'");
            if (empty($firstpost)) {
                $trade_aid = DB::result_first("SELECT aid FROM " . DB::table('forum_trade') . " WHERE pid='{$threadimage['pid']}'");
                if ($trade_aid == $aid) {
                    $firstpost = 1;
                }
            }
        } else {
            $firstpost = 0;
        }
        if (empty($firstpost)) {
            showmessage('set_cover_faild', '', array(), array('closetime' => 3));
        }
        if (setthreadcover(0, 0, $aid)) {
            $threadimage = daddslashes($threadimage);
            DB::delete('forum_threadimage', "tid='{$threadimage['tid']}'");
Exemple #16
0
 function _getThreadPosts($tIds)
 {
     global $_G;
     $result = array();
     $posttable = getposttablebytid($tIds);
     foreach ($posttable as $posttableid => $tid) {
         $query = DB::query("SELECT * FROM " . DB::table($posttableid) . " WHERE tid IN (" . dimplode($tid) . ") AND first='1' AND invisible='0'");
         while ($post = DB::fetch($query)) {
             $result[$post['tid']] = $this->_convertPost($post);
         }
     }
     return $result;
 }
if (!$_G['group']['allowstickreply']) {
    showmessage('undefined_action', NULL);
}
$topiclist = $_G['gp_topiclist'];
if (empty($topiclist)) {
    showmessage('admin_stickreply_invalid');
} elseif (!$_G['tid']) {
    showmessage('admin_nopermission', NULL);
}
$posttable = getposttablebytid($_G['tid']);
$sticktopiclist = $posts = array();
foreach ($topiclist as $pid) {
    $post = DB::fetch_first("SELECT p.tid, p.authorid, p.dateline, p.first, t.special FROM " . DB::table($posttable) . " p\r\n\t\tLEFT JOIN " . DB::table('forum_thread') . " t USING(tid) WHERE p.pid='{$pid}'");
    $posts[]['authorid'] = $post['authorid'];
    $sqladd = $post['special'] ? "AND first=0" : '';
    $posttable = getposttablebytid($post['tid']);
    $curpostnum = DB::result_first("SELECT COUNT(*) FROM " . DB::table($posttable) . " WHERE tid='{$post['tid']}' AND dateline<='{$post['dateline']}' {$sqladd}");
    if (empty($post['first'])) {
        $sticktopiclist[$pid] = $curpostnum;
    }
}
if (!submitcheck('modsubmit')) {
    $stickpid = '';
    foreach ($sticktopiclist as $id => $postnum) {
        $stickpid .= '<input type="hidden" name="topiclist[]" value="' . $id . '" />';
    }
    include template('forum/topicadmin_action');
} else {
    if ($_G['gp_stickreply']) {
        foreach ($sticktopiclist as $pid => $postnum) {
            DB::query("REPLACE INTO " . DB::table('forum_poststick') . " SET tid='{$_G['tid']}', pid='{$pid}', position='{$postnum}', dateline='{$_G['timestamp']}'");
 /**
  * 获取转发主题信息 For DiscuzX1.5
  * @param $tid int 论坛thread id
  * @return array
  */
 function forShare($tid)
 {
     $threadURL = $this->getThreadUrl($tid);
     $url = ' ' . $threadURL;
     /* 分表 */
     $posttable = getposttablebytid($tid);
     if (empty($posttable)) {
         return FALSE;
     }
     /* 获取主题信息 */
     $db = XWB_plugin::getDB();
     $query = "SELECT pid, subject, message FROM " . DB::table($posttable) . " t WHERE tid='{$tid}' AND invisible='0' AND first='1'";
     $post = $db->fetch_first($query);
     if (empty($post)) {
         return FALSE;
     }
     /* 转码 */
     $subject = $this->_convert(trim($post['subject']));
     /* 过滤UBB与表情 */
     $subject = $this->_filter($subject);
     /* 将最后附带的url给删除 */
     $subject = preg_replace("|\\s*http://[a-z0-9-\\.\\?\\=&_@/%#]*\$|sim", "", $subject);
     /* 合并标题和链接 */
     $message = $subject . $url;
     // 取出所有图片
     $img_urls = array();
     if (XWB_plugin::pCfg('is_upload_image')) {
         $image_list = $this->_getImage($post['pid'], $post['message'], 999999);
         /* 增加新浪帖子同步图标过滤 2010-11-1 */
         $iconLogo = XWB_plugin::getPluginUrl('images/bgimg/icon_logo.png');
         if (in_array($iconLogo, $image_list)) {
             $unKey = array_search($iconLogo, $image_list);
             unset($image_list[$unKey]);
         }
         /* END */
         if (!empty($image_list)) {
             $img_urls = $image_list;
         }
     }
     return array('url' => $threadURL, 'title' => $subject, 'message' => $message, 'pics' => array_map('trim', $img_urls));
 }
Exemple #19
0
 switch ($_GET['from_idtype']) {
     case 'blogid':
         $blog = array_merge(C::t('home_blog')->fetch($_GET['from_id']), C::t('home_blogfield')->fetch($_GET['from_id']));
         if ($blog) {
             if ($blog['friend']) {
                 showmessage('article_push_invalid_private');
             }
             $article['title'] = getstr($blog['subject'], 0);
             $article['summary'] = portalcp_get_summary($blog['message']);
             $article['fromurl'] = 'home.php?mod=space&uid=' . $blog[uid] . '&do=blog&id=' . $blog[blogid];
             $article['author'] = $blog['username'];
             $article_content['content'] = dhtmlspecialchars($blog['message']);
         }
         break;
     default:
         $posttable = getposttablebytid($_GET['from_id']);
         $thread = C::t('forum_thread')->fetch($_GET['from_id']);
         $thread = array_merge($thread, C::t('forum_post')->fetch_threadpost_by_tid_invisible($_GET['from_id']));
         if ($thread) {
             $article['title'] = $thread['subject'];
             $thread['message'] = portalcp_get_postmessage($thread, $_GET['getauthorall']);
             $article['summary'] = portalcp_get_summary($thread['message']);
             $article['fromurl'] = 'forum.php?mod=viewthread&tid=' . $thread['tid'];
             $article['author'] = $thread['author'];
             $article_content['content'] = dhtmlspecialchars($thread['message']);
             $article['attach_image'] = $article['attach_file'] = '';
             foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $thread['tid'], 'pid', $thread['pid'], 'aid DESC') as $attach) {
                 $attachcode = '[attach]' . $attach['aid'] . '[/attach]';
                 if (!strexists($article_content['content'], $attachcode)) {
                     $article_content['content'] .= '<br /><br />' . $attachcode;
                 }
 private function _adminTopic($fid, $tid, $pid, $act, $type)
 {
     global $_G;
     $errorMsg = '';
     $_GET['topiclist'] = array($_GET['pid']);
     // 在DISCUZ_ROOT/source/module/forum/forum_topicadmin.php基础上进行二次开发
     $_GET['topiclist'] = !empty($_GET['topiclist']) ? is_array($_GET['topiclist']) ? array_unique($_GET['topiclist']) : $_GET['topiclist'] : array();
     loadcache(array('modreasons', 'stamptypeid', 'threadtableids'));
     require_once libfile('function/post');
     require_once libfile('function/misc');
     $modpostsnum = 0;
     $resultarray = $thread = array();
     if ($_G['group']['reasonpm'] == 2 || $_G['group']['reasonpm'] == 3 || !empty($_GET['sendreasonpm'])) {
         $forumname = strip_tags($_G['forum']['name']);
         $sendreasonpm = 1;
     } else {
         $sendreasonpm = 0;
     }
     if ($type == 'topic') {
         if ($act == 'band') {
             $resultarray = $this->_topicAdmin_band($fid, $tid, $pid, $act, $type, array('sendreasonpm' => $sendreasonpm, 'thread' => $_G['forum_thread']));
         } else {
             // 在DISCUZ_ROOT/source/include/topicadmin/topicadmin_moderate.php基础上进行二次开发
             $thread = $_G['forum_thread'];
             $thread['dblastpost'] = $thread['lastpost'];
             $threadlist[$thread['tid']] = $thread;
             $modpostsnum = count($threadlist);
             $stickcheck = $closecheck = $digestcheck = array('', '', '', '', '');
             empty($threadlist[$_G['tid']]['displayorder']) ? $stickcheck[0] = 'selected="selected"' : ($stickcheck[$threadlist[$_G['tid']]['displayorder']] = 'selected="selected"');
             empty($threadlist[$_G['tid']]['digest']) ? $digestcheck[0] = 'selected="selected"' : ($digestcheck[$threadlist[$_G['tid']]['digest']] = 'selected="selected"');
             empty($threadlist[$_G['tid']]['closed']) ? $closecheck[0] = 'checked="checked"' : ($closecheck[1] = 'checked="checked"');
             if (!empty($_POST)) {
                 $tidsarr = array_keys($threadlist);
                 $moderatetids = dimplode($tidsarr);
                 $reason = checkreasonpm();
                 $stampstatus = 0;
                 $stampaction = 'SPA';
                 $operationMap = array('top' => 'stick', 'marrow' => 'digest', 'delete' => 'delete');
                 $operation = $operationMap[$act];
                 $updatemodlog = TRUE;
                 switch ($act) {
                     case 'top':
                         $sticklevel = intval($_GET['sticklevel']);
                         if ($sticklevel < 0 || $sticklevel > 3 || $sticklevel > $_G['group']['allowstickthread']) {
                             // showmessage('no_privilege_stickthread');
                             $this->_exitWithHtmlAlert('no_privilege_stickthread');
                         }
                         $expiration = checkexpiration($_GET['expirationstick'], $operation);
                         $expirationstick = $sticklevel ? $_GET['expirationstick'] : 0;
                         $forumstickthreads = $_G['setting']['forumstickthreads'];
                         $forumstickthreads = isset($forumstickthreads) ? dunserialize($forumstickthreads) : array();
                         C::t('forum_thread')->update($tidsarr, array('displayorder' => $sticklevel, 'moderated' => 1), true);
                         $delkeys = array_keys($threadlist);
                         foreach ($delkeys as $k) {
                             unset($forumstickthreads[$k]);
                         }
                         C::t('common_setting')->update('forumstickthreads', $forumstickthreads);
                         $stickmodify = 0;
                         foreach ($threadlist as $thread) {
                             $stickmodify = (in_array($thread['displayorder'], array(2, 3)) || in_array($sticklevel, array(2, 3))) && $sticklevel != $thread['displayorder'] ? 1 : $stickmodify;
                         }
                         if ($_G['setting']['globalstick'] && $stickmodify) {
                             require_once libfile('function/cache');
                             updatecache('globalstick');
                         }
                         $modaction = $sticklevel ? $expiration ? 'EST' : 'STK' : 'UST';
                         C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('STK', 'UST', 'EST', 'UES'), array('status' => 0));
                         if (!$sticklevel) {
                             $stampaction = 'SPD';
                         }
                         $stampstatus = 1;
                         break;
                     case 'marrow':
                         $digestlevel = intval($_GET['digestlevel']);
                         if ($digestlevel < 0 || $digestlevel > 3 || $digestlevel > $_G['group']['allowdigestthread']) {
                             // showmessage('no_privilege_digestthread');
                             $this->_exitWithHtmlAlert('no_privilege_digestthread');
                         }
                         $expiration = checkexpiration($_GET['expirationdigest'], $operation);
                         $expirationdigest = $digestlevel ? $expirationdigest : 0;
                         C::t('forum_thread')->update($tidsarr, array('digest' => $digestlevel, 'moderated' => 1), true);
                         foreach ($threadlist as $thread) {
                             if ($thread['digest'] != $digestlevel) {
                                 if ($digestlevel == $thread['digest']) {
                                     continue;
                                 }
                                 $extsql = array();
                                 if ($digestlevel > 0 && $thread['digest'] == 0) {
                                     $extsql = array('digestposts' => 1);
                                 }
                                 if ($digestlevel == 0 && $thread['digest'] > 0) {
                                     $extsql = array('digestposts' => -1);
                                 }
                                 if ($digestlevel == 0) {
                                     $stampaction = 'SPD';
                                 }
                                 updatecreditbyaction('digest', $thread['authorid'], $extsql, '', $digestlevel - $thread['digest']);
                             }
                         }
                         $modaction = $digestlevel ? $expiration ? 'EDI' : 'DIG' : 'UDG';
                         C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('DIG', 'UDI', 'EDI', 'UED'), array('status' => 0));
                         $stampstatus = 2;
                         break;
                     case 'delete':
                         if (!$_G['group']['allowdelpost']) {
                             // showmessage('no_privilege_delpost');
                             $this->_exitWithHtmlAlert('no_privilege_delpost');
                         }
                         loadcache('threadtableids');
                         $stickmodify = 0;
                         $deleteredirect = $remarkclosed = array();
                         foreach ($threadlist as $thread) {
                             if ($thread['digest']) {
                                 updatecreditbyaction('digest', $thread['authorid'], array('digestposts' => -1), '', -$thread['digest']);
                             }
                             if (in_array($thread['displayorder'], array(2, 3))) {
                                 $stickmodify = 1;
                             }
                             if ($_G['forum']['status'] == 3 && $thread['closed'] > 1) {
                                 $deleteredirect[] = $thread['closed'];
                             }
                             if ($thread['isgroup'] == 1 && $thread['closed'] > 1) {
                                 $remarkclosed[] = $thread['closed'];
                             }
                         }
                         $modaction = 'DEL';
                         require_once libfile('function/delete');
                         $tids = array_keys($threadlist);
                         if ($_G['forum']['recyclebin']) {
                             deletethread($tids, true, true, true);
                             manage_addnotify('verifyrecycle', $modpostsnum);
                         } else {
                             deletethread($tids, true, true);
                             $updatemodlog = FALSE;
                         }
                         $forumstickthreads = $_G['setting']['forumstickthreads'];
                         $forumstickthreads = !empty($forumstickthreads) ? dunserialize($forumstickthreads) : array();
                         $delkeys = array_keys($threadlist);
                         foreach ($delkeys as $k) {
                             unset($forumstickthreads[$k]);
                         }
                         C::t('common_setting')->update('forumstickthreads', $forumstickthreads);
                         C::t('forum_forum_threadtable')->delete_none_threads();
                         if (!empty($deleteredirect)) {
                             deletethread($deleteredirect);
                         }
                         if (!empty($remarkclosed)) {
                             C::t('forum_thread')->update($remarkclosed, array('closed' => 0));
                         }
                         if ($_G['setting']['globalstick'] && $stickmodify) {
                             require_once libfile('function/cache');
                             updatecache('globalstick');
                         }
                         updateforumcount($_G['fid']);
                         if ($_GET['crimerecord']) {
                             include_once libfile('function/member');
                             foreach ($threadlist as $thread) {
                                 crime('recordaction', $thread['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $thread['tid'], 'pid' => 0)));
                             }
                         }
                         break;
                     case 'close':
                         if (!$_G['group']['allowclosethread']) {
                             $this->_exitWithHtmlAlert('no_privilege_closethread');
                         }
                         $expiration = checkexpiration($_GET['expirationclose'], $operation);
                         $modaction = $expiration ? 'ECL' : 'CLS';
                         C::t('forum_thread')->update($tidsarr, array('closed' => 1, 'moderated' => 1), true);
                         C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS', 'OPN', 'ECL', 'UCL', 'EOP', 'UEO'), array('status' => 0));
                         break;
                     case 'open':
                         if (!$_G['group']['allowclosethread']) {
                             $this->_exitWithHtmlAlert('no_privilege_openthread');
                         }
                         $expiration = checkexpiration($_GET['expirationclose'], $operation);
                         $modaction = $expiration ? 'EOP' : 'OPN';
                         C::t('forum_thread')->update($tidsarr, array('closed' => 0, 'moderated' => 1), true);
                         C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS', 'OPN', 'ECL', 'UCL', 'EOP', 'UEO'), array('status' => 0));
                         break;
                     case 'move':
                         if (!$_G['group']['allowmovethread']) {
                             $this->_exitWithHtmlAlert('no_privilege_movethread');
                         }
                         $moveto = $_GET['moveto'];
                         $toforum = C::t('forum_forum')->fetch_info_by_fid($moveto);
                         if (!$toforum || $_G['adminid'] != 1 && $toforum['status'] != 1 || $toforum['type'] == 'group') {
                             // showmessage('admin_move_invalid');
                             $this->_exitWithHtmlAlert('admin_move_invalid');
                         } elseif ($_G['fid'] == $toforum['fid']) {
                             continue;
                         } else {
                             $moveto = $toforum['fid'];
                             $modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $toforum['modnewposts'] ? 1 : 0;
                             $modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $toforum['modnewposts'] ? 1 : 0;
                             if ($modnewthreads || $modnewreplies) {
                                 // showmessage('admin_move_have_mod');
                                 $this->_exitWithHtmlAlert('admin_move_have_mod');
                             }
                         }
                         if ($_G['adminid'] == 3) {
                             $priv = C::t('forum_forumfield')->check_moderator_for_uid($moveto, $_G['uid'], $_G['member']['accessmasks']);
                             if (($priv['postperm'] && !in_array($_G['groupid'], explode("\t", $priv['postperm'])) || $_G['member']['accessmasks'] && ($priv['allowview'] || $priv['allowreply'] || $priv['allowgetattach'] || $priv['allowpostattach']) && !$priv['allowpost']) && !$priv['istargetmod']) {
                                 // showmessage('admin_move_nopermission');
                                 $this->_exitWithHtmlAlert('admin_move_nopermission');
                             }
                         }
                         $moderate = array();
                         $stickmodify = 0;
                         $toforumallowspecial = array(1 => $toforum['allowpostspecial'] & 1, 2 => $toforum['allowpostspecial'] & 2, 3 => isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && $toforum['allowpostspecial'] & 4, 4 => $toforum['allowpostspecial'] & 8, 5 => $toforum['allowpostspecial'] & 16, 127 => $_G['setting']['threadplugins'] ? dunserialize($toforum['threadplugin']) : array());
                         foreach ($threadlist as $tid => $thread) {
                             $allowmove = 0;
                             if (!$thread['special']) {
                                 $allowmove = 1;
                             } else {
                                 if ($thread['special'] != 127) {
                                     $allowmove = $toforum['allowpostspecial'] ? $toforumallowspecial[$thread['special']] : 0;
                                 } else {
                                     if ($toforumallowspecial[127]) {
                                         $posttable = getposttablebytid($thread['tid']);
                                         $message = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
                                         $message = $message['message'];
                                         $sppos = strrpos($message, chr(0) . chr(0) . chr(0));
                                         $specialextra = substr($message, $sppos + 3);
                                         $allowmove = in_array($specialextra, $toforumallowspecial[127]);
                                     } else {
                                         $allowmove = 0;
                                     }
                                 }
                             }
                             if ($allowmove) {
                                 $moderate[] = $tid;
                                 if (in_array($thread['displayorder'], array(2, 3))) {
                                     $stickmodify = 1;
                                 }
                                 if ($_GET['appbyme_movetype'] == 'redirect') {
                                     // if($_GET['type'] == 'redirect') {
                                     $insertdata = array('fid' => $thread['fid'], 'readperm' => $thread['readperm'], 'author' => $thread['author'], 'authorid' => $thread['authorid'], 'subject' => $thread['subject'], 'dateline' => $thread['dateline'], 'lastpost' => $thread['dblastpost'], 'lastposter' => $thread['lastposter'], 'views' => 0, 'replies' => 0, 'displayorder' => 0, 'digest' => 0, 'closed' => $thread['tid'], 'special' => 0, 'attachment' => 0, 'typeid' => $_GET['threadtypeid']);
                                     $newtid = C::t('forum_thread')->insert($insertdata, true);
                                     if ($newtid) {
                                         C::t('forum_threadclosed')->insert(array('tid' => $thread['tid'], 'redirect' => $newtid), true, true);
                                     }
                                 }
                             }
                         }
                         if (!($moderatetids = implode(',', $moderate))) {
                             showmessage('admin_moderate_invalid');
                         }
                         $fieldarr = array('fid' => $moveto, 'isgroup' => 0, 'typeid' => $_GET['threadtypeid'], 'moderated' => 1);
                         if ($_G['adminid'] == 3) {
                             $fieldarr['displayorder'] = 0;
                         }
                         C::t('forum_thread')->update($tidsarr, $fieldarr, true);
                         C::t('forum_forumrecommend')->update($tidsarr, array('fid' => $moveto));
                         loadcache('posttableids');
                         $posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
                         foreach ($posttableids as $id) {
                             C::t('forum_post')->update_by_tid($id, $tidsarr, array('fid' => $moveto));
                         }
                         $typeoptionvars = C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tidsarr);
                         foreach ($typeoptionvars as $typeoptionvar) {
                             C::t('forum_typeoptionvar')->update_by_tid($typeoptionvar['tid'], array('fid' => $moveto));
                             C::t('forum_optionvalue')->update($typeoptionvar['sortid'], $typeoptionvar['tid'], $_G['fid'], "fid='{$moveto}'");
                         }
                         if ($_G['setting']['globalstick'] && $stickmodify) {
                             require_once libfile('function/cache');
                             updatecache('globalstick');
                         }
                         $modaction = 'MOV';
                         $_G['toforum'] = $toforum;
                         updateforumcount($moveto);
                         updateforumcount($_G['fid']);
                         break;
                     default:
                         $errorMsg = '错误的动作参数';
                         break;
                 }
                 if ($errorMsg == '') {
                     if ($updatemodlog) {
                         if ($operation != 'delete') {
                             updatemodlog($moderatetids, $modaction, $expiration);
                         } else {
                             updatemodlog($moderatetids, $modaction, $expiration, 0, $reason);
                         }
                     }
                     updatemodworks($modaction, $modpostsnum);
                     foreach ($threadlist as $thread) {
                         modlog($thread, $modaction);
                     }
                     if ($sendreasonpm) {
                         $modactioncode = lang('forum/modaction');
                         $modtype = $modaction;
                         $modaction = $modactioncode[$modaction];
                         foreach ($threadlist as $thread) {
                             if ($operation == 'move') {
                                 sendreasonpm($thread, 'reason_move', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'tofid' => $toforum['fid'], 'toname' => $toforum['name'], 'from_id' => 0, 'from_idtype' => 'movethread'));
                             } else {
                                 sendreasonpm($thread, 'reason_moderate', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'from_id' => 0, 'from_idtype' => 'moderate_' . $modtype));
                             }
                         }
                     }
                     if ($stampstatus) {
                         set_stamp($stampstatus, $stampaction, $threadlist, $expiration);
                     }
                     $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview'));
                 }
             } else {
                 if ($act == 'move') {
                     require_once libfile('function/forumlist');
                     $forumselect = forumselect(FALSE, 0, $threadlist[$_G['tid']]['fid'], $_G['adminid'] == 1 ? TRUE : FALSE);
                 }
             }
         }
     } else {
         if ($type == 'post') {
             if ($act == 'band') {
                 $resultarray = $this->_topicAdmin_band($fid, $tid, $pid, $act, $type, array('sendreasonpm' => $sendreasonpm, 'thread' => $_G['forum_thread']));
             } else {
                 // 在DISCUZ_ROOT/source/include/topicadmin/topicadmin_delpost.php基础上进行二次开发
                 $resultarray = array();
                 $thread = $_G['forum_thread'];
                 $topiclist = array($pid);
                 $modpostsnum = 1;
                 $pids = $posts = $authors = array();
                 $posttable = getposttablebytid($_G['tid']);
                 foreach (C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $topiclist, false) as $post) {
                     if ($post['tid'] != $_G['tid']) {
                         continue;
                     }
                     if ($post['first'] == 1) {
                         dheader("location: {$_G['siteurl']}forum.php?mod=topicadmin&action=moderate&operation=delete&optgroup=3&fid={$_G['fid']}&moderate[]={$thread['tid']}&inajax=yes" . ($_GET['infloat'] ? "&infloat=yes&handlekey={$_GET['handlekey']}" : ''));
                     } else {
                         $authors[$post['authorid']] = 1;
                         $pids[] = $post['pid'];
                         $posts[] = $post;
                     }
                 }
                 if (!empty($_POST)) {
                     $reason = checkreasonpm();
                     $uidarray = $puidarray = $auidarray = array();
                     $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
                     if ($pids) {
                         require_once libfile('function/delete');
                         if ($_G['forum']['recyclebin']) {
                             deletepost($pids, 'pid', true, false, true);
                             manage_addnotify('verifyrecyclepost', $modpostsnum);
                         } else {
                             $logs = array();
                             $ratelog = C::t('forum_ratelog')->fetch_all_by_pid($pids);
                             $rposts = C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $pids, false);
                             foreach (C::t('forum_ratelog')->fetch_all_by_pid($pids) as $rpid => $author) {
                                 if ($author['score'] > 0) {
                                     $rpost = $rposts[$rpid];
                                     updatemembercount($rpost['authorid'], array($author['extcredits'] => -$author['score']));
                                     $author['score'] = $_G['setting']['extcredits'][$id]['title'] . ' ' . -$author['score'] . ' ' . $_G['setting']['extcredits'][$id]['unit'];
                                     $logs[] = dhtmlspecialchars("{$_G['timestamp']}\t{$_G[member][username]}\t{$_G['adminid']}\t{$rpost['author']}\t{$author['extcredits']}\t{$author['score']}\t{$thread['tid']}\t{$thread['subject']}\t{$delpostsubmit}");
                                 }
                             }
                             if (!empty($logs)) {
                                 writelog('ratelog', $logs);
                                 unset($logs);
                             }
                             deletepost($pids, 'pid', true);
                         }
                         if ($_GET['crimerecord']) {
                             include_once libfile('function/member');
                             foreach ($posts as $post) {
                                 crime('recordaction', $post['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $post['tid'], 'pid' => $post['pid'])));
                             }
                         }
                     }
                     updatethreadcount($_G['tid'], 1);
                     updateforumcount($_G['fid']);
                     $_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']);
                     $modaction = 'DLP';
                     $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$_GET['page']}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post', 'notictype' => 'post') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason), 'modtids' => 0, 'modlog' => $thread);
                 }
             }
         }
     }
     // 在DISCUZ_ROOT/source/module/forum/forum_topicadmin.php基础上进行二次开发
     if ($resultarray) {
         if ($resultarray['modtids']) {
             updatemodlog($resultarray['modtids'], $modaction, $resultarray['expiration']);
         }
         updatemodworks($modaction, $modpostsnum);
         if (is_array($resultarray['modlog'])) {
             if (isset($resultarray['modlog']['tid'])) {
                 modlog($resultarray['modlog'], $modaction);
             } else {
                 foreach ($resultarray['modlog'] as $thread) {
                     modlog($thread, $modaction);
                 }
             }
         }
         if ($resultarray['reasonpm']) {
             $modactioncode = lang('forum/modaction');
             $modaction = $modactioncode[$modaction];
             foreach ($resultarray['reasonpm']['data'] as $var) {
                 sendreasonpm($var, $resultarray['reasonpm']['item'], $resultarray['reasonvar'], $resultarray['reasonpm']['notictype']);
             }
         }
         // showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
         $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview'));
     }
     $this->getController()->renderPartial('topicAdmin', array('formUrl' => WebUtils::createUrl_oldVersion('forum/topicadminview', array('fid' => $fid, 'tid' => $tid, 'pid' => $pid, 'act' => $act, 'type' => $type)), 'errorMsg' => $errorMsg, 'action' => $act, '_G' => $_G, 'stickcheck' => $stickcheck, 'digestcheck' => $digestcheck, 'closecheck' => $closecheck, 'forumselect' => WebUtils::u($forumselect)));
 }
Exemple #21
0
     $common_url = "home.php?mod=space&uid={$org['uid']}&do=blog&id={$article['id']}";
     $form_url = "home.php?mod=spacecp&ac=comment";
     $article['commentnum'] = C::t('home_comment')->count_by_id_idtype($article['id'], 'blogid');
     if ($article['commentnum']) {
         $query = C::t('home_comment')->fetch_all_by_id_idtype($article['id'], 'blogid', 0, 20, '', 'DESC');
         foreach ($query as $value) {
             if ($value['status'] == 0 || $_G['adminid'] == 1 || $value['uid'] == $_G['uid']) {
                 $commentlist[] = $value;
             }
         }
     }
 } elseif ($article['idtype'] == 'tid') {
     $common_url = "forum.php?mod=viewthread&tid={$article['id']}";
     $form_url = "forum.php?mod=post&action=reply&tid={$article['id']}&replysubmit=yes&infloat=yes&handlekey=fastpost";
     require_once libfile('function/discuzcode');
     $posttable = empty($thread['posttable']) ? getposttablebytid($article['id']) : $thread['posttable'];
     $_G['tid'] = $article['id'];
     $article['commentnum'] = getcount($posttable, array('tid' => $article['id'], 'first' => '0'));
     if ($article['allowcomment'] && $article['commentnum']) {
         $attachpids = $attachtags = array();
         $_G['group']['allowgetattach'] = $_G['group']['allowgetimage'] = 1;
         foreach (C::t('forum_post')->fetch_all_by_tid('tid:' . $article['id'], $article['id'], true, 'ASC', 0, 20, null, 0) as $value) {
             $value['uid'] = $value['authorid'];
             $value['username'] = $value['author'];
             if ($value['status'] != 1 && !$value['first']) {
                 $value['message'] = discuzcode($value['message'], $value['smileyoff'], $value['bbcodeoff'], $value['htmlon']);
                 $value['cid'] = $value['pid'];
                 $commentlist[$value['pid']] = $value;
                 if ($value['attachment']) {
                     $attachpids[] = $value['pid'];
                     if (preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $value['message'], $matchaids)) {
        cpmsg("{$lang['counter_forum']}: " . cplang('counter_processing', array('current' => $start, 'next' => $end)), $nextlink, 'loading');
    } else {
        $inc = $id['max'] + 1;
        DB::query("ALTER TABLE " . DB::table('forum_post') . " AUTO_INCREMENT = {$inc}");
        cpmsg('tools:success', "action=plugins&identifier=tools&operation={$operation}&do={$do}&pmod=maintain&cp=aboutdb", 'succeed');
    }
} elseif (submitcheck('clearthreadsubmit', 1)) {
    $id = getmaxmin('forum_thread', 'tid');
    if ($_G['gp_start'] == 0) {
        $_G['gp_start'] = $id['min'];
    }
    $start = $_G['gp_start'];
    $end = $_G['gp_start'] + $rpp;
    $query = DB::query("SELECT tid,subject FROM " . DB::table('forum_thread') . " WHERE tid >= {$start} AND tid < {$end}");
    while ($thread = DB::fetch($query)) {
        $posttableid = getposttablebytid($thread[tid]);
        $posts = DB::result_first("SELECT count(*) FROM " . DB::table("{$posttableid}") . " WHERE tid = {$thread['tid']}");
        if ($posts <= 0) {
            $rows++;
            DB::delete('forum_thread', "tid = {$thread['tid']}");
        } elseif ($thread['subject'] == '') {
            $rows++;
            DB::delete('forum_thread', "tid = {$thread['tid']}");
            DB::delete("{$posttableid}", "tid = {$thread['tid']}");
        } else {
            $query = DB::query("SELECT a.aid FROM " . DB::table("{$posttableid}") . " p," . DB::table('forum_attachment') . " a WHERE a.tid = {$thread['tid']} AND a.pid = p.pid AND p.invisible = 0 LIMIT 1");
            $attachment = DB::num_rows($query) ? 1 : 0;
            //修复附件
            $query = "SELECT pid, subject, rate FROM " . DB::table("{$posttableid}") . " WHERE tid= {$thread['tid']}  AND invisible='0' ORDER BY dateline LIMIT 1";
            $firstpost = DB::fetch_first($query);
            $firstpost['subject'] = trim($firstpost['subject']) ? $firstpost['subject'] : $thread['subject'];