Example #1
0
 /**
  * 请求debug查看sql信息和请求参数
  */
 public static function dbDebug()
 {
     if (!RThink_Config::get('app.debug')) {
         return;
     }
     $debug_info = array();
     $db_profilers = self::getFrontController()->getRequest()->getParam('db_profilers');
     $total_query = 0;
     $total_time = 0.0;
     $query_detail = array();
     is_array($db_profilers) || ($db_profilers = array());
     foreach ($db_profilers as $db_profiler) {
         $query_profiles = $db_profiler->getQueryProfiles();
         foreach ($query_profiles as $query_profile) {
             $query_detail[$query_profile->getQueryType()][] = array('sql' => $query_profile->getQuery(), 'time' => $query_profile->getElapsedSecs());
         }
         $total_query += $db_profiler->getTotalNumQueries();
         $total_time += $db_profiler->getTotalElapsedSecs();
     }
     if (!empty($db_profilers)) {
         foreach ($query_detail as $detail_item) {
             foreach ($detail_item as $item_val) {
                 $debug_info[] = sprintf('执行时间: %f; SQL: %s' . PHP_EOL, $item_val['time'], $item_val['sql']);
             }
         }
         $debug_info[] = sprintf('SQL语句总数: %d 总花费时间: %f 秒' . PHP_EOL, $total_query, $total_time);
     }
     self::getFrontController()->getResponse()->prepend('db_debug_footer', PHP_EOL . '-->');
     foreach ($debug_info as $key => $debug_item) {
         self::getFrontController()->getResponse()->prepend('db_debug_body_' . $key, $debug_item);
     }
     self::getFrontController()->getResponse()->prepend('db_debug_header', '<!--' . PHP_EOL);
 }
Example #2
0
 public function indexAction()
 {
     /** 验证是否登录 **/
     $this->verify(__METHOD__);
     $post = $this->getRequest()->getPost();
     $imageKey = RThink_Config::get('app.imageKey');
     $videoKey = RThink_Config::get('app.videoKey');
     $pt = '.';
     $imageName = $videoName = '';
     //上传图片和视频
     if ($_FILES['Image']['error'] == 0) {
         $imageName = md5($imageKey . $post['ClassNo']) . $pt . $this->getFileExtend($post['file_0']);
         move_uploaded_file($_FILES['Image']['tmp_name'], RThink_Config::get('app.imagePath') . '\\' . $imageName);
     }
     if ($_FILES['Video']['error'] == 0) {
         $videoName = md5($videoKey . $post['ClassNo']) . $pt . $this->getFileExtend($post['file_1']);
         move_uploaded_file($_FILES['Video']['tmp_name'], RThink_Config::get('app.videoPath') . '\\' . $videoName);
     }
     $params = array('No' => $post['No'], 'ClassType' => $post['ClassType'], 'ClassNo' => $post['ClassNo'], 'Grade' => $post['Grade'], 'SubjectID' => $post['SubjectID'], 'Chapter' => $post['Chapter'], 'Name' => $post['Name'], 'Teacher' => $post['Teacher'], 'Desc' => $post['Desc'], 'Price' => $post['Price'], 'UpdateTime' => date('Y-m-d H:i:s'));
     if ($imageName != '') {
         $params['Image'] = $imageName;
     }
     if ($videoName != '') {
         $params['Video'] = $videoName;
     }
     $ClassID = $this->getRequest()->getPost('ClassID');
     if (null != $ClassID) {
         Admin_ClassesModel::instance()->update($params, array('ClassID' => $ClassID));
     } else {
         $params['CreateTime'] = date('Y-m-d H:i:s');
         Admin_ClassesModel::instance()->add($params);
     }
     $this->sendMsg(1, "操作成功");
 }
Example #3
0
 public function indexAction()
 {
     /** 验证是否登录 **/
     $this->verify(__METHOD__);
     //@todo  $this->verify(__METHOD__);
     // $id = $this->getRequest()->getParam('id');
     $data = array();
     $data['grade'] = RThink_Config::get('app.grade');
     $data['subject'] = RThink_Config::get('app.subject');
     // if (empty($id)) {
     $data['pagename'] = '菜单添加';
     // $parent = Admin_MenuModel::instance()->getAdminMenuListByIds($parent_id);
     // $parent = isset($parent[0]) ? $parent[0] : array('id' => '', 'modle' => '');
     // $data['parent_id'] = $parent['id'];
     // $data['info']['modle'] = $parent['modle'];
     // $data['info']['orders'] = 0;
     // }
     // else {
     //     $data['pagename'] = '菜单编辑';
     //     $data['info'] = Admin_MenuModel::instance()->getAdminMenuListByIds($id);
     //     $data['info'] = $data['info'][0];
     //     $data['parent_id'] = $data['info']['parent_id'];
     // }
     // $data['info'] += array('hidden' => 0, 'target' => 0, 'top' => 0, 'ajax' => 0);
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #4
0
 public function errorAction()
 {
     $errors = $this->_getParam('error_handler');
     if (!$errors || !$errors instanceof ArrayObject) {
         $this->view->data['message'] = 'You have reached the error page';
         return;
     }
     switch ($errors->type) {
         case RThink_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
         case RThink_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case RThink_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             // 404 error -- Controller or action not found
             $this->getResponse()->setHttpResponseCode(404);
             $this->view->data['message'] = '页面找不到';
             break;
         default:
             // application error
             $this->getResponse()->setHttpResponseCode(500);
             $this->view->data['message'] = '应用错误';
             break;
     }
     // conditionally display exceptions
     if (RThink_Config::get('app.debug') && RThink_Config::get('app.display_exceptions') == true) {
         $this->view->data['exception'] = $errors->exception;
     }
     $this->view->data['request'] = $errors->request;
     $this->render($this->view->data);
 }
Example #5
0
 public function indexAction()
 {
     /** 验证是否登录 **/
     $this->verify(__METHOD__);
     $classid = $this->getRequest()->getParam('ClassID');
     $data = array();
     if (empty($classid)) {
         $data['pagename'] = '课程添加';
         $data['info'] = array();
     } else {
         $data['pagename'] = '课程编辑';
         $data['info'] = Admin_ClassesModel::instance()->fetchRow(array('condition' => 'classid = ?', 'bind' => array($classid)));
     }
     $data['grade'] = RThink_Config::get('app.grade');
     $subject = Admin_SubjectModel::instance()->fetchAll(array());
     $subjectList = array();
     foreach ($subject as $key => $value) {
         if (!isset($subjectList[$value['Grade']])) {
             $subjectList[$value['Grade']] = array();
         }
         array_push($subjectList[$value['Grade']], $value);
     }
     $data['subjectList'] = $subjectList;
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #6
0
 public function indexAction()
 {
     //检查权限
     $this->verify(__METHOD__);
     $show['pagename'] = '科目列表';
     $grade = $this->getRequest()->getQuery('grade', '');
     $perpage = 20;
     $page = intval($this->getRequest()->getQuery('page'));
     $page = $page ? $page : 1;
     $data = $count_opt = array();
     $option = array('condition' => '', 'order' => 'Grade asc', 'limit' => array('offset' => ($page - 1) * $perpage, 'count' => $perpage));
     if (!empty($grade)) {
         $option['condition'] .= "grade = ?";
         $option['bind'] = array($grade);
         $count_opt = array('condition' => "grade = ?", 'bind' => array($grade));
     }
     $data['subjectList'] = Admin_SubjectModel::instance()->fetchAll($option);
     $data['count'] = Admin_SubjectModel::instance()->count($count_opt);
     $data['grade'] = RThink_Config::get('app.grade');
     $pagination = new Pagination();
     $data['pagination'] = $pagination->maxnum($data['count'], $perpage)->show('page_metronic');
     $data['menu'] = Widget_Admin_MenuModel::headerMenu();
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #7
0
 public function indexAction()
 {
     //检查权限
     $admin = $this->verify(__METHOD__);
     $show['pagename'] = '选择课程列表';
     $MemberID = $this->getRequest()->getParam('MemberID', 0);
     $Grade = $this->getRequest()->getParam('Grade', 0);
     $SubjectID = $this->getRequest()->getParam('SubjectID', 0);
     $perpage = 20;
     $page = intval($this->getRequest()->getParam('page'));
     $page = $page ? $page : 1;
     $data = $count_opt = array();
     //个人信息
     $member_option = array('condition' => 'MemberID = ?', 'bind' => array($MemberID));
     $MemberInfo = Admin_MemberModel::instance()->fetchAll($member_option);
     $data['MemberInfo'] = $MemberInfo[0];
     $Grade = empty($Grade) ? $MemberInfo[0]['Grade'] : $Grade;
     //所选课程列表
     $option = array('order' => 'ChosenID desc,B.ClassNo asc', 'limit' => array('offset' => ($page - 1) * $perpage, 'count' => $perpage));
     if (!empty($SubjectID)) {
         $option['condition'][] = 'B.SubjectID = ?';
         $option['bind'][] = $SubjectID;
     }
     if (!empty($Grade)) {
         $option['condition'][] = 'B.Grade = ?';
         $option['bind'][] = $Grade;
     }
     if (!empty($MemberID)) {
         $option['condition'][] = 'A.MemberID = ?';
         $option['bind'][] = $MemberID;
     }
     $option['condition'] = implode(' and ', $option['condition']);
     $count_opt['condition'] = $option['condition'];
     $count_opt['bind'] = $option['bind'];
     $data['ChosenList'] = Admin_ChosenModel::instance()->getChosenClassList($option);
     $count = Admin_ChosenModel::instance()->getChosenCount($count_opt);
     $data['count'] = $count[0]['count'];
     $data['grade'] = RThink_Config::get('app.grade');
     $subject = Admin_SubjectModel::instance()->fetchAll(array());
     $subjectList = array();
     foreach ($subject as $key => $value) {
         if (!isset($subjectList[$value['Grade']])) {
             $subjectList[$value['Grade']] = array();
         }
         array_push($subjectList[$value['Grade']], $value);
     }
     $data['subjectList'] = $subjectList;
     $pagination = new Pagination();
     $data['pagination'] = $pagination->maxnum($data['count'], $perpage)->show('page_metronic');
     $data['query'] = array('MemberID' => $MemberID, 'SubjectID' => $SubjectID, 'Grade' => $Grade);
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #8
0
 public function indexAction()
 {
     $this->verify(__METHOD__);
     $Grade = $this->getRequest()->getPost('Grade');
     $SubjectID = $this->getRequest()->getPost('SubjectID');
     $Title = $this->getRequest()->getPost('Title');
     $Chapter = $this->getRequest()->getPost('Chapter');
     $subject = RThink_Config::get('app.subject');
     $data = array('Grade' => $Grade, 'Title' => $Title, 'Chapter' => $Chapter, 'SubjectID' => $SubjectID, 'CreateTime' => date('Y-m-d H:i:s'));
     /* 写入账号 */
     Admin_ChapterModel::instance()->add($data);
     $this->sendMsg(1, "操作成功");
 }
Example #9
0
 public function indexAction()
 {
     $this->verify(__METHOD__);
     $Grade = $this->getRequest()->getPost('Grade');
     $SubjectType = $this->getRequest()->getPost('SubjectType');
     $subject = RThink_Config::get('app.subject');
     $Title = $subject[$SubjectType];
     if (empty($Title)) {
         $this->sendMsg(-1, '科目添加异常');
     }
     $data = array('Grade' => $Grade, 'Title' => $Title, 'SubjectType' => $SubjectType, 'CreateTime' => date('Y-m-d H:i:s'));
     /* 写入账号 */
     Admin_SubjectModel::instance()->add($data);
     $this->sendMsg(1, "操作成功");
 }
Example #10
0
 public function indexAction()
 {
     //检查权限
     $this->verify(__METHOD__);
     $show['pagename'] = '章节列表';
     $grade = $this->getRequest()->getQuery('Grade', '');
     $subjectID = $this->getRequest()->getQuery('SubjectID', '');
     $perpage = 20;
     $page = intval($this->getRequest()->getQuery('page'));
     $page = $page ? $page : 1;
     $data = $count_opt = array();
     $option = array('condition' => '', 'order' => 'Grade asc', 'limit' => array('offset' => ($page - 1) * $perpage, 'count' => $perpage));
     $conditionArr = $bindArr = array();
     if (!empty($grade)) {
         $conditionArr[] = "Grade = ?";
         $bindArr[] = $grade;
     }
     if (!empty($subjectID)) {
         $conditionArr[] = "SubjectID = ?";
         $bindArr[] = $subjectID;
     }
     $option['condition'] = $count_opt['condition'] = implode(' and ', $conditionArr);
     $option['bind'] = $count_opt['bind'] = $bindArr;
     $data['ChapterList'] = Admin_ChapterModel::instance()->fetchAll($option);
     $subject = Admin_SubjectModel::instance()->fetchAll(array());
     $subjectList = array();
     foreach ($subject as $key => $value) {
         if (!isset($subjectList[$value['Grade']])) {
             $subjectList[$value['Grade']] = array();
         }
         array_push($subjectList[$value['Grade']], $value);
     }
     $data['subjectList'] = $subjectList;
     $data['count'] = Admin_ChapterModel::instance()->count($count_opt);
     $data['grade'] = RThink_Config::get('app.grade');
     $pagination = new Pagination();
     $data['pagination'] = $pagination->maxnum($data['count'], $perpage)->show('page_metronic');
     $data['menu'] = Widget_Admin_MenuModel::headerMenu();
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #11
0
 /**
  * 获取指定键值的配置参数
  *
  * @param string $key
  * @return null string array
  */
 public static function get($key = '')
 {
     if ('' != $key) {
         if (isset(self::$_config_cache[$key])) {
             return self::$_config_cache[$key];
         }
     } else {
         if (!empty(self::$_config_struct)) {
             return self::$_config_struct;
         }
     }
     class_exists('RThink_Controller_Front', false) || (require 'RThink/Controller/Front.php');
     $config_file = RThink_Controller_Front::getInstance()->getParam('config_file');
     $config_section = RThink_Controller_Front::getInstance()->getParam('config_section');
     if (empty(self::$_config_struct)) {
         include $config_file;
         self::$_config_struct = ${$config_section};
     }
     if ('' == $key) {
         return self::$_config_struct;
     }
     $key_list = explode('.', $key);
     foreach ($key_list as $key_node) {
         if (isset(self::$_config_cache[$key])) {
             if (!isset(self::$_config_cache[$key][$key_node])) {
                 class_exists('RThink_Config_Exception', false) || (require 'RThink/Config/Exception.php');
                 throw new RThink_Config_Exception('配置文件节点链{' . $key . '}中[' . $key_node . ']节点不存在');
             }
             self::$_config_cache[$key] = self::$_config_cache[$key][$key_node];
         } else {
             if (!isset(self::$_config_struct[$key_node])) {
                 class_exists('RThink_Config_Exception', false) || (require 'RThink/Config/Exception.php');
                 throw new RThink_Config_Exception('配置文件节点链{' . $key . '}中[' . $key_node . ']节点不存在');
             }
             self::$_config_cache[$key] = self::$_config_struct[$key_node];
         }
     }
     return self::$_config_cache[$key];
 }
Example #12
0
 public function indexAction()
 {
     /** 验证是否登录 **/
     $this->verify(__METHOD__);
     //@todo  $this->verify(__METHOD__);
     // $id = $this->getRequest()->getParam('id');
     $data = array();
     $data['grade'] = RThink_Config::get('app.grade');
     $data['subject'] = RThink_Config::get('app.subject');
     $data['pagename'] = '菜单添加';
     $subject = Admin_SubjectModel::instance()->fetchAll(array());
     $subjectList = array();
     foreach ($subject as $key => $value) {
         if (!isset($subjectList[$value['Grade']])) {
             $subjectList[$value['Grade']] = array();
         }
         array_push($subjectList[$value['Grade']], $value);
     }
     $data['subjectList'] = $subjectList;
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #13
0
 public function indexAction()
 {
     //检查权限
     $admin = $this->verify(__METHOD__);
     $show['pagename'] = '推荐课程列表';
     $MemberID = $this->getRequest()->getQuery('MemberID', 0);
     $SubjectID = $this->getRequest()->getQuery('SubjectID');
     $perpage = 20;
     $page = intval($this->getRequest()->getQuery('page'));
     $page = $page ? $page : 1;
     $data = $count_opt = array();
     $option = array('condition' => 'A.MemberID = ?', 'bind' => array($MemberID), 'order' => 'RecommendID desc', 'limit' => array('offset' => ($page - 1) * $perpage, 'count' => $perpage));
     if (!empty($SubjectID)) {
         $option['condition'] .= ' and B.SubjectID = ?';
         $option['bind'][] = $SubjectID;
     }
     $count_opt['condition'] = $option['condition'];
     $count_opt['bind'] = $option['bind'];
     $data['RecommendList'] = Admin_RecommendModel::instance()->getRecommendClassList($option);
     $data['count'] = Admin_RecommendModel::instance()->getRecommendCount($count_opt);
     $data['grade'] = RThink_Config::get('app.grade');
     $member_option = array('condition' => 'MemberID = ?', 'bind' => array($MemberID));
     $MemberInfo = Admin_MemberModel::instance()->fetchAll($member_option);
     $data['MemberInfo'] = $MemberInfo[0];
     $TeacherList = Admin_AdminModel::instance()->fetchAll(array());
     $TeacherList_tmp = array();
     foreach ($TeacherList as $key => $value) {
         $TeacherList_tmp[$value['id']] = $value;
     }
     $data['TeacherList'] = $TeacherList_tmp;
     $grade = $MemberInfo[0]['Grade'];
     $member_option = array('condition' => 'Grade = ?', 'bind' => array($grade));
     $data['SubjectList'] = Admin_SubjectModel::instance()->fetchAll($member_option);
     $pagination = new Pagination();
     $data['pagination'] = $pagination->maxnum($data['count'], $perpage)->show('page_metronic');
     $data['query'] = array('MemberID' => $MemberID, 'SubjectID' => $SubjectID);
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #14
0
 public function indexAction()
 {
     //检查权限
     $this->verify(__METHOD__);
     $show['pagename'] = '学员列表';
     $grade = $this->getRequest()->getQuery('Grade');
     $mobile = $this->getRequest()->getQuery('Mobile');
     $name = $this->getRequest()->getQuery('Name');
     $perpage = 20;
     $page = intval($this->getRequest()->getQuery('page'));
     $page = $page ? $page : 1;
     $data = $count_opt = array();
     $option = array('condition' => '', 'order' => 'Grade asc', 'limit' => array('offset' => ($page - 1) * $perpage, 'count' => $perpage));
     $conditionArr = $bindArr = array();
     if (!empty($grade)) {
         $conditionArr[] = "grade = ?";
         $bindArr[] = $grade;
     }
     if (!empty($mobile)) {
         $conditionArr[] = "mobile = ?";
         $bindArr[] = $mobile;
     }
     if (!empty($name)) {
         $conditionArr[] = "name like ?";
         $bindArr[] = "%{$name}%";
     }
     $option['condition'] = $count_opt['condition'] = implode(' and ', $conditionArr);
     $option['bind'] = $count_opt['bind'] = $bindArr;
     $data['memberList'] = Admin_MemberModel::instance()->fetchAll($option);
     $data['count'] = Admin_MemberModel::instance()->count($count_opt);
     $data['grade'] = RThink_Config::get('app.grade');
     $pagination = new Pagination();
     $data['pagination'] = $pagination->maxnum($data['count'], $perpage)->show('page_metronic');
     $data['query'] = array('Mobile' => $mobile, 'Grade' => $grade, 'Name' => $name);
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #15
0
 /**
  * 数据缓存
  */
 public function cacheAction()
 {
     $mc_conf = RThink_Config::get('memcache');
     // var_dump($mc_conf);
     $mc = LibLoader::factory('cache', array('adapter' => 'memcache', 'params' => $mc_conf), true);
     $key = 'lang';
     $val = 'php';
     $mc->save($val, $key);
     //
     //        $mc->remove($key);
     //        $mc->touch($key, 10);
     //
     $res = $mc->load($key);
     //
     $metata = $mc->getMetadatas($key);
     //
     var_dump($res, $metata);
 }
Example #16
0
 public function __construct()
 {
     $db_conf = RThink_Config::get('db.test');
     parent::__construct($db_conf);
 }
Example #17
0
 public function indexAction()
 {
     //检查权限
     $this->verify(__METHOD__);
     $show['pagename'] = '课程列表';
     $grade = $this->getRequest()->getQuery('Grade');
     $subject = $this->getRequest()->getQuery('SubjectID');
     $chapter = $this->getRequest()->getQuery('Chapter');
     $classno = $this->getRequest()->getQuery('ClassNo');
     $memberID = $this->getRequest()->getQuery('MemberID');
     $perpage = 20;
     $page = intval($this->getRequest()->getQuery('page'));
     $page = $page ? $page : 1;
     $data = $count_opt = array();
     $option = array('condition' => '', 'order' => 'ClassNo asc,Grade asc', 'limit' => array('offset' => ($page - 1) * $perpage, 'count' => $perpage));
     $data['count'] = Admin_AdminModel::instance()->count($count_opt);
     $conditionArr = $bindArr = array();
     if (!empty($grade)) {
         $conditionArr[] = "grade = ?";
         $bindArr[] = $grade;
     }
     if (!empty($subject)) {
         $conditionArr[] = "subjectid = ?";
         $bindArr[] = $subject;
     }
     if (!empty($classno)) {
         $conditionArr[] = "classno = ?";
         $bindArr[] = $classno;
     }
     if (!empty($chapter)) {
         $conditionArr[] = "chapter = ?";
         $bindArr[] = $chapter;
     }
     $option['condition'] = $count_opt['condition'] = implode(' and ', $conditionArr);
     $option['bind'] = $count_opt['bind'] = $bindArr;
     // print_r($option);exit;
     $data['classList'] = Admin_ClassesModel::instance()->fetchAll($option);
     $data['count'] = Admin_ClassesModel::instance()->count($count_opt);
     $data['grade'] = RThink_Config::get('app.grade');
     $pagination = new Pagination();
     $data['pagination'] = $pagination->maxnum($data['count'], $perpage)->show('page_metronic');
     $data['menu'] = Widget_Admin_MenuModel::headerMenu();
     $data['query'] = array('ClassNo' => $classno, 'Grade' => $grade, 'SubjectID' => $subject, 'Chapter' => $chapter, 'MemberID' => $memberID);
     $subject = Admin_SubjectModel::instance()->fetchAll(array());
     $subjectList = array();
     foreach ($subject as $key => $value) {
         if (!isset($subjectList[$value['Grade']])) {
             $subjectList[$value['Grade']] = array();
         }
         array_push($subjectList[$value['Grade']], $value);
     }
     $data['subjectList'] = $subjectList;
     $recommendClassIds = array();
     if (!empty($memberID)) {
         $recommend_option = array('fields' => 'ClassID', 'condition' => 'MemberID = ?', 'bind' => array($memberID), 'order' => 'ClassID desc', 'limit' => '');
         $recommendClasses = Admin_RecommendModel::instance()->fetchAll($recommend_option);
         foreach ($recommendClasses as $key => $value) {
             $recommendClassIds[] = $value['ClassID'];
         }
     }
     $data['recommendClassIds'] = $recommendClassIds;
     $this->setInvokeArg('layout', 'admin1_layout');
     $this->render($data);
 }
Example #18
0
 public function indexAction()
 {
     var_dump(RThink_Config::get('db'));
     // 可以直接以数组形式获取一级、二级的配置参数
     var_dump(RThink_Config::get('db.test'));
 }
Example #19
0
 /**
  * 获取cache对象
  * @return null|object
  */
 protected function getCache()
 {
     if (null == $this->_cache) {
         class_exists('Cache', false) || (require 'Cache.php');
         //默认使用memcache缓存
         $mc_conf = RThink_Config::get('memcache');
         $this->_cache = Cache::singleton(array('params' => $mc_conf));
     }
     return $this->_cache;
 }