init: 从宝塔同步到 Gitea
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
use \think\Controller;
|
||||
use think\Lang;
|
||||
use think\Session;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
use think\Loader;
|
||||
use think\Response;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
class Common Extends Controller{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$user_info = Session::get('user_info');
|
||||
if(empty($user_info) || $user_info == null){
|
||||
Session::clear();
|
||||
if(request()->isPost() && request()->isAjax()){
|
||||
$returnData = ['code'=>0,'msg'=>'登录超时','url'=>'login/index'];
|
||||
$response = Response::create($returnData,'json')->header([]);
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
$this->redirect('/login/index',302);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// 语言包统一渲染
|
||||
$langType = cookie('think_var');
|
||||
$lang = Lang::get('agent');
|
||||
$jsonlang = json_encode($lang);
|
||||
$this->assign('langType',$langType);
|
||||
$this->assign('lang',$lang);
|
||||
$this->assign('jsonlang',$jsonlang);
|
||||
|
||||
}
|
||||
//修改密码
|
||||
public function update_password(){
|
||||
$user_id = $this->request->param('user_id');
|
||||
$old_password = $this->request->param('old_password');
|
||||
$new_password1 = $this->request->param('new_password1');
|
||||
$new_password2 = $this->request->param('new_password2');
|
||||
if(!$old_password){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请输入旧密码';
|
||||
return $msg;
|
||||
}
|
||||
if(!$new_password1){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请输入新密码';
|
||||
return $msg;
|
||||
}
|
||||
if(strlen($new_password1) < 6 || strlen($new_password1) > 20){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '密码长度必须是6到20个字符';
|
||||
return $msg;
|
||||
}
|
||||
if(!$new_password2){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '请再次输入新密码';
|
||||
return $msg;
|
||||
}
|
||||
if($new_password1 != $new_password2){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '两次输入的密码不一致';
|
||||
return $msg;
|
||||
}
|
||||
$user_pass = Db::name('user')->where('id',$user_id)->value('password');
|
||||
$old_password = think_ucenter_md5($old_password,UC_AUTH_KEY);
|
||||
if($user_pass != $old_password){
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '原密码错误';
|
||||
return $msg;
|
||||
}
|
||||
$new_password = think_ucenter_md5($new_password1,UC_AUTH_KEY);
|
||||
$is_passwprd = Db::name('user')->where('id',$user_id)->update(['password' => $new_password]);
|
||||
if($is_passwprd == 1){
|
||||
$msg['status'] = 2;
|
||||
$msg['code'] = '修改成功';
|
||||
}else{
|
||||
$msg['status'] = 1;
|
||||
$msg['code'] = '修改失败,请稍后再试';
|
||||
}
|
||||
return $msg;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*+----------------------------------------------------------
|
||||
* 输出Excel函数
|
||||
*+----------------------------------------------------------
|
||||
* @param string $data 数据
|
||||
*+----------------------------------------------------------
|
||||
*/
|
||||
public function exportExcelCore($data,$savefile=null,$title=null,$sheetname='sheet1'){
|
||||
$z = array('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');
|
||||
Loader::import('PHPExcel.PHPExcel');
|
||||
Loader::import('PHPExcel.PHPExcel.IOFactory.PHPExcel_IOFactory');
|
||||
$PHPExcel = new \PHPExcel();
|
||||
$PHPSheet = $PHPExcel->getActiveSheet();
|
||||
$PHPSheet->setTitle('报表'); //给当前活动sheet设置名称
|
||||
//设置行头
|
||||
$num = 1;
|
||||
foreach($title AS $key => $value){
|
||||
$PHPSheet->setCellValue($z[$key].$num,$value);
|
||||
}
|
||||
$n = 2;
|
||||
foreach($data AS $k => $v){
|
||||
foreach($v AS $k2 => $v2){
|
||||
$PHPSheet->setCellValue($z[$k2].$n,$v2);
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
$PHPWriter = \PHPExcel_IOFactory::createWriter($PHPExcel,"Excel5");
|
||||
header('Content-Disposition: attachment;filename="'.$savefile.'.xls"');
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
$PHPWriter->save("php://output"); //表示在$path路径下面生成demo.xlsx文件
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user