/** * @param array $data * @param int $code */ protected function repjson($data = [], $code = 200) { if ($code !== 200) { $this->response->withStatus($code, Http\Http::getStatus($code)); } $this->response->withHeader('Content-Type', 'application/json; charset=' . getini('site/charset')); $data = $data ? output_json($data) : ''; $this->response->write($data); }
public function set($key, $value, $ttl = 0) { $ret = false; if ($this->enable) { $data = [$value]; $ret = $this->cacher->set($this->_key($key), output_json($data), $ttl); } return $ret; }
/** * 获取当前坐标附近的消息 */ function GetLocalMessage() { $latitude = isset($_REQUEST['latitude']) ? (double) $_REQUEST['latitude'] : 0; $longitude = isset($_REQUEST['longitude']) ? (double) $_REQUEST['longitude'] : 0; $imei = isset($_REQUEST['imei']) ? $_REQUEST['imei'] : 0; $messList = mdl_message_item::getInstance()->GetAppointCoordinateMessage($latitude, $longitude); $result = array('state' => "1", 'message' => $messList); output_json($result); }
/** We will respond to all requests with a JSON response :) **/ function json_respond($status, $msg) { if ($status != "OK") { // Log Failures. $logmsg = "RXALARM - POSTFAIL - " . $status . " - " . $msg; error_log($logmsg, 0); } $output = array('status' => $status, 'msg' => $msg); output_json($output); }
public function student() { $userdata = $this->session->userdata; if ($userdata['exam_ticket_out'] > 0 && $userdata['txt_student_tichu'] == 1) { output_json(CODE_SUCCESS, 'success', 'fail'); die; } else { output_json(CODE_SUCCESS, 'success', 'success'); die; } }
/** * 通过GSM基站信息解析出gps坐标 */ function GsmToGps() { $cellId = isset($_REQUEST['cid']) ? (int) $_REQUEST['cid'] : 0; $locationAreaCode = isset($_REQUEST['lac']) ? (int) $_REQUEST['lac'] : 0; $mobileCountryCode = isset($_REQUEST['mcc']) ? (int) $_REQUEST['mcc'] : 0; $mobileNetworkCode = isset($_REQUEST['mnc']) ? (int) $_REQUEST['mnc'] : 0; $imei = isset($_REQUEST['imei']) ? $_REQUEST['imei'] : 0; $locale = tls_gpsparse::GsmToGps($cellId, $locationAreaCode, $mobileCountryCode, $mobileNetworkCode); //解析地址 $AddressZH = tls_gpsparse::GetAddress($locale['latitude'], $locale['longitude'], 'zhcn'); //记日志 mdl_log_gsm::getInstance()->ParseGsmToGpsLog($imei, $cellId, $locationAreaCode, $mobileCountryCode, $mobileNetworkCode, $locale['latitude'], $locale['longitude'], $AddressZH); //返回结果 $result = array('state' => "1", 'message' => $locale); output_json($result); }
/** * 有模型的缓存 model/data/*.php * @param $cachekey * @param bool $reset * @return bool|mixed|void */ function datacache($cachekey, $reset = false) { if (!$cachekey) { return false; } if (!$reset) { $data = cache('get', $cachekey); if (is_null($data)) { $dataclass = '\\Model\\Data\\' . ucfirst($cachekey); $data = $dataclass::getInstance()->getdata(); cache('set', $cachekey, output_json($data)); } else { $data = json_decode($data, true); } return $data; } else { //重置缓存 $dataclass = '\\Model\\Data\\' . ucfirst($cachekey); $data = $dataclass::getInstance()->getdata(); return cache('set', $cachekey, output_json($data)); } }
function message($message, $uri = null, $msg_type = 'notice', $redirect_time = 5) { $CI =& get_instance(); //如果是ajax请求,则返回json数据 if ($CI->input->is_ajax_request()) { if ($msg_type == 'success') { output_json(CODE_SUCCESS, $message, array(), $uri); } else { output_json(CODE_ERROR, $message, array(), $uri); } } $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/'; if ($uri || $referer) { if ($uri !== false) { if (empty($uri)) { $uri = 'javascript:history.go(-1);'; } else { if (substr($uri, 0, 10) != 'javascript' && substr($uri, 0, 4) != 'http') { $uri = site_url($uri); } if (substr($uri, 0, 10) == 'javascript') { $uri = $referer; } } } } else { $uri = 'javascript:history.go(-1);'; } $data['msg_type'] = $msg_type; $data['message'] = $message; $data['url_forward'] = $uri; $data['redirect_time'] = $redirect_time * 1000; $content = $CI->load->view('common/message', $data, TRUE); ob_end_clean(); echo $content; exit; }
} } else { //echo "mind 2"; $postgis_diff = "\r\n UPDATE\r\n temp_reach_hull\r\n SET\r\n diff = (\r\n SELECT\r\n st_multi(\r\n ST_SymDifference(t1.the_geom, t2.the_geom)\r\n ) AS diff\r\n FROM\r\n (\r\n SELECT\r\n the_geom\r\n FROM\r\n temp_reach_hull\r\n WHERE\r\n id=" . $ids[$intervall - $i - 1] . "\r\n ) AS t1,\r\n (\r\n SELECT\r\n the_geom\r\n FROM\r\n temp_reach_hull\r\n WHERE\r\n id=" . $ids[$intervall - $i] . "\r\n ) AS t2\r\n )\r\n WHERE\r\n id=" . $ids[$intervall - $i - 1] . "\r\n RETURNING\r\n ST_AsGeoJSON(diff)\r\n "; //echo $postgis_diff.'<br>'; $result_geojson = pg_query($db_conn, $postgis_diff); $row_geojson = pg_fetch_array($result_geojson); $geojson = $row_geojson[0]; //echo "geojson Nr. ".$i." :".print_r(json_decode($geojson)->coordinates)."<br>"; if ($featCollVal == "true") { array_push($geo, buildFeature(json_decode($geojson), $minutesCount)); } if ($featCollVal == "false") { array_push($geo, json_decode($geojson)->coordinates); } } } } //X. delete temp hulls from PostGIS db foreach ($ids as $id) { clearEntry($id, $schema, "temp_reach_hull"); } //baue FeatureCollection oder MultiPolygon mit den HullPolygonen im Array $geo und gebe am Ende das Ergebnis als GeoJSON aus if ($featCollVal == "true") { $json_output = buildFeatureCollection($geo); } if ($featCollVal == "false") { $json_output = buildMultiPolygon($geo); } output_json(json_encode($json_output)); }
/** * @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, '密码修改成功.'); }
// // // // foreach($val as $k=>$v){ // // // // echo "$k:$v;"; // // // // } // // // // echo "<br />"; // // // // } //// TES POTONGAN KODE IVAN R. LANIN define(LF, "\r\n"); // Tampilkan hasil if ($data) { $rows = count($data); switch ($_GET['f']) { case 'xml': $ret .= output_xml($data); break; case 'json': $ret .= output_json($data); break; case 'csv': foreach ($data[0] as $column => $value) { $head .= ($head ? ',' : '') . $column; } $ret .= $head . LF; foreach ($data as $rows) { $row = ''; foreach ($rows as $column => $value) { $row .= ($row ? ',' : '') . $value; } $ret .= $row . LF; } break; default:
} elseif ($act == "add") { $id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0; if ($id) { $row = $db->get_row("select * from data where id = " . $id, ARRAY_A); $row["content"] = html_entity_decode($row["content"]); } else { $row = array("id" => 0, "name" => "", "sort" => 0, "dataclass_id" => 0, "content" => "", "type" => intval($_REQUEST['type'])); } $smarty->assign('row', $row); $smarty->display('admin/admin_data_add.html'); } elseif ($act == "addsubmit") { $list = array("name" => str_filter($_REQUEST["name"]), "content" => str_filter($_REQUEST["content"]), "sort" => intval($_REQUEST["sort"]), "dataclass_id" => intval($_REQUEST["dataclass_id"]), "type" => intval($_REQUEST["type"])); $id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0; if ($id) { $sql = SqlText::update("data", $list, "id=" . $id); $db->query($sql); output_json(0, "更新成功"); } else { $list["add_time"] = time(); $list["hits"] = 0; $sql = SqlText::insert("data", $list); $db->query($sql); output_json(0, "添加成功"); } } elseif ($act == "del") { $sql = "delete from data where id = " . intval($_REQUEST["id"]); $db->query($sql); output_json(0, "删除成功"); } else { exit("错误请求"); }
/** * 获取某期考试 所考到的所有考场 按照地域分类,从高->低 * 关联表:rd_region rd_exam_place rd_school * * @return void */ private function get_exam_areas_bak() { $exam_pid = intval($this->input->get('exam_pid')); $place_id = $this->input->get('place_id'); if (!$exam_pid || $place_id == '') { output_json(CODE_SUCCESS, '', array()); } if (!$place_id) { $result = $this->db->query("select s.* from {pre}school s, {pre}exam_place p where p.exam_pid={$exam_pid} and p.school_id=s.school_id group by school_id")->result_array(); } else { $result = $this->db->query("select s.* from {pre}school s, {pre}exam_place p where p.exam_pid={$exam_pid} and p.place_id={$place_id} and p.school_id=s.school_id group by school_id")->result_array(); } //按照地域级别深度 进行归档 /* * 依次是 国家->省->地市->区县 */ $region_ids = array(); foreach ($result as $item) { $region_ids[] = $item['province']; $region_ids[] = $item['city']; $region_ids[] = $item['area']; } $region_ids = array_unique($region_ids); //获取地域名称 $region_ids = implode(', ', $region_ids); $region_result = $this->db->query("select region_id, region_name, region_type, parent_id from {pre}region where region_id in({$region_ids})")->result_array(); $regions = array(); $addresses = array(); $parent_regions = array(); foreach ($region_result as $val) { $regions[$val['region_id']] = array('name' => $val['region_name'], 'pid' => $val['parent_id']); $addresses[] = array($val['region_id'], $val['region_name'], $val['parent_id']); $parent_regions[$val['parent_id']][] = $val['region_id']; } $data = array('region' => array(array('region_type' => '0', 'id' => 'select_country', 'depth' => '0', 'name' => 'comparison_level_region', 'onchange' => "region.changed(this, 1, 'select_province{depth}');region.changed(document.getElementById('select_province{depth}'), 1, 'select_city{depth}');region.changed(document.getElementById('select_city{depth}'), 1, 'select_area{depth}');region.changed(document.getElementById('select_area{depth}'), 1, 'select_school{depth}');", 'data' => array(array('name' => '--请选择国家--', 'region_id' => '0'), array('name' => '中国', 'region_id' => '1'))))); //当前对比等级 $comparison_level = urldecode($this->input->get('comparison_level')); $comparison_level = (array) json_decode($comparison_level); $tmp_c_l = array(); foreach ($comparison_level as $val) { $tmp_c_l[] = (array) $val; } $comparison_level = is_array($tmp_c_l) ? $tmp_c_l : array(); $cl_region = isset($comparison_level[0]['region']) ? $comparison_level[0]['region'] : ''; $cl_school = isset($comparison_level[0]['school']) ? $comparison_level[0]['school'] : 0; $cl_country = isset($cl_region[0]) ? $cl_region[0] : 0; $cl_province = isset($cl_region[1]) ? $cl_region[1] : 0; $cl_city = isset($cl_region[2]) ? $cl_region[2] : 0; $cl_area = isset($cl_region[3]) ? $cl_region[3] : 0; $provinces = array(array('name' => '--请选择省--', 'region_id' => '0', 'pid' => '0')); $cities = array(array('name' => '--请选择市--', 'region_id' => '0', 'pid' => '0')); $areas = array(array('name' => '--请选择区县--', 'region_id' => '0', 'pid' => '0')); $schools = array(array('name' => '--请选择学校--', 'school_id' => '0', 'pid' => '0')); foreach ($result as $item) { $cl_country && ($provinces[] = array('name' => isset($regions[$item['province']]) ? $regions[$item['province']]['name'] : '--', 'region_id' => $item['province'], 'pid' => isset($regions[$item['province']]) ? $regions[$item['province']]['pid'] : '0')); $cities[] = array('name' => isset($regions[$item['city']]) ? $regions[$item['city']]['name'] : '--', 'region_id' => $item['city'], 'pid' => isset($regions[$item['city']]) ? $regions[$item['city']]['pid'] : '0'); $areas[] = array('name' => isset($regions[$item['area']]) ? $regions[$item['area']]['name'] : '--', 'region_id' => $item['area'], 'pid' => isset($regions[$item['area']]) ? $regions[$item['area']]['pid'] : '0'); $schools[] = array('name' => $item['school_name'], 'school_id' => $item['school_id'], 'pid' => $item['area']); //id需要加1000 为了区分区域 $addresses[] = array(100000 + $item['school_id'], $item['school_name'], $item['area']); } //地域 $data['region'][] = array('region_type' => '1', 'id' => 'select_province', 'depth' => '1', 'name' => 'comparison_level_region', 'onchange' => "region.changed(this, 2, 'select_city{depth}');region.changed(document.getElementById('select_city{depth}'), 2, 'select_area{depth}');region.changed(document.getElementById('select_area{depth}'), 2, 'select_school{depth}');", 'data' => $provinces); $data['region'][] = array('region_type' => '2', 'id' => 'select_city', 'depth' => '2', 'name' => 'comparison_level_region', 'onchange' => "region.changed(this, 3, 'select_area{depth}');region.changed(document.getElementById('select_area{depth}'), 3, 'select_school{depth}');", 'data' => $cities); $data['region'][] = array('region_type' => '3', 'id' => 'select_area', 'depth' => '3', 'name' => 'comparison_level_region', 'onchange' => "region.changed(this, 4, 'select_school{depth}');", 'data' => $areas); //学校 $data['school'] = array('id' => 'select_school', 'depth' => '4', 'name' => 'comparison_level_school', 'data' => $schools); //所有地区缓存 $data['address'] = $addresses; output_json(CODE_SUCCESS, '', $data); }
/** * * 获取用户信息, 昵称 / 头像 / ... */ function get() { $uid = isset($_REQUEST['uid']) ? (int) $_REQUEST['uid'] : 0; $d = !empty($uid) ? mdl_account_basic::getInstance()->get($uid) : array(); output_json($d); }
$args[$param->getName()] = $param->getDefaultValue(); } else { header('HTTP/1.0 400 Bad Request'); echo "400 Expected Argument Not Specified ({$param->getName()})"; exit; continue; } } else { $args[$param->getName()] = $_REQUEST[$param->getName()]; unset($_REQUEST[$param->getName()]); } } if (!empty($_REQUEST)) { header('HTTP/1.0 400 Bad Request'); $k = array_keys($_REQUEST); echo "400 Invalid Argument ({$k[0]})"; exit; } // TODO try catch $out = $reflector->invokeArgs(api($api), $args); // TODO Type en fonction + ajouter XML + CSV header("Content-type: application/json"); echo output_json($out); } else { header('HTTP/1.0 400 Bad Request'); echo "400 Bad Request (dn={$dn})"; exit; } } } }
header("Location: http://www." . get_action(4)); die; } else { $et->load("console")->fire_forget(get_action(3)); } $ED->email = " Job received with action: " . get_action(3) . ". " . $the_callback_email . " will be notified once this job is completed."; } catch (Console_exception $e) { $ED->errors[] = $e->getMessage(); } break; case "404": // import wikipedia article $ED->domain = get_action(3); $ED->topics = get_action(4); try { $ED->results = $et->load("wikipedia")->set_domain($ED->domain)->import($ED->topics); } catch (Wikipedia_exception $e) { $ED->errors[] = $e->getMessage(); } break; } /** * Notify administrators. */ if (in_array(get_action(2), array("create", "quick", "suggest", "import", "404"))) { if (wp_mail($the_callback_email, "Ethach " . ucfirst(get_action()), json_encode($ED))) { } $ED->email = "Emailed sent."; } output_json($ED);
/** * The standard log function for Open-AudIT. Writes logs to a text file in the desired format (json or syslog). * * @access public * * @category Function * * @author Mark Unwin <*****@*****.**> * * @param Object log_details An object containing details you wish to log * * @return NULL [logs the provided string to the log file] */ function output() { error_reporting(E_ALL); $CI =& get_instance(); if ($CI->response->meta->id == 888888888888.0) { $CI->response->meta->id = NULL; unset($CI->response->data); $CI->response->data = array(); } if (!empty($CI->response->data) and count($CI->response->data) > 0) { $CI->response->data = output_convert($CI->response->data); } if (!empty($CI->response->included) and $CI->response->meta->collection != 'scripts') { $CI->response->included = output_convert($CI->response->included); } create_links(); // if we have errors set, make sure we remove the data object / array if (count($CI->response->errors) > 0) { unset($CI->response->data); } else { unset($CI->response->errors); } switch ($CI->response->meta->format) { case 'screen': output_screen($CI->response); break; case 'json_data': output_json_data(); break; case 'datatables': output_datatables(); break; case 'excel': output_excel($CI->response); break; case 'csv': output_csv($CI->response); break; case 'html': output_html($CI->response); break; case 'table': output_report($CI->response); break; case 'html_formatted': output_html_formatted($CI->response); break; case 'table_formatted': output_table_formatted($CI->response); break; case 'xml': output_xml($CI->response); break; case 'json': output_json($CI->response); break; case 'rss': output_rss($CI->response); break; case 'pdf': // TODO: need to insert the PDF function here output_screen($CI->response); break; case 'doc': // TODO: need to insert the doc / docx function here output_screen($CI->response); break; default: output_screen($CI->response); break; } }
<?php require '../loader.php'; /** * create user script */ $userId = input_post('user_id'); $name = input_post('name'); $avatar = input_post('avatar'); if ($userId && $name && $avatar) { // initiate users class $users = new Users(); // check for user existanse $isExists = $users->isUserExists($userId); if ($isExists) { echo output_json(FALSE, ERR_DUPLICATE_DATA); } else { // create a new user object $user = $users->createUser($userId, $name, $avatar); if ($user) { echo output_json(TRUE, ERR_EMPTY, $user); } else { echo output_json(FALSE, ERR_SERVER_ERROR); } } } else { echo output_json(FALSE, ERR_MISSING_DATA); } /* End of file create_user.php */ /* Location ./scripts/create_user.php */
<?php require 'init.php'; $act = isset($_REQUEST["act"]) ? $_REQUEST["act"] : "default"; if ($act == "default") { $id = intval($_REQUEST["id"]); $sql = "select * from articlesingle where id = " . $id; $row = $db->get_row($sql, ARRAY_A); $row["content"] = html_entity_decode($row["content"]); $smarty->assign('row', $row); $smarty->display('admin/admin_articlesingle.html'); } elseif ($act == "update") { $id = intval($_REQUEST["id"]); $content = str_filter($_REQUEST["content"]); $sql = "update articlesingle set content = '" . $content . "' where id = " . $id; $db->query($sql); output_json(0, "更新成功"); }
/** * 考生考试期间 * 离开考试界面 * 次数保存 */ public function set_window_blur() { if ($uid = $this->session->userdata('exam_uid')) { $this->load->model('exam/exam_model'); $current_exam = $this->exam_model->get_cookie_current_exam(true); $this->load->model('exam/student_log_stat_model', 'stat_model'); $this->stat_model->set_student_window_blur_count($current_exam['exam_id'], $current_exam['place_id'], $uid); output_json(CODE_SUCCESS, 'ok'); } }
<?php require_once dirname(__FILE__) . '/upress.php'; function output_json($object) { $output = null; foreach ($object as $name => $value) { $output .= $output ? "," : "{"; $value = preg_replace('/"/', '\\"', $value); $output .= "\"{$name}\": \"{$value}\""; } if ($output) { return $output . "}"; } else { return "{}"; } } $method = $_GET['method']; switch ($method) { case 'process_event': $result = upress_validate_event_dt($_GET['dtstart'], $_GET['dtend']); echo output_json($result); break; case 'process_location': $result = upress_process_location($_GET["location"]); echo output_json($result); break; }
/** * 学生登录检查 */ public function check_login() { //获取当前 $current_exam = $this->exam_model->get_session_current_exam(true); $exam_ticket = trim($this->input->post('exam_ticket')); $password = $this->input->post('password'); if (!strlen($exam_ticket)) { output_json(CODE_ERROR, '请输入正确的准考证号.'); } if (!is_email($exam_ticket) && !is_idcard($exam_ticket) && !is_numeric($exam_ticket)) { output_json(CODE_ERROR, '请输入合法的登陆帐号.'); } if (!strlen($password)) { output_json(CODE_ERROR, '密码不能为空.'); } //检查帐号密码是否正确 $this->load->model('demo/student_model'); $student = $this->student_model->is_valid_student($exam_ticket, $password); if (!$student) { output_json(CODE_ERROR, '登陆帐号或密码不正确,请检查.'); } $place_id = $current_exam['place_id']; $user_id = $student['uid']; //设置考生考卷信息 $place_id = $current_exam['place_id']; $uid = $student['uid']; $this->load->model('demo/exam_test_paper_model'); $test_paper_model = $this->exam_test_paper_model; //设定考生考卷 /** * 需要事先判断 本场考试 是否已经分配考生试卷 */ $test_papers = $test_paper_model->get_stduent_test_paper($place_id, $uid, 'etp_flag,etp_id', null); if (!count($test_papers)) { $insert_ids = $test_paper_model->set_student_test_paper($place_id, $uid); //设置考试记录 if ($insert_ids === false) { output_json(CODE_ERROR, '抱歉,该学科未分配样卷.', array(), 'demo/index/login'); } if (count($insert_ids)) { $this->session->set_userdata(array('etp_id' => implode(',', $insert_ids))); } } else { $etp_flag = $test_papers[0]['etp_flag']; if ($etp_flag < 0) { output_json(CODE_ERROR, '很遗憾,您在本场考试中有作弊行为,无法继续考试.', array(), 'demo/index/login'); } elseif ($etp_flag > 0) { //用于生成测评报告标识 $all_userdata = $this->session->all_userdata(); $report_mark = $all_userdata['exam_pid'] . '_' . $all_userdata['subject_id'] . '_' . $uid . '_' . $all_userdata['exam_id']; $this->session->set_userdata('report_mark', $report_mark); output_json(CODE_SUCCESS, '抱歉,您已经交卷了, 将为您跳转到您的测评报告.', array(), 'setTimeout(function () {window.location.href="' . site_url('demo/test/report/?act=get') . '";}, 3000);'); //message('抱歉,您已经交卷了, 将为您跳转到您的测评报告.', 'demo/test/report?act=get'); } } //添加考场在考人员统计 //检查考生是否已经登录过 $this->load->model('demo/student_log_stat_model'); try { $this->student_log_stat_model->set_exam_place_member($current_exam['exam_id'], $current_exam['place_id'], $user_id); } catch (Exception $e) { output_json(CODE_ERROR, $e->getMessage()); } //==================登录成功操作======================== //考生登录成功,将考生信息保存在session $student['demo_exam_uid'] = $student['uid']; //补齐当前考生的 学校 & 年级信息 $this->load->model('demo/school_model'); $school = $this->school_model->get_school_by_id($student['school_id']); $student['school_name'] = count($school) ? $school['school_name'] : '--'; //获取年级信息 $grade_id = $student['grade_id']; $grades = C('grades'); $student['grade_name'] = isset($grades[$grade_id]) ? $grades[$grade_id] : '--'; //设置考生的会话 $this->student_model->set_exam_student_session($student); //判断该考生是否有离开考试界面嫌疑 $this->load->model('demo/student_log_stat_model', 'log_stat_model'); if ($this->log_stat_model->has_beyond_active_time($current_exam['exam_id'], $current_exam['place_id'], $uid)) { //机考日志 demo_exam_log(EXAM_LOG_RELOGIN_AFTER_LEAVE_TEST_PAGE); $this->log_stat_model->set_exam_place_student_active_status($current_exam['exam_id'], $current_exam['place_id'], $uid); } else { //机考日志 demo_exam_log(EXAM_LOG_LOGIN, array('ip' => $this->input->ip_address())); } output_json(CODE_SUCCESS); }
} unset($_SESSION["admin_vcode"]); } else { output_json(2); } } if ($user["pwd"] == $pwd) { unset($user["pwd"]); $_SESSION["curr_user"] = $user; $user["err_login"] = 0; $id = $user["id"]; unset($user["id"]); $db->query(SqlText::update("user", $user, "id = " . $id)); if (isset($_REQUEST["remember"]) && $_REQUEST["remember"] == 1) { setcookie("curr_user_name", urlencode(Encrypt::encode($user["name"])), time() + 86400 * 7); } output_json(0, "登录成功"); } else { $user["err_login"] += 1; $id = $user["id"]; unset($user["id"]); unset($user["pwd"]); $db->query(SqlText::update("user", $user, "id = " . $id)); output_json(1, "密码错误"); } } else { output_json(1, "没有此用户"); } } else { exit("错误请求"); }
/** * ription 用户帐号状态修改 * * @param int $status * 增加/减少 * * @param int $uid * 用户id */ public function reset_account_status() { if (!$this->check_power('account_manage')) { return; } $status = intval($this->input->post('status')); $uid = intval($this->input->post('uid')); // 检查是否存在该学生 $account = CommonModel::get_student($uid, 'account,account_status'); if (!count($account['account'])) { output_json(CODE_ERROR, '不存在该学生.'); } // 修改学生密码 $flag = CommonModel::reset_status($uid, $status); if (!$flag) { output_json(CODE_ERROR, '帐号修改失败,请重试'); } output_json(CODE_SUCCESS, '帐号修改成功.'); }
$id = intval($_REQUEST["id"]); if ($id == $_SESSION["curr_user"]["id"]) { output_json(1, "不能删除自己"); } else { $where = "id=" . $_REQUEST["id"]; $sql = SqlText::delete("user", $where); $db->query($sql); output_json(0, "删除成功"); } } elseif ($act == "pwd") { $smarty->display('admin/admin_admin_pwd.html'); } elseif ($act == "pwdsubmit") { $old_pwd = str_filter($_REQUEST["old_pwd"]); $pwd = str_filter($_REQUEST["pwd"]); $pwd2 = str_filter($_REQUEST["pwd2"]); if ($pwd == $pwd2) { $sql = SqlText::func("count", "id", "user", "name='" . $_SESSION["curr_user"]["name"] . "' and pwd='" . $old_pwd . "'"); $result = $db->get_var($sql); if ($result) { $list = array("pwd" => $pwd); $db->query(SqlText::update("user", $list, "name='" . $_SESSION["curr_user"]["name"] . "'")); output_json(0, "修改成功"); } else { output_json(1, "旧密码错误"); } } else { output_json(1, "第二次输入密码不正确"); } } else { exit("错误请求"); }
/** * 获取考场统计信息 */ public function statics() { $data = array(); if ($this->session->userdata('exam_i_uid')) { $data_type = $this->input->get('data_type'); $exam_id = $this->session->userdata('exam_i_exam_id'); $place_id = $this->session->userdata('exam_i_place_id'); //将该考生从当前考场中退出 $this->load->model('exam/student_log_stat_model', 'log_stat_model'); $data_types = @explode(',', $data_type); if (is_array($data_types) && count($data_types)) { foreach ($data_types as $type) { if ($type == 'online') { //在考人数 $count = $this->log_stat_model->count_exam_place_members($exam_id, $place_id); $data['online'] = $count ? $count : 0; } if ($type == 'submit') { //交卷人数 $result = $this->db->query("select count(distinct(`uid`)) as count from {pre}exam_test_paper where exam_pid={$exam_id} and place_id={$place_id} and etp_flag <> 0")->result_array(); $data['submit'] = $result[0]['count']; } } } } output_json(CODE_SUCCESS, 'ok', $data); }
/** * 重置密码 * * @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, '密码修改成功.'); }
/** * 自由考试机考调用服务接口 */ public function service_report_data() { set_time_limit(0); $secretkey = $this->input->get('secretkey'); $params = json_decode(Func::strDecode($secretkey), true); if (empty($params)) { output_json('fail', '数据传输有误!'); } $this->load->model('cron/report/general_html_model'); try { if ($this->general_html_model->general_free_exam_html($params)) { output_json('success'); } else { output_json('fail', '评估报告生成错误,请联系管理员!'); } } catch (Exception $e) { output_json('fail', $e->getMessage()); } }
if ($dbupdate2) { if (!isset($staus)) { // if it is set, keep old value. $status = true; } } else { $status = false; } } else { // Format has be frigged with. $status = false; } } /** User Msg (Output). **/ if (!isset($status)) { // no status, no change. $msg = '<div class="alert alert-info"><button class="close" data-dismiss="alert">×</button><strong>No Change!</strong><br />Nothing to do.</div>'; } else { if ($status) { $msg = '<div class="alert alert-success"><button class="close" data-dismiss="alert">×</button><strong>Sucess!</strong><br />Changes Saved.</div>'; } else { $msg = '<div class="alert alert-error"><button class="close" data-dismiss="alert">×</button><strong>Error!</strong><br />Oops, Something went wrong. Reboot and try again.</div>'; } } $output = array('msg' => $msg); output_json($output);
public function out_student_save() { $exam_ticket = trim($this->input->post('account')); $password = $this->input->post('password'); $place_id = intval($this->input->post('place_id')); $exam_id = intval($this->input->post('exam_id')); $txt_student_tichu = intval($this->input->post('txt_student_tichu')); if (!strlen($password)) { output_json(CODE_ERROR, '理由不能为空.'); } if (!strlen($txt_student_tichu)) { output_json(CODE_ERROR, '状态不能为空.'); } // 检查帐号密码是否正确 $this->load->model(APPPATH . 'models/exam/student_model'); $student = $this->student_model->is_valid_student($exam_ticket); if (!$student) { output_json(CODE_ERROR, '该考生不存在.'); } $user_id = $student['uid']; // 重置考生密码 try { if ($txt_student_tichu == '1') { $action = 'out_student'; } else { $action = 'in_student'; } if ($action && ($log_type = Log_type_desc::get_log_alia($action))) { $log_content = $password; exam_log_1($log_type, $log_content, $user_id, $place_id, $exam_id); } $session_data = array('exam_ticket_out' => $exam_ticket, 'password_out' => $password, 'txt_student_tichu' => $txt_student_tichu); $this->session->set_userdata($session_data); ExamPlaceModel::out_exam_place_student($place_id, $user_id, $password, $txt_student_tichu); if ($txt_student_tichu == 1) { output_json(CODE_SUCCESS, '<p></p><p>踢出成功, 该考生考试信息为:</p><p><strong>准考证号:</strong>' . $exam_ticket . ' </p>'); } else { output_json(CODE_SUCCESS, '<p></p><p>恢复成功, 该考生考试信息为:</p><p><strong>准考证号:</strong>' . $exam_ticket . ' </p>'); } } catch (Exception $e) { output_json(CODE_ERROR, '<p></p><p>踢出失败,请重试(如多次出现类似情况,请联系系统管理员)</p>'); } }