Beispiel #1
0
function block_bbspost($paramarr)
{
    global $_SGLOBAL, $_SGET;
    dbconnect(1);
    @(include_once S_ROOT . './data/system/bbsforums.cache.php');
    $fidarr = array();
    foreach ($_SGLOBAL['bbsforumarr'] as $value) {
        if (!empty($value['allowshare'])) {
            $fidarr[] = $value['fid'];
        }
    }
    $fids = simplode($fidarr);
    if (empty($paramarr['sql'])) {
        //set sql var
        $sql = array();
        //select
        $sql['select'] = 'SELECT *';
        //from
        $sql['from'] = 'FROM ' . tname('posts', 1);
        //where
        $wherearr = array();
        if (!empty($paramarr['pid'])) {
            $paramarr['pid'] = getdotstring($paramarr['pid'], 'int');
            $wherearr[] = 'pid IN (' . $paramarr['pid'] . ')';
        } else {
            $wherearr[] = 'invisible = 0';
            if (!empty($paramarr['fid'])) {
                $paramarr['fid'] = getdotstring($paramarr['fid'], 'int');
                if ($paramarr['fid']) {
                    $wherearr[] = 'fid IN (' . $paramarr['fid'] . ')';
                }
            }
            $wherearr[] = 'fid IN (' . $fids . ')';
            if (!empty($paramarr['tid'])) {
                $paramarr['tid'] = getdotstring($paramarr['tid'], 'int');
                if ($paramarr['tid']) {
                    $wherearr[] = 'tid IN (' . $paramarr['tid'] . ')';
                }
            }
            if (!empty($paramarr['first'])) {
                $wherearr[] = 'first = 1';
            }
            if (!empty($paramarr['attachment'])) {
                $wherearr[] = 'attachment = 1';
            }
        }
        if (!empty($wherearr)) {
            $sql['where'] = 'WHERE ' . implode(' AND ', $wherearr);
        }
        //order
        if (!empty($paramarr['order'])) {
            $sql['order'] = 'ORDER BY ' . $paramarr['order'];
        }
        //limit
        if (!empty($paramarr['perpage'])) {
            $paramarr['perpage'] = intval($paramarr['perpage']);
            if (empty($paramarr['perpage'])) {
                $paramarr['perpage'] = 20;
            }
            if (empty($_SGET['page'])) {
                $_SGET['page'] = 1;
            }
            $_SGET['page'] = intval($_SGET['page']);
            if ($_SGET['page'] < 1) {
                $_SGET['page'] = 1;
            }
            $start = ($_SGET['page'] - 1) * $paramarr['perpage'];
            $sql['limit'] = 'LIMIT ' . $start . ',' . $paramarr['perpage'];
        } else {
            if (empty($paramarr['limit'])) {
                $sql['limit'] = 'LIMIT 0,1';
            } else {
                $paramarr['limit'] = getdotstring($paramarr['limit'], 'int', true, array(), 1, false);
                if ($paramarr['limit']) {
                    $sql['limit'] = 'LIMIT ' . $paramarr['limit'];
                } else {
                    $sql['limit'] = 'LIMIT 0,1';
                }
            }
        }
        //query
        $sqlstring = implode(' ', $sql);
        dbconnect(1);
        //multi
        $listcount = 1;
        if (!empty($paramarr['perpage'])) {
            $listcount = $_SGLOBAL['db_bbs']->result($_SGLOBAL['db_bbs']->query('SELECT COUNT(*) FROM ' . tname('posts', 1) . ' ' . $sql['where']), 0);
            if ($listcount) {
                $urlarr = $_SGET;
                unset($urlarr['page']);
                $theblockarr['multipage'] = multi($listcount, $paramarr['perpage'], $_SGET['page'], $urlarr, 0);
            }
        }
    } else {
        dbconnect(1);
        $bbsdb = $_SGLOBAL['db_bbs'];
        include_once S_ROOT . './function/block_sql.func.php';
        list($sqlstring, $listcount) = runsql($paramarr, $bbsdb);
        if (!empty($paramarr['perpage'])) {
            if ($listcount) {
                $urlarr = $_SGET;
                unset($urlarr['page']);
                $theblockarr['multipage'] = multi($listcount, $paramarr['perpage'], $_SGET['page'], $urlarr, 0);
            }
        }
    }
    //query
    if ($listcount) {
        if (empty($paramarr['subjectdot'])) {
            $paramarr['subjectdot'] = 0;
        }
        if (empty($paramarr['messagedot'])) {
            $paramarr['messagedot'] = 0;
        }
        $query = $_SGLOBAL['db_bbs']->query($sqlstring);
        $aids = $dot = '';
        $theblockarr['text'] = array();
        while ($post = $_SGLOBAL['db_bbs']->fetch_array($query)) {
            //附件
            if ($post['attachment']) {
                $aids .= $dot . $post['pid'];
                $dot = ', ';
            }
            //链接
            $post['url'] = getbbsurl('viewthread.php', array('tid' => $post['tid']));
            //标题处理
            if (!empty($post['subject'])) {
                $post['subjectall'] = $post['subject'];
            }
            if (!empty($post['subject']) && !empty($paramarr['subjectlen'])) {
                $post['subject'] = cutstr($post['subject'], $paramarr['subjectlen'], $paramarr['subjectdot']);
            }
            //内容
            if (!empty($post['message']) && !empty($paramarr['messagelen'])) {
                $post['message'] = trim(stripbbcode(strip_tags($post['message'])));
                $post['message'] = trim(cutstr($post['message'], $paramarr['messagelen'], $paramarr['messagedot']));
            }
            if (empty($post['subject']) && !empty($post['message'])) {
                $post['subject'] = $post['subjectall'] = cutstr(trim(stripbbcode(strip_tags($post['message']))), 40, 1);
            }
            $theblockarr['text'][] = $post;
        }
        //附件处理
        if ($aids) {
            $sqlstring = 'SELECT * FROM ' . tname('attachments', 1) . ' WHERE pid IN (' . $aids . ')';
            $query = $_SGLOBAL['db_bbs']->query($sqlstring);
            while ($attach = $_SGLOBAL['db_bbs']->fetch_array($query)) {
                $value['attachment'] = getbbsattachment($value);
                $theblockarr[$attach['pid']][] = $attach;
            }
        }
        unset($aids, $dot);
    }
    return $theblockarr;
}
Beispiel #2
0
 }
 if (!empty($post['psubject'])) {
     $post['subject'] = $post['psubject'];
 }
 $thevalue['digest'] = $post['digest'];
 $thevalue['top'] = $post['displayorder'];
 include_once S_ROOT . '/include/bbcode.inc.php';
 if ($post['attachment']) {
     $query = $_SGLOBAL['db_bbs']->query("SELECT * FROM " . tname('attachments', 1) . " WHERE pid='{$post['pid']}'");
     if ($_SGLOBAL['db_bbs']->num_rows($query)) {
         while ($attach = $_SGLOBAL['db_bbs']->fetch_array($query)) {
             $attach['dateline'] = sgmdate($attach['dateline']);
             $attach['attachicon'] = S_URL . '/images/base/download.gif';
             $attach['attachsize'] = formatsize($attach['filesize']);
             $attach['attachimg'] = $attach['isimage'];
             $attach['attachment'] = getbbsattachment($attach);
             $post['attachments'][$attach['aid']] = $attach;
         }
     }
 }
 if (empty($post['htmlon'])) {
     $post['htmlon'] = $post['allowhtml'];
 }
 $post['message'] = bbcode($post['message'], $post['bbcodeoff'], $post['smileyoff'], $post['htmlon'], 0);
 if (!empty($post['attachments'])) {
     if (preg_match("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $post['message'])) {
         $post['message'] = preg_replace("/\\[attach\\](\\d+)\\[\\/attach\\]/ie", "postattachtag(\\1)", $post['message']);
     }
 }
 //Ìû×Ó¸½¼þ´¦Àí
 if (!empty($post['attachments'])) {