function update_content() { $content_model = new Content_model(); $content_service = new Content_service(); $content_model->set_content($this->input->post('content_text')); $content_model->set_content_id($this->input->post('content_id')); echo $content_service->update_content($content_model); }
public function visit($type, $contentID = false) { switch ($type) { case FeedContentTypes::USER_CONTENT: $ugc = new Content_model(); $item = $ugc->get_by_id($contentID); if ($item) { $this->load->view('content_vote', array('item' => $item, 'voteUpUrl' => site_url('content/up/' . $item->ContentID), 'voteDownUrl' => site_url('content/down/' . $item->ContentID))); } else { die('No content found with given ID...'); } break; default: header('Location: ' . site_url('')); break; } }
/** * lay content tu key va render ra view * * @param mixed $key */ function renderContent($key, $get_by = 'content') { $contentModel = new Content_model(); $contentObj = $contentModel->getby_key($key); $str = ''; if (isset($contentObj[$get_by])) { $str = $contentObj[$get_by]; } $html = html_entity_decode($str, ENT_QUOTES, 'UTF-8'); return $html; }
public function list_tag($_params) { if (!$this->ci) { return NULL; } $system = array('num' => '', 'form' => '', 'page' => '', 'site' => '', 'flag' => '', 'more' => '', 'catid' => '', 'field' => '', 'order' => '', 'space' => '', 'cache' => (int) SITE_QUERY_CACHE, 'action' => '', 'return' => '', 'module' => APP_DIR, 'modelid' => '', 'keyword' => '', 'urlrule' => '', 'pagesize' => ''); $param = $where = array(); $params = explode(' ', $_params); $sysadj = array('IN', 'BEWTEEN', 'BETWEEN', 'LIKE', 'NOTIN', 'NOT', 'BW'); foreach ($params as $t) { $var = substr($t, 0, strpos($t, '=')); $val = substr($t, strpos($t, '=') + 1); if (!$var) { continue; } if (isset($system[$var])) { // 系统参数,只能出现一次,不能添加修饰符 $system[$var] = $val; } else { if (preg_match('/^([A-Z_]+)(.+)/', $var, $match)) { // 筛选修饰符参数 $_pre = explode('_', $match[1]); $_adj = ''; foreach ($_pre as $p) { if (in_array($p, $sysadj)) { $_adj = $p; } } $where[] = array('adj' => $_adj, 'name' => $match[2], 'value' => $val); } else { $where[] = array('adj' => '', 'name' => $var, 'value' => $val); } $param[$var] = $val; // 用于特殊action } } // 替换order中的非法字符 if (isset($system['order']) && $system['order']) { $system['order'] = str_ireplace(array('"', "'", ')', '(', ';', 'select', 'insert'), '', $system['order']); } // action switch ($system['action']) { case 'cache': // 系统缓存数据 if (!isset($param['name'])) { return $this->_return($system['return'], 'name参数不存在'); } $pos = strpos($param['name'], '.'); if ($pos !== FALSE) { $_name = substr($param['name'], 0, $pos); $_param = substr($param['name'], $pos + 1); } else { $_name = $param['name']; $_param = NULL; } $cache = $this->_cache_var($_name, !$system['site'] ? SITE_ID : $system['site']); if (!$cache) { return $this->_return($system['return'], "缓存({$_name})不存在,请在后台更新缓存"); } if ($_param) { @eval('$data=$cache' . $this->_get_var($_param) . ';'); if (!$data) { return $this->_return($system['return'], "缓存({$_name})参数不存在!!"); } } else { $data = $cache; } return $this->_return($system['return'], $data, ''); break; case 'content': // 模块文档内容 if (!isset($param['id'])) { return $this->_return($system['return'], 'id参数不存在'); } $dirname = $system['module'] ? $system['module'] : APP_DIR; if (!$dirname) { return $this->_return($system['return'], 'module参数不能为空'); } $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $module = get_module($dirname, $system['site']); if (!$module) { return $this->_return($system['return'], "模块({$system['module']})未安装"); } // 定义的模块内容模型类 $file = FCPATH . $module['dirname'] . '/models/Content_model.php'; if (!is_file($file)) { return $this->_return($system['return'], "模块({$system['module']})文件models/Content_model.php不存在"); } require_once $file; $db = new Content_model(); $db->link = $this->ci->site[$system['site']]; $db->prefix = $this->ci->db->dbprefix($system['site'] . '_' . $module['dirname']); // 缓存查询结果 $data = $db->get($param['id']); $page = max(1, (int) $_GET['page']); $name = 'list-action-content-' . md5(dr_array2string($param)) . '-' . $page; $cache = $this->ci->get_cache_data($name); if (!$cache) { $fields = $module['field']; $fields = $module['category'][$data['catid']]['field'] ? array_merge($fields, $module['category'][$data['catid']]['field']) : $fields; // 模块表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); // 格式化数据 $data = $this->ci->field_format_value($fields, $data, $page, $module['dirname']); if ($system['field'] && $data) { $_field = explode(',', $system['field']); foreach ($data as $i => $t) { if (strpos($i, '_') !== 0 && !in_array($i, $_field)) { unset($data[$i]); } } } // 格式化显示自定义字段内容 $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], array($cache), ''); break; case 'category': // 栏目 $dirname = $system['module'] ? $system['module'] : APP_DIR; if (!$dirname) { return $this->_return($system['return'], 'module参数不能为空'); } $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $module = get_module($dirname, $system['site']); if (!$module || count($module['category']) == 0) { return $this->_return($system['return'], "模块({$system['module']})尚未安装"); } $i = 0; $show = isset($param['show']) ? 1 : 0; // 有show参数表示显示隐藏栏目 $return = array(); foreach ($module['category'] as $t) { if ($system['num'] && $i >= $system['num']) { break; } if (!$t['show'] && !$show) { continue; } if (isset($param['pid']) && $t['pid'] != (int) $param['pid']) { continue; } if (isset($param['letter']) && $t['letter'] != $param['letter']) { continue; } if (isset($param['id']) && !in_array($t['id'], explode(',', $param['id']))) { continue; } if (isset($system['more']) && !$system['more']) { unset($t['field'], $t['setting']); } $return[] = $t; $i++; } if (!$return) { return $this->_return($system['return'], '没有匹配到内容'); } return $this->_return($system['return'], $return, ''); break; case 'linkage': // 联动菜单 $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $linkage = $this->ci->get_cache('linkage-' . $system['site'] . '-' . $param['code']); if (!$linkage) { return $this->_return($system['return'], "联动菜单{$param['code']}不存在,请在后台更新缓存"); } $i = 0; $return = array(); foreach ($linkage as $t) { if ($system['num'] && $i >= $system['num']) { break; } if (isset($param['pid']) && $t['pid'] != (int) $param['pid']) { continue; } if (isset($param['id']) && !in_array($t['id'], explode(',', $param['id']))) { continue; } $return[] = $t; $i++; } if (!$return) { foreach ($linkage as $t) { if ($t['pid'] == (int) $linkage[$param['pid']]['pid']) { if ($system['num'] && $i >= $system['num']) { break; } if (isset($param['id']) && !in_array($t['id'], explode(',', $param['id']))) { continue; } $return[] = $t; $i++; } } if (!$return) { return $this->_return($system['return'], '没有匹配到内容'); } } return $this->_return($system['return'], isset($param['call']) && $param['call'] ? @array_reverse($return) : $return, ''); break; case 'search_field': // 搜索字段筛选 $catid = $system['catid']; $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $module = get_module($system['module'] ? $system['module'] : APP_DIR, $system['site']); if (!$module || count($module['category'][$catid]['field']) == 0) { return $this->_return($system['return'], '模块未安装或者此栏目无附加字段'); } $return = array(); foreach ($module['category'][$catid]['field'] as $t) { if ($t['issearch'] && $t['ismain'] && ($t['fieldtype'] == 'Select' || $t['fieldtype'] == 'Radio')) { $data = @explode(PHP_EOL, $t['setting']['option']['options']); if ($data) { $list = array(); foreach ($data as $c) { list($name, $value) = @explode('|', $c); if ($name && !is_null($value)) { $list[] = array('name' => trim($name), 'value' => trim($value)); } } if ($list) { $return[] = array('name' => $t['name'], 'field' => $t['fieldname'], 'data' => $list); } } } } return $this->_return($system['return'], $return, ''); break; case 'navigator': // 网站导航 $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $navigator = $this->ci->get_cache('navigator-' . $system['site']); // 导航缓存 if (!$navigator) { return $this->_return($system['return'], '导航数据为空'); } $i = 0; $show = isset($param['show']) ? 1 : 0; // 有show参数表示显示隐藏栏目 $data = $navigator[(int) $param['type']]; if (!$data) { // 没有查询到内容 return $this->_return($system['return'], '没有查询到内容'); } $return = array(); foreach ($data as $t) { if ($system['num'] && $i >= $system['num']) { break; } if (isset($param['pid']) && $t['pid'] != (int) $param['pid']) { continue; } if (isset($param['id']) && $t['id'] != (int) $param['id']) { continue; } if (!$t['show'] && !$show) { continue; } $return[] = $t; $i++; } if (!$return) { return $this->_return($system['return'], '没有匹配到内容'); } return $this->_return($system['return'], $return, ''); break; case 'page': // 单页调用 $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $name = $system['module'] ? $system['module'] : 'index'; $data = $this->ci->get_cache('page-' . $system['site'], 'data', $name); // 单页缓存 if (!$data) { return $this->_return($system['return'], '没有查询到内容'); } $i = 0; $show = isset($param['show']) ? 1 : 0; // 有show参数表示显示隐藏栏目 $field = $this->ci->dcache->get('page-field-' . $system['site']); $return = array(); foreach ($data as $id => $t) { if (!is_numeric($id)) { continue; } if ($system['num'] && $i >= $system['num']) { break; } if (!$t['show'] && !$show) { continue; } if (isset($param['pid']) && $t['pid'] != (int) $param['pid']) { continue; } if (isset($param['id']) && !in_array($t['id'], explode(',', $param['id']))) { continue; } $t['setting'] = dr_string2array($t['setting']); $return[] = $this->ci->field_format_value($field, $t, 1); $i++; } if (!$return) { return $this->_return($system['return'], '没有匹配到内容'); } return $this->_return($system['return'], $return, $sql); break; case 'related': // 相关文章 $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $module = get_module($system['module'] ? $system['module'] : APP_DIR, $system['site']); if (!$module) { return $this->_return($system['return'], "模块({$system['module']})未安装"); // 没有模块数据时返回空 } if (!$param['tag']) { return $this->_return($system['return'], '没有查询到内容'); // 没有查询到内容 } else { $where = array(); $array = explode(',', $param['tag']); foreach ($array as $name) { if ($name) { $where[] = '(`title` LIKE "%' . $this->ci->db->escape_str($name) . '%" OR `keywords` LIKE "%' . $this->ci->db->escape_str($name) . '%")'; } } $where = implode(' OR ', $where); } $table = $this->ci->db->dbprefix($system['site'] . '_' . $module['dirname']); // 模块主表 $sql = "SELECT " . ($system['field'] ? $system['field'] : "*") . " FROM {$table} WHERE {$where} ORDER BY updatetime DESC LIMIT " . ($system['num'] ? $system['num'] : 10); $data = $this->_query($sql, $system['site'], $system['cache']); // 缓存查询结果 $name = 'list-action-sql-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { $fields = $module['field']; // 模块表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t, 1, $module['dirname']); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql); break; case 'tag': // 调用tag $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $module = get_module($system['module'] ? $system['module'] : APP_DIR, $system['site']); if (!$module) { // 没有模块数据时返回空 return $this->_return($system['return'], "模块({$system['module']})未安装"); } $table = $this->ci->db->dbprefix($system['site'] . '_' . $module['dirname'] . '_tag'); // tag表 $sql = "SELECT id,name,code,hits FROM {$table} ORDER BY hits DESC LIMIT " . ($system['num'] ? $system['num'] : 10); $data = $this->_query($sql, $system['site'], $system['cache']); // 没有查询到内容 if (!$data) { return $this->_return($system['return'], '没有查询到内容'); } // 缓存查询结果 $name = 'list-action-tag-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { foreach ($data as $i => $t) { $data[$i]['url'] = dr_tag_url($module, $t['name'], 1, $module['dirname']); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql); break; case 'sql': // 直接sql查询 if (preg_match('/sql=\'(.+)\'/sU', $_params, $sql)) { $db = !$system['site'] ? $system['module'] ? $this->ci->site[SITE_ID] : $this->ci->db : $this->ci->site[$system['site']]; // 数据库对象 $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $sql = str_replace('@#', $db->dbprefix, trim($sql[1])); if (stripos($sql, 'SELECT') !== 0) { return $this->_return($system['return'], 'SQL语句只能是SELECT查询语句'); } $total = 0; $pages = ''; // 如存在分页条件才进行分页查询 if ($system['page'] && $system['urlrule']) { $page = max(1, (int) $_GET['page']); $row = $this->_query(preg_replace('/select(.*)from/iUs', 'SELECT count(*) as c FROM', $sql), $system['site'], $system['cache'], FALSE); $total = (int) $row['c']; $pagesize = $system['pagesize'] ? $system['pagesize'] : 10; // 没有数据时返回空 if (!$total) { return $this->_return($system['return'], '没有查询到内容', $sql, 0); } $sql .= ' LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination(str_replace('[page]', '{page}', urldecode($system['urlrule'])), $pagesize, $total); } $data = $this->_query($sql, $system['site'], $system['cache']); $fields = NULL; if ($system['module'] && ($module = get_module($system['module'], $system['site']))) { $fields = $module['field']; // 模块主表的字段 } elseif ($system['modelid'] && ($model = $this->ci->get_cache('space-model', $system['modelid']))) { $fields = $model['field']; // 空间模型的字段 } if ($fields) { // 缓存查询结果 $name = 'list-action-sql-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { // 模块表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t, 1, isset($module['dirname']) && $module['dirname'] ? $module['dirname'] : ''); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } $data = $cache; } return $this->_return($system['return'], $data, $sql, $total, $pages); } else { return $this->_return($system['return'], '参数不正确,SQL语句必须用单引号包起来'); // 没有查询到内容 } break; case 'model': // 空间模型 $uid = (int) $system['space']; $mid = (int) $system['modelid']; if (!$mid) { return $this->_return($system['return'], 'modelid参数必须存在,请在后台更新缓存'); // 参数判断 } $model = $this->ci->get_cache('space-model', $mid); if (!$model) { return $this->_return($system['return'], "空间模型({$system['modelid']})未安装"); // 没有模型数据时返回空 } $tableinfo = $this->ci->get_cache('table'); if (!$tableinfo) { $this->ci->load->model('system_model'); $tableinfo = $this->ci->system_model->cache(); // 表结构缓存 } if (!$tableinfo) { return $this->_return($system['return'], '表结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); // 没有表结构缓存时返回空 } $system['order'] = !$system['order'] ? 'updatetime' : $system['order']; // 默认排序参数 if ($uid) { $where[] = array('adj' => '', 'name' => 'space_id', 'value' => $uid); if (isset($system['catid']) && $system['catid']) { $this->ci->load->model('space_category_model'); $category = $this->ci->space_category_model->get_data(0, $uid, 1); // 栏目id集合不存在时则重新修复栏目数据 if (!$category[$system['catid']]['childids']) { $this->ci->space_category_model->repair($uid); } $where[] = array('adj' => $category[$system['catid']]['child'] ? 'IN' : '', 'name' => 'catid', 'value' => $category[$system['catid']]['child'] ? $category[$system['catid']]['childids'] : $system['catid']); } } $table = $this->ci->db->dbprefix('space_' . $model['table']); // 模块主表 $where = $this->_set_where_field_prefix($where, $tableinfo[$table]['field'], $table); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table]['field'], $table); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table]['field'], $table); // 给排序字段加上表前缀 $total = 0; $fields = $model['field']; // 主表的字段 $sql_from = $table; // sql的from子句 $sql_limit = $pages = ''; $sql_where = $this->_get_where($where); // sql的where子句 // 当前作者不缓存 if ($this->ci->uid == $uid) { $system['cache'] = 0; } if ($system['page'] && $system['urlrule']) { $page = max(1, (int) $_GET['page']); $urlrule = str_replace('[page]', '{page}', urldecode($system['urlrule'])); $pagesize = (int) $system['pagesize']; $pagesize = $pagesize ? $pagesize : 10; $sql = "SELECT count(*) as c FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " ORDER BY NULL"; $row = $this->_query($sql, 0, $system['cache'], FALSE); $total = (int) $row['c']; // 没有数据时返回空 if (!$total) { return $this->_return($system['return'], '没有查询到内容', $sql, 0); } $sql_limit = 'LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination($urlrule, $pagesize, $total); } elseif ($system['num']) { $sql_limit = "LIMIT {$system['num']}"; } $sql = "SELECT " . ($system['field'] ? $system['field'] : "*") . " FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " " . ($system['order'] ? "ORDER BY {$system['order']}" : "") . " {$sql_limit}"; $data = $this->_query($sql, 0, $system['cache']); // 缓存查询结果 $name = 'list-action-space-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { // 模块表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql, $total, $pages); break; case 'space_content': // 空间模型文档内容 $id = (int) $param['id']; $mid = (int) $system['modelid']; if (!$id) { return $this->_return($system['return'], 'id参数不存在'); } if (!$mid) { return $this->_return($system['return'], 'modelid参数必须存在,请在后台更新缓存'); // 参数判断 } // 模型缓存 $model = $this->ci->get_cache('space-model', $mid); if (!$model) { return $this->_return($system['return'], "空间模型({$system['modelid']})未安装"); // 没有模型数据时返回空 } // 模型表名称和缓存 $name = $this->ci->db->dbprefix('space_' . $model['table']) . '-space-show-' . $id; $data = $this->ci->get_cache_data($name); $time = $system['cache'] ? $system['cache'] : 36000; if ($time && !$data) { $data = $this->ci->db->where('id', $id)->get('space_' . $model['table'])->row_array(); $this->ci->set_cache_data($name, $data, $time); } // 格式化输出自定义字段 $fields = $model['field']; $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); $data = $this->ci->field_format_value($fields, $data, max(1, (int) $_GET['page'])); // 输出返回字段 $field = $system['field'] ? explode(',', $system['field']) : NULL; if ($field) { $temp = $data; $data = array(); foreach ($field as $i) { $data[$i] = isset($temp[$i]) ? $temp[$i] : ''; } } return $this->_return($system['return'], array($data), ''); break; case 'extend': // 子内容调用 $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $dirname = $system['module'] ? $system['module'] : APP_DIR; if (!$dirname) { return $this->_return($system['return'], 'module参数不能为空'); } $module = get_module($dirname, $system['site']); if (!$module) { return $this->_return($system['return'], "模块({$dirname})未安装"); // 没有模块数据时返回空 } $tableinfo = $this->ci->get_cache('table'); if (!$tableinfo) { $this->ci->load->model('system_model'); $tableinfo = $this->ci->system_model->cache(); // 表结构缓存 } if (!$tableinfo) { return $this->_return($system['return'], '表结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); // 没有表结构缓存时返回空 } $system['order'] = !$system['order'] ? 'displayorder desc,inputtime asc' : $system['order']; // 默认排序参数 $table = $this->ci->db->dbprefix($system['site'] . '_' . $module['dirname'] . '_extend'); // 表名称 $where = $this->_set_where_field_prefix($where, $tableinfo[$table]['field'], $table); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table]['field'], $table); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table]['field'], $table); // 给排序字段加上表前缀 $total = 0; $fields = $module['extend']; // 主表的字段 $sql_from = $table; // sql的from子句 $sql_limit = $pages = ''; $sql_where = $this->_get_where($where); // sql的where子句 if (defined('MODULE_HTML') && MODULE_HTML) { $system['cache'] = 0; } if ($system['page'] && $system['urlrule']) { $page = max(1, (int) $_GET['page']); $urlrule = str_replace('[page]', '{page}', urldecode($system['urlrule'])); $pagesize = (int) $system['pagesize']; $pagesize = $pagesize ? $pagesize : 10; $sql = "SELECT count(*) as c FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " ORDER BY NULL"; $row = $this->_query($sql, 0, $system['cache'], FALSE); $total = (int) $row['c']; // 没有数据时返回空 if (!$total) { return $this->_return($system['return'], '没有查询到内容', $sql, 0); } $sql_limit = 'LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination($urlrule, $pagesize, $total); } elseif ($system['num']) { $sql_limit = "LIMIT {$system['num']}"; } $sql = "SELECT " . ($system['field'] ? $system['field'] : "*") . " FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " " . ($system['order'] ? "ORDER BY {$system['order']}" : "") . " {$sql_limit}"; $data = $this->_query($sql, $system['site'], $system['cache']); // 缓存查询结果 $name = 'list-action-extend-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { // 表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t, 1, $module['dirname']); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql, $total, $pages); break; case 'form': // 表单调用 $mid = $system['form']; $site = $system['site'] ? $system['site'] : SITE_ID; // 表单参数为数字时按id读取 if (is_numeric($mid)) { $form = $this->ci->get_cache('form-' . $site, $mid); } else { $form = $this->ci->get_cache('form-name-' . $site, $mid); } // 判断是否存在 if (!$form) { return $this->_return($system['return'], "表单({$mid})不存在"); // 参数判断 } // 表结构缓存 $tableinfo = $this->ci->get_cache('table'); if (!$tableinfo) { $this->ci->load->model('system_model'); $tableinfo = $this->ci->system_model->cache(); } if (!$tableinfo) { return $this->_return($system['return'], '表结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); // 没有表结构缓存时返回空 } // 将catid作为普通字段 if (isset($system['catid']) && $system['catid']) { $where[] = array('adj' => '', 'name' => 'catid', 'value' => $system['catid']); } $system['order'] = !$system['order'] ? 'inputtime' : $system['order']; // 默认排序参数 $table = $this->ci->db->dbprefix($site . '_form_' . $form['table']); // 表单表名称 $where = $this->_set_where_field_prefix($where, $tableinfo[$table]['field'], $table); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table]['field'], $table); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table]['field'], $table); // 给排序字段加上表前缀 $total = 0; $fields = $form['field']; // 主表的字段 $sql_from = $table; // sql的from子句 $sql_limit = $pages = ''; $sql_where = $this->_get_where($where); // sql的where子句 if ($system['page'] && $system['urlrule']) { $page = max(1, (int) $_GET['page']); $urlrule = str_replace('[page]', '{page}', urldecode($system['urlrule'])); $pagesize = (int) $system['pagesize']; $pagesize = $pagesize ? $pagesize : 10; $sql = "SELECT count(*) as c FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " ORDER BY NULL"; $row = $this->_query($sql, $site, $system['cache'], FALSE); $total = (int) $row['c']; // 没有数据时返回空 if (!$total) { return $this->_return($system['return'], '没有查询到内容', $sql, 0); } $sql_limit = 'LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination($urlrule, $pagesize, $total); } elseif ($system['num']) { $sql_limit = "LIMIT {$system['num']}"; } $sql = "SELECT " . ($system['field'] ? $system['field'] : "*") . " FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " " . ($system['order'] ? "ORDER BY {$system['order']}" : "") . " {$sql_limit}"; $data = $this->_query($sql, 0, $system['cache']); // 缓存查询结果 $name = 'list-action-form-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { // 表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql, $total, $pages); break; case 'mform': // 模块表单调用 $site = $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $dirname = $system['module'] ? $system['module'] : APP_DIR; if (!$dirname) { return $this->_return($system['return'], 'module参数不能为空'); } $module = get_module($dirname, $system['site']); if (!$module) { return $this->_return($system['return'], "模块({$dirname})未安装"); // 没有模块数据时返回空 } $fid = $system['form']; $form = $module['form'][$fid]; if (!$form) { return $this->_return($system['return'], "模块表单({$fid})不存在"); // 参数判断 } $tableinfo = $this->ci->get_cache('table'); if (!$tableinfo) { $this->ci->load->model('system_model'); $tableinfo = $this->ci->system_model->cache(); // 表结构缓存 } if (!$tableinfo) { return $this->_return($system['return'], '表结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); // 没有表结构缓存时返回空 } $system['order'] = !$system['order'] ? 'inputtime' : $system['order']; // 默认排序参数 $table = $this->ci->db->dbprefix($site . '_' . $module['dirname'] . '_form_' . $fid); // 表单表名称 $where = $this->_set_where_field_prefix($where, $tableinfo[$table]['field'], $table); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table]['field'], $table); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table]['field'], $table); // 给排序字段加上表前缀 $total = NULL; $fields = $form['field']; // 主表的字段 $sql_from = $table; // sql的from子句 $sql_where = $this->_get_where($where); // sql的where子句 $sql_limit = $pages = ''; if ($system['page'] && $system['urlrule']) { $page = max(1, (int) $_GET['page']); $urlrule = str_replace('[page]', '{page}', urldecode($system['urlrule'])); $pagesize = (int) $system['pagesize']; $pagesize = $pagesize ? $pagesize : 10; $sql = "SELECT count(*) as c FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " ORDER BY NULL"; $row = $this->_query($sql, $site, $system['cache'], FALSE); $total = (int) $row['c']; // 没有数据时返回空 if (!$total) { return $this->_return($system['return'], '没有查询到内容', $sql, 0); } $sql_limit = 'LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination($urlrule, $pagesize, $total); } elseif ($system['num']) { $sql_limit = "LIMIT {$system['num']}"; } $sql = "SELECT " . ($system['field'] ? $system['field'] : "*") . " FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " " . ($system['order'] ? "ORDER BY {$system['order']}" : "") . " {$sql_limit}"; $data = $this->_query($sql, $site, $system['cache']); // 缓存查询结果 $name = 'list-action-mform-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { // 表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t, 1, $module['dirname']); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql, $total, $pages); break; case 'member': // 会员信息 $tableinfo = $this->ci->get_cache('table'); if (!$tableinfo) { $this->ci->load->model('system_model'); $tableinfo = $this->ci->system_model->cache(); // 表结构缓存 } if (!$tableinfo) { // 没有表结构缓存时返回空 return $this->_return($system['return'], '表结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); } $table = $this->ci->db->dbprefix('member'); // 主表 $system['order'] = !$system['order'] ? 'uid' : $system['order']; // 默认排序参数 $where = $this->_set_where_field_prefix($where, $tableinfo[$table]['field'], $table); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table]['field'], $table); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table]['field'], $table); // 给排序字段加上表前缀 $sql_from = $table; // sql的from子句 if ($system['more']) { // 会员附表 $more = $this->ci->db->dbprefix('member_data'); // 附表 $where = $this->_set_where_field_prefix($where, $tableinfo[$more]['field'], $more); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$more]['field'], $more); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$more]['field'], $more); // 给排序字段加上表前缀 $sql_from .= " LEFT JOIN {$more} ON `{$table}`.`uid`=`{$more}`.`uid`"; // sql的from子句 } $total = 0; $sql_limit = ''; $sql_where = $this->_get_where($where); // sql的where子句 if ($system['page'] && $system['urlrule']) { // 如存在分页条件才进行分页查询 $page = max(1, (int) $_GET['page']); $urlrule = str_replace('[page]', '{page}', urldecode($system['urlrule'])); $pagesize = (int) $system['pagesize']; $pagesize = $pagesize ? $pagesize : 10; $row = $this->_query("SELECT count(*) as c FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " ORDER BY NULL", $system['site'], $system['cache'], FALSE); $total = (int) $row['c']; if (!$total) { // 没有数据时返回空 return $this->_return($system['return'], '没有查询到内容', $sql, 0); } $sql_limit = ' LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination(str_replace('[page]', '{page}', $urlrule), $pagesize, $total); } elseif ($system['num']) { $sql_limit = "LIMIT {$system['num']}"; } $sql = "SELECT " . ($system['field'] ? $system['field'] : "*") . " FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " " . ($system['order'] == "null" ? "" : " ORDER BY {$system['order']}") . " {$sql_limit}"; $data = $this->_query($sql, $system['site'], $system['cache']); // 缓存查询结果 $name = 'list-action-member-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { // 系统字段 $fields['regtime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql, $total, $pages); break; case 'space': // 空间数据 $tableinfo = $this->ci->get_cache('table'); if (!$tableinfo) { $this->ci->load->model('system_model'); $tableinfo = $this->ci->system_model->cache(); // 表结构缓存 } if (!$tableinfo) { return $this->_return($system['return'], '表结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); // 没有表结构缓存时返回空 } $table = $this->ci->db->dbprefix('space'); // 空间主表 $system['order'] = !$system['order'] ? 'displayorder' : $system['order']; // 默认排序参数 if ($system['keyword']) { $where[] = array('adj' => 'LIKE', 'name' => 'name', 'value' => '%' . $system['keyword'] . '%'); } $where[] = array('adj' => '', 'name' => 'status', 'value' => 1); $where = $this->_set_where_field_prefix($where, $tableinfo[$table]['field'], $table); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table]['field'], $table); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table]['field'], $table); // 给排序字段加上表前缀 $sql_from = $table; // sql的from子句 if ($system['more']) { // 会员附表 $more = $this->ci->db->dbprefix('member_data'); // 附表 $where = $this->_set_where_field_prefix($where, $tableinfo[$more]['field'], $more); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$more]['field'], $more); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$more]['field'], $more); // 给排序字段加上表前缀 $sql_from .= " LEFT JOIN {$more} ON `{$table}`.`uid`=`{$more}`.`uid`"; // sql的from子句 } if ($system['more'] == 2) { // 会员主表 $more2 = $this->ci->db->dbprefix('member'); // 附表 $where = $this->_set_where_field_prefix($where, $tableinfo[$more2]['field'], $more2); // 给条件字段加上表前缀 if ($system['field']) { $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$more2]['field'], $more2); // 给显示字段加上表前缀 } else { $system['field'] = "`{$table}`.*" . ($more ? ",`{$more}`.*" : "") . ",`{$more2}`.`username`,`{$more2}`.`groupid`,`{$more2}`.`uid`"; } $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$more2]['field'], $more2); // 给排序字段加上表前缀 $sql_from .= " LEFT JOIN {$more2} ON `{$table}`.`uid`=`{$more2}`.`uid`"; // sql的from子句 } $total = 0; $sql_limit = ''; $sql_where = $this->_get_where($where); // sql的where子句 if ($system['flag']) { // 推荐位调用 $_ids = $this->_query("select uid from {$table}_flag where `flag`=" . (int) $system['flag'], $system['site'], $system['cache']); $in = array(); foreach ($_ids as $t) { $in[] = $t['uid']; } if (!$in) { // 没有查询到内容 return $this->_return($system['return'], '没有查询到推荐位内容'); } $sql_where = ($sql_where ? $sql_where . ' AND' : '') . " `{$table}`.`uid` IN (" . implode(',', $in) . ")"; } if ($system['page'] && $system['urlrule']) { // 如存在分页条件才进行分页查询 $page = max(1, (int) $_GET['page']); $urlrule = str_replace('[page]', '{page}', urldecode($system['urlrule'])); $pagesize = (int) $system['pagesize']; $pagesize = $pagesize ? $pagesize : 10; $sql = "SELECT count(*) as c FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " ORDER BY NULL"; $row = $this->_query($sql, $system['site'], $system['cache'], FALSE); $total = (int) $row['c']; if (!$total) { // 没有数据时返回空 return $this->_return($system['return'], '没有查询到内容', $sql, 0); } $sql_limit = ' LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination(str_replace('[page]', '{page}', $urlrule), $pagesize, $total); } elseif ($system['num']) { $sql_limit = "LIMIT {$system['num']}"; } $sql = "SELECT " . ($system['field'] ? $system['field'] : "*") . " FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " " . ($system['order'] == "null" ? "" : " ORDER BY {$system['order']}") . " {$sql_limit}"; $data = $this->_query($sql, $system['site'], $system['cache']); // 缓存查询结果 $name = 'list-action-space-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { // 系统字段 $fields['regtime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql, $total, $pages); break; case 'module': // 模块数据 $dirname = $system['module'] ? $system['module'] : APP_DIR; if (!$dirname) { return $this->_return($system['return'], 'module参数不能为空'); } $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $module = get_module($dirname, $system['site']); if (!$module) { // 没有模块数据时返回空 return $this->_return($system['return'], "模块({$dirname})未安装"); } $tableinfo = $this->ci->get_cache('table'); if (!$tableinfo) { $this->ci->load->model('system_model'); $tableinfo = $this->ci->system_model->cache(); // 表结构缓存 } if (!$tableinfo) { // 没有表结构缓存时返回空 return $this->_return($system['return'], '表结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); } $table = $this->ci->db->dbprefix($system['site'] . '_' . $module['dirname']); // 模块主表 if (!isset($tableinfo[$table]['field'])) { return $this->_return($system['return'], '表(' . $table . ')结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); } // 排序操作 if (!$system['order'] && $where[0]['adj'] == 'IN' && $where[0]['name'] == 'id') { // 按id序列来排序 $system['order'] = strlen($where[0]['value']) < 10000 ? 'instr("' . $where[0]['value'] . '", `' . $table . '`.`id`)' : 'NULL'; } else { if (!$system['order']) { if ($system['flag']) { $system['order'] = 'displayorder_desc,updatetime_desc'; // 默认排序参数 } else { $system['order'] = 'updatetime'; // 默认排序参数 } } } // 栏目筛选 if ($system['catid']) { if (strpos($system['catid'], ',') !== FALSE) { $where[] = array('adj' => 'IN', 'name' => 'catid', 'value' => $system['catid']); } elseif ($module['category'][$system['catid']]['child']) { $where[] = array('adj' => 'IN', 'name' => 'catid', 'value' => $module['category'][$system['catid']]['childids']); } else { $where[] = array('adj' => '', 'name' => 'catid', 'value' => (int) $system['catid']); } } $fields = $module['field']; // 主表的字段 $where = $this->_set_where_field_prefix($where, $tableinfo[$table]['field'], $table); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table]['field'], $table); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table]['field'], $table); // 给排序字段加上表前缀 $sql_from = $table; // sql的from子句 // 关联栏目附加表 if ($system['more']) { $_catid = (int) $system['catid']; if (isset($module['category'][$_catid]['field']) && $module['category'][$_catid]['field']) { $fields = array_merge($fields, $module['category'][$_catid]['field']); $table_more = $table . '_category_data'; // 栏目附加表 $where = $this->_set_where_field_prefix($where, $tableinfo[$table_more]['field'], $table_more); // 给条件字段加上表前缀 $system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table_more]['field'], $table_more); // 给显示字段加上表前缀 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table_more]['field'], $table_more); // 给排序字段加上表前缀 $sql_from .= " LEFT JOIN {$table_more} ON `{$table_more}`.`id`=`{$table}`.`id`"; // sql的from子句 } } $total = 0; $sql_limit = $pages = ''; $sql_where = $this->_get_where($where); // sql的where子句 // 推荐位调用 if ($system['flag']) { $_w = strpos($sytem['flag'], ',') ? '`flag` IN (' . $sytem['flag'] . ')' : '`flag`=' . (int) $system['flag']; $_i = $this->_query("select id from {$table}_flag where " . $_w, $system['site'], $system['cache']); $in = array(); foreach ($_i as $t) { $in[] = $t['id']; } // 没有查询到内容 if (!$in) { return $this->_return($system['return'], '没有查询到内容'); } $sql_where = ($sql_where ? $sql_where . ' AND' : '') . "`{$table}`.`id` IN (" . implode(',', $in) . ")"; unset($_w, $_i, $in); } if ($system['page']) { $page = max(1, (int) $_GET['page']); if (is_numeric($system['catid'])) { $urlrule = dr_category_url($module, $module['category'][$system['catid']], '{page}'); $pagesize = $system['pagesize'] ? (int) $system['pagesize'] : (int) $module['category'][$system['catid']]['setting']['template']['pagesize']; } else { $urlrule = str_replace('[page]', '{page}', urldecode($system['urlrule'])); $pagesize = (int) $system['pagesize']; } $pagesize = $pagesize ? $pagesize : 10; $sql = "SELECT count(*) as c FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . " ORDER BY NULL"; $row = $this->_query($sql, $system['site'], $system['cache'], FALSE); $total = (int) $row['c']; // 没有数据时返回空 if (!$total) { return $this->_return($system['return'], '没有查询到内容', $sql, 0); } $sql_limit = 'LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination($urlrule, $pagesize, $total); } elseif ($system['num']) { $sql_limit = "LIMIT {$system['num']}"; } $sql = "SELECT " . ($system['field'] ? $system['field'] : '*') . " FROM {$sql_from} " . ($sql_where ? "WHERE {$sql_where}" : "") . ($system['order'] == "null" ? "" : " ORDER BY {$system['order']}") . " {$sql_limit}"; $data = $this->_query($sql, $system['site'], $system['cache']); // 缓存查询结果 $name = 'list-action-module-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache && is_array($data)) { // 模块表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t, 1, $module['dirname']); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache ? $cache : $data, $sql, $total, $pages); break; case 'search': // 模块的搜索 $total = (int) $param['total']; // 没有数据时返回空 if (!$total) { return $this->_return($system['return'], 'total参数为空', $sql, 0); } $dirname = $system['module'] ? $system['module'] : APP_DIR; if (!$dirname) { return $this->_return($system['return'], 'module参数不能为空'); } // 没有id时返回空 if (!$param['id']) { return $this->_return($system['return'], 'id参数为空', $sql, 0); } $system['site'] = !$system['site'] ? SITE_ID : $system['site']; // 默认站点参数 $module = get_module($dirname, $system['site']); if (!$module) { // 没有模块数据时返回空 return $this->_return($system['return'], "模块({$dirname})未安装"); } $tableinfo = $this->ci->get_cache('table'); if (!$tableinfo) { $this->ci->load->model('system_model'); $tableinfo = $this->ci->system_model->cache(); // 表结构缓存 } if (!$tableinfo) { // 没有表结构缓存时返回空 return $this->_return($system['return'], '表结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); } $table = $this->ci->db->dbprefix($system['site'] . '_' . $module['dirname']); // 模块主表 if (!isset($tableinfo[$table]['field'])) { return $this->_return($system['return'], '表(' . $table . ')结构缓存不存在(排查方式:后台-系统-数据备份,查看是否显示正常的表结构)'); } $fields = $module['field']; // 主表的字段 $sql_from = $table; // sql的from子句 $system['catid'] = intval($system['catid']); // 排序操作 $system['order'] = $this->_set_order_field_prefix($system['order'] ? $system['order'] : 'updatetime', $tableinfo[$table]['field'], $table); // 给排序字段加上表前缀 // 关联栏目附加表 if ($system['more'] && isset($module['category'][$system['catid']]['field']) && $module['category'][$system['catid']]['field']) { $fields = array_merge($fields, $module['category'][$system['catid']]['field']); $table_more = $table . '_category_data'; // 栏目附加表 $sql_from .= " LEFT JOIN {$table_more} ON `{$table_more}`.`id`=`{$table}`.`id`"; // sql的from子句 $system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table_more]['field'], $table_more); // 给排序字段加上表前缀 } $sql_limit = $pages = ''; $sql_where = '`id` IN(SELECT `cid` FROM `' . $table . '_search_index` WHERE `id`="' . $param['id'] . '")'; // sql的where子句 // 搜索分页 $page = max(1, (int) $_GET['page']); $urlrule = str_replace('[page]', '{page}', urldecode($system['urlrule'])); $pagesize = (int) $system['pagesize']; $pagesize = $pagesize ? $pagesize : 10; $sql_limit = 'LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize; $pages = $this->_get_pagination($urlrule, $pagesize, $total); $sql = "SELECT " . ($system['field'] ? $system['field'] : '*') . " FROM {$sql_from} WHERE {$sql_where} ORDER BY {$system['order']} {$sql_limit}"; $data = $this->_query($sql, $system['site'], $system['cache']); // 缓存查询结果 $name = 'list-action-search-' . md5($sql); $cache = $this->ci->get_cache_data($name); if (!$cache) { // 模块表的系统字段 $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); // 格式化显示自定义字段内容 foreach ($data as $i => $t) { $data[$i] = $this->ci->field_format_value($fields, $t, 1, $module['dirname']); } $cache = $this->ci->set_cache_data($name, $data, $system['cache']); } return $this->_return($system['return'], $cache, $sql, $total, $pages); break; default: return $this->_return($system['return'], 'list标签必须含有参数action或者action参数错误'); break; } }