示例#1
0
 protected function _getDetails(&$list)
 {
     //check whether thread list image mode is open
     global $_G;
     if (isset($_G['setting']['bigapp_settings']) && is_string($_G['setting']['bigapp_settings'])) {
         $_G['setting']['bigapp_settings'] = unserialize($_G['setting']['bigapp_settings']);
     }
     if (isset($_G['setting']['bigapp_settings']['threadlist_image_mode']) && !$_G['setting']['bigapp_settings']['threadlist_image_mode']) {
         return;
     }
     $tids = array();
     foreach ($list as $l) {
         $tids[] = $l['tid'];
     }
     if (empty($tids)) {
         return;
     }
     $sql = 'SELECT pid, tid, first FROM ' . DB::table('forum_post') . ' WHERE tid IN (' . implode(', ', $tids) . ')';
     $query = DB::query($sql);
     $threadInfo = array();
     $pids = array();
     while ($tmp = DB::fetch($query)) {
         if (!!$tmp['first']) {
             if (isset($pids[$threadInfo[$tmp['tid']]['pid']])) {
                 unset($pids[$threadInfo[$tmp['tid']]['pid']]);
             }
             $threadInfo[$tmp['tid']] = array('pid' => $tmp['pid']);
             $pids[$tmp['pid']] = $tmp['pid'];
         }
     }
     if (empty($pids)) {
         return;
     }
     $pids = array_values($pids);
     $sql = 'SELECT pid, tid, message FROM ' . DB::table('forum_post') . ' WHERE pid IN (' . implode(', ', $pids) . ')';
     $query = DB::query($sql);
     while ($tmp = DB::fetch($query)) {
         $threadInfo[$tmp['tid']]['message'] = $tmp['message'];
     }
     $sql = 'SELECT aid, tid, tableid, pid FROM ' . DB::table('forum_attachment') . ' WHERE pid IN (' . implode(', ', $pids) . ')';
     $tbIdx = array();
     $query = DB::query($sql);
     while ($tmp = DB::fetch($query)) {
         if ($tmp['tableid'] < 10) {
             $threadInfo[$tmp['tid']]['aid'][] = $tmp['aid'];
             $tbIdx[$tmp['tableid']][] = $tmp['aid'];
         }
     }
     foreach ($tbIdx as $tableId => $aids) {
         $sql = 'SELECT aid, tid, attachment, description, remote, isimage FROM ' . DB::table('forum_attachment_' . $tableId) . ' WHERE aid IN (' . implode(', ', $aids) . ')';
         $query = DB::query($sql);
         while ($tmp = DB::fetch($query)) {
             $isImage = $tmp['isimage'];
             if ($tmp['isimage'] && !$_G['setting']['attachimgpost']) {
                 $isImage = 0;
             }
             if ($isImage) {
                 $threadInfo[$tmp['tid']]['attachments'][$tmp['aid']] = array('attachment' => $tmp['attachment'], 'description' => $tmp['description'], 'remote' => $tmp['remote'], 'isimage' => $isImage);
             }
         }
     }
     BigAppAPI::_getPictures($threadInfo);
     foreach ($list as &$l) {
         $l['attachment_urls'] = array();
         $l['message_abstract'] = '';
         if (isset($threadInfo[$l['tid']]['message'])) {
             $l['message_abstract'] = $threadInfo[$l['tid']]['message'];
         }
         if (isset($threadInfo[$l['tid']]['attachment_urls'])) {
             $l['attachment_urls'] = $threadInfo[$l['tid']]['attachment_urls'];
         }
         if (true === BigAppConf::$enablePicOpt) {
             foreach ($l['attachment_urls'] as &$_url) {
                 if (ApiUtils::isOptFix($_url)) {
                     $_url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$thumbSize) . '&url=' . urlencode($_url);
                     $_url = str_replace('source/plugin/mobile/', '', $_url);
                     $_url = str_replace('source/plugin/bigapp/', '', $_url);
                 }
             }
             unset($_url);
         }
     }
     unset($l);
 }
示例#2
0
function getDetails(&$list)
{
    global $_G;
    $tbTids = array();
    foreach ($list as $l) {
        $tids[$l['tid']] = array('tid' => $l['tid'], 'posttableid' => $l['posttableid']);
        if (0 == $l['posttableid']) {
            $table = DB::table('forum_post');
        } else {
            $table = DB::table('forum_post') . '_' . $l['posttableid'];
        }
        $tbTids[$table][] = $l['tid'];
    }
    $sqls = array();
    foreach ($tbTids as $table => &$tids) {
        $tids = array_unique($tids);
        $sql = 'SELECT pid, tid, message FROM ' . $table . ' WHERE tid IN (' . implode(', ', $tids) . ') AND first = 1';
        $sqls[] = $sql;
    }
    unset($tids);
    if (empty($sqls)) {
        return;
    }
    $threadInfo = array();
    $pids = array();
    foreach ($sqls as $sql) {
        true === BIGAPP_DEV && runlog('bigapp', 'get message from forum_thread, sql: ' . $sql);
        $query = DB::query($sql);
        while ($tmp = DB::fetch($query)) {
            $threadInfo[$tmp['tid']] = array('pid' => $tmp['pid'], 'tid' => $tmp['tid'], 'message' => $tmp['message']);
            $pids[$tmp['pid']] = $tmp['pid'];
        }
    }
    if (empty($pids)) {
        return;
    }
    $sql = 'SELECT aid, tid, tableid, pid FROM ' . DB::table('forum_attachment') . ' WHERE pid IN (' . implode(', ', $pids) . ')';
    true === BIGAPP_DEV && runlog('bigapp', 'get aid and tableid from db [ sql: ' . $sql . ' ]');
    $tbIdx = array();
    $query = DB::query($sql);
    while ($tmp = DB::fetch($query)) {
        if ($tmp['tableid'] < 10) {
            $threadInfo[$tmp['tid']]['aid'][] = $tmp['aid'];
            $tbIdx[$tmp['tableid']][] = $tmp['aid'];
        }
    }
    foreach ($tbIdx as $tableId => $aids) {
        $sql = 'SELECT aid, tid, attachment, description, remote, isimage FROM ' . DB::table('forum_attachment_' . $tableId) . ' WHERE aid IN (' . implode(', ', $aids) . ')';
        true === BIGAPP_DEV && runlog('bigapp', 'get attachment info from db, sql: ' . $sql);
        $query = DB::query($sql);
        while ($tmp = DB::fetch($query)) {
            $isImage = $tmp['isimage'];
            if ($tmp['isimage'] && !$_G['setting']['attachimgpost']) {
                $isImage = 0;
            }
            if ($isImage) {
                $threadInfo[$tmp['tid']]['attachments'][$tmp['aid']] = array('attachment' => $tmp['attachment'], 'description' => $tmp['description'], 'remote' => $tmp['remote'], 'isimage' => $isImage);
                continue;
            }
            true === BIGAPP_DEV && runlog('bigapp', 'attachment is not an image or attachimgpost is not true, ignore [ attachment info: ' . $tmp['attachment'] . ' ]');
        }
    }
    getPictures($threadInfo);
    foreach ($list as &$l) {
        if (isset($threadInfo[$l['tid']]['message']) && is_string($threadInfo[$l['tid']]['message'])) {
            $l['message_abstract'] = $threadInfo[$l['tid']]['message'];
        }
        if (isset($threadInfo[$l['tid']]['attachment_urls']) && is_array($threadInfo[$l['tid']]['attachment_urls'])) {
            $l['attachment_urls'] = $threadInfo[$l['tid']]['attachment_urls'];
        }
        if (true === BigAppConf::$enablePicOpt) {
            foreach ($l['attachment_urls'] as &$_url) {
                if (ApiUtils::isOptFix($_url)) {
                    $_url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&size=' . urlencode(BigAppConf::$thumbSize) . '&url=' . urlencode($_url);
                    $_url = str_replace('source/plugin/mobile/', '', $_url);
                    $_url = str_replace('source/plugin/bigapp/', '', $_url);
                }
            }
            unset($_url);
        }
    }
    unset($l);
}
示例#3
0
 static function callback2($matches)
 {
     global $_G;
     $collect =& BigAppAPI::$collect;
     $attachments =& BigAppAPI::$attachments;
     if (isset($matches[1]) && !empty($matches[1])) {
         return '<br />';
     }
     //回车、换行或者swf格式,直接删除
     if (isset($matches[2]) && !empty($matches[2]) || isset($matches[3]) && !empty($matches[3]) || isset($matches[6]) && !empty($matches[6])) {
         return '';
     }
     //非链接形式的URL地址,增加可点击
     if (isset($matches[9])) {
         $url = $matches[0];
         if (empty($matches[9])) {
             $url = 'http://' . $url;
         }
         return '<a href="' . $url . '" target="_blank">' . $matches[0] . '</a>';
     }
     //普通形式的、可点击的,直接返回
     if (isset($matches[7]) || isset($matches[8])) {
         return $matches[0];
     }
     //图片或表情
     $smiles = array('smile.gif' => "😌", 'sad.gif' => "😔", 'biggrin.gif' => "😃", 'cry.gif' => "😭", 'huffy.gif' => "😠", 'shocked.gif' => "😲", 'shocked.png' => "😲", 'tongue.gif' => "😜", 'shy.gif' => "😆", 'titter.gif' => "😝", 'sweat.gif' => "😓", 'mad.gif' => "😫", 'lol.gif' => "😁", 'loveliness.gif' => "😊", 'funk.gif' => "😱", 'curse.gif' => "😤", 'dizzy.gif' => "😖", 'shutup.gif' => "😷", 'sleepy.gif' => "😪", 'hug.gif' => "😚", 'victory.gif' => "✌", 'time.gif' => "⏰", 'kiss.gif' => "💋", 'handshake.gif' => "👌", 'call.gif' => "📞", 'sun.png' => "🌞");
     if (isset($matches[4]) && !empty($matches[4])) {
         /*			$out = preg_match('/smile.gif|sad.gif|biggrin.gif|cry.gif|huffy.gif|shocked.gif|shocked.png|tongue.gif|shy.gif|titter.gif|sweat.gif|' .
         					'mad.gif|lol.gif|loveliness.gif|funk.gif|curse.gif|dizzy.gif|shutup.gif|sleepy.gif|hug.gif|victory.gif|time.gif|' . 
         					'kiss.gif|handshake.gif|call.gif|sun.png/', $matches[4], $_matches); */
         $out = preg_match('/static\\/image\\/smiley/', $matches[4], $_matches);
         if (1 === $out && 1 === count($_matches)) {
             $out2 = preg_match('/\\/[a-zA-Z0-9_]*.gif|.png|.jpg$/', $matches[4], $_matches);
             if (1 === $out && 1 === count($_matches)) {
                 $url = $matches[4];
                 $url = str_replace('source/plugin/mobile/', '', $url);
                 $url = str_replace('source/plugin/bigapp/', '', $url);
                 $ret = '<img class="smile-png" src="' . $url . '?id=bigapp:getsmile" />';
                 return $ret;
             }
             //return $smiles[$_matches[0]];
         }
         //src matched
         $arrUrl = parse_url($matches[4]);
         if (!isset($arrUrl['scheme'])) {
             $ret = ApiUtils::getDzRoot() . $matches[4];
         } else {
             $ret = str_replace('source/plugin/mobile/', '', $matches[4]);
             $ret = str_replace('source/plugin/bigapp/', '', $ret);
         }
         if (true === BigAppConf::$enablePicOpt && ApiUtils::isOptFix($ret)) {
             $ret = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$detailSize) . '&url=' . urlencode($ret);
         }
         $collect[] = array('type' => 1, 'url' => $ret);
         //orginal picture
         //$ret = 'src="' . $ret . '"';
         $ret = str_replace($matches[4], $ret, $matches[0]);
         return $ret;
     }
     if (isset($matches[5]) && !empty($matches[5])) {
         $url = $matches[5];
         if (true === BigAppConf::$enablePicOpt && ApiUtils::isOptFix($url)) {
             $url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$detailSize) . '&url=' . urlencode($matches[5]);
             $url = str_replace('source/plugin/mobile/', '', $url);
             $url = str_replace('source/plugin/bigapp/', '', $url);
         }
         return '<img src="' . $url . '"></img>';
     }
     //attach matched
     if (!isset($matches[5])) {
         return $matches[0];
     }
     if (!isset($attachments[$matches[5]])) {
         return $matches[0];
     }
     if (!$attachments[$matches[5]]['isimage']) {
         return '';
         //if not an image, ignore
     }
     $url = $attachments[$matches[5]]['url'] . $attachments[$matches[5]]['attachment'];
     $tmp = parse_url($url);
     if (!isset($tmp['scheme'])) {
         $url = ApiUtils::getDzRoot() . $attachments[$matches[5]]['url'] . $attachments[$matches[5]]['attachment'];
     }
     if (true === BigAppConf::$enablePicOpt && ApiUtils::isOptFix($url)) {
         $url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$detailSize) . '&url=' . urlencode($url);
         $url = str_replace('source/plugin/mobile/', '', $url);
         $url = str_replace('source/plugin/bigapp/', '', $url);
     }
     $collect = array('type' => 2, 'url' => $url, 'description' => isset($attachments[$matches[5]]['description']) ? $attachments[$matches[5]]['description'] : '');
     unset($attachments[$matches[5]]);
     return '<img src="' . $url . '"></img>';
 }
示例#4
0
 protected function _getDetails(&$list)
 {
     //check whether thread list image mode is open
     global $_G;
     if (isset($_G['setting']['bigapp_settings']) && is_string($_G['setting']['bigapp_settings'])) {
         $_G['setting']['bigapp_settings'] = unserialize($_G['setting']['bigapp_settings']);
     }
     if (isset($_G['setting']['bigapp_settings']['threadlist_image_mode']) && !$_G['setting']['bigapp_settings']['threadlist_image_mode']) {
         return;
     }
     $tids = array();
     foreach ($list as $l) {
         $tids[] = $l['tid'];
     }
     if (empty($tids)) {
         return;
     }
     $_tids = $tids;
     $tids = array();
     $expire = 5;
     $threadInfoCache = array();
     foreach ($_tids as $tid) {
         $cacheKey = 'bigapptsum' . $tid;
         loadcache($cacheKey);
         if (isset($_G['cache'][$cacheKey]) && TIMESTAMP - $_G['cache'][$cacheKey]['expiration'] <= $expire) {
             $threadInfoCache[$tid] = $_G['cache'][$cacheKey]['variable'];
         } else {
             $tids[] = $tid;
         }
     }
     $threadInfo = array();
     if (!empty($tids)) {
         runlog('bigapp', 'such tids has no cache, get them from database [ tids: ' . json_encode($tids) . ' ]');
         $sql = 'SELECT pid, tid, first FROM ' . DB::table('forum_post') . ' WHERE tid IN (' . implode(', ', $tids) . ')';
         $query = DB::query($sql);
         $pids = array();
         while ($tmp = DB::fetch($query)) {
             //if(!isset($threadInfo[$tmp['tid']]) || $threadInfo[$tmp['tid']]['pid'] > $tmp['pid']){
             if (!!$tmp['first']) {
                 if (isset($pids[$threadInfo[$tmp['tid']]['pid']])) {
                     unset($pids[$threadInfo[$tmp['tid']]['pid']]);
                 }
                 $threadInfo[$tmp['tid']] = array('pid' => $tmp['pid']);
                 $pids[$tmp['pid']] = $tmp['pid'];
             }
         }
         if (!empty($pids)) {
             $pids = array_values($pids);
             $sql = 'SELECT pid, tid, message FROM ' . DB::table('forum_post') . ' WHERE pid IN (' . implode(', ', $pids) . ')';
             $query = DB::query($sql);
             while ($tmp = DB::fetch($query)) {
                 $threadInfo[$tmp['tid']]['message'] = $tmp['message'];
             }
             $sql = 'SELECT aid, tid, tableid, pid FROM ' . DB::table('forum_attachment') . ' WHERE pid IN (' . implode(', ', $pids) . ')';
             $tbIdx = array();
             $query = DB::query($sql);
             while ($tmp = DB::fetch($query)) {
                 if ($tmp['tableid'] < 10) {
                     $threadInfo[$tmp['tid']]['aid'][] = $tmp['aid'];
                     $tbIdx[$tmp['tableid']][] = $tmp['aid'];
                 }
             }
             foreach ($tbIdx as $tableId => $aids) {
                 $sql = 'SELECT aid, tid, attachment, description, remote, isimage FROM ' . DB::table('forum_attachment_' . $tableId) . ' WHERE aid IN (' . implode(', ', $aids) . ')';
                 $query = DB::query($sql);
                 while ($tmp = DB::fetch($query)) {
                     $isImage = $tmp['isimage'];
                     if ($tmp['isimage'] && !$_G['setting']['attachimgpost']) {
                         $isImage = 0;
                     }
                     if ($isImage) {
                         $threadInfo[$tmp['tid']]['attachments'][$tmp['aid']] = array('attachment' => $tmp['attachment'], 'description' => $tmp['description'], 'remote' => $tmp['remote'], 'isimage' => $isImage);
                     }
                 }
             }
             BigAppAPI::_getPictures($threadInfo);
             foreach ($threadInfo as $tid => $tInfo) {
                 runlog('bigapp', 'save thread sum [ tid: ' . $tid . ' ]');
                 savecache('bigapptsum' . $tid, array('variable' => $tInfo, 'expiration' => TIMESTAMP));
             }
         }
     }
     foreach ($threadInfoCache as $tid => $tInfo) {
         if (!isset($threadInfo[$tid])) {
             $threadInfo[$tid] = $tInfo;
         }
     }
     foreach ($list as &$l) {
         $l['attachment_urls'] = array();
         $l['message_abstract'] = '';
         if (isset($threadInfo[$l['tid']]['message'])) {
             $l['message_abstract'] = $threadInfo[$l['tid']]['message'];
         }
         if (isset($threadInfo[$l['tid']]['attachment_urls'])) {
             $l['attachment_urls'] = $threadInfo[$l['tid']]['attachment_urls'];
         }
         if (true === BigAppConf::$enablePicOpt) {
             foreach ($l['attachment_urls'] as &$_url) {
                 if (ApiUtils::isOptFix($_url)) {
                     $_url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$thumbSize) . '&url=' . urlencode($_url);
                     $_url = str_replace('source/plugin/mobile/', '', $_url);
                     $_url = str_replace('source/plugin/bigapp/', '', $_url);
                 }
             }
             unset($_url);
         }
     }
     unset($l);
 }