public function __construct($name) { $name = Filter::string($name); $this->_error = $_FILES[$name]["error"]; $this->_name = $_FILES[$name]["name"]; $this->_type = $_FILES[$name]["type"]; $this->_size = $_FILES[$name]["size"]; $this->_tmp_name = $_FILES[$name]["tmp_name"]; }
/** * 列表 * * @author mrmsl <*****@*****.**> * @date 2013-06-07 11:09:51 * * @return void 无返回值 */ public function listAction() { $sort = Filter::string('sort', 'get', $this->_pk_field); //排序字段 if (!in_array($sort, $this->_getDbFields())) { $log = __METHOD__ . ': ' . __LINE__ . ',' . L('QUERY,CONTROLLER_NAME,%。,ORDER,COLUMN') . $sort . L('NOT_EXIST'); C('TRIGGER_ERROR', array($log)); $this->_model->addLog($log, LOG_TYPE_INVALID_PARAM); $this->_ajaxReturn(false, L('SERVER_ERROR')); } $order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get'); //排序 $order = toggle_order($order); $keyword = Filter::string('keyword', 'get'); //关键字 $date_start = Filter::string('date_start', 'get'); //开始时间 $date_end = Filter::string('date_end', 'get'); //结束时间 $template_id = Filter::int('template_id', 'get'); // $column = Filter::string('column', 'get'); //搜索字段 $where = array(); if ('' !== $keyword && in_array($column, array('subject', 'content', 'email'))) { $where[$column] = $this->_buildMatchQuery($column, $keyword, Filter::string('match_mode', 'get')); } if ($date_start && ($date_start = strtotime($date_start))) { $where['add_time'][] = array('EGT', $date_start); } if ($date_end && ($date_end = strtotime($date_end))) { $where['add_time'][] = array('ELT', $date_end); } if (isset($where['add_time']) && count($where['add_time']) == 1) { $where['add_time'] = $where['add_time'][0]; } if ($template_id) { $where['template_id'] = $template_id; } $total = $this->_model->where($where)->count(); if ($total === false) { //查询出错 $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR')); } elseif ($total == 0) { //无记录 $this->_ajaxReturn(true, '', null, $total); } $page_info = Filter::page($total); $data = $this->_model->where($where)->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select(); $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR')); //出错 $templates = $this->_getCache(false, 'Mail'); foreach ($data as &$v) { $v['template_name'] = isset($templates[$id = $v['template_id']]) ? $templates[$id]['template_name'] : ''; } $this->_ajaxReturn(true, '', $data, $total); }
/** * 列表管理 * * @author mrmsl <*****@*****.**> * @date 2012-07-19 12:40:43 * @lastmodify 2013-01-28 11:22:55 by mrmsl * * @return void 无返回值 */ public function listAction() { $column = Filter::string('column', 'get'); //搜索字段 $keyword = Filter::string('keyword', 'get'); //搜索关键字 $area_id = Filter::int('node', 'get'); //地区id //搜索 by mrmsl on 2012-07-24 18:02:02 if (!$area_id && $column && $keyword && in_array($column, array('area_name', 'area_code'))) { $this->_queryTree($column, $keyword); } elseif ($area_id) { $this->_ajaxReturn(true, '', $this->_getTreeData($area_id, false)); } $data = $this->_getCache(0, CONTROLLER_NAME . '_tree'); $this->_ajaxReturn(true, '', $data, count($this->_getCache())); }
/** * 列表 * * @author mrmsl <*****@*****.**> * @lastmodify 2013-01-22 10:40:26 by mrmsl * * @return void 无返回值 */ public function listAction() { $sort = Filter::string('sort', 'get', $this->_pk_field); //排序字段 $sort = 'a.' . $sort; $order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get'); //排序 $order = toggle_order($order); $keyword = Filter::string('keyword', 'get'); //关键字 $date_start = Filter::string('date_start', 'get'); //开始时间 $date_end = Filter::string('date_end', 'get'); //结束时间 $column = Filter::string('column', 'get'); //搜索字段 $where = array(); if ($keyword !== '' && in_array($column, array('username', 'realname', 'admin_id'))) { $where['b.' . $column] = $this->_buildMatchQuery('b.' . $column, $keyword, Filter::string('match_mode', 'get'), 'admin_id'); } if ($date_start && ($date_start = strtotime($date_start))) { $where['a.login_time'][] = array('EGT', $date_start); } if ($date_end && ($date_end = strtotime($date_end))) { $where['a.login_time'][] = array('ELT', $date_end); } if (isset($where['a.login_time']) && count($where['a.login_time']) == 1) { $where['a.login_time'] = $where['a.login_time'][0]; } $where && $this->_model->join('JOIN ' . TB_ADMIN . ' AS b ON a.admin_id=b.admin_id'); $total = $this->_model->alias('a')->where($where)->count(); if ($total === false) { //查询出错 $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR')); } elseif ($total == 0) { //无记录 $this->_ajaxReturn(true, '', null, $total); } $page_info = Filter::page($total); $data = $this->_model->alias('a')->join('JOIN ' . TB_ADMIN . ' AS b ON a.admin_id=b.admin_id')->where($where)->field('a.*,b.username,b.realname,INET_NTOA(a.login_ip) AS login_ip')->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select(); $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR')); //出错 $this->_ajaxReturn(true, '', $data, $total); }
/** * 列表 * * @author mrmsl <*****@*****.**> * @lastmodify 2013-01-22 10:40:26 by mrmsl * * @return void 无返回值 */ public function listAction() { $sort = Filter::string('sort', 'get', $this->_pk_field); //排序字段 $sort = in_array($sort, $this->_getDbFields()) ? $sort : $this->_pk_field; $order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get'); //排序 $order = toggle_order($order); $keyword = Filter::string('keyword', 'get'); //关键字 $date_start = Filter::string('date_start', 'get'); //注册开始时间 $date_end = Filter::string('date_end', 'get'); //注册结束时间 $log_type = Filter::int('log_type', 'get'); //日志类型 $where = $log_type != LOG_TYPE_ALL ? array('log_type' => $log_type) : array(); if ($keyword !== '') { $where['content'] = $this->_buildMatchQuery('content', $keyword, Filter::string('match_mode', 'get')); } if ($date_start && ($date_start = strtotime($date_start))) { $where['log_time'][] = array('EGT', $date_start); } if ($date_end && ($date_end = strtotime($date_end))) { $where['log_time'][] = array('ELT', $date_end); } if (isset($where['log_time']) && count($where['log_time']) == 1) { $where['log_time'] = $where['log_time'][0]; } $total = $this->_model->where($where)->count(); if ($total === false) { //查询出错 $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_LOG') . L('TOTAL_NUM,ERROR')); } elseif ($total == 0) { //无记录 $this->_ajaxReturn(true, '', null, $total); } $page_info = Filter::page($total); $data = $this->_model->where($where)->field('*,INET_NTOA(user_ip) AS user_ip')->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select(); $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_LOG') . L('LIST,ERROR')); //出错 $this->_ajaxReturn(true, '', $data, $total); }
/** * 压缩 * * @author mrmsl <*****@*****.**> * @date 2012-06-15 16:35:42 * @lastmodify 2013-01-22 10:53:56 by mrmsl * * @return void 无返回值 */ public function packAction() { $this->_js_file = (include APP_PATH . 'include/required_js.php'); $file = Filter::string('file'); !$file && $this->_ajaxReturn(false, L('FILENAME,IS_EMPTY')); if ($file == 'all') { require CORE_PATH . 'functions/dir.php'; $file = list_dir(PACKER_JS_PATH); foreach ($file as $v) { is_file($v) && '.js' == substr($v, -3) && false === strpos($v, '.min.js') && $this->_packFile($v); } $this->_merge(); } else { $this->_denyDirectory($file); $file = explode(',', $file); $merge = false; foreach ($file as $v) { if (!is_file($filename = PACKER_JS_PATH . $v) || strpos($v, '.min.') || '.js' != substr($v, -3)) { continue; } $basename = basename($v); if (!$merge && (isset($this->_js_file[$basename]) || 'base.js' == $basename)) { $merge = true; } $this->_packFile($filename); } $merge && $this->_merge(); } $this->_model->addLog(L('COMPRESS,%js,FILENAME,%:') . join(',', $file)); $this->_ajaxReturn(true, L('COMPRESS,SUCCESS')); }
/** * 验证用户密码是否正确 * * @author mrmsl <*****@*****.**> * @date 2012-07-12 09:12:50 * @lastmodify 2013-01-22 11:48:48 by mrmsl * * @param array $admin_arr 所有管理员 * @param array $admin_info 管理员信息 * @param string $password 密码 * @param string $mac_address 网卡信息 * * @return bool true密码正确,否则false */ private function _checkPasswordIsCorrect(&$admin_arr, $admin_info, $password, $mac_address) { if ($admin_info['password'] == $password) { //密码正确 $verifycode = Filter::string('_verify_code'); if ('' === $verifycode) { return L('PLEASE_ENTER,VERIFY_CODE'); } C('T_VERIFYCODE_ORDER', $admin_info['verify_code_order']); $check_verifycode = $this->_checkVerifycode($verifycode, 'module_admin'); if (true !== $check_verifycode) { return $check_verifycode; } $admin_id = $admin_info['admin_id']; $user_ip = get_client_ip(); //登陆ip $time = time(); //登陆时间 $mac = $admin_info['is_restrict'] && !$admin_info['mac_address'] ? ",mac_address='{$mac_address}'" : ''; //网卡信息为空,更新 //更新管理员最后登陆时间,最后登陆ip,登陆次数 $this->getDb()->execute('UPDATE ' . TB_ADMIN . " SET login_num=login_num+1,last_login_time={$time},last_login_ip='{$user_ip}'{$mac},lock_start_time=0,lock_end_time=0,lock_memo='' WHERE admin_id={$admin_id}"); //记录管理员登陆历史 $this->getDb()->execute('INSERT INTO ' . TB_ADMIN_LOGIN_HISTORY . "(admin_id,login_time,login_ip) VALUES({$admin_id},{$time}," . get_client_ip(1) . ')'); $this->_module->setAdminSession($admin_info); //设置session //管理员日志 $this->addLog(L('LOGIN,SUCCESS') . ".{$admin_info['username']}({$admin_info['realname']})", LOG_TYPE_ADMIN_LOGIN_INFO); $admin_arr[$admin_id]['login_num']++; $admin_arr[$admin_id]['last_login_time'] = $time; $admin_arr[$admin_id]['last_login_ip'] = $user_ip; $admin_arr[$admin_id]['is_lock'] = 0; $admin_arr[$admin_id]['lock_start_time'] = 0; $admin_arr[$admin_id]['lock_end_time'] = 0; $admin_arr[$admin_id]['lock_memo'] = ''; if ($mac) { //网卡信息有变更 $admin_arr[$admin_id]['mac_address'] = $mac_address; } $this->_setCache($admin_arr, 'Admin'); //缓存 clear_verifycoe('module_admin'); //清空验证码 return true; } return false; }
public static function get($key) { $key = Filter::string($key); return $_SESSION[$key]; }
/** * 根据两字段组合值获取数据,如id及add_time匹配才能获取到数据,而不仅仅根据id * * @author mrmsl <*****@*****.**> * @date 2013-06-14 16:22:53 * * @param string|array $field_arr 组合字段,通常为array('id','add_time') * @param string $data 组合信息,默认null=$_POST['data'],格式:id1|add_time1,id2|add_time2,... * @param string $field 选取字段,默认* * @param string $table ,默认null * * @return array 数据 */ protected function _getPairsData($field_arr, $data = null, $field = '*', $pk_field = null, $table = null) { $data = null === $data ? Filter::string('data') : $data; $return_arr = array(); if (!$data) { return $return_arr; } $data = explode(',', $data); foreach ($data as $k => $v) { $v_arr = explode('|', $v); if (isset($v_arr[0], $v_arr[1]) && ($column_1 = intval($v_arr[0])) && ($column_2 = intval($v_arr[1]))) { $return_arr[$column_1] = $column_2; } } if (!$return_arr) { $error = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . L('INVALID_PARAM') . var_export($data, true); trigger_error($error, E_USER_ERROR); return $return_arr; } $column_1_arr = array_keys($return_arr); $column_2_arr = array_values($return_arr); $pk_field = $pk_field ? $pk_field : $this->_pk_field; $field_arr = is_array($field_arr) ? $field_arr : explode(',', $field_arr); $table && $this->_model->table($table); $data = $this->_model->where(array($field_arr[0] => array('IN', $column_1_arr), $field_arr[1] => array('IN', $column_2_arr)))->field($field)->index($pk_field)->select(); $un_match = count($data) == count($return_arr) ? '' : 'data count not match.'; foreach ($data as $k => $v) { if ($return_arr[$k] != $v[$field_arr[1]]) { //id与时间不匹配 $un_match .= ",{$k}({$return_arr[$k]}) => {$k}({$v[$field_arr[1]]})[correct]"; unset($data[$k]); } } if ($un_match) { $error = get_method_line(__METHOD__, __LINE__, LOG_NORMAL_ERROR) . L('PAIRS_DATA_UN_MATCH') . $un_match; trigger_error($error, E_USER_ERROR); } return $data; }
/** * 查看文件 * * @author mrmsl <*****@*****.**> * @date 2013-06-28 11:22:40 * * @return void 无返回值 */ public function viewAction() { $filename = Filter::string('filename', 'get'); //文件名 $path = LOG_PATH . trim($filename, '/'); $data = array('filename' => $filename); if (!is_file($path)) { //文件不存在 $this->_model->addLog(L('LOG,FILE') . $path . L('NOT_EXIST'), LOG_TYPE_INVALID_PARAM); $data['content'] = L('LOG,FILE') . $filename . L('NOT_EXIST'); } else { $content = file_get_contents($path); $replace = false; $find = array('error', 'eval', 'invalid', 'failed'); foreach (array('error', 'eval', 'invalid', 'failed') as $v) { if (stripos($content, $v)) { $replace = true; break; } } $content = $replace ? preg_replace('/(.+(' . join('|', $find) . ').+)/i', '<span style="color: red">\\1</span>', $content) : $content; $data['content'] = nl2br($content); } $this->_ajaxReturn(true, '', $data); }
/** * 根据两字段组合值获取数据,如id及add_time匹配才能获取到数据,而不仅仅根据id * * @author mrmsl <*****@*****.**> * @date 2013-06-14 16:22:53 * * @param string|array $field_arr 组合字段,通常为array('id','add_time') * @param string $data 组合信息,默认null=$_POST['data'],格式:id1|add_time1,id2|add_time2,... * @param string $field 选取字段,默认* * @param string $table ,默认null * * @return array 数据 */ protected function _getPairsData($field_arr, $data = null, $field = '*', $pk_field = null, $table = null) { $data = null === $data ? Filter::string('data') : $data; $return_arr = array(); if (!$data) { return $return_arr; } $data = explode(',', $data); foreach ($data as $k => $v) { $v_arr = explode('|', $v); if (isset($v_arr[0], $v_arr[1]) && ($column_1 = intval($v_arr[0])) && ($column_2 = intval($v_arr[1]))) { $return_arr[$column_1] = $column_2; } } if (!$return_arr) { $log = __METHOD__ . ': ' . __LINE__ . ',' . L('INVALID_PARAM') . var_export($data, true); C('TRIGGER_ERROR', array($log)); $this->_model->addLog($log, LOG_TYPE_INVALID_PARAM); return $return_arr; } $column_1_arr = array_keys($return_arr); $column_2_arr = array_values($return_arr); $pk_field = $pk_field ? $pk_field : $this->_pk_field; $field_arr = is_array($field_arr) ? $field_arr : explode(',', $field_arr); $table && $this->_model->table($table); $data = $this->_model->where(array($field_arr[0] => array('IN', $column_1_arr), $field_arr[1] => array('IN', $column_2_arr)))->field($field)->key_column($pk_field)->select(); $un_match = count($data) == count($return_arr) ? '' : 'data count not match.'; foreach ($data as $k => $v) { if ($return_arr[$k] != $v[$field_arr[1]]) { //id与时间不匹配 $un_match .= ",{$k}({$return_arr[$k]}) => {$k}({$v[$field_arr[1]]})[correct]"; unset($data[$k]); } } if ($un_match) { $log = __METHOD__ . ': ' . __LINE__ . ',' . $un_match; C('TRIGGER_ERROR', array($log, E_USER_WARNING)); $this->_model->addLog($log, LOG_TYPE_INVALID_PARAM); } return $data; }
/** * 列表 * * @author mrmsl <*****@*****.**> * @date 2012-12-28 11:48:07 * @lastmodify 2013-01-22 11:00:14 by mrmsl * * @return void 无返回值 */ public function listAction() { $data = array_values($this->cache()); $this->_unshift && array_unshift($data, array($this->_pk_field => 0, $this->_name_column => isset($_POST['emptyText']) ? Filter::string('emptyText') : L('PLEASE_SELECT'))); $this->_ajaxReturn(true, '', $data); }
/** * 后台删除博客,微博静态文件 * * @author mrmsl <*****@*****.**> * @date 2013-05-17 10:51:07 * * @return void 无返回值 */ public function deleteBlogHtmlAction() { $pk_value = Filter::string($pk_field = $this->_pk_field); $pk_value = map_int($pk_value, true); if ($pk_value) { $error = ''; $log = ''; $name_column = empty($this->_name_column) ? '' : $this->_name_column; $field = $pk_field . ',link_url' . ($name_column ? ',' . $name_column : ''); $data = $this->_model->field($field)->index($pk_field)->where(array($pk_field => array('IN', $pk_value)))->select(); $delete = array(); foreach ($pk_value as $v) { if (isset($data[$v])) { $delete[] = array('link_url' => $data[$v]['link_url']); $log .= ',' . ($name_column ? ",{$data[$v][$name_column]}({$v})" : $v); } else { $error .= ',' . $v; } } if ($error) { $log_content = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . L('CONTROLLER_NAME') . $error . L('NOT_EXIST'); trigger_error($log_content, E_USER_ERROR); } if ($log) { $this->_deleteBlogHtml($delete); $this->_model->addLog(L('DELETE,CONTROLLER_NAME,STATIC_PAGE') . substr($log, 1) . L('SUCCESS')); $this->_ajaxReturn(true, L('DELETE,SUCCESS')); } else { $log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . L('DELETE,CONTROLLER_NAME,STATIC_PAGE,FAILURE,%: ,INVALID_PARAM,%:,CONTROLLER_NAME') . $error . L('NOT_EXIST'); trigger_error($log, E_USER_ERROR); } } if (empty($error)) { $log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . L("DELETE,CONTROLLER_NAME,STATIC_PAGE,FAILURE,%: ,INVALID_PARAM,%:,CONTROLLER_NAME,%{$this->_pk_field},IS_EMPTY"); trigger_error($log, E_USER_ERROR); } $this->_ajaxReturn(false, L('DELETE,FAILURE')); }
/** * ajax异步获取博客,微博元数据,包括点击量,评论数等 * * @author mrmsl <*****@*****.**> * @date 2013-05-02 16:21:34 * @lastmodify 2013-05-03 08:41:05 by mrmsl * * @return void 无返回值 */ public function metaInfoAction() { /*foreach (array(TB_BLOG, TB_MINIBLOG) as $table) { foreach($this->_model->table($table)->select() as $v) { $sql = sprintf('UPDATE %s SET hits=%d,comments=%d,diggs=%d WHERE blog_id=%d', $table, rand(1, 1000), rand(1, 50), rand(1, 20), $v['blog_id']); $this->_model->execute($sql); } }*/ $this->_updateHits(); //统计点击 $blog = Filter::string('blog'); $miniblog = Filter::string('miniblog'); if (!$blog && !$miniblog) { //空数据 $this->triggerError($log = __METHOD__ . ': ' . __LINE__ . ',' . L('INVALID_PARAM')); $this->_model->addLog($log, LOG_TYPE_INVALID_PARAM); $this->_ajaxReturn(false); } $blog = 0 === strpos($blog, ',') ? substr($blog, 1) : $blog; $miniblog = 0 === strpos($miniblog, ',') ? substr($miniblog, 1) : $miniblog; $field_arr = 'blog_id,add_time'; $field = 'blog_id,add_time,hits,comments,diggs'; $miniblog_data = $this->_getPairsData($field_arr, $miniblog, $field, 'blog_id', TB_MINIBLOG); $blog_data = $this->_getPairsData($field_arr, $blog, $field, 'blog_id', TB_BLOG); $this->_ajaxReturn(array('blog' => $blog_data, 'miniblog' => $miniblog_data, 'success' => true)); }
/** * 列表 * * @author mrmsl <*****@*****.**> * @date 2013-05-13 15:54:17 * * @return void 无返回值 */ public function listAction() { $db_fields = $this->_getDbFields(); //表字段 $sort = Filter::string('sort', 'get', $this->_pk_field); //排序字段 $sort = in_array($sort, $db_fields) ? $sort : 'sort_order'; $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get'); //排序 $order = toggle_order($order); $data = $this->_model->order($sort . ' ' . $order)->select(); false === $data && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR')); //出错 $this->_ajaxReturn(true, '', $data); }
/** * (解除)锁定 * * @author mrmsl <*****@*****.**> * @date 2012-09-05 17:19:49 * @lastmodify 2013-01-21 15:46:53 by mrmsl * * @return void 无返回值 */ function lockAction() { $pk_id = Filter::string($this->_pk_field); //管理员id $is_lock = Filter::int('is_lock') ? 1 : 0; //1:锁定;0:解除锁定 if ($is_lock) { $msg = ''; $data = array('lock_start_time' => APP_NOW_TIME, 'lock_end_time' => APP_NOW_TIME + 7200, 'lock_memo' => ''); } else { $msg = L('RELEASE'); $data = array('lock_start_time' => 0, 'lock_end_time' => 0, 'lock_memo' => ''); } $this->_setField($data, $is_lock, $msg . L('LOCK')); }
/** * 列表管理 * * @author mrmsl <*****@*****.**> * @date 2012-12-28 16:45:42 * @lastmodify 2013-01-22 10:48:23 by mrmsl * * @return void 无返回值 */ public function listAction() { $sort = Filter::string('sort', 'get', 'sort_order'); //排序字段 $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get'); //排序 $order = toggle_order($order); $keyword = Filter::string('keyword', 'get'); //关键字 $module_id = Filter::int('module_id', 'get'); //所属模块 $column = Filter::string('column', 'get'); //搜索字段 $where = array(); if ($keyword !== '' && in_array($column, array('var_name', 'var_value_zh_cn', 'var_value_en'))) { $where['a.' . $column] = $this->_buildMatchQuery('a.' . $column, $keyword, Filter::string('match_mode', 'get')); } if ($module_id) { !$this->cache($module_id, 'LanguageModules') && $this->_ajaxReturn(true, '', array(), 0); $where['a.module_id'] = $module_id; } $total = $this->_model->alias('a')->where($where)->count(); if ($total === false) { //查询出错 $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR')); } elseif ($total == 0) { //无记录 $this->_ajaxReturn(true, '', null, $total); } $page_info = Filter::page($total); $data = $this->_model->alias('a')->join('JOIN ' . TB_LANGUAGE_MODULES . ' AS m ON a.module_id=m.module_id')->where($where)->field('a.*,m.module_name')->limit($page_info['limit'])->order('a.' . $sort . ' ' . $order)->select(); $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR')); //出错 $this->_ajaxReturn(true, '', $data, $total); }
/** * 加载表单域 * * @author mrmsl <*****@*****.**> * @date 2012-08-27 14:06:37 * @lastmodify 2013-01-22 10:30:15 by mrmsl * * @return void 无返回值 */ public function publicFormAction() { $controller = Filter::string('controller', 'get'); //控制器 $action = Filter::string('action', 'get'); //操作方法 $callback = Filter::string('callback', 'get'); //jsonp callback $error_msg = L('GET,CONTROLLER_NAME_FIELD,DATA,FAILURE') . "controller={$controller}&action={$action}"; if ($controller && $action) { $this->_checkAdminPriv($controller, $action); //权限判断 by mashanlin on 2012-08-30 11:04:14 $data = $this->_model->alias('f')->field('f.field_id,f.menu_id,f.field_code,f.input_value,f.field_name,f.input_name,m.controller,m.action')->join(TB_MENU . ' AS m ON f.menu_id=m.menu_id')->where("m.controller='{$controller}' AND m.action='{$action}' AND f.is_enable=1")->order('f.sort_order ASC,f.field_id ASC')->select(); $field = array(); $data === false && $this->_sqlErrorExit($error_msg); foreach ($data as $item) { $input_name = $item['input_name']; //输入框名称 $field_name = $item['field_name']; //表单域名 $field_code = $item['field_code']; //js代码 if (!($field_code = $this->_shortcutCode($field_code))) { continue; } $find = array('@fieldLabel', '@field_name', '@input_name', '@value'); $field_label = sprintf('<a class="a-font-000" href="#controller=field&action=add&field_id=%d&back=%s">%s</a>', $item['field_id'], urlencode("#controller={$controller}&action={$action}"), $field_name, $input_name); $replace = array($field_label, $field_name, $input_name, strpos($item['input_value'], "\n") ? str_replace("\n", "\\n", $item['input_value']) : $item['input_value']); $field_code = trim(str_ireplace($find, $replace, $field_code)); $field[] = strpos($field_code, 'extField.') === 0 ? $field_code : '{' . $field_code . '}'; } //end foreach if (isset($item)) { $field[] = "{xtype: 'hidden', name: '_menu_id', value: {$item['menu_id']}}"; } $field = "{$callback}(function () {var extField = Yab.Field.field();return " . ($field ? '[' . join(',' . EOL_LF . EOL_LF, $field) . ']' : $this->_model->table(TB_MENU)->where("controller='{$controller}' AND action='{$action}'")->getField('menu_id')) . ';})'; exit($field); } else { $this->_model->addLog($error_msg, LOG_TYPE_INVALID_PARAM); send_http_status(HTTP_STATUS_SERVER_ERROR); $this->_ajaxReturn(false); } }
/** * 博客列表 * * @author mrmsl <*****@*****.**> * @date 2013-04-18 11:50:55 * * @return void 无返回值 */ public function indexAction() { $cate_name = Filter::string('name', 'get'); if ('tag' == Filter::get('flag', 'get')) { //标签 $this->_fetchBlog($cate_name); return; } $cate_arr = $this->_getCache(); if (!$cate_arr) { $this->_showMessage('no arr', null, 404); } if ('' === $cate_name) { //category.shtml $this->_fetchBlog(array('cate_id' => 0, 'cate_name' => L('CN_WANGWEN'), 'link_url' => BASE_SITE_URL . 'category' . C('HTML_SUFFIX'))); return; } foreach ($cate_arr as $v) { if ($v['en_name'] == $cate_name) { $cate_info = $v; break; } } if (!isset($cate_info)) { $this->triggerError(__METHOD__ . ': ' . __LINE__ . ',' . $cate_name . ' ' . L('NOT_EXIST')); $this->_showMessage($cate_name . ' ' . L('NOT_EXIST'), null, 404); } $this->_fetchBlog($cate_info); }
/** * 生成语言包 * * @author mrmsl <*****@*****.**> * @data 2013-06-21 16:03:22 * * @return void 无返回值 */ public function buildAction() { if ($t_module_id = C('T_MODULE_ID')) { //$this->R() $module_id = $t_module_id; } else { $module_id = Filter::string($this->_pk_field); } if (!$module_id && null === $t_module_id) { $log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . L('PRIMARY_KEY,DATA,IS_EMPTY'); trigger_error($log, E_USER_ERROR); $this->_ajaxReturn(false, L('BUILD,LANGUAGE_ITEM,CACHE,FAILURE')); } $module_id = 'all' == $module_id ? $this->_exclude_delete_id : map_int($module_id, true); if ($intersect = array_intersect($this->_exclude_delete_id, $module_id)) { //是否包含1,2,3 foreach ($intersect as $v) { $module_id = array_merge($module_id, $this->_getChildrenIds($v, false, true)); } } $module_id = array_unique($module_id); $modules = $this->cache(); $error = ''; $log = ''; foreach ($module_id as $k => $v) { //验证语言模块 if (isset($modules[$v])) { $item = $modules[$v]; $log .= ",{$item['module_name']}({$item[$this->_pk_field]})"; } else { unset($module_id[$k]); $error .= ',id(' . $v . ')'; } } if (!$module_id && null === $t_module_id) { $log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . L('PRIMARY_KEY,DATA,IS_EMPTY'); trigger_error($log, E_USER_ERROR); $this->_ajaxReturn(false, L('BUILD,LANGUAGE_ITEM,CACHE,FAILURE')); } $data = $this->_getBuildData($module_id); foreach ($data['php_data'] as $key => $content) { F($key, $content, LANG_PATH); } $this->_buildScriptItems($data['js_data']); if ($error) { $log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . $error . L('NOT_EXIST'); trigger_error($log); } if (null === $t_module_id) { $this->_model->addLog(L('BUILD,LANGUAGE_ITEM,CACHE') . $log . L('SUCCESS')); $this->_ajaxReturn(true, L('BUILD,SUCCESS')); } }
/** * 管理员列表 * * @author mrmsl <*****@*****.**> * @date 2012-12-26 14:22:09 * @lastmodify 2013-03-31 19:03:13 by mrmsl * * @return void 无返回值 */ public function listAction() { $db_fields = $this->_getDbFields(); //表字段 $sort = Filter::string('sort', 'get', $this->_pk_field); //排序字段 $sort = in_array($sort, $db_fields) ? $sort : $this->_pk_field; $sort = 'c.' . $sort; $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get'); //排序 $order = toggle_order($order); $keyword = Filter::string('keyword', 'get'); //关键字 $date_start = Filter::string('date_start', 'get'); //添加开始时间 $date_end = Filter::string('date_end', 'get'); //添加结束时间 $column = Filter::string('column', 'get'); //搜索字段 $type = Filter::int('type', 'get'); //类型 $status = Filter::int('auditing', 'get'); //状态 $reply_type = Filter::int('admin_reply_type', 'get'); //回复状态 $where = array(); $column_arr = array('username' => 'c.username', 'email' => 'c.email', 'content' => 'c.content', 'blog_id' => 'c.blog_id', 'miniblog_id' => 'c.blog_id', 'blog_content' => 'b.content', 'blog_title' => 'b.title'); if ($keyword !== '' && isset($column_arr[$column])) { $where[$column_arr[$column]] = $this->_buildMatchQuery($column_arr[$column], $keyword, Filter::string('match_mode', 'get')); if ('blog_content' == $column || 'blog_title' == $column) { $table = ' JOIN ' . TB_BLOG . ' AS b ON b.blog_id=c.blog_id'; } } if ($date_start && ($date_start = strtotime($date_start))) { $where['c.add_time'][] = array('EGT', $date_start); } if ($date_end && ($date_end = strtotime($date_end))) { $where['c.add_time'][] = array('ELT', $date_end); } if (isset($where['c.add_time']) && count($where['c.add_time']) == 1) { $where['c.add_time'] = $where['c.add_time'][0]; } if (-1 != $type) { //类型 $where['c.type'] = $type; } if (-1 != $status) { //状态 $where['c.status'] = $status; } if (-1 != $reply_type) { //回复状态 $where['c.admin_reply_type'] = $reply_type; } isset($table) && $this->_model->join($table); $total = $this->_model->alias('c')->where($where)->count('c.blog_id'); if ($total === false) { //查询出错 $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR')); } elseif ($total == 0) { //无记录 $this->_ajaxReturn(true, '', null, $total); } $page_info = Filter::page($total); isset($table) && $this->_model->join($table); $data = $this->_model->alias('c')->field('c.*,INET_NTOA(user_ip) AS user_ip')->where($where)->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select(); $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR')); //出错 $selected = array(COMMENT_TYPE_BLOG => array(), COMMENT_TYPE_MINIBLOG => array()); foreach ($data as $k => $v) { $type = $v['type']; $blog_id = $v['blog_id']; if (COMMENT_TYPE_BLOG == $type) { if (isset($selected[COMMENT_TYPE_BLOG][$blog_id])) { $info = $selected[COMMENT_TYPE_BLOG][$blog_id]; } else { $info = $this->_model->table(TB_BLOG)->where('blog_id=' . $blog_id)->field('title,link_url')->find(); $selected[COMMENT_TYPE_BLOG][$blog_id] = $info; } $data[$k]['title'] = $info['title']; $data[$k]['link_url'] = $info['link_url']; } elseif (COMMENT_TYPE_MINIBLOG == $type) { if (isset($selected[COMMENT_TYPE_MINIBLOG][$blog_id])) { $info = $selected[COMMENT_TYPE_MINIBLOG][$blog_id]; } else { $info = $this->_model->table(TB_MINIBLOG)->where('blog_id=' . $v['blog_id'])->field('add_time,link_url')->find(); $selected[COMMENT_TYPE_MINIBLOG][$blog_id] = $info; } $data[$k]['title'] = new_date('Y-m-d', $info['add_time']) . ' ' . L('MINIBLOG'); $data[$k]['link_url'] = $info['link_url']; } } //end foreach $this->_ajaxReturn(true, '', $data, $total); }
/** * 管理员列表 * * @author mrmsl <*****@*****.**> * @date 2012-12-26 14:22:09 * @lastmodify 2013-03-31 19:03:13 by mrmsl * * @return void 无返回值 */ public function listAction() { $db_fields = $this->_getDbFields(); //表字段 $sort = Filter::string('sort', 'get', $this->_pk_field); //排序字段 $sort = in_array($sort, $db_fields) ? $sort : $this->_pk_field; $order = empty($_GET['dir']) ? Filter::string('order', 'get') : Filter::string('dir', 'get'); //排序 $order = toggle_order($order); $keyword = Filter::string('keyword', 'get'); //关键字 $date_start = Filter::string('date_start', 'get'); //注册开始时间 $date_end = Filter::string('date_end', 'get'); //注册结束时间 $cate_id = Filter::int('cate_id', 'get'); //所属管理组 $column = Filter::string('column', 'get'); //搜索字段 $is_delete = Filter::int('is_delete', 'get'); //删除 $is_issue = Filter::int('is_issue', 'get'); //状态 $where = array(); if ($keyword !== '' && in_array($column, array('title', 'seo_keyword', 'seo_description', 'content', 'from_name', 'from_url'))) { $where['' . $column] = $this->_buildMatchQuery('' . $column, $keyword, Filter::string('match_mode', 'get')); } if ($date_start && ($date_start = strtotime($date_start))) { $where['add_time'][] = array('EGT', $date_start); } if ($date_end && ($date_end = strtotime($date_end))) { $where['add_time'][] = array('ELT', $date_end); } if (isset($where['add_time']) && count($where['add_time']) == 1) { $where['add_time'] = $where['add_time'][0]; } if (-1 != $is_delete) { //删除 $where['is_delete'] = $is_delete; } if (-1 != $is_issue) { //状态 $where['is_issue'] = $is_issue; } if ($cate_id) { $cate_arr = $this->_getCache($cate_id, 'Category'); if (!$cate_arr) { $this->_model->addLog(L("INVALID_PARAM,%:,BELONG_TO_CATEGORY,%cate_id({$cate_id}),NOT_EXIST"), LOG_TYPE_INVALID_PARAM); $this->_ajaxReturn(true); } $where['cate_id'] = array('IN', $this->_getChildrenIds($cate_id, true, true, 'Category')); } $total = $this->_model->where($where)->count(); if ($total === false) { //查询出错 $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_BLOG') . L('TOTAL_NUM,ERROR')); } elseif ($total == 0) { //无记录 $this->_ajaxReturn(true, '', null, $total); } $page_info = Filter::page($total); $data = $this->_model->where($where)->field('content', true)->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select(); $data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_BLOG') . L('LIST,ERROR')); //出错 $cate_arr = $this->_getCache(false, 'Category'); foreach ($data as &$v) { $v['cate_name'] = $cate_arr[$v['cate_id']]['cate_name']; } $this->_ajaxReturn(true, '', $data, $total); }
/** * 导航功能菜单 * * @author mrmsl <*****@*****.**> * @lastmodify 2013-01-22 10:48:51 by mrmsl * * @return void 无返回值 */ public function publicTreeAction() { $data = $this->_getTree(); //增加顶级菜单 $this->_unshift && array_unshift($data, array('menu_id' => 0, 'menu_name' => isset($_GET['emptyText']) ? Filter::string('emptyText', 'get') : L('TOP_LEVEL_MENU'), 'leaf' => true)); $parent_id = Filter::int('parent_id', 'get'); //添加指定菜单子菜单,获取指定菜单信息by mashanlng on 2012-08-21 13:53:35 if ($parent_id && ($parent_info = $this->_getCache($parent_id))) { $parent_info = array('menu_id' => $parent_id, 'controller' => $parent_info['controller'], 'parent_name' => $parent_info['menu_name'], '_priv_id' => join(',', array_keys($parent_info['priv'])), 'priv' => join(',', $parent_info['priv'])); $this->_ajaxReturn(array('data' => $data, 'parent_data' => $parent_info)); } $this->_ajaxReturn(true, '', $data); }
/** * 所属分类 * * @author mrmsl <*****@*****.**> * @date 2013-03-21 13:58:09 * * @return void 无返回值 */ public function publicCategoryAction() { $data = $this->_getCategory(); //增加顶级分类 $this->_unshift && array_unshift($data, array('cate_id' => 0, 'cate_name' => isset($_GET['emptyText']) ? Filter::string('emptyText', 'get') : L('TOP_LEVEL_CATEGORY'), 'leaf' => true)); $parent_id = Filter::int('parent_id', 'get'); //添加指定分类子分类,获取指定分类信息by mashanlng on 2012-08-21 13:53:35 if ($parent_id && ($parent_info = $this->cache($parent_id))) { $parent_info = array('cate_id' => $parent_id, 'parent_name' => $parent_info['cate_name']); $this->_ajaxReturn(array('data' => $data, 'parent_data' => $parent_info)); } $this->_ajaxReturn(true, '', $data); }
public function delete($id, $table = NULL) { if (!empty($table)) { $this->_tableName = Filter::string($table); } $id = Filter::int($id); try { $sql = "DELETE FROM `{$this->_tableName}` WHERE `id`= ? "; $sth = $this->_dbh->prepare($sql); $sth->bindParam(1, $id); $sth->execute(); } catch (PDOExecption $e) { print "Delete Error!: " . $e->getMessage() . "</br>"; } }