示例#1
0
 function uploadmsg($statusid)
 {
     global $_G;
     $errorMap = array(0 => '上传成功', 10 => '非法提交', 2 => '上传失败', 6 => '附件个数超限制', 1 => '非法附件后缀', 2 => '上传失败', 3 => '附件超最大限制', 4 => '附件超最大限制', 5 => '附件超最大限制', 11 => '今日附件总大小超限制', 8 => '保存图片失败', 9 => '保存附件失败', 7 => '文件格式不一致');
     $msg = '附件提交失败';
     if (isset($errorMap[$statusid])) {
         $msg = $errorMap[$statusid];
     }
     if (function_exists('iconv')) {
         $msg = iconv('UTF-8', CHARSET . '//ignore', $msg);
     } else {
         $msg = mb_convert_encoding($msg, CHARSET, 'UTF-8');
     }
     $variable = array('code' => $statusid, 'message' => $msg, 'ret' => array('aId' => $this->aid, 'relative_url' => $this->attach['attachment'], 'abs_url' => ApiUtils::getDzRoot() . $_G['setting']['attachurl'] . 'forum/' . $this->attach['attachment'], 'image' => $this->attach['isimage'] ? -1 : 2));
     bigapp_core::result(bigapp_core::variable($variable));
 }
示例#2
0
 protected function _getPictures(&$threadInfo)
 {
     global $_G;
     $collect =& BigAppAPI::$collect;
     foreach ($threadInfo as $tid => &$info) {
         $collect = array();
         $message = str_replace("\r", '', $info['message']);
         $message = str_replace("\n", '', $message);
         $message = str_replace('\\r', '', $message);
         $message = str_replace('\\n', '', $message);
         if (function_exists('iconv')) {
             $message = iconv(CHARSET, 'UTF-8//ignore', $message);
         } else {
             $message = mb_convert_encoding($message, 'UTF-8', CHARSET);
         }
         $message = preg_replace_callback('/\\[img.*?\\](.*?)\\[\\/img\\]|\\[attach\\]([0-9]+)\\[\\/attach\\]|\\[i.*\\](.*)' . '\\[\\/i\\]|\\[.*?\\]|\\n|\\r/', 'BigAppAPI::imgCallback', $message);
         if (function_exists('mb_substr')) {
             $message = mb_substr($message, 0, 1000, 'UTF-8');
         } else {
             $message = substr($message, 0, 2000);
         }
         /*$find = array(':)', ':(', ':D', ':\'(', ':@', ':o', ':P', ':$', ';P', ':L', ':Q', ':lol', ':loveliness:', 
         				':funk:', ':curse:', ':dizzy:', ':shutup:', ':sleepy:', ':hug:', ':victory:', ':time:', ':kiss:', ':handshake', ':call:');
         		$replace = array("\xF0\x9F\x98\x8C", "\xF0\x9F\x98\x94",  "\xF0\x9F\x98\x83", "\xF0\x9F\x98\xAD", "\xF0\x9F\x98\xA0", 
         				"\xF0\x9F\x98\xB2", "\xF0\x9F\x98\x9C", "\xF0\x9F\x98\x86", "\xF0\x9F\x98\x9D",  "\xF0\x9F\x98\x93",  "\xF0\x9F\x98\xAB", 
         				"\xF0\x9F\x98\x81", "\xF0\x9F\x98\x8A", "\xF0\x9F\x98\xB1", "\xF0\x9F\x98\xA4", "\xF0\x9F\x98\x96", "\xF0\x9F\x98\xB7", 
         				"\xF0\x9F\x98\xAA", "\xF0\x9F\x98\x9A", "\xE2\x9C\x8C", "\xE2\x8F\xB0", "\xF0\x9F\x92\x8B", "\xF0\x9F\x91\x8C", "\xF0\x9F\x93\x9E");*/
         //$message = str_replace($find, $replace, $message);
         loadcache(array('smilies', 'smileytypes'));
         foreach ($_G['cache']['smilies']['replacearray'] as $id => $img) {
             $pattern = $_G['cache']['smilies']['searcharray'][$id];
             $message = preg_replace($pattern, '[表情]', $message);
         }
         if (function_exists('mb_strlen')) {
             if (mb_strlen($message, 'UTF-8') > 30) {
                 $message = mb_substr($message, 0, 30, 'UTF-8') . '...';
             }
         } else {
             if (strlen($message) > 60) {
                 $message = substr($message, 0, 30) . '...';
             }
         }
         $info['message'] = '__DONT_DICONV_TO_UTF8___' . $message;
         $attachments = array();
         $infoAttrs = $info['attachments'];
         foreach ($collect as $attach) {
             if (is_numeric($attach)) {
                 if (isset($infoAttrs[$attach])) {
                     $url = ($infoAttrs[$attach]['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
                     $url .= $infoAttrs[$attach]['attachment'];
                     $tmp = parse_url($url);
                     if (!isset($tmp['scheme'])) {
                         $url = ApiUtils::getDzRoot() . $url;
                     }
                     $info['attachment_urls'][] = $url;
                     unset($infoAttrs[$attach]);
                 }
                 continue;
             }
             $tmp = parse_url($attach);
             if (!isset($tmp['scheme'])) {
                 $url = ApiUtils::getDzRoot() . $attach;
             } else {
                 $url = str_replace('source/plugin/mobile/', '', $attach);
                 $url = str_replace('source/plugin/mobile/', '', $url);
             }
             $info['attachment_urls'][] = $url;
         }
         global $_G;
         //feed others
         foreach ($infoAttrs as $aid => $aInfo) {
             $url = ($aInfo['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
             $url .= $aInfo['attachment'];
             $tmp = parse_url($url);
             if (!isset($tmp['scheme'])) {
                 $url = ApiUtils::getDzRoot() . $url;
             }
             $info['attachment_urls'][] = $url;
         }
     }
     unset($info);
 }
示例#3
0
 function output()
 {
     global $_G, $thread;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     if ($GLOBALS['hiddenreplies']) {
         foreach ($GLOBALS['postlist'] as $k => $post) {
             if (!$post['first'] && $_G['uid'] != $post['authorid'] && $_G['uid'] != $_G['forum_thread']['authorid'] && !$_G['forum']['ismoderator']) {
                 $GLOBALS['postlist'][$k]['message'] = lang('plugin/mobile', 'mobile_post_author_visible');
                 $GLOBALS['postlist'][$k]['attachments'] = array();
             }
         }
     }
     $_G['thread']['lastpost'] = dgmdate($_G['thread']['lastpost']);
     $_G['thread']['ordertype'] = $GLOBALS['ordertype'];
     if (!empty($_GET['viewpid'])) {
         $GLOBALS['postlist'][$_GET['viewpid']] = $GLOBALS['post'];
     }
     if (!$_G['thread']['maxposition']) {
         $_G['thread']['maxposition'] = "1";
     }
     if ($GLOBALS['rushreply']) {
         $_G['thread']['rushreply'] = $GLOBALS['rushreply'];
         $_G['thread']['rushresult'] = $GLOBALS['rushresult'];
     }
     foreach ($GLOBALS['comments'] as $pid => $comments) {
         $comments = bigapp_core::getvalues($comments, array('/^\\d+$/'), array('id', 'tid', 'pid', 'author', 'authorid', 'dateline', 'comment', 'avatar'));
         foreach ($comments as $k => $c) {
             $comments[$k]['avatar'] = avatar($c['authorid'], 'small', true);
             $comments[$k]['dateline'] = dgmdate($c['dateline'], 'u');
         }
         $GLOBALS['comments'][$pid] = $comments;
     }
     $variable = array('thread' => $_G['thread'], 'fid' => $_G['fid'], 'postlist' => array_values(bigapp_core::getvalues($GLOBALS['postlist'], array('/^\\d+$/'), array('uid', 'pid', 'tid', 'author', 'first', 'dbdateline', 'dateline', 'username', 'adminid', 'memberstatus', 'authorid', 'username', 'groupid', 'memberstatus', 'status', 'message', 'number', 'memberstatus', 'groupid', 'attachment', 'attachments', 'attachlist', 'imagelist', 'anonymous', 'extcredits2', 'posts', 'threads', 'authortitle', 'position', 'postreview', 'isWater'))), 'allowpostcomment' => $_G['setting']['allowpostcomment'], 'comments' => $GLOBALS['comments'], 'commentcount' => $GLOBALS['commentcount'], 'imagelist' => array(), 'ppp' => $_G['ppp'], 'totalpage' => $GLOBALS['totalpage'], 'setting_rewriterule' => $_G['setting']['rewriterule'], 'setting_rewritestatus' => $_G['setting']['rewritestatus'], 'forum_threadpay' => $_G['forum_threadpay'], 'cache_custominfo_postno' => $_G['cache']['custominfo']['postno']);
     //帖子举报
     $variable['report']['enable'] = '1';
     $variable['report']['handlekey'] = 'miscreport' . $variable['postlist'][0]['tid'];
     $language_file = 'source/language/lang_template.php';
     if (file_exists($language_file)) {
         require_once $language_file;
     }
     $report_msg = explode(",", $lang['report_reason_message']);
     foreach ($report_msg as $key => $msg) {
         #$report_msg[$key] = preg_replace('/[|\'/', '', $msg);
         $msg = str_replace('[', '', $msg);
         $msg = str_replace(']', '', $msg);
         $msg = str_replace("'", "", $msg);
         $report_msg[$key] = $msg;
     }
     if (empty($report_msg[0])) {
         $variable['report']['content'] = array();
     } else {
         $variable['report']['content'] = $report_msg;
     }
     foreach ($variable['postlist'] as &$_item) {
         $_item['dateline'] = preg_replace('/<.*?\\>/', '', $_item['dateline']);
     }
     unset($_item);
     if (!empty($GLOBALS['threadsortshow'])) {
         $optionlist = array();
         foreach ($GLOBALS['threadsortshow']['optionlist'] as $key => $val) {
             $val['optionid'] = $key;
             $optionlist[] = $val;
         }
         if (!empty($optionlist)) {
             $GLOBALS['threadsortshow']['optionlist'] = $optionlist;
             $GLOBALS['threadsortshow']['threadsortname'] = $_G['forum']['threadsorts']['types'][$thread['sortid']];
         }
     }
     $threadsortshow = bigapp_core::getvalues($GLOBALS['threadsortshow'], array('/^(?!typetemplate).*$/'));
     if (!empty($threadsortshow)) {
         $variable['threadsortshow'] = $threadsortshow;
     }
     foreach ($variable['postlist'] as $k => &$post) {
         if (!$_G['forum']['ismoderator'] && $_G['setting']['bannedmessages'] & 1 && ($post['authorid'] && !$post['username'] || $_G['thread']['digest'] == 0 && ($post['groupid'] == 4 || $post['groupid'] == 5 || $post['memberstatus'] == '-1'))) {
             $message = lang('forum/template', 'message_banned');
         } elseif (!$_G['forum']['ismoderator'] && $post['status'] & 1) {
             $message = lang('forum/template', 'message_single_banned');
         } elseif ($GLOBALS['needhiddenreply']) {
             $message = lang('forum/template', 'message_ishidden_hiddenreplies');
         } elseif ($post['first'] && $_G['forum_threadpay']) {
             $message = lang('forum/template', 'pay_threads') . ' ' . $GLOBALS['thread']['price'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'];
         } elseif ($_G['forum_discuzcode']['passwordlock']) {
             $message = lang('forum/template', 'message_password_exists');
         } else {
             $message = '';
         }
         //回帖举报
         ##############################
         /*if($_G['uid'] != $variable['postlist'][$k]['authorid']) {
         				$variable['postlist'][$k]['report']['enable'] = '1';
         				$variable['postlist'][$k]['report']['handlekey']='miscreport'.$variable['postlist'][$k]['pid'];
         				$variable['postlist'][$k]['report']['content'] = lang('plugin/bigapp', 'report_reason_message');
         		} else {
         				$variable['postlist'][$k]['report']['enable'] = '0';
         		}*/
         ##############################
         if ($message) {
             $variable['postlist'][$k]['message'] = $message;
         }
         if ($post['anonymous'] && !$_G['forum']['ismoderator']) {
             $variable['postlist'][$k]['username'] = $variable['postlist'][$k]['author'] = $_G['setting']['anonymoustext'];
             $variable['postlist'][$k]['adminid'] = $variable['postlist'][$k]['groupid'] = $variable['postlist'][$k]['authorid'] = 0;
             if ($post['first']) {
                 $variable['thread']['authorid'] = 0;
             }
         }
         if (strpos($variable['postlist'][$k]['message'], '[/tthread]') !== FALSE) {
             $matches = array();
             preg_match('/\\[tthread=(.+?),(.+?)\\](.*?)\\[\\/tthread\\]/', $variable['postlist'][$k]['message'], $matches);
             $variable['postlist'][$k]['message'] = preg_replace('/\\[tthread=(.+?)\\](.*?)\\[\\/tthread\\]/', lang('plugin/qqconnect', 'connect_tthread_message', array('username' => $matches[1], 'nick' => $matches[2])), $variable['postlist'][$k]['message']);
         }
         $variable['postlist'][$k]['message'] = preg_replace("/<a\\shref=\"([^\"]+?)\"\\starget=\"_blank\">\\[viewimg\\]<\\/a>/is", "<img src=\"\\1\" />", $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = BigAppAPI::_findimg($variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = str_replace('!post_hide_reply_hidden!', lang('plugin/bigapp', 'post_hide_reply_hide'), $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = str_replace('post_hide_reply_hidden', lang('plugin/bigapp', 'post_hide_reply_hide'), $variable['postlist'][$k]['message']);
         if ($GLOBALS['aimgs'][$post['pid']]) {
             $imagelist = array();
             foreach ($GLOBALS['aimgs'][$post['pid']] as $aid) {
                 $extra = '';
                 $url = BigAppAPI::_parseimg('', $GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['url'] . $GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['attachment'], '');
                 if ($GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['thumb']) {
                     $extra = 'file="' . $url . '" ';
                     $url .= '.thumb.jpg';
                 }
                 $extra .= 'attach="' . $post['pid'] . '" ';
                 if (strexists($variable['postlist'][$k]['message'], '[attach]' . $aid . '[/attach]')) {
                     $variable['postlist'][$k]['message'] = str_replace('[attach]' . $aid . '[/attach]', '<div class="img"><img src="' . $url . '" ' . $extra . '/></div>', $variable['postlist'][$k]['message']);
                     unset($variable['postlist'][$k]['attachments'][$aid]);
                 } elseif (!in_array($aid, $_G['forum_attachtags'][$post['pid']])) {
                     $imagelist[] = $aid;
                 }
             }
             $variable['postlist'][$k]['imagelist'] = $imagelist;
         }
         $variable['postlist'][$k]['message'] = preg_replace("/\\[attach\\]\\d+\\[\\/attach\\]/i", '', $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = preg_replace('/(&nbsp;){2,}/', '', $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['dateline'] = strip_tags($post['dateline']);
         $variable['postlist'][$k]['groupiconid'] = bigapp_core::usergroupIconId($post['groupid']);
         if ($post['first']) {
             $post['recommends'] = $_G['thread']['recommends'];
             $post['recommend_add'] = $_G['thread']['recommend_add'];
             $post['recommend_sub'] = $_G['thread']['recommend_sub'];
             $post['enable_recommend'] = 0;
             if (($_G['group']['allowrecommend'] || !$_G['uid']) && $_G['setting']['recommendthread']['status']) {
                 $post['enable_recommend'] = 1;
                 $post['click2login'] = 0;
                 if (!$_G['uid']) {
                     $post['click2login'] = 1;
                 }
             }
             $post['addtext'] = $_G['setting']['recommendthread']['addtext'];
             $post['subtext'] = $_G['setting']['recommendthread']['subtracttext'];
             $post['recommend_value'] = $_G['group']['allowrecommend'];
             $post['recommended'] = 0;
             if (C::t('forum_memberrecommend')->fetch_by_recommenduid_tid($_G['uid'], $post['tid'])) {
                 $post['recommended'] = 1;
             }
         } else {
             $post['enable_support'] = 0;
             @preg_match('/^x([0-9\\.]+)/i', $_G['setting']['version'], $matches);
             $num = 0;
             if (isset($matches[1])) {
                 $num = $matches[1];
             }
             if ($num >= 3.1 && !$_G['forum_thread']['special'] && !$rushreply && !$hiddenreplies && $_G['setting']['repliesrank'] && !$post['first'] && !($post['isWater'] && $_G['setting']['filterednovote'])) {
                 $post['enable_support'] = 1;
                 $post['click2login'] = 0;
                 if (!$_G['uid']) {
                     $post['click2login'] = 1;
                 }
             }
             if (function_exists('iconv')) {
                 $post['supporttext'] = iconv('UTF-8', CHARSET . '//ignore', '支持');
                 $post['opposetext'] = iconv('UTF-8', CHARSET . '//ignore', '反对');
             } else {
                 $post['supporttext'] = mb_convert_encoding('支持', CHARSET, 'UTF-8');
                 $post['opposetext'] = mb_convert_encoding('反对', CHARSET, 'UTF-8');
             }
             $post['support'] = 0;
             $post['oppose'] = 0;
             if (isset($post['postreview']['support'])) {
                 $post['support'] = $post['postreview']['support'];
             }
             if (isset($post['postreview']['against'])) {
                 $post['oppose'] = $post['postreview']['against'];
             }
             unset($post['isWater']);
             unset($post['postreview']);
         }
     }
     unset($post);
     foreach ($GLOBALS['aimgs'] as $pid => $aids) {
         foreach ($aids as $aid) {
             $variable['imagelist'][] = $GLOBALS['postlist'][$pid]['attachments'][$aid]['url'] . $GLOBALS['postlist'][$pid]['attachments'][$aid]['attachment'];
         }
     }
     $variable['special_poll'] = BigAppAPI::getPollInfo();
     if (!empty($GLOBALS['rewardprice'])) {
         $variable['special_reward']['rewardprice'] = $GLOBALS['rewardprice'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]['title'];
         $variable['special_reward']['bestpost'] = $GLOBALS['bestpost'];
     }
     if (!empty($GLOBALS['trades'])) {
         $variable['special_trade'] = $GLOBALS['trades'];
     }
     if (!empty($GLOBALS['debate'])) {
         $variable['special_debate'] = $GLOBALS['debate'];
     }
     if (!empty($GLOBALS['activity'])) {
         $variable['special_activity'] = $GLOBALS['activity'];
         $variable['special_activity']['allapplynum'] = $GLOBALS['allapplynum'];
         if ($_G['setting']['activitycredit'] && $GLOBALS['activity']['credit'] && !$GLOBALS['applied']) {
             $variable['special_activity']['creditcost'] = $GLOBALS['activity']['credit'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['activitycredit']]['title'];
         }
         $setting = array();
         foreach ($GLOBALS['activity']['ufield']['userfield'] as $field) {
             $setting[$field] = $_G['cache']['profilesetting'][$field];
         }
         $variable['special_activity']['joinfield'] = bigapp_core::getvalues($setting, array('/./'), array('fieldid', 'formtype', 'available', 'title', 'formtype', 'choices'));
         $variable['special_activity']['userfield'] = $GLOBALS['ufielddata']['userfield'];
         $variable['special_activity']['extfield'] = $GLOBALS['ufielddata']['extfield'];
         $variable['special_activity']['basefield'] = bigapp_core::getvalues($GLOBALS['applyinfo'], array('message', 'payment'));
         $variable['special_activity']['closed'] = $GLOBALS['activityclose'];
         if ($GLOBALS['applied'] && $GLOBALS['isverified'] < 2) {
             if (!$GLOBALS['isverified']) {
                 $variable['special_activity']['status'] = 'wait';
             } else {
                 $variable['special_activity']['status'] = 'joined';
             }
             if (!$GLOBALS['activityclose']) {
                 $variable['special_activity']['button'] = 'cancel';
             }
         } elseif (!$GLOBALS['activityclose']) {
             if ($GLOBALS['isverified'] != 2) {
                 $variable['special_activity']['status'] = 'join';
             } else {
                 $variable['special_activity']['status'] = 'complete';
             }
             $variable['special_activity']['button'] = 'join';
         }
     }
     $variable['forum']['password'] = $variable['forum']['password'] ? '1' : '0';
     BigAppAPI::modifyPost2($variable['postlist']);
     if (isset($variable['thread']['tid'])) {
         $variable['thread']['share_url'] = rtrim(ApiUtils::getDzRoot(), '/') . '/forum.php?mod=viewthread&tid=' . $variable['thread']['tid'];
     } else {
         $variable['thread']['share_url'] = '';
     }
     $variable['jump#pid'] = isset($_G['jump#pid']) ? $_G['jump#pid'] : "0";
     $variable['page'] = isset($_G['page']) ? $_G['page'] : "1";
     bigapp_core::result(bigapp_core::variable($variable));
 }
示例#4
0
function getPictures(&$threadInfo)
{
    global $_G, $collect;
    foreach ($threadInfo as $tid => &$info) {
        $collect = array();
        $message = str_replace("\r", '', $info['message']);
        $message = str_replace("\n", '', $message);
        $message = str_replace('\\r', '', $message);
        $message = str_replace('\\n', '', $message);
        if (function_exists('iconv')) {
            $message = iconv(CHARSET, 'UTF-8//ignore', $message);
            foreach ($info['attachments'] as &$att) {
                $att['description'] = '__DONT_DICONV_TO_UTF8___' . iconv(CHARSET, 'UTF-8//ignore', $att['description']);
            }
            unset($att);
        } else {
            $message = mb_convert_encoding($message, 'UTF-8', CHARSET);
            foreach ($info['attachments'] as &$att) {
                $att['description'] = '__DONT_DICONV_TO_UTF8___' . mb_convert_encoding($att['description'], 'UTF-8', CHARSET);
            }
            unset($att);
        }
        $message = preg_replace_callback('/\\[img.*?\\](.*?)\\[\\/img\\]|\\[attach\\]([0-9]+)\\[\\/attach\\]|\\[hide\\](.*?)\\[\\/hide\\]|\\[i.*\\](.*)' . '\\[\\/i\\]|\\[.*?\\]|\\n|\\r/', 'imgCallback', $message);
        $oldMessage = $message;
        if (function_exists('mb_substr')) {
            $message = mb_substr($message, 0, 30, 'UTF-8');
        } else {
            $message = substr($message, 0, 60);
        }
        if ($oldMessage !== $message) {
            $message .= '...';
        }
        loadcache(array('smilies', 'smileytypes'));
        foreach ($_G['cache']['smilies']['replacearray'] as $id => $img) {
            $pattern = $_G['cache']['smilies']['searcharray'][$id];
            $message = preg_replace($pattern, '[表情]', $message);
        }
        $info['message'] = '__DONT_DICONV_TO_UTF8___' . $message;
        $infoAttrs = $info['attachments'];
        foreach ($collect as $attach) {
            true === BIGAPP_DEV && runlog('bigapp', 'process attach collect [ ' . $attach . ' ]');
            if (is_numeric($attach)) {
                if (isset($infoAttrs[$attach])) {
                    $url = ($infoAttrs[$attach]['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
                    $url .= $infoAttrs[$attach]['attachment'];
                    $tmp = parse_url($url);
                    if (!isset($tmp['scheme'])) {
                        $url = ApiUtils::getDzRoot() . $url;
                    }
                    $info['attachment_urls'][] = $url;
                    unset($infoAttrs[$attach]);
                }
                continue;
            }
            $tmp = parse_url($attach);
            if (!isset($tmp['scheme'])) {
                $url = ApiUtils::getDzRoot() . $attach;
            } else {
                $url = str_replace('source/plugin/mobile/', '', $attach);
                $url = str_replace('source/plugin/mobile/', '', $url);
            }
            $info['attachment_urls'][] = $url;
        }
        foreach ($infoAttrs as $aid => $aInfo) {
            $url = ($aInfo['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
            $url .= $aInfo['attachment'];
            $tmp = parse_url($url);
            if (!isset($tmp['scheme'])) {
                $url = ApiUtils::getDzRoot() . $url;
            }
            $info['attachment_urls'][] = $url;
        }
    }
    unset($info);
}
示例#5
0
 public function output()
 {
     global $_G;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     if (isset($GLOBALS['list']) && is_array($GLOBALS['list'])) {
         foreach ($GLOBALS['list'] as &$v) {
             $v['icon'] = ApiUtils::getImgPath($v['icon']);
             loadcache(array('bigapp_favforum_' . $v['id'], 'plugin'));
             $expire = 5;
             if (!$_G['cache']['bigapp_favforum_' . $v['id']] || TIMESTAMP - $_G['cache']['bigapp_favforum_' . $v['id']]['expiration'] > $expire) {
                 $sql = 'SELECT description, icon FROM ' . DB::table('forum_forumfield') . ' WHERE fid = ' . $v['id'];
                 $query = DB::query($sql);
                 $description = '';
                 $icon = ApiUtils::getImgPath($v['icon']);
                 while ($fInfo = DB::fetch($query)) {
                     $description = $fInfo['description'];
                     $icon = ApiUtils::getDzRoot() . $_G['setting']['attachurl'] . 'common/' . $fInfo['icon'];
                     break;
                 }
                 $sql = 'SELECT threads, posts, todayposts FROM ' . DB::table('forum_forum') . ' WHERE fid = ' . $v['id'];
                 $query = DB::query($sql);
                 $nums = array('threads' => 0, 'posts' => 0, 'todayposts' => 0, 'yesterdayposts' => 0);
                 while ($tmp = DB::fetch($query)) {
                     $nums = $tmp;
                     break;
                 }
                 $fInfo = array_merge($fInfo, $nums);
                 savecache('bigapp_favforum_' . $v['id'], array('variable' => $fInfo, 'expiration' => TIMESTAMP));
             } else {
                 $fInfo = $_G['cache']['bigapp_favforum_' . $v['id']]['variable'];
                 $description = $fInfo['description'];
                 $icon = ApiUtils::getDzRoot() . $_G['setting']['attachurl'] . 'common/' . $fInfo['icon'];
             }
             $v['icon'] = $icon;
             $v['description'] = preg_replace('/<.*?>/', '', $description);
             $v['name'] = $v['title'];
             $v['threads'] = $fInfo['threads'];
             $v['posts'] = $fInfo['posts'];
             $v['todayposts'] = $fInfo['todayposts'];
             $v['yesterdayposts'] = isset($fInfo['yesterdayposts']) ? $fInfo['yesterdayposts'] : 0;
             unset($v['title']);
         }
     }
     if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] <= 0) {
         $_GET['page'] = 1;
     }
     $start = $GLOBALS['perpage'] * ($_GET['page'] - 1);
     $end = count($GLOBALS['list']) + $start;
     loadcache('forum');
     if ($end >= $GLOBALS['count']) {
         $GLOBALS['need_more'] = 0;
     } else {
         $GLOBALS['need_more'] = 1;
     }
     $list = array_values($GLOBALS['list']);
     $newList = array();
     if (is_array($list) && !empty($list)) {
         foreach ($list as $fav) {
             if (!empty($fav['threads'])) {
                 $newList[] = $fav;
             }
         }
     } else {
         $newList = $list;
     }
     $variable = array('list' => $newList, 'perpage' => $GLOBALS['perpage'], 'need_more' => $GLOBALS['need_more'], 'count' => $GLOBALS['count']);
     bigapp_core::result(bigapp_core::variable($variable));
 }
示例#6
0
 function output()
 {
     global $_G;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     $variable['data'] = "";
     $formatRec = array('aid', 'catid', 'title', 'summary', 'pic', 'dateline', 'catname', 'content', 'url', 'contents');
     if ('list' == $_GET['mod']) {
         $variable['data'] = array();
         $_G['catid'] = $catid = max(0, intval($_GET['catid']));
         $page = max(1, intval($_GET['page']));
         $cat = category_remake($catid);
         if (!empty($cat)) {
             $wheresql = category_get_wheresql($cat);
             $list = category_get_list($cat, $wheresql, $page);
             if (!empty($list)) {
                 $articleList = array();
                 foreach ($list['list'] as $key => $value) {
                     if (!empty($value['pic'])) {
                         $tmp = parse_url($value['pic']);
                         if (!isset($tmp['scheme'])) {
                             $url = ApiUtils::getDzRoot() . $value['pic'];
                         } else {
                             $url = str_replace('source/plugin/mobile/', '', $attach);
                             $url = str_replace('source/plugin/mobile/', '', $url);
                         }
                         $list['list'][$key]['pic'] = $url;
                     }
                     //暂时不支持存在url 跳转的文章
                     if (isset($value['url']) && !empty($value['url'])) {
                         unset($list['list'][$key]);
                         continue;
                     }
                     foreach ($value as $k => $v) {
                         if (!in_array($k, $formatRec)) {
                             unset($list['list'][$key][$k]);
                         }
                     }
                     $articleList[] = $list['list'][$key];
                 }
                 $variable['data'] = $articleList;
                 $variable['perpage'] = $cat['perpage'];
                 $variable['needmore'] = count($articleList) < $cat['perpage'] ? '0' : '1';
             }
         }
     } else {
         $aid = empty($_GET['aid']) ? 0 : intval($_GET['aid']);
         $article = C::t('portal_article_title')->fetch($aid);
         if (!empty($article)) {
             $content = C::t('portal_article_content')->fetch_all($aid);
             if (is_array($content)) {
                 foreach ($content as $i => $c) {
                     if ($i != 0) {
                         $content[0]['content'] .= $c['content'];
                     }
                 }
             }
             $article = array_merge($content[0], $article);
             foreach ($article as $k => $v) {
                 if (!in_array($k, $formatRec)) {
                     unset($article[$k]);
                 }
             }
             $article['content'] = self::filterContent($article['content']);
             $article['dateline'] = date('Y-m-d H:i', $article['dateline']);
             $article['share_url'] = rtrim(ApiUtils::getDzRoot(), '/') . '/portal.php?mod=view&aid=' . $aid;
             $variable['data'] = $article;
         }
     }
     bigapp_core::result(bigapp_core::variable($variable));
 }
示例#7
0
 protected function _getPictures(&$threadInfo)
 {
     global $_G;
     $collect =& BigAppAPI::$collect;
     foreach ($threadInfo as $tid => &$info) {
         $collect = array();
         $message = str_replace("\r", '', $info['message']);
         $message = str_replace("\n", '', $message);
         $message = str_replace('\\r', '', $message);
         $message = str_replace('\\n', '', $message);
         if (function_exists('iconv')) {
             $message = iconv(CHARSET, 'UTF-8//ignore', $message);
         } else {
             $message = mb_convert_encoding($message, 'UTF-8', CHARSET);
         }
         $message = preg_replace_callback('/\\[img.*?\\](.*?)\\[\\/img\\]|\\[attach\\]([0-9]+)\\[\\/attach\\]|\\[hide\\](.*?)\\[\\/hide\\]|\\[i.*\\](.*)' . '\\[\\/i\\]|\\[.*?\\]|\\n|\\r/', 'BigAppAPI::imgCallback', $message);
         //fix bug, pre_replace_callback not used on some sites
         $message = preg_replace('/\\[img.*?\\](.*?)\\[\\/img\\]|\\[attach\\]([0-9]+)\\[\\/attach\\]|\\[hide\\](.*?)\\[\\/hide\\]|\\[i.*\\](.*)' . '\\[\\/i\\]|\\[.*?\\]|\\n|\\r/', '', $message);
         if (function_exists('mb_substr')) {
             $message = mb_substr($message, 0, 1000, 'UTF-8');
         } else {
             $message = substr($message, 0, 2000);
         }
         loadcache(array('smilies', 'smileytypes'));
         foreach ($_G['cache']['smilies']['replacearray'] as $id => $img) {
             $pattern = $_G['cache']['smilies']['searcharray'][$id];
             $message = preg_replace($pattern, '[表情]', $message);
         }
         if (function_exists('mb_strlen')) {
             if (mb_strlen($message, 'UTF-8') > 30) {
                 $message = mb_substr($message, 0, 30, 'UTF-8') . '...';
             }
         } else {
             if (strlen($message) > 60) {
                 $message = substr($message, 0, 30) . '...';
             }
         }
         $info['message'] = '__DONT_DICONV_TO_UTF8___' . $message;
         $attachments = array();
         $infoAttrs = $info['attachments'];
         foreach ($collect as $attach) {
             if (is_numeric($attach)) {
                 if (isset($infoAttrs[$attach])) {
                     $url = ($infoAttrs[$attach]['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
                     $url .= $infoAttrs[$attach]['attachment'];
                     $tmp = parse_url($url);
                     if (!isset($tmp['scheme'])) {
                         $url = ApiUtils::getDzRoot() . $url;
                     }
                     $info['attachment_urls'][] = $url;
                     unset($infoAttrs[$attach]);
                 }
                 continue;
             }
             $tmp = parse_url($attach);
             if (!isset($tmp['scheme'])) {
                 $url = ApiUtils::getDzRoot() . $attach;
             } else {
                 $url = str_replace('source/plugin/mobile/', '', $attach);
                 $url = str_replace('source/plugin/mobile/', '', $url);
             }
             $info['attachment_urls'][] = $url;
         }
         //feed others
         foreach ($infoAttrs as $aid => $aInfo) {
             $url = ($aInfo['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
             $url .= $aInfo['attachment'];
             $tmp = parse_url($url);
             if (!isset($tmp['scheme'])) {
                 $url = ApiUtils::getDzRoot() . $url;
             }
             $info['attachment_urls'][] = $url;
         }
     }
     unset($info);
 }