示例#1
0
function getCommentDbByTypeid($type, $typeid, $page, $url)
{
    global $db, $groupid, $db_shield, $db_perpage, $db_windpost;
    if (!checkCommType($type)) {
        Showmsg('undefined_action');
    }
    $wordsfb = L::loadClass('FilterUtil');
    $commentdb = $subcommentdb = array();
    $count = $db->get_value("SELECT COUNT(*) FROM pw_comment WHERE type=" . pwEscape($type) . " AND typeid=" . pwEscape($typeid) . " AND upid='0'");
    $numofpage = ceil($count / $db_perpage);
    $start = ($page - 1) * $db_perpage;
    $limit = pwLimit($start, $db_perpage);
    $query = $db->query("SELECT c.id,c.uid,c.username,c.title,c.postdate,c.typeid,c.upid,c.ifwordsfb,m.icon as face,m.groupid FROM pw_comment c LEFT JOIN pw_members m ON c.uid=m.uid WHERE c.type=" . pwEscape($type) . " AND c.typeid=" . pwEscape($typeid) . " AND upid='0' ORDER BY postdate DESC {$limit}");
    while ($rt = $db->fetch_array($query)) {
        $rt['postdate'] = get_date($rt['postdate']);
        list($rt['face']) = showfacedesign($rt['face'], 1, 'm');
        if ($rt['groupid'] == 6 && $db_shield && $groupid != 3) {
            $rt['title'] = getLangInfo('other', 'ban_comment');
        } elseif (!$wordsfb->equal($rt['ifwordsfb'])) {
            $rt['title'] = $wordsfb->convert($rt['title'], array('id' => $rt['id'], 'type' => 'comments', 'code' => $rt['ifwordsfb']));
        }
        if (strpos($rt['title'], '[s:') !== false) {
            $rt['title'] = showface($rt['title']);
        }
        if (strpos($rt['title'], '[url') !== false) {
            $rt['title'] = convert($rt['title'], $db_windpost);
        }
        $commentids[] = $rt['id'];
        $commentdb[$rt['id']] = $rt;
    }
    if ($commentids) {
        $query = $db->query("SELECT c.id,c.uid,c.username,c.title,c.postdate,c.typeid,c.upid,c.ifwordsfb,m.icon as face,m.groupid FROM pw_comment c LEFT JOIN pw_members m ON c.uid=m.uid WHERE c.type=" . pwEscape($type) . " AND c.typeid=" . pwEscape($typeid) . " AND upid IN (" . pwImplode($commentids) . ") ORDER BY postdate ASC");
        while ($rt = $db->fetch_array($query)) {
            $rt['postdate'] = get_date($rt['postdate']);
            list($rt['face']) = showfacedesign($rt['face'], 1, 'm');
            if ($rt['groupid'] == 6 && $db_shield && $groupid != 3) {
                $rt['title'] = getLangInfo('other', 'ban_comment');
            } elseif (!$wordsfb->equal($rt['ifwordsfb'])) {
                $rt['title'] = $wordsfb->convert($rt['title'], array('id' => $rt['id'], 'type' => 'comments', 'code' => $rt['ifwordsfb']));
            }
            $subcommentdb[$rt['upid']][$rt['id']] = $rt;
        }
    }
    $pages = numofpage($count, $page, $numofpage, $url);
    return array($commentdb, $subcommentdb, $pages);
}
示例#2
0
文件: index.php 项目: jechiy/PHPWind
    $lastcomment = end($comment);
    $a = 'showcommlist';
    require_once printEOT('m_ajax');
    ajax_footer();
} elseif ($a == 'commreply') {
    require_once R_P . 'require/showimg.php';
    require_once R_P . 'require/postfunc.php';
    banUser();
    S::gp(array('type', 'id', 'title', 'upid', 'position', 'other'), 'P');
    $title = nl2br(str_replace(array('=', '%26'), array('=', '&'), $title));
    $id = (int) $id;
    $upid = (int) $upid ? (int) $upid : 0;
    if (!$id) {
        Showmsg('undefined_action');
    }
    if (!checkCommType($type)) {
        Showmsg('undefined_action');
    }
    $app_table = $id_filed = '';
    list($app_table, $id_filed) = getCommTypeTable($type);
    $count = $db->get_value("SELECT COUNT(*) AS count FROM pw_comment WHERE type=" . S::sqlEscape($type) . " AND typeid=" . S::sqlEscape($id));
    if ($count > 99) {
        Showmsg('mode_o_com_count_max');
    }
    if (strlen($title) < 3 || strlen($title) > 200) {
        Showmsg('mode_o_com_title_error');
    }
    require_once R_P . 'require/bbscode.php';
    $wordsfb = L::loadClass('FilterUtil', 'filter');
    if (($banword = $wordsfb->comprise($title, true, true)) !== false) {
        Showmsg('title_wordsfb');