Ejemplo n.º 1
0
 public function studentAdd($data = array())
 {
     if (!empty($data)) {
         $account_data['login_email'] = $data['login_email'];
         $account_data['login_pass'] = MD5(Crypt::encrypt(123456));
         //默认密码
         $account_data['account_type'] = 2;
         //默认账户类型
         $account_data['create_time'] = $data['create_time'];
         $account_data['modify_time'] = $data['modify_time'];
         $account_id = D('Account')->accountAdd($account_data);
         if ($account_id) {
             $data['account_id'] = $account_id;
             $bool = $this->data($data)->add();
             if ($bool) {
                 return array('status' => 'true', 'msg' => '新增学员成功', 'data' => $bool);
             } else {
                 // $bool = D('Account')->accountDelete(); to do ...
                 return array('status' => 'true', 'msg' => '新增学员失败', 'data' => $account_id);
             }
         } else {
             return array('status' => 'false', 'msg' => '学员Account添加失败');
         }
     }
 }
 /**
  * 下载
  * @author jry <*****@*****.**>
  */
 public function download($token)
 {
     if (empty($token)) {
         $this->error('token参数错误!');
     }
     //解密下载token
     $file_md5 = \Think\Crypt::decrypt($token, user_md5(is_login()));
     if (!$file_md5) {
         $this->error('下载链接已过期,请刷新页面!');
     }
     $public_upload_object = D('PublicUpload');
     $file_id = $public_upload_object->getFieldByMd5($file_md5, 'id');
     if (!$public_upload_object->download($file_id)) {
         $this->error($public_upload_object->getError());
     }
 }
Ejemplo n.º 3
0
 public function resetAccount()
 {
     $data = I('post.');
     $acParam = array('pkid' => $data['acId'], 'login_email' => $data['email'], 'login_pass' => MD5(C('DATA_AUTH_KEY') . Crypt::encrypt(strtolower($data['password']))));
     /* $bool = D('Account')->checkMailUnique($acParam['login_email'],$acParam['pkid']);
        if(!$bool){
            exit(json_encode(array('status' => 'fail','msg' => '修改失败','email' => 'notunique')));
        } */
     $pwdRule = checkpass($data['password']);
     if (!$pwdRule) {
         exit(json_encode(array('status' => 'fail', 'msg' => '修改失败', 'pass_word' => 'notunique')));
     }
     $stParam = array('pkid' => $data['enId'], 'login_email' => $data['email']);
     //$result = D('Account')->data($acParam)->save();
     $this->StudentModel->data($stParam)->save();
     /*  if($result !== false){
             exit(json_encode(array('status' => 'success','msg' => '修改成功')));
         }else{
             exit(json_encode(array('status' => 'fail','msg' => '修改失败')));
         } */
 }
Ejemplo n.º 4
0
 /**
  * 获取文章详情
  * @author jry <*****@*****.**>
  */
 public function detail($id, $map = null)
 {
     //获取基础表信息
     $con = array();
     $con['id'] = $id;
     $con['status'] = array('egt', 1);
     // 正常、隐藏两种状态是可以访问的
     if ($map) {
         $con = array_merge($con, $map);
     }
     $info = $this->where($con)->find();
     if (!is_array($info)) {
         $this->error = '文章被禁用或已删除!';
         return false;
     }
     // 阅读量加1
     $result = $this->where(array('id' => $id))->SetInc('view');
     // 获取作者信息
     $info['user'] = get_user_info($info['uid']);
     // 获取发帖数量
     $info['user']['post_count'] = $this->where(array('uid' => $info['uid']))->count();
     // 获取文档模型相关信息
     $doc_type_info = D($this->moduleName . '/Type')->find($info['category_info']['doc_type']);
     if ($doc_type_info['system']) {
         $this->error = '文档类型错误!';
         return false;
     }
     $info['doc_type_info'] = $doc_type_info;
     // 根据文章模型获取扩展表的息
     $extend_table_object = D($this->moduleName . '/' . $this->moduleName . ucfirst($doc_type_info['name']));
     $extend_data = $extend_table_object->find($id);
     // 基础信息与扩展信息合并
     if (is_array($extend_data)) {
         $info = array_merge($info, $extend_data);
     }
     // 获取筛选字段
     $con = array();
     $con['id'] = array('in', $doc_type_info['filter_field']);
     $attribute_object = D($this->moduleName . '/Attribute');
     $filter_field_list = $attribute_object->where($con)->select();
     $new_filter_field_list = array();
     foreach ($filter_field_list as $key => $val) {
         $val['options'] = parse_attr($val['options']);
         $new_filter_field_list[$val['name']] = $val;
     }
     $info['filter_field_list'] = $new_filter_field_list;
     // 给文档主要字段赋值,如:文章标题、商品名称
     $type_main_field = $attribute_object->getFieldById($doc_type_info['main_field'], 'name');
     $info['main_field'] = $info[$type_main_field];
     // 下载文件地址加密
     if ($info['file']) {
         $file_list = explode(',', $info['file']);
         foreach ($file_list as &$file) {
             $file = D('Home/Upload')->find($file);
             $uid = is_login();
             if ($uid) {
                 $file['token'] = \Think\Crypt::encrypt($file['md5'], user_md5($uid), 3600);
             } else {
                 $file['token'] = 'please login';
             }
         }
         $info['file_list'] = $file_list;
     }
     // 获取上一篇和下一篇文章信息
     $info['previous'] = $this->getPrevious($info);
     $info['next'] = $this->getNext($info);
     return $info;
 }
Ejemplo n.º 5
0
 /**
  * 文章信息
  * @author jry <*****@*****.**>
  */
 public function detail($id)
 {
     $map['status'] = array('egt', 1);
     // 正常、隐藏两种状态是可以访问的
     $info = D('Article')->where($map)->detail($id);
     if (!$info) {
         $this->error('您访问的文档已禁用或不存在');
     }
     $result = D('Article')->where(array('id' => $id))->SetInc('view');
     // 阅读量加1
     // 获取文档所属分类详细信息
     $category_info = D('Category')->find($info['cid']);
     // 获取该分类绑定文档模型的主要字段
     $type_object = D('Type');
     $attribute_object = D('Attribute');
     $doc_type_info = $type_object->find($category_info['doc_type']);
     $type_main_field = $type_object->getFieldById($category_info['doc_type'], 'main_field');
     $type_main_field = $attribute_object->getFieldById($doc_type_info['main_field'], 'name');
     // 获取筛选字段
     $con = array();
     $con['id'] = array('in', $doc_type_info['filter_field']);
     $filter_field_list = $attribute_object->where($con)->select();
     $new_filter_field_list = array();
     foreach ($filter_field_list as $key => $val) {
         $val['options'] = parse_attr($val['options']);
         $new_filter_field_list[$val['name']] = $val;
     }
     // 给文档主要字段赋值,如:文章标题、商品名称
     $info['main_field'] = $info[$type_main_field];
     if ($info['file']) {
         $file_list = explode(',', $info['file']);
         foreach ($file_list as &$file) {
             $file = D('Home/Upload')->find($file);
             $uid = is_login();
             if ($uid) {
                 $file['token'] = \Think\Crypt::encrypt($file['md5'], user_md5($uid), 3600);
             } else {
                 $file['token'] = 'please login';
             }
         }
         $info['file_list'] = $file_list;
     }
     // 设置文档显示模版
     if (C('CURRENT_THEME')) {
         if ($category_info['detail_template']) {
             $template = 'article/' . $info['detail_template'];
         } else {
             $template = 'article/detail_default';
         }
     } else {
         $template = $category_info['detail_template'] ? 'Home/article/' . $category_info['detail_template'] : 'Home/article/detail_default';
     }
     // 获取作者信息
     $info['user'] = get_user_info($info['uid']);
     $this->assign('info', $info);
     $this->assign('_current_category', $category_info);
     $this->assign('_filter_field_list', $new_filter_field_list);
     $this->assign('_search_url', U('index', array('cid' => $category_info['id'])));
     // 构造搜索地址
     $this->assign('meta_title', $info['main_field']);
     $this->assign('meta_keywords', $info['tags'] ?: C('WEB_SITE_KEYWORD'));
     $this->assign('meta_description', $info['abstract'] ?: C('WEB_SITE_DESCRIPTION'));
     $this->assign('meta_cover', $info['cover']);
     Cookie('__forward__', $_SERVER['REQUEST_URI']);
     $this->display($template);
 }
 /**
  * 行为扩展的执行入口必须是run
  * @author jry <*****@*****.**>
  */
 public function run(&$content)
 {
     // 安装模式下直接返回
     if (defined('BIND_MODULE') && BIND_MODULE === 'Install') {
         return;
     }
     // 数据缓存前缀
     // 获取ThinkPHP控制器分级时控制器名称
     $controller_name = explode('/', CONTROLLER_NAME);
     if (sizeof($controller_name) === 2) {
         C('DATA_CACHE_PREFIX', ENV_PRE . MODULE_NAME . '_' . $controller_name[0] . '_');
     } else {
         C('DATA_CACHE_PREFIX', ENV_PRE . MODULE_NAME . '_');
     }
     // 读取数据库中的配置
     $system_config = S('DB_CONFIG_DATA');
     if (!$system_config) {
         // 获取所有系统配置
         $system_config = D('Admin/Config')->lists();
         // 获取所有安装的模块配置
         $module_list = D('Admin/Module')->where(array('status' => '1'))->select();
         foreach ($module_list as $val) {
             $module_config[strtolower($val['name'] . '_config')] = json_decode($val['config'], true);
             $module_config[strtolower($val['name'] . '_config')]['module_name'] = $val['name'];
         }
         if ($module_config) {
             // 合并模块配置
             $system_config = array_merge($system_config, $module_config);
             // 加载模块标签库及行为扩展
             $system_config['TAGLIB_PRE_LOAD'] = explode(',', C('TAGLIB_PRE_LOAD'));
             // 先取出配置文件中定义的否则会被覆盖
             foreach ($module_config as $key => $val) {
                 // 加载模块标签库
                 if ($val['taglib']) {
                     foreach ($val['taglib'] as $tag) {
                         $system_config['TAGLIB_PRE_LOAD'][] = $val['module_name'] . '\\TagLib\\' . $tag . '';
                     }
                 }
                 // 加载模块行为扩展
                 if ($val['behavior']) {
                     foreach ($val['behavior'] as $bhv) {
                         \Think\Hook::add('corethink_behavior', $val['module_name'] . '\\Behavior\\' . $bhv . 'Behavior');
                     }
                 }
             }
             $system_config['TAGLIB_PRE_LOAD'] = implode(',', $system_config['TAGLIB_PRE_LOAD']);
         }
         // 获取当前主题的名称
         $current_theme = D('Admin/Theme')->where(array('current' => 1))->order('id asc')->find();
         // 当前模块模版参数配置
         $system_config['TMPL_PARSE_STRING'] = C('TMPL_PARSE_STRING');
         // 先取出配置文件中定义的否则会被覆盖
         $system_config['TMPL_PARSE_STRING']['__IMG__'] = __ROOT__ . '/' . APP_PATH . MODULE_NAME . '/View/Public/img';
         $system_config['TMPL_PARSE_STRING']['__CSS__'] = __ROOT__ . '/' . APP_PATH . MODULE_NAME . '/View/Public/css';
         $system_config['TMPL_PARSE_STRING']['__JS__'] = __ROOT__ . '/' . APP_PATH . MODULE_NAME . '/View/Public/js';
         $system_config['TMPL_PARSE_STRING']['__LIBS__'] = __ROOT__ . '/' . APP_PATH . MODULE_NAME . '/View/Public/libs';
         if ($current_theme) {
             $current_theme['module'] = explode(',', $current_theme['module']);
             $current_theme['module'][] = 'Home';
             // 强制支持主题对Home的支持
             // 一旦开启主题那么前台必须启用主题相关模版(后台无需支持主题)
             $theme_public_path = './Theme/' . $current_theme['name'] . '/Home/Public';
             if (is_dir($theme_public_path)) {
                 $system_config['TMPL_PARSE_STRING']['__HOME_IMG__'] = __ROOT__ . '/' . $theme_public_path . '/img';
                 $system_config['TMPL_PARSE_STRING']['__HOME_CSS__'] = __ROOT__ . '/' . $theme_public_path . '/css';
                 $system_config['TMPL_PARSE_STRING']['__HOME_JS__'] = __ROOT__ . '/' . $theme_public_path . '/js';
                 $system_config['TMPL_PARSE_STRING']['__HOME_LIBS__'] = __ROOT__ . '/' . $theme_public_path . '/libs';
             }
             // 如果启用的主题配置里勾选了当前模块那么当前模块启用主题相关模版否则仍启用系统模版
             if (in_array(MODULE_NAME, $current_theme['module'])) {
                 $system_config['CURRENT_THEME'] = $current_theme['name'];
                 // 设置当前主题
                 $theme_public_path = './Theme/' . $current_theme['name'] . '/' . MODULE_NAME . '/Public';
                 $theme_wap_path = './Theme/' . $current_theme['name'] . '/' . MODULE_NAME . '/wap';
                 if (is_dir($theme_public_path)) {
                     $system_config['TMPL_PARSE_STRING']['__IMG__'] = __ROOT__ . '/' . $theme_public_path . '/img';
                     $system_config['TMPL_PARSE_STRING']['__CSS__'] = __ROOT__ . '/' . $theme_public_path . '/css';
                     $system_config['TMPL_PARSE_STRING']['__JS__'] = __ROOT__ . '/' . $theme_public_path . '/js';
                     $system_config['TMPL_PARSE_STRING']['__LIBS__'] = __ROOT__ . '/' . $theme_public_path . '/libs';
                 }
                 // 判断是否含有wap专用模版
                 if (is_dir($theme_wap_path)) {
                     $system_config['HAS_WAP'] = 'wap';
                 }
             }
         } else {
             // 判断是否含有wap专用模版
             if (sizeof($controller_name) === 2) {
                 if (is_dir(APP_PATH . MODULE_NAME . '/View/Home/wap')) {
                     $system_config['HAS_WAP'] = 'wap';
                 }
             } else {
                 if (is_dir(APP_PATH . MODULE_NAME . '/View/wap')) {
                     $system_config['HAS_WAP'] = 'wap';
                 }
             }
         }
         // 不直接在config里配置这些参数而要在这里配置是为了支持功能模块的相关架构
         if (MODULE_NAME === 'Admin' || $controller_name[0] === 'Admin') {
             // Admin后台与模块后台标记
             $system_config['MODULE_MARK'] = 'Admin';
             // SESSION与COOKIE与前缀设置避免冲突
             $system_config['SESSION_PREFIX'] = ENV_PRE . 'Admin_';
             // Session前缀
             $system_config['COOKIE_PREFIX'] = ENV_PRE . 'Admin_';
             // Cookie前缀
             // 错误页面模板
             $system_config['TMPL_ACTION_ERROR'] = APP_PATH . 'Admin/View/Public/think/error.html';
             // 错误跳转对应的模板文件
             $system_config['TMPL_ACTION_SUCCESS'] = APP_PATH . 'Admin/View/Public/think/success.html';
             // 成功跳转对应的模板文件
             $system_config['TMPL_EXCEPTION_FILE'] = APP_PATH . 'Admin/View/Public/think/exception.html';
             // 异常页面的模板文件
         } else {
             if (MODULE_NAME === 'Home' || $controller_name[0] === 'Home') {
                 // Home前台与模块前台标记
                 $system_config['MODULE_MARK'] = 'Home';
                 // SESSION与COOKIE与前缀设置避免冲突
                 $system_config['SESSION_PREFIX'] = ENV_PRE . 'Home_';
                 // Session前缀
                 $system_config['COOKIE_PREFIX'] = ENV_PRE . 'Home_';
                 // Cookie前缀
                 // 错误页面模板
                 $system_config['TMPL_ACTION_ERROR'] = APP_PATH . 'Home/View/Public/think/error.html';
                 // 错误跳转对应的模板文件
                 $system_config['TMPL_ACTION_SUCCESS'] = APP_PATH . 'Home/View/Public/think/success.html';
                 // 成功跳转对应的模板文件
                 $system_config['TMPL_EXCEPTION_FILE'] = APP_PATH . 'Home/View/Public/think/exception.html';
                 // 异常页面的模板文件
             }
         }
         S('DB_CONFIG_DATA', $system_config, 3600);
         // 缓存配置
     }
     C($system_config);
     // 添加配置
     // 如果存在wap专用模版同时又确实是wap方式访问则设置WAP标记
     if (C('HAS_WAP') && is_wap()) {
         C('IS_WAP', C('HAS_WAP'));
     }
     // 检测系统授权
     if ($system_config['MODULE_MARK'] === 'Home' && C('CT_USERNAME') !== 'trial') {
         $sn_decode = \Think\Crypt::decrypt(C('CT_SN'), md5(sha1(C('CT_USERNAME'))));
         if ($sn_decode) {
             $sn_decode = explode('[ct]', base64_decode($sn_decode));
             $sn_decode_server = json_decode($sn_decode[0], true);
             if (!in_array($_SERVER['SERVER_NAME'], $sn_decode_server)) {
                 die('很抱歉,该域名未授权!请联系:<a href="http://www.corethink.cn">http://www.corethink.cn</a>');
             }
             if (md5(sha1(C('CT_USERNAME'))) !== $sn_decode[1]) {
                 die('很抱歉,该帐号未授权!请联系:<a href="http://www.corethink.cn">http://www.corethink.cn</a>');
             }
         } else {
             die('很抱歉,您的授权已过期!请联系:<a href="http://www.corethink.cn">http://www.corethink.cn</a>');
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * 管理员信息更新
  * @author Martin.Cheng <*****@*****.**>
  */
 public function update()
 {
     if (IS_POST) {
         $id = I("post.user_id");
         $data['login_email'] = I('post.mail');
         $data['truename'] = I('post.username');
         $data['avatar'] = I('post.headpic');
         $data['mobile'] = I('post.mobile');
         $data['valid_status'] = I('post.status');
         $data['modify_time'] = $this->nowtime;
         $password = I('post.password');
         if (!empty($password)) {
             $data['login_pass'] = MD5(Crypt::encrypt(I('post.password')));
         }
         $bool = $this->AdminUserModel->adminUpdata($data, I("post.user_id"));
         if ($bool) {
             $this->redirect("AdminUser/index", '', 3, '修改成功');
         } else {
             $this->redirect("AdminUser/edit", array('id' => $id), 3, '修改失败');
         }
     }
 }
 /**
  * 文章信息
  * @author jry <*****@*****.**>
  */
 public function detail($id)
 {
     $map['status'] = array('egt', 1);
     //正常、隐藏两种状态是可以访问的
     $info = D('Document')->where($map)->detail($id);
     if (!$info) {
         $this->error('您访问的文档已禁用或不存在');
     }
     $result = D('Document')->where(array('id' => $id))->SetInc('view');
     //阅读量加1
     //获取文档所属分类详细信息
     $category_info = D('Category')->find($info['cid']);
     //获取该分类绑定文档模型的主要字段
     $document_type_object = D('DocumentType');
     $document_type_main_field = $document_type_object->getFieldById($category_info['doc_type'], 'main_field');
     $document_type_main_field = D('DocumentAttribute')->getFieldById($document_type_main_field, 'name');
     //给文档主要字段赋值,如:文章标题、商品名称
     $info['main_field'] = $info[$document_type_main_field];
     if ($info['file']) {
         $file_list = explode(',', $info['file']);
         foreach ($file_list as &$file) {
             $file = D('PublicUpload')->find($file);
             $uid = is_login();
             if ($uid) {
                 $file['token'] = \Think\Crypt::encrypt($file['md5'], user_md5($uid), 60);
             } else {
                 $file['token'] = 'please login';
             }
         }
         $info['file_list'] = $file_list;
     }
     //设置文档显示模版
     $template = $category_info['detail_template'] ? 'Document/' . $category_info['detail_template'] : 'Document/detail_default';
     $this->assign('info', $info);
     $this->assign('__CURRENT_CATEGORY__', $category_info['id']);
     $this->assign('meta_title', $info['main_field']);
     Cookie('__forward__', $_SERVER['REQUEST_URI']);
     $this->display($template);
 }