function comment_list($vars) { if ($vars['display'] && empty($vars['loop'])) { if (empty($vars['_display'])) { $_vars = iCMS::app_ref(true); $vars = array_merge($vars, $_vars); } return comment_list_display($vars); } $where_sql = " `status`='1'"; if (isset($vars['appid'])) { $appid = (int) $vars['appid']; $where_sql .= " AND `appid`='{$appid}'"; } if (isset($vars['cid!'])) { $ncids = explode(',', $vars['cid!']); $vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true)); $where_sql .= iPHP::where($ncids, 'cid', 'not'); } if (isset($vars['cid'])) { $cid = explode(',', $vars['cid']); $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true)); $where_sql .= iPHP::where($cid, 'cid'); } isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'"); $vars['pid'] && ($where_sql .= " AND `pid`='" . (int) $vars['pid'] . "'"); $vars['iid'] && ($where_sql .= " AND `iid`='" . (int) $vars['iid'] . "'"); $vars['id'] && ($where_sql .= " AND `id`='" . (int) $vars['id'] . "'"); $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10"; $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1; $by = $vars['by'] == 'ASC' ? "ASC" : "DESC"; switch ($vars['orderby']) { default: $order_sql = " ORDER BY `id` {$by}"; } $md5 = md5($where_sql . $order_sql); $offset = 0; $limit = "LIMIT {$maxperpage}"; if ($vars['page']) { isset($vars['total_cache']) && ($_GET['total_cahce'] = true); $total = iPHP::total($md5, "SELECT count(*) FROM `#iCMS@__comment` WHERE {$where_sql} limit 1"); $pgconf = array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:comment'), 'ajax' => $vars['page_ajax'] ? 'iCMS.comment.page' : FALSE, 'nowindex' => $GLOBALS['page']); if ($vars['display'] == 'iframe' || $vars['page_ajax']) { iS::gp('pn', 'GP', 2); $pgconf['page_name'] = 'pn'; $pgconf['nowindex'] = $GLOBALS['pn']; } isset($vars['total_cache']) && ($pgconf['total_type'] = $vars['total_cache']); $multi = iCMS::page($pgconf); $offset = $multi->offset; $limit = "LIMIT {$offset},{$maxperpage}"; // if($offset>1000){ //$where_sql.=" AND `id` >= (SELECT `id` FROM `#iCMS@__comment` WHERE {$where_sql} {$order_sql} LIMIT {$offset},1)"; //$limit = "LIMIT {$maxperpage}"; // } iPHP::assign("comment_total", $total); } if ($vars['cache']) { $cache_name = iPHP_DEVICE . '/comment/' . $md5 . "/" . (int) $offset; $resource = iCache::get($cache_name); } if (empty($resource)) { $resource = iDB::all("SELECT * FROM `#iCMS@__comment` WHERE {$where_sql} {$order_sql} {$limit}"); //iDB::debug(1); $ln = $GLOBALS['page'] - 1 < 0 ? 0 : $GLOBALS['page'] - 1; if ($resource) { foreach ($resource as $key => $value) { if ($vars['date_format']) { $value['addtime'] = get_date($value['addtime'], $vars['date_format']); } $value['url'] = iCMS_API . '?app=comment&do=goto&iid=' . $value['iid'] . '&appid=' . $value['appid'] . '&cid=' . $value['cid']; $value['lou'] = $total - ($i + $ln * $maxperpage); $value['content'] = nl2br($value['content']); $value['user'] = user::info($value['userid'], $value['username'], $vars['facesize']); $value['reply_uid'] && ($value['reply'] = user::info($value['reply_uid'], $value['reply_name'], $vars['facesize'])); $value['total'] = $total; if ($vars['page']) { $value['page'] = array('total' => $multi->totalpage, 'perpage' => $multi->perpage); } $value['param'] = array("appid" => iCMS_APP_COMMENT, "id" => $value['id'], "userid" => $value['userid'], "name" => $value['username']); $resource[$key] = $value; } } $vars['cache'] && iCache::set($cache_name, $resource, $cache_time); } return $resource; }
define('iPHP_PATH', dirname(strtr(__FILE__, '\\', '/'))); require iPHP_PATH . '/iPHP.version.php'; require iPHP_PATH . '/iPHP.define.php'; if (function_exists('memory_get_usage') && (int) @ini_get('memory_limit') < abs(intval(iPHP_MEMORY_LIMIT))) { @ini_set('memory_limit', iPHP_MEMORY_LIMIT); } @ini_set('date.timezone', iPHP_TIME_ZONE); //设置时区 function_exists('date_default_timezone_set') && date_default_timezone_set(iPHP_TIME_ZONE); require iPHP_PATH . '/iPHP.compat.php'; require iPHP_PATH . '/iPHP.class.php'; set_error_handler('iPHP_ERROR_HANDLER'); iPHP::timer_start(); //security iPHP::LoadClass("Security", 'S'); iS::filter(); iS::gp('page', 'GP', 2); define('__SELF__', $_SERVER['PHP_SELF']); define('__REF__', $_SERVER['HTTP_REFERER']); $iDB_CLASS = 'Mysql'; iPHP_DB_TYPE == 'mysql' && version_compare(PHP_VERSION, '5.5', '>=') && ($iDB_CLASS = 'Mysqli'); iPHP_DB_TYPE == 'pgsql' && ($iDB_CLASS = 'Pgsql'); iPHP_DB_TYPE == 'sqlite' && ($iDB_CLASS = 'SQLite'); iPHP::loadClass($iDB_CLASS, 'DB'); //加载数据库操作类 iPHP::loadClass("FileSystem", 'FS'); //加载文件操作类 iPHP::loadClass('Cache'); //加载缓存操作类 iPHP::loadClass("Template"); //加载模板操作类