diff --git a/app/BaseController.php b/app/BaseController.php
index 2c20de2e..c6b98c28 100644
--- a/app/BaseController.php
+++ b/app/BaseController.php
@@ -40,8 +40,7 @@ abstract class BaseController
* @var array
*/
protected $middleware = [
- 'online'
- ,'login'
+ 'login'
,'auth'
];
diff --git a/app/admin/model/Admin.php b/app/admin/model/Admin.php
index af203eb4..7131370d 100644
--- a/app/admin/model/Admin.php
+++ b/app/admin/model/Admin.php
@@ -71,13 +71,6 @@ class Admin extends BaseModel
}
- // // 用户角色获取器
- // public function userGroup()
- // {
- // return $this->belongsToMany('AuthGroup', 'AuthGroupAccess', 'id', 'uid');
- // }
-
-
// 获取密码
public function password($username)
{
@@ -139,14 +132,6 @@ class Admin extends BaseModel
}
- // // 角色关联
- // public function authGroup()
- // {
- // return $this->hasMany('AuthGroupAccess', 'uid', 'id')
- // ->field('id, uid, group_id');
- // }
-
-
// 获取角色名称
public function getGroupnames($userid)
{
diff --git a/app/admin/model/AuthGroupAccess.php b/app/admin/model/AuthGroupAccess.php
index 09435c55..38170c5a 100644
--- a/app/admin/model/AuthGroupAccess.php
+++ b/app/admin/model/AuthGroupAccess.php
@@ -56,6 +56,7 @@ class AuthGroupAccess extends BaseModel
return $data;
}
+
// 考试设置关联表
public function jsUser()
diff --git a/app/admin/validate/RuleGroup.php b/app/admin/validate/RuleGroup.php
deleted file mode 100644
index 3cad141f..00000000
--- a/app/admin/validate/RuleGroup.php
+++ /dev/null
@@ -1,24 +0,0 @@
- ['规则1','规则2'...]
- *
- * @var array
- */
- protected $rule = [];
-
- /**
- * 定义错误信息
- * 格式:'字段名.规则名' => '错误信息'
- *
- * @var array
- */
- protected $message = [];
-}
diff --git a/app/base/controller/ToolsBase.php b/app/base/controller/ToolsBase.php
index 9e355e70..0faca213 100644
--- a/app/base/controller/ToolsBase.php
+++ b/app/base/controller/ToolsBase.php
@@ -1,5 +1,5 @@
gradeName($riqi);
+ return $njList;
}
// 班级列表
function banJiNamelist()
{
- $bjarr = array(
- '1' => '一班'
- ,'2' => '二班'
- ,'3' => '三班'
- ,'4' => '四班'
- ,'5' => '五班'
- ,'6' => '六班'
- ,'7' => '七班'
- ,'8' => '八班'
- ,'9' => '九班'
- ,'10' => '十班'
- ,'11' => '十一班'
- ,'12' => '十二班'
- ,'13' => '十三班'
- ,'14' => '十四班'
- ,'15' => '十五班'
- ,'16' => '十六班'
- ,'17' => '十七班'
- ,'18' => '十八班'
- ,'19' => '十九班'
- ,'20' => '二十班'
- ,'21' => '二十一班'
- ,'22' => '二十二班'
- ,'23' => '二十三班'
- ,'24' => '二十四班'
- ,'25' => '二十五班'
- );
-
- return $bjarr;
+ // 实例化年级控制器
+ $bj = new \app\tools\controller\Banji;
+ $njList= $bj->banJiNamelist();
+ return $njList;
}
@@ -93,27 +47,8 @@
* $type为1的时候是虚岁,2的时候是周岁
*/
function getAgeByBirth($date = 0, $type = 1){
- $nowYear = date("Y", time());
- $nowMonth = date("m", time());
- $nowDay = date("d", time());
- $birthYear = date("Y", $date);
- $birthMonth = date("m", $date);
- $birthDay = date("d", $date);
- if($type == 1){
- $age = $nowYear - ($birthYear - 1);
- }elseif($type == 2){
- if($nowMonth < $birthMonth){
- $age = $nowYear - $birthYear - 1;
- }elseif($nowMonth == $birthMonth){
- if($nowDay < $birthDay){
- $age = $nowYear - $birthYear - 1;
- }else{
- $age = $nowYear - $birthYear;
- }
- }else{
- $age = $nowYear - $birthYear;
- }
- }
+ $tearch = new \app\teacher\model\Tearcher;
+ $age = $tearch->fBirth($data, $type);
return $age;
}
@@ -121,8 +56,9 @@
// EXCEL表格列名
function excelColumnName()
{
- $liemingarr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ','BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW'];
- return $liemingarr;
+ $excel = new \app\tools\controller\Excel;
+ $data = $excel->excelColumnName();
+ return $data;
}
@@ -131,21 +67,8 @@
{
// 实例化单位模型
$sch = new \app\system\model\School;
- // 实例化类别数据模型
- $cat = new \app\system\model\Category;
- // 获取获取级别列表
- $catlist = $cat->where('p_id', 102)
- ->where('status', 1)
- ->column('id', 'title');
-
- // 查询学校
- $schlist = $sch->where('jibie_id', 'between', [$catlist[$low], $catlist[$high]])
- ->where('status', 1)
- ->order(['jibie_id'=>$order,'paixu'])
- ->field('id, title, jiancheng')
- ->select();
-
- return $schlist;
+ $data = $sch->srcJibie($low, $high, $order);
+ return $data;
}
@@ -154,65 +77,39 @@
{
// 实例化单位模型
$sch = new \app\system\model\School;
- $schlist = $sch->where('status&kaoshi', 1)
- ->order(['paixu'])
- ->field('id, title, jiancheng')
- ->select();
-
+ $schlist = $sch->kaoshi();
return $schlist;
}
- // 整理教师名
- function teacherNames($list = array())
- {
- if(count($list) == 0 )
- {
- return '';
- }
+ // // 整理教师名
+ // function teacherNames($list = array())
+ // {
+ // if(count($list) == 0 )
+ // {
+ // return '';
+ // }
- $names = '';
- foreach ($list as $key => $value) {
- if($key == 0)
- {
- $names = $value['teacher']['xingming'];
- }else{
- $names = $names . '、'. $value['teacher']['xingming'];
- }
- }
+ // $names = '';
+ // foreach ($list as $key => $value) {
+ // if($key == 0)
+ // {
+ // $names = $value['teacher']['xingming'];
+ // }else{
+ // $names = $names . '、'. $value['teacher']['xingming'];
+ // }
+ // }
- return $names;
- }
-
-
-
+ // return $names;
+ // }
// 给数组按多条件排序
function sortArrByManyField(){
$args = func_get_args();
- if(empty($args)){
- return null;
- }
- $arr = array_shift($args);
- if(!is_array($arr)){
- throw new Exception("第一个参数不为数组");
- }
-
- foreach($args as $key => $field){
- if(is_string($field)){
- $temp = array();
- foreach($arr as $index => $val){
- $temp[$index] = $val[$field];
- }
- $args[$key] = $temp;
- }
- }
- $args[] = &$arr;//引用值
- $keys = array_keys($args[0]);
- call_user_func_array('array_multisort', $args);
-
- return array_pop($args);;
+ $tools = new \app\tools\controller\Index;
+ $arr = $tools->sortArrByManyField($args);
+ return $arr;
}
@@ -224,30 +121,20 @@
* */
function array_cover($cover = array(), $covered = array())
{
- foreach ($cover as $key => $value) {
- if(isset($covered[$key]) == true)
- {
- $covered[$key] = $cover[$key];
- }
- }
- return $covered;
+ $tools = new \app\tools\controller\Index;
+ $arr = $tools->($cover, $covered);
+ return $arr;
}
-
/**
* 获取参加考试的学科
* 返回 $data
* */
- function subjectList($status = '', $kaoshi = '')
+ function subjectList()
{
- $src = [
- 'status' => $status
- ,'kaoshi' => $kaoshi
- ];
-
$sbj = new \app\teach\model\Subject;
- $data = $sbj->search($src);
+ $data = $sbj->kaoshi();
return $data;
}
@@ -262,18 +149,9 @@
*/
function strToArray($str)
{
- // 如果str是字符串,则转换成数组
- if(is_array($str) == false)
- {
- $str = explode(',', $str);
- }
- // 循环数组,删除空元素
- foreach ($str as $key => $value) {
- if($value == "" && $value == null){
- unset($str[$key]);
- }
- }
- return $str;
+ $tools = new \app\tools\controller\Index;
+ $data = $tools->strToArray($str);
+ return $data;
}
@@ -285,31 +163,8 @@
*/
function reSetObject($obj, $srcfrom)
{
- // 整理变量
- $src = [
- 'field' => 'update_time'
- ,'order' => 'desc'
- ,'page' => 1
- ,'limit' => 10
- ];
- $src = array_cover($srcfrom, $src) ;
- $str1 = $src['field'];
- $str2 = $src['order'];
-
- // 整理数据
- $cnt = $obj->count();
- $obj = $obj->order($src['field'], $src['order']);
-
- $limit_start = $src['page'] * $src['limit'] - $src['limit'];
- $limit_length = $src['limit'];
- $obj = $obj->slice($limit_start, $limit_length);
- $data = [
- 'code' => 0 // ajax请求次数,作为标识符
- ,'msg' => "" // 获取到的结果数(每页显示数量)
- ,'count' => $cnt // 符合条件的总数据量
- ,'data' => $obj //获取到的数据结果
- ];
-
+ $tools = new \app\tools\controller\Index;
+ $data = $tools->reSetObject($obj, $srcfrom);
return $data;
}
@@ -322,31 +177,7 @@
*/
function reSetArray($arr, $srcfrom)
{
- // 整理变量
- $src = [
- 'field' => 'update_time'
- ,'order' => 'desc'
- ,'page' => 1
- ,'limit' => 10
- ];
- $src = array_cover($srcfrom, $src) ;
-
- // 重新整理数据
- $cnt = count($arr); # 记录总数
- if($cnt > 0){
- $src['order'] == 'desc' ? $src['order'] = SORT_DESC
- : $src['order'] = SORT_ASC; # 数据排序
- $arr = sortArrByManyField($arr, $src['field'], $src['order']);
- }
- $limit_start = $src['page'] * $src['limit'] - $src['limit']; # 获取当前页数据
- $limit_length = $src['limit'];
- $arr = array_slice($arr, $limit_start, $limit_length);
- $data = [ # 数据合并
- 'code' => 0 , # ajax请求次数,作为标识符
- 'msg' => "", # 获取到的结果数(每页显示数量)
- 'count' => $cnt, # 符合条件的总数据量
- 'data' => $arr, # 获取到的数据结果
- ];
-
+ $tools = new \app\tools\controller\Index;
+ $data = $tools->reSetArray($arr, $srcfrom);
return $data;
}
diff --git a/app/facade/OnLine.php b/app/facade/OnLine.php
index e8fc8894..b2760cca 100644
--- a/app/facade/OnLine.php
+++ b/app/facade/OnLine.php
@@ -7,6 +7,6 @@ class OnLine extends Facade
{
protected static function getFacadeClass()
{
- return '\app\formattools\controller\OnLine';
+ return '\app\tools\controller\OnLine';
}
}
diff --git a/app/formattools/controller/Index.php b/app/formattools/controller/Index.php
deleted file mode 100644
index 06eb72a9..00000000
--- a/app/formattools/controller/Index.php
+++ /dev/null
@@ -1,18 +0,0 @@
- $value) {
- $array[$value->subjectName->lieming] = $value;
- unset($array[$key]);
- }
- return $array;
- }
-}
diff --git a/app/formattools/controller/OnLine.php b/app/formattools/controller/OnLine.php
deleted file mode 100644
index c57fb092..00000000
--- a/app/formattools/controller/OnLine.php
+++ /dev/null
@@ -1,21 +0,0 @@
-isAjax();
- if($isajax)
- {
- $this->error($msg, '/login/err');
- }else{
- echo "";
- }
- return true;
- }
-}
diff --git a/app/middleware/Online.php b/app/middleware/Online.php
index 891bb0cb..e711e621 100644
--- a/app/middleware/Online.php
+++ b/app/middleware/Online.php
@@ -14,6 +14,7 @@ class Online
*/
public function handle($request, \Closure $next)
{
+ dump('online');
// 判断是否在线,如果不在线则跳转
$online = session('?onlineCategory');
if($online == false)
diff --git a/app/middleware/UserLogin.php b/app/middleware/UserLogin.php
index be2ba170..94389ed4 100644
--- a/app/middleware/UserLogin.php
+++ b/app/middleware/UserLogin.php
@@ -14,6 +14,7 @@ class UserLogin
*/
public function handle($request, \Closure $next)
{
+ dump('userlogin');
$category = session('onlineCategory');
$isajax = $request->isAjax();
if ($category != 'admin')
@@ -22,19 +23,11 @@ class UserLogin
\app\facade\OnLine::jump('/login', '请使用管理员帐号登录');
}
- // 尝试从session中获取用户名和密码
- $username = session('?admin.username') ? $username = session('admin.username') : $username = '';
- $password = session('?admin.password') ? $password = session('admin.password') : $password = '';
- // 尝试从cookie中获取用户名和密码
- if (strlen($username) < 1 )
- {
- $username = cookie('?username') ? $username = cookie('username') : $username = '';
- $password = cookie('?password') ? $password = cookie('password') : $password = '';
- }
+ $userInfo = \app\facade\OnLine::getLoginInfo('admin');
// 检验用户名或密码是否正确
$yz = new \app\login\controller\Index;
- $yz = $yz->check($username,$password);
+ $yz = $yz->check($userInfo['username'],$userInfo['password']);
if($yz['status'] == 0){
\app\facade\OnLine::jump('/login', '请使用新密码登录');
diff --git a/app/system/model/School.php b/app/system/model/School.php
index 978ad753..355fda26 100644
--- a/app/system/model/School.php
+++ b/app/system/model/School.php
@@ -90,4 +90,36 @@ class School extends BaseModel
->select();
return $data;
}
+
+
+ // 根据是否能组织考试查询单位
+ public function kaoshi()
+ {
+ $data = $this->where('kaoshi', 1)
+ ->order(['jibie_id', 'paixu'])
+ ->field('id, title, jiancheng')
+ ->select();
+ return $data;
+ }
+
+
+ // 根据级别查询单位
+ public function srcJibie($low = '班级', $high = '其它级', $order = 'asc')
+ {
+ // 实例化类别数据模型
+ $cat = new \app\system\model\Category;
+ // 获取获取级别列表
+ $catlist = $cat->where('p_id', 102)
+ ->where('status', 1)
+ ->column('id', 'title');
+
+ // 查询学校
+ $schlist = $this->where('jibie_id', 'between', [$catlist[$low], $catlist[$high]])
+ ->where('status', 1)
+ ->order(['jibie_id' => $order, 'paixu'])
+ ->field('id, title, jiancheng')
+ ->select();
+
+ return $schlist;
+ }
}
diff --git a/app/teach/model/Banji.php b/app/teach/model/Banji.php
index 75f689a0..fa48da24 100644
--- a/app/teach/model/Banji.php
+++ b/app/teach/model/Banji.php
@@ -236,4 +236,69 @@ class Banji extends BaseModel
}
+ // 生成年级名
+ public function gradeName($riqi=0)
+ {
+ // 定义学年时间节点日期为每年的8月1日
+ // $yd = '8-1';
+ if($riqi == 0)
+ {
+ $jiedian = strtotime(date('Y') . '-8-1');
+ $thisday = time();
+ $nian = date('Y');
+ }else{
+ $jiedian = strtotime(date('Y', $riqi) . '-8-1');
+ $thisday = $riqi;
+ $nian = date('Y', $riqi);
+ }
+
+ $thisday <= $jiedian ? $str = 1 : $str = 0;
+ $nian = $nian - $str;
+
+ $njlist = array();
+ $njlist[$nian] = '一年级';
+ $njlist[$nian - 1] = '二年级';
+ $njlist[$nian - 2] = '三年级';
+ $njlist[$nian - 3] = '四年级';
+ $njlist[$nian - 4] = '五年级';
+ $njlist[$nian - 5] = '六年级';
+
+ return $njlist;
+ }
+
+
+ // 班级列表
+ public function className()
+ {
+ $bjarr = array(
+ '1' => '一班'
+ ,'2' => '二班'
+ ,'3' => '三班'
+ ,'4' => '四班'
+ ,'5' => '五班'
+ ,'6' => '六班'
+ ,'7' => '七班'
+ ,'8' => '八班'
+ ,'9' => '九班'
+ ,'10' => '十班'
+ ,'11' => '十一班'
+ ,'12' => '十二班'
+ ,'13' => '十三班'
+ ,'14' => '十四班'
+ ,'15' => '十五班'
+ ,'16' => '十六班'
+ ,'17' => '十七班'
+ ,'18' => '十八班'
+ ,'19' => '十九班'
+ ,'20' => '二十班'
+ ,'21' => '二十一班'
+ ,'22' => '二十二班'
+ ,'23' => '二十三班'
+ ,'24' => '二十四班'
+ ,'25' => '二十五班'
+ );
+ return $bjarr;
+ }
+
+
}
diff --git a/app/teach/model/Subject.php b/app/teach/model/Subject.php
index dc5f8e84..37bc7b43 100644
--- a/app/teach/model/Subject.php
+++ b/app/teach/model/Subject.php
@@ -38,7 +38,7 @@ class Subject extends BaseModel
}
// 获取参加考试的学科
- public function searchKaoshi()
+ public function kaoshi()
{
$data = self::where('kaoshi', 1)
->field('id, title, jiancheng, lieming')
diff --git a/app/teacher/model/Teacher.php b/app/teacher/model/Teacher.php
index 8043cb08..800e69a1 100644
--- a/app/teacher/model/Teacher.php
+++ b/app/teacher/model/Teacher.php
@@ -339,4 +339,34 @@ class Teacher extends BaseModel
return $str;
}
+
+
+ /**
+ * $date是时间戳
+ * $type为1的时候是虚岁,2的时候是周岁
+ */
+ function fBirth($date = 0, $type = 1){
+ $nowYear = date("Y", time());
+ $nowMonth = date("m", time());
+ $nowDay = date("d", time());
+ $birthYear = date("Y", $date);
+ $birthMonth = date("m", $date);
+ $birthDay = date("d", $date);
+ if($type == 1){
+ $age = $nowYear - ($birthYear - 1);
+ }elseif($type == 2){
+ if($nowMonth < $birthMonth){
+ $age = $nowYear - $birthYear - 1;
+ }elseif($nowMonth == $birthMonth){
+ if($nowDay < $birthDay){
+ $age = $nowYear - $birthYear - 1;
+ }else{
+ $age = $nowYear - $birthYear;
+ }
+ }else{
+ $age = $nowYear - $birthYear;
+ }
+ }
+ return $age;
+ }
}
diff --git a/app/tools/common.php b/app/tools/common.php
new file mode 100644
index 00000000..d433d0cb
--- /dev/null
+++ b/app/tools/common.php
@@ -0,0 +1,2 @@
+setInputEncoding('GBK');
- $excelReader->setDelimiter(',');
- }
- $phpexcel = $excelReader->load($path);
- $activeSheet = $phpexcel->getActiveSheet();
- $sheet = $activeSheet->toArray();
- return $sheet;
- }
-
-
/**
* 获取文件信息并保存
*
@@ -40,7 +20,7 @@ class Excel
* str $data['val'] 返回信息
* str $data['url'] 文件路径
*/
- function saveFileInfo($file, $list, $isSave = false)
+ public function saveFileInfo($file, $list, $isSave = false)
{
$hash = $file->hash('sha1');
$f = new \app\system\model\Fields;
@@ -85,5 +65,28 @@ class Excel
return $data;
}
-
+
+ /**读取电子表格数据**/
+ public function readXls($filename){
+ $path = $filename;
+ setlocale(LC_ALL, 'zh_CN'); //csv中文乱码
+ $inputFileType = IOFactory::identify($path);
+ $excelReader = IOFactory::createReader($inputFileType);
+ if ($inputFileType == 'Csv') { //csv文件读取设置
+ $excelReader->setInputEncoding('GBK');
+ $excelReader->setDelimiter(',');
+ }
+ $phpexcel = $excelReader->load($path);
+ $activeSheet = $phpexcel->getActiveSheet();
+ $sheet = $activeSheet->toArray();
+ return $sheet;
+ }
+
+
+ // 定义EXCEL列名
+ public function excelColumnName()
+ {
+ $liemingarr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ','BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW'];
+ return $liemingarr;
+ }
}
diff --git a/app/tools/controller/Index.php b/app/tools/controller/Index.php
new file mode 100644
index 00000000..9c28b4a0
--- /dev/null
+++ b/app/tools/controller/Index.php
@@ -0,0 +1,165 @@
+ $value) {
+ // $array[$value->subjectName->lieming] = $value;
+ // unset($array[$key]);
+ // }
+ // return $array;
+ // }
+
+
+ // 给数组按多条件排序
+ public function sortArrByManyField(){
+ $args = func_get_args();
+ if(empty($args)){
+ return null;
+ }
+ $arr = array_shift($args);
+ if(!is_array($arr)){
+ throw new Exception("第一个参数不为数组");
+ }
+
+ foreach($args as $key => $field){
+ if(is_string($field)){
+ $temp = array();
+ foreach($arr as $index => $val){
+ $temp[$index] = $val[$field];
+ }
+ $args[$key] = $temp;
+ }
+ }
+ $args[] = &$arr;//引用值
+ $keys = array_keys($args[0]);
+ call_user_func_array('array_multisort', $args);
+
+ return array_pop($args);;
+ }
+
+
+ /**
+ * 根据键值,用数组2的值替换数组1的值
+ * $cover 覆盖数组,存储新值的数组
+ * $covered 被覆盖数组,被更改值的数组
+ * 返回 新arr1
+ * */
+ public function array_cover($cover = array(), $covered = array())
+ {
+ foreach ($cover as $key => $value) {
+ if(isset($covered[$key]) == true)
+ {
+ $covered[$key] = $cover[$key];
+ }
+ }
+ return $covered;
+ }
+
+
+ /**
+ * 把request到的参数转换成数组,并删除空值
+ *
+ * @access public
+ * @param str或array $str 表单中获取的参数
+ * @return array 返回类型
+ */
+ public function strToArray($str)
+ {
+ // 如果str是字符串,则转换成数组
+ if(is_array($str) == false)
+ {
+ $str = explode(',', $str);
+ }
+ // 循环数组,删除空元素
+ foreach ($str as $key => $value) {
+ if($value == "" && $value == null){
+ unset($str[$key]);
+ }
+ }
+ return $str;
+ }
+
+
+ /**
+ * 把重新整理从数据模型中返回的对象
+ * @access public
+ * @param str或array $str 表单中获取的参数
+ * @return array 返回类型
+ */
+ public function reSetObject($obj, $srcfrom)
+ {
+ // 整理变量
+ $src = [
+ 'field' => 'update_time'
+ ,'order' => 'desc'
+ ,'page' => 1
+ ,'limit' => 10
+ ];
+ $src = array_cover($srcfrom, $src) ;
+ $str1 = $src['field'];
+ $str2 = $src['order'];
+
+ // 整理数据
+ $cnt = $obj->count();
+ $obj = $obj->order($src['field'], $src['order']);
+
+ $limit_start = $src['page'] * $src['limit'] - $src['limit'];
+ $limit_length = $src['limit'];
+ $obj = $obj->slice($limit_start, $limit_length);
+ $data = [
+ 'code' => 0 // ajax请求次数,作为标识符
+ ,'msg' => "" // 获取到的结果数(每页显示数量)
+ ,'count' => $cnt // 符合条件的总数据量
+ ,'data' => $obj //获取到的数据结果
+ ];
+
+ return $data;
+ }
+
+
+ /**
+ * 把重新整理从数据模型中返回的对象
+ * @access public
+ * @param str或array $str 表单中获取的参数
+ * @return array 返回类型
+ */
+ public function reSetArray($arr, $srcfrom)
+ {
+ // 整理变量
+ $src = [
+ 'field' => 'update_time'
+ ,'order' => 'desc'
+ ,'page' => 1
+ ,'limit' => 10
+ ];
+ $src = array_cover($srcfrom, $src) ;
+
+ // 重新整理数据
+ $cnt = count($arr); # 记录总数
+ if($cnt > 0){
+ $src['order'] == 'desc' ? $src['order'] = SORT_DESC
+ : $src['order'] = SORT_ASC; # 数据排序
+ $arr = sortArrByManyField($arr, $src['field'], $src['order']);
+ }
+ $limit_start = $src['page'] * $src['limit'] - $src['limit']; # 获取当前页数据
+ $limit_length = $src['limit'];
+ $arr = array_slice($arr, $limit_start, $limit_length);
+ $data = [ # 数据合并
+ 'code' => 0 , # ajax请求次数,作为标识符
+ 'msg' => "", # 获取到的结果数(每页显示数量)
+ 'count' => $cnt, # 符合条件的总数据量
+ 'data' => $arr, # 获取到的数据结果
+ ];
+
+ return $data;
+ }
+}
diff --git a/app/searchtools/controller/Kaoshi.php b/app/tools/controller/Kaoshi1.php
similarity index 99%
rename from app/searchtools/controller/Kaoshi.php
rename to app/tools/controller/Kaoshi1.php
index 7371eb9a..f8ef24fd 100644
--- a/app/searchtools/controller/Kaoshi.php
+++ b/app/tools/controller/Kaoshi1.php
@@ -26,7 +26,5 @@ class Kaoshi extends ToolsBase
$data = $ksset->srcGrade($kaoshi_id);
return $data;
}
-
-
}
diff --git a/app/tools/controller/OnLine.php b/app/tools/controller/OnLine.php
new file mode 100644
index 00000000..11042e19
--- /dev/null
+++ b/app/tools/controller/OnLine.php
@@ -0,0 +1,49 @@
+isAjax();
+ if($isajax)
+ {
+ $this->error($msg, '/login/err');
+ }else{
+ echo "";
+ }
+ return true;
+ }
+
+
+ // 获取用户信息
+ public function getLoginInfo($yu)
+ {
+ $username = '';
+ $password = '';
+ // 尝试从session中获取用户名和密码
+ $username = session('?'.$yu.'.username')
+ ? $username = session($yu.'.username') : $username = '';
+ $password = session('?'.$yu.'.password')
+ ? $password = session($yu.'.password') : $password = '';
+ // 尝试从cookie中获取用户名和密码
+ if (strlen($username) < 1 )
+ {
+ $username = cookie('?username')
+ ? $username = cookie('username') : $username = '';
+ $password = cookie('?password')
+ ? $password = cookie('password') : $password = '';
+ }
+
+ $userInfo = [
+ 'username' => $username
+ ,'password' => $password
+ ];
+
+ return $userInfo;
+ }
+}
diff --git a/app/tools/event.php b/app/tools/event.php
new file mode 100644
index 00000000..ec349f1b
--- /dev/null
+++ b/app/tools/event.php
@@ -0,0 +1,5 @@
+