/** * 重置密码 * * @return void */ public function reset_password() { if (!$this->check_power('teacher_download_manage')) { return; } $new_password = $this->input->post('new_password'); $new_confirm_password = $this->input->post('confirm_password'); $id = intval($this->input->post('uid')); if (is_string($passwd_msg = is_password($new_password))) { output_json(CODE_ERROR, $passwd_msg); } if (!strlen(trim($new_confirm_password))) { output_json(CODE_ERROR, '确认密码不能为空.'); } if ($new_confirm_password != $new_password) { output_json(CODE_ERROR, '两次密码输入不一致.'); } //检查旧密码是否正确 $passwd = TeacherDownloadModel::get_by_id($id, 'password'); if (!count($passwd)) { output_json(CODE_ERROR, '不存在该监考人员.'); } //检查帐号密码是否正确 $flag = TeacherDownloadModel::reset_password($id, my_md5($new_password)); if (!$flag) { output_json(CODE_ERROR, '密码修改失败,请重试'); } output_json(CODE_SUCCESS, '密码修改成功.'); }
/** * 题库管理员密码重置 * from 后台管理员批量导入 */ public function resetpwd() { $hash = $this->input->get('code'); $admin_id = admin_email_hash('decode', $hash, 1800); $admin_id && ($admin = CpUserModel::get_cpuser($admin_id)); if (!$admin) { message('重置链接已失效,请重新提交申请', 'admin/index/login'); } if ($this->input->post('act') == 'submit') { $password = $this->input->post('password'); $newpwd_confirm = $this->input->post('password_confirm'); if (is_string($passwd_msg = is_password($password))) { message($passwd_msg); } if ($password != $newpwd_confirm) { message('您两次输入密码不一致,返回请确认!'); } $this->db->update('admin', array('password' => my_md5($password)), array('admin_id' => $admin_id)); message('您的新密码已设置成功.', 'admin/index/login', 'success'); } else { // 模版 $this->load->view('cpuser/resetpwd', array('hash' => $hash)); } }
/** * @description 重置密码 * @author * @final * @param int $uid 学生id * @param string $new_password 新密码 * @param string $confirm_password 重复密码 */ public function reset_password() { if (!$this->check_power('student_manage')) { return; } $new_password = $this->input->post('new_password'); $new_confirm_password = $this->input->post('confirm_password'); $uid = intval($this->input->post('uid')); if (is_string($passwd_msg = is_password($new_password))) { output_json(CODE_ERROR, $passwd_msg); } if (!strlen(trim($new_confirm_password))) { output_json(CODE_ERROR, '确认密码不能为空.'); } if ($new_confirm_password != $new_password) { output_json(CODE_ERROR, '两次密码输入不一致.'); } //检查是否存在该学生 $passwd = StudentModel::get_student($uid, 'password'); if (!count($passwd)) { output_json(CODE_ERROR, '不存在该学生.'); } //修改学生密码 $flag = StudentModel::reset_password($uid, my_md5($new_password)); if (!$flag) { output_json(CODE_ERROR, '密码修改失败,请重试'); } output_json(CODE_SUCCESS, '密码修改成功.'); }
/** * 重置密码处理 * * @return void */ public function reset_password_deal() { /* 教师信息 */ $teacher = $this->session->userdata('teacher'); if (!$teacher) { message('会话已失效,请重新提交', 'student/teacher_download/login'); } $old_password = $this->input->post('old_password'); $new_password = $this->input->post('new_password'); $repeat_password = $this->input->post('repeat_password'); if (my_md5($old_password) != $teacher['password']) { message('密码错误!请重试!'); } if (is_string($passwd_msg = is_password($new_password))) { message($passwd_msg); } if ($new_password != $repeat_password) { message('您两次输入密码不一致!请重试!'); } $rst = $this->db->update('teacher_download', array('password' => my_md5($new_password)), array('id' => $teacher['id'])); message('您的新密码已设置成功,重新登陆后生效', 'student/teacher_download/reset_password', 'success'); }
/** * 重置监考人员密码 */ public function reset_password() { $password = $this->input->post('old_password'); $new_password = $this->input->post('new_password'); $new_confirm_password = $this->input->post('confirm_password'); $uid = intval($this->input->post('uid')); if (!strlen(trim($password))) { output_json(CODE_ERROR, '旧密码不能为空.'); } if (is_string($passwd_msg = is_password($new_password))) { output_json(CODE_ERROR, $passwd_msg); } if (!strlen(trim($new_confirm_password))) { output_json(CODE_ERROR, '确认密码不能为空.'); } if ($new_confirm_password != $new_password) { output_json(CODE_ERROR, '两次密码输入不一致.'); } $invigilator_id = $this->session->userdata('exam_i_uid'); if ($uid <= 0 || $uid != $invigilator_id) { output_json(CODE_ERROR, '不存在该监考人员.'); } $this->load->model('exam/exam_invigilator_model'); //检查旧密码是否正确 $invigilater_passwd = $this->exam_invigilator_model->get_invigilator_by_id($uid, 'invigilator_password'); if (!count($invigilater_passwd)) { output_json(CODE_ERROR, '不存在该监考人员.'); } if ($invigilater_passwd != my_md5($password)) { output_json(CODE_ERROR, '旧密码不正确,请核实.'); } //检查帐号密码是否正确 $flag = $this->exam_invigilator_model->reset_invigilator_password($invigilator_id, my_md5($new_password)); if (!$flag) { output_json(CODE_ERROR, '密码修改失败,请重试(如多次出现类似情况,请联系系统管理员)'); } output_json(CODE_SUCCESS, '密码修改成功,请重新登录.'); }
/** * 修改学生登录密码 * * @param int 学生id * @param string 新密码(已加密) * @return boolean */ public function reset_password($uid, $password) { return $this->_update($uid, array('password' => my_md5($password))); }
public static function studentAjaxLogin($param, $bPasswordEnc = false, $bValidateOnly = false) { $resp = new AjaxResponse(); $param = Func::param_copy($param, 'ticket', 'password'); if (empty($param['ticket']) || empty($param['password'])) { $resp->alert('帐号或密码不能为空!'); return $resp; } $where = array(); $bind = array(); if (is_email($param['ticket'])) { $where[] = 'email = ?'; $bind[] = $param['ticket']; } else { if (is_idcard($param['ticket'])) { $where[] = 'idcard = ?'; $bind[] = $param['ticket']; } else { //message('请输入合法的登陆帐号'); $where[] = 'exam_ticket = ? OR external_account = ?'; $bind[] = $param['ticket']; $bind[] = $param['ticket']; } } $where[] = 'password = ?'; if ($bPasswordEnc) { $bind[] = $param['password']; } else { $bind[] = my_md5($param['password']); } $sql_where = implode(') AND (', $where); $sql = <<<EOT SELECT uid, email, first_name, last_name, idcard, exam_ticket, CONCAT(last_name, first_name) AS fullname, external_account, maprule, grade_id, sex, birthday, picture, mobile, is_check, last_login, last_ip, email_validate, status, is_delete, addtime, account, account_status FROM rd_student WHERE ({$sql_where}) EOT; $user = Fn::db()->fetchRow($sql, $bind); if ($user) { $uid = $user['uid']; if (trim($user['picture'])) { $user['avatar_url'] = __IMG_ROOT_URL__ . $user['picture']; } else { $user['avatar_url'] = __IMG_ROOT_URL__ . 'zeming/exam/head.gif'; } $resp->exdata = $user; if (!$bValidateOnly) { $sess = Fn::sess(); if ($sess->userdata('uid') == $uid) { // 当前登录用户已经是请求登录用户,不需要再登录了 $resp->refresh(); } else { $data = array(); $data['last_login'] = time(); $data['last_ip'] = Func::get_client_ip(); Fn::db()->update('rd_student', $data, 'uid = ' . $uid); $sess->set_userdata(array('uid' => $uid, 'uinfo' => $user)); $sql = "SELECT * FROM rd_student_ranking WHERE uid = {$uid}"; $score_ranks = Fn::db()->fetchRow($sql); if (!$score_ranks && $user['grade_id'] == 6) { // 在basic页面会自动判断是否填写完全学生成绩并进行提示跳转 $resp->redirect(site_url('student/profile/basic')); } else { $resp->refresh(); } } } } else { $resp->alert('帐号或密码不正确!'); } return $resp; }
public function resetpwd() { Fn::ajax_call($this, 'login', 'logout'); $hash = $this->input->get('code'); $uid = email_hash('decode', $hash, 1800); $uid && ($student = StudentModel::get_student($uid)); if (!$student) { message('重置链接已失效,请重新提交申请', 'student/index/forget'); } if ($this->input->post('act') == 'submit') { $password = $this->input->post('password'); $newpwd_confirm = $this->input->post('password_confirm'); if (is_string($passwd_msg = is_password($password))) { message($passwd_msg); } if ($password != $newpwd_confirm) { message('您两次输入密码不一致,返回请确认!'); } $this->db->update('student', array('password' => my_md5($password)), array('uid' => $uid)); $now_time = time() - 1800; $sql = "UPDATE {pre}user_resetpassword SET expiretime='{$now_time}' WHERE uid='{$uid}' and hash = '{$hash}'"; $row = $this->db->query($sql); message('您的新密码已设置成功.', 'student/index/login', 'success'); } else { $data = array(); $data['uinfo'] = StudentModel::studentLoginUInfo(); $data['hash'] = $hash; // 模版 $this->load->view('index/resetpwd', $data); } }
/** * 根据excel导入学生并将导入的学生加入考场中 */ public function import_student_save() { set_time_limit(0); $place_id = intval($this->input->post('place_id')); if (!$place_id) { message('考场不存在'); } if ($this->db->get_where('exam_place', array('start_time <=' => time(), 'place_id' => $place_id))->row_array()) { message('该考场正在考试或已结束,无法做此操作', '/admin/place_student/index/' . $place_id); } $message = array(); $school_id = intval($this->input->post('school_id')); if (!$school_id) { $message[] = '考场地址有错误'; } $start_line = intval($this->input->post('start_line')); if ($start_line < 1) { $message[] = '请输入学生信息在Excel文件开始的行'; } $fullname_column = intval($this->input->post('fullname_column')); if ($fullname_column < 1) { $message[] = '请输入姓名在Excel文件的列'; } $exam_ticket_column = intval($this->input->post('exam_ticket_column')); if ($exam_ticket_column < 1) { $message[] = '请输入准考证号在Excel文件的列'; } if ($fullname_column && $exam_ticket_column && $fullname_column == $exam_ticket_column) { $message[] = '姓名和准考证号在Excel文件中不能为同一列'; } if (!$_FILES['file']) { $message[] = '请选择导入的Excel文件'; } $grade_id = intval($this->input->post('grade_id')); $mobile_column = intval($this->input->post('mobile_column')); $school_column = intval($this->input->post('school_column')); $auto_set_paper = intval($this->input->post('auto_set_paper')); $import_tables = array_filter(explode(',', $this->input->post('import_table'))); $schools = array(); $school_names = $this->input->post('school_key'); if ($school_names) { $school_ids = $this->input->post('school_ids'); foreach ($school_names as $key => $name) { $name = str_replace(' ', '', $name); $sch_id = isset($school_ids[$key]) ? intval($school_ids[$key]) : 0; if ($sch_id > 0) { $schools[$name] = $sch_id; } else { $message[] = $name . "对应的学校ID不能为空"; } } } if ($message) { message(implode('<br>', $message)); } /** * 上传文件 */ $upload_path = '../../cache/excel/'; $file_name = microtime(true) . '.' . end(explode('.', $_FILES['file']['name'])); $upload_file = $upload_path . $file_name; if (!is_dir($upload_path)) { mkdir($upload_path, '0777', true); } if (!@move_uploaded_file($_FILES['file']['tmp_name'], $upload_file)) { message('导入文件失败,请重新导入!'); } else { $exam = $this->db->from('rd_exam e')->join('rd_exam_place ep', "e.exam_id=ep.exam_pid", 'left')->where('place_id', $place_id)->get()->row_array(); $grade_id = $grade_id ? $grade_id : $exam['grade_id']; if (!$school_column) { $school = $this->db->get_where('school', array('school_id' => $school_id))->row_array(); } $place_student = $this->db->get_where('rd_exam_place_student', array('place_id' => $place_id))->result_array(); $place_uids = array(); foreach ($place_student as $val) { $place_uids[] = $val['uid']; } $uids = array(); //未加入考场的学生 //导入结果信息统计 $stat = array('total' => 0, 'success' => 0, 'fail' => 0, 'exist' => 0); /** * 读取excel */ $this->load->library('PHPExcel'); $this->load->library('PHPExcel/IOFactory'); $inputFileType = IOFactory::identify($upload_file); $objReader = IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($upload_file); $sheetcount = $objPHPExcel->getSheetCount(); for ($i = 0; $i < $sheetcount; $i++) { if ($import_tables && !in_array($i + 1, $import_tables)) { continue; } $list = array_filter($objPHPExcel->getSheet($i)->toArray()); if (!empty($list)) { $line_count = count($list); for ($j = $start_line - 1; $j < $line_count; $j++) { $list[$j] = array_filter($list[$j]); if (empty($list[$j])) { continue; } $student_name = str_replace(' ', '', $list[$j][$fullname_column - 1]); $external_exam_ticket = trim($list[$j][$exam_ticket_column - 1]); if (!$student_name || !$external_exam_ticket) { continue; } $stat['total']++; if (empty($student_name)) { $message['fail']['student_name'][] = $external_exam_ticket; $stat['fail']++; continue; } if (empty($external_exam_ticket)) { $message['fail']['exam_ticket'][] = $student_name; $stat['fail']++; continue; } $exam_ticket = exam_ticket_maprule_encode($external_exam_ticket, $exam['exam_ticket_maprule']); if (!is_numeric($exam_ticket)) { $message['fail']['exam_ticket_error'][] = $student_name . "-" . $external_exam_ticket; $stat['fail']++; continue; } //判断准考证号是否已注册 if ($tmp_student = $this->db->select('uid')->from('student')->where('exam_ticket', $exam_ticket)->get()->row_array()) { $message['exist'][] = $student_name . "-" . $external_exam_ticket; $stat['exist']++; if (!in_array($tmp_student['uid'], $place_uids)) { $this->db->replace('exam_place_student', array('place_id' => $place_id, 'uid' => $tmp_student['uid'])); $uids[] = $tmp_student['uid']; } } else { $mobile = ''; if ($mobile_column && is_phone($list[$j][$mobile_column - 1])) { $mobile = $list[$j][$mobile_column - 1]; } if ($school_column && $schools) { $sch_name = str_replace(' ', '', $list[$j][$school_column - 1]); $school_id = intval($schools[$sch_name]); if (!isset($school_info[$school_id])) { $school_info[$school_id] = $this->db->get_where('school', array('school_id' => $school_id))->row_array(); } $school = $school_info[$school_id]; if (!$school) { message('学校“' . $sch_name . '”信息不存在,请设置学校对应的学校ID!'); } } $insert_data = array('email' => $exam_ticket . "@mail.exam.new-steps.com", 'first_name' => mb_substr($student_name, 1, strlen($student_name), 'utf-8'), 'last_name' => mb_substr($student_name, 0, 1, 'utf-8'), 'exam_ticket' => $exam_ticket, 'external_account' => $external_exam_ticket, 'maprule' => $exam['exam_ticket_maprule'], 'password' => my_md5($exam['exam_ticket_maprule'] ? $external_exam_ticket : '123456'), 'mobile' => $mobile, 'grade_id' => $grade_id, 'province' => $school['province'], 'city' => $school['city'], 'area' => $school['area'], 'school_id' => $school_id, 'source_from' => '2', 'addtime' => time()); $this->db->insert('student', $insert_data); $uid = $this->db->insert_id(); if ($uid) { $stat['success']++; $this->db->replace('exam_place_student', array('place_id' => $place_id, 'uid' => $uid)); $uids[] = $uid; } else { $stat['fail']++; $message['fail']['insert_fail'][] = $student_name . "-" . $external_exam_ticket; // . '(' . $this->db->last_query() . ')'; } } } } } //新加入考场的学生加入分配试卷计划任务中 if ($auto_set_paper && $uids) { $insert_data = array(); $insert_data['place_id'] = $place_id; $insert_data['uid_data'] = json_encode($uids); $insert_data['status'] = 0; $insert_data['c_time'] = time(); $insert_data['u_time'] = time(); $this->db->insert('cron_task_place_student_paper', $insert_data); } @unlink($upload_file); $data = array(); $data['place_id'] = $place_id; $data['message'] = $message; $data['stat'] = $stat; $this->load->view('place_student/import_student_result', $data); } }
/** * 修改密码 */ public function editpwd() { Fn::ajax_call($this, 'login', 'logout'); if (!$this->_uinfo['uid']) { redirect('student/index/login'); } $data = array(); $data['uinfo'] = $this->_uinfo; $uid = $this->_uinfo['uid']; if ($oldpwd = $this->input->post('oldpwd')) { $newpwd = $this->input->post('newpwd'); $newpwd_confirm = $this->input->post('newpwd_confirm'); if (is_string($passwd_msg = is_password($newpwd))) { message($passwd_msg); } if ($newpwd != $newpwd_confirm) { message('新密码两次输入不一致!'); } $query = $this->db->select('password')->get_where('student', array('uid' => $uid)); $user = $query->row_array(); if ($user['password'] !== my_md5($oldpwd)) { message('原密码错误!'); } $this->db->update('student', array('password' => my_md5($newpwd)), array('uid' => $uid)); message('密码修改成功!', 'student/profile/preview', 'success'); } else { $this->load->view('profile/editpwd', $data); } }
/** * @description 组装插入数据(包括随机生成密码和帐号) * @param array $data 待处理用户数据 */ private function _general_data($data) { /** * todo: * 根据表rd_admin将补齐以下字段: * admin_user * password * addtime * last_ip */ $admin_user_interval = 5000; $admin_user_prefix = 'zeming_import_'; $now = time(); //获取批量导入的管理员列表(按照用户名降序排) $sql = <<<EOT select admin_user from rd_admin where `from`=2 order by admin_user desc limit 0,1 EOT; $max_admin_user = Fn::db()->fetchRow($sql); $max_admin_user = count($max_admin_user) ? $max_admin_user['admin_user'] : 0; $admin_user_rand_min = intval($max_admin_user) + 10; $admin_user_rand_max = $admin_user_rand_min + $admin_user_interval; $code = CODE_SUCCESS; $msg = array(); foreach ($data as &$item) { $item['admin_user'] = $admin_user_prefix . mt_rand($admin_user_rand_min, $admin_user_rand_max); $item['action_list'] = ''; //$action_list; $item['action_type'] = ''; //$action_type; $password = auto_general_password(); $item['prototype_password'] = $password; $item['password'] = my_md5($password); $item['addtime'] = $now; $item['from'] = '2'; $item['last_ip'] = '0.0.0.0'; } return array('code' => $code, 'msg' => '', 'data' => $data); }