コード例 #1
0
ファイル: Profile.php プロジェクト: dalinhuang/StudentManage
 function edit_pwd()
 {
     if ($this->__req->is_post()) {
         header("Content-Type: application/json; charset=utf-8");
         $login = login_class();
         $rt = ['status' => false, 'msg' => NULL];
         if (!$login->is_login()) {
             $rt['msg'] = '未登录';
         } else {
             $old = trim($this->__req->post('old_pwd'));
             $new_pwd = trim($this->__req->post('new_pwd'));
             $new_c_pwd = trim($this->__req->post('new_c_pwd'));
             if (empty($old) || empty($new_pwd) || empty($new_c_pwd)) {
                 $rt['msg'] = '表单有空值';
             } else {
                 if ($new_pwd !== $new_c_pwd) {
                     $rt['msg'] = "密码确认不一致";
                 } else {
                     if (strlen($new_c_pwd) < 6) {
                         $rt['msg'] = '新密码长度不得小于六位';
                     } else {
                         $rt['msg'] = $login->edit_pwd($old, $new_pwd);
                         if ($rt['msg'] === true) {
                             $rt['status'] = true;
                         }
                     }
                 }
             }
         }
         echo json_encode($rt);
     } else {
         $this->__view('home/profile_edit_pwd.php');
     }
 }
コード例 #2
0
ファイル: Home.php プロジェクト: dalinhuang/StudentManage
 /**
  * 登陆页面
  */
 public function login()
 {
     $msg = "";
     if ($this->__req->is_post()) {
         $user = $this->__req->post('user_name');
         $pwd = $this->__req->post('user_pwd');
         switch ($this->__req->post('login_type')) {
             case "student":
                 $msg = login_class()->student_login($user, $pwd);
                 break;
             case "teacher":
                 $msg = login_class()->teacher_login($user, $pwd);
                 break;
             case "admin":
                 $msg = login_class()->login($user, $pwd);
                 break;
             default:
                 $msg = "未知登录类型";
                 break;
         }
         if ($msg === true) {
             redirect('');
         }
     }
     $this->setTitle("后台登录");
     $this->__view("home/login.php", ['msg' => $msg]);
 }
コード例 #3
0
ファイル: Report.php プロジェクト: dalinhuang/StudentManage
 function __construct()
 {
     parent::__construct();
     if (!login_class()->is_login()) {
         redirect(['Home', 'login']);
     }
 }
コード例 #4
0
ファイル: BaseInfo.php プロジェクト: dalinhuang/StudentManage
 function __construct()
 {
     parent::__construct();
     $this->info_data = cfg()->load(_RootPath_ . "/config/base_info.php");
     if (!login_class()->is_login()) {
         redirect(['Home', 'login']);
     }
 }
コード例 #5
0
ファイル: Page.php プロジェクト: dalinhuang/StudentManage
 /**
  * @param string $class
  * @return string
  */
 public function get_user_menu($class = "active")
 {
     $list = cfg()->get('menu');
     $rt = "";
     $ui = $this->__uri->getUriInfo()->getUrlList();
     $access = access_class();
     foreach ($list as $v) {
         $flag = $this->menu_rule_check($v['url'], $ui);
         if ((!isset($v['role']) || login_class()->check_role($v['role'])) && (!isset($v['hide']) || !$v['hide'] || $v['hide'] && $flag[0])) {
             if (isset($v['access']) && !$access->has($v['access'])) {
                 continue;
             }
             $rt .= "<li role=\"presentation\"" . ($flag ? " class=\"{$class}\"" : '') . "><a href='" . get_url($v['url']) . "'>" . $v['name'] . "</a></li>\n";
         }
     }
     return $rt;
 }
コード例 #6
0
ファイル: Access.php プロジェクト: dalinhuang/StudentManage
 function __construct()
 {
     $login = login_class();
     if ($login->is_login()) {
         $list = [];
         switch ($login->getLoginType()) {
             case "admin":
                 $list = db_class()->get_admin_allow_access($login->uid());
                 break;
             case "teacher":
             case "student":
                 $list = db_class()->get_role_allow_access($login->role_id());
                 break;
         }
         $this->table = list2keymap($list, 'name', ['r', 'w']);
     }
 }
コード例 #7
0
ファイル: Access.php プロジェクト: dalinhuang/StudentManage
 private function check()
 {
     if (!login_class()->check_role(1)) {
         if ($this->__req->is_ajax() && $this->__req->is_post()) {
             echo json_encode(['status' => false, 'msg' => '无访问权限']);
         } else {
             $this->__view("home/permission_deny.php");
         }
         return false;
     }
     return true;
 }
コード例 #8
0
ファイル: Scores.php プロジェクト: dalinhuang/StudentManage
 public function get_ajax()
 {
     $access = access_class();
     $type = $this->__req->get('type');
     $login = login_class();
     switch ($type) {
         case "student":
             if ($login->is_login() && $login->getLoginType() == "student" && !$access->read("my_curriculum")) {
                 $this->permission_deny();
                 return;
             }
             break;
         case "teacher":
             if ($login->is_login() && $login->getLoginType() == "teacher" && !$access->read("teacher_curriculum")) {
                 $this->permission_deny();
                 return;
             }
             break;
         default:
             $this->permission_deny();
             return;
     }
     header("Content-Type: application/json; charset=utf-8");
     $mc_grade = $this->__req->post('mc_grade');
     $mc_year = $this->__req->post('mc_year');
     $mc_number = $this->__req->post('mc_number');
     $info = [];
     if (!empty($mc_number)) {
         $info['mc_number'] = $mc_number;
     }
     if (!empty($mc_grade)) {
         $info['mc_grade'] = $mc_grade;
     }
     if (!empty($mc_year)) {
         $info['mc_year'] = $mc_year;
     }
     switch ($type) {
         case "student":
             unset($info['mc_grade']);
             $list = db_class()->student_scores($login->uid(), $info);
             break;
         case "teacher":
             $list = db_class()->teacher_curriculum($login->uid(), $info);
             break;
         default:
             $this->permission_deny();
             return;
     }
     if ($list !== false) {
         echo json_encode(['status' => true, 'msg' => $list]);
     } else {
         echo json_encode(['status' => false, 'msg' => '查询失败']);
     }
 }