/** * 得到帖子中的圖片 * @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; }
/** *判斷主題是否存在 *param $tid - 主題id */ function checkbbstid($tid) { global $_G, $_SC; $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'], 'silent' => true))); $db->connect(); if ($db->result_first("SELECT count(*) FROM {$bbs_dbpre}forum_thread WHERE tid = {$tid}")) { $db->close(); unset($db); return true; } else { $db->close(); unset($db); return false; } }
show_table_row(array('<span style="float: left">配置转换过程</span><label style="float: right"><input type="checkbox" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'prgs\')" id="chkall" name="chkall" checked> 全选</label>'), 'title'); if ($setting['start']) { show_table_row(array('转换之前运行的程序'), 'bg1'); echo "<tr class=bg2><td colspan=2>\n<ul id=\"ulist\">"; foreach ($setting['start'] as $key => $value) { echo "<li><label><input type=\"checkbox\" class=\"checkbox\" name=\"prgs[]\" value=\"c_prg_{$key}.php\" checked> {$key}({$value})</label></li>"; } echo "</ul>\n</td></tr>"; } $tablelist = array(); $cdir = dir($prgdir); while (($entry = $cdir->read()) !== false) { if ($entry != '.' && $entry != '..' && is_file($prgdir . $entry)) { if (preg_match("/uc_/", $entry)) { $table_source = str_replace('.php', '', $db_source->tablepre . $entry); $source_exist = $db_source->result_first("SHOW TABLES LIKE '" . substr($table_source, strpos($table_source, '.') + 1) . "'"); if (empty($source_exist)) { continue; } } $tablelist[] = $entry; } } $cdir->close(); if ($tablelist) { sort($tablelist); show_table_row(array('<span style="float: left">数据表转换程序</span>'), 'bg1'); echo "<tr class=bg2><td colspan=2>\n<ul id=\"ulist\">"; foreach ($tablelist as $entry) { echo "<li><label><input type=\"checkbox\" class=\"checkbox\" name=\"prgs[]\" value=\"{$entry}\" checked> " . basename($entry, '.php') . "</label></li>"; }