/** * 得到帖子中的圖片 * @param $tid - 帖子ID * @param $firstpostonly - 首帖 * @param $page - 分頁參數 * @param $limit - 每頁列出數目,初始為 9 * @param $minsize - 附件體積最少為,單位KB * @param $getcount - 是否取總數(若取總數則不取具體信息) */ function list_thread_pic($tid = 0, $firstpostonly = 0, $page = 0, $limit = 9, $minsize = 20, $getcount = 0) { global $_G, $_SC; $tid = intval($tid); $page = intval($page); $limit = intval($limit); $minsize = intval($minsize); $firstpostonly = intval($firstpostonly); $ret_attach = array(); $thread = list_threads($tid); //取得帖子基本信息 if ($thread) { $bbs_dbpre = $_SC['bbs_dbpre']; $db = new db_mysql(array(1 => array('tablepre' => $_SC['bbs_dbpre'], 'dbcharset' => $_SC['bbs_dbcharset'], 'dbhost' => $_SC['bbs_dbhost'], 'dbuser' => $_SC['bbs_dbuser'], 'dbpw' => $_SC['bbs_dbpw'], 'dbname' => $_SC['bbs_dbname']))); $db->connect(); if ($firstpostonly) { $wheresql = " a.pid='{$thread['pid']}'"; } else { $wheresql = " a.tid='{$tid}' AND a.uid='{$thread['authorid']}'"; } $minsize = $minsize * 1024; $wheresql .= " AND a.filesize>'{$minsize}'"; $wheresql .= " AND a.isimage='1'"; if ($getcount) { $countsql = "SELECT count(a.aid) FROM {$bbs_dbpre}attachments a"; $count = $db->result_first("{$countsql} WHERE {$wheresql}"); return $count; //返回計數 } else { // 得到附件目錄 $sql = "SELECT * FROM {$bbs_dbpre}settings WHERE variable IN ('attachurl', 'boardurl', 'ftp')"; $query = $db->query($sql); while ($rs = $db->fetch_array($query)) { $ret_attach[$rs['variable']] = $rs['value']; } $ret_attach['ftp'] = unserialize($ret_attach['ftp']); if (empty($ret_attach['boardurl'])) { $ret_attach['boardurl'] = $_SC['bbs_url'] . '/'; } $selectsql = "SELECT a.aid, a.pid, a.price, a.dateline, a.readperm, a.downloads, a.filename, a.filetype, a.filesize, a.attachment, a.thumb, a.remote, aa.description FROM {$bbs_dbpre}attachments a LEFT JOIN {$bbs_dbpre}attachmentfields aa ON a.aid=aa.aid"; $sql = "{$selectsql} WHERE {$wheresql} LIMIT " . $page * $limit . ", {$limit}"; $query = $db->query($sql); while ($attach = $db->fetch_array($query)) { if ($attach['remote']) { $attach['url'] = $ret_attach['ftp']['attachurl'] . '/' . $attach['attachment']; } else { $attach['url'] = (strpos($ret_attach['attachurl'], 'http://') === 0 ? $ret_attach['attachurl'] : $ret_attach['boardurl'] . $ret_attach['attachurl']) . '/' . $attach['attachment']; } $ret_attach['attachments'][$attach['aid']] = $attach; } } $db->close(); unset($db); } return $ret_attach; }
} } if ($i == 0) { echo '<script relatedtype="text/javascript" charset="' . $_G['charset'] . '">alert(\'' . lang('noresult_content') . '\')</script>'; } } elseif ($opt == 'previewconsume') { $id = intval($_GET['id']); $shopid = intval($_GET['shopid']); $coupon_title = trim($_GET['coupon_title']); $brief = trim($_GET['brief']); $exception = trim($_GET['exception']); $shopinfo = DB::fetch(DB::query("SELECT subject, address, tel FROM " . tname('shopitems') . " WHERE itemid='{$shopid}'")); $coupon_title = biconv($coupon_title, 'UTF-8', $_G['charset']); $brief = biconv($brief, 'UTF-8', $_G['charset']); $exception = biconv($exception, 'UTF-8', $_G['charset']); $createimgarr = array('preview' => 1, 'id' => $id, 'coupon_title' => $coupon_title, 'dealer_name' => $shopinfo['subject'], 'begin_date' => $_GET['begin_date'], 'end_date' => $_GET['end_date'], 'brief' => $brief, 'exception' => $exception, 'address' => $shopinfo['address'], 'hotline' => $shopinfo['tel']); require_once B_ROOT . './source/adminfunc/tool.func.php'; if ($consumeimgpath = image_text($createimgarr)) { echo '<img width="750px" height="466px" src="' . getattachurl($consumeimgpath) . '?time=' . $_G['timestamp'] . '">'; } } elseif ($opt == 'getThread' && $_GET['tid'] > 0) { //管理員專用 require_once B_ROOT . './api/bbs_pic.php'; showxmlheader('GBK'); echo '<threadinfo>'; echo showarraytoxml(list_threads(intval($_GET['tid'])), 'GBK'); echo '</threadinfo>'; } else { //其他情況 echo "<option value=\"0\" selected=\"selected\">" . lang('please_select') . "</option>\n"; }