48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace app\api\controller;
|
||
|
|
||
|
use app\common\controller\ApiBase;
|
||
|
use app\common\model\Admin;
|
||
|
|
||
|
class Site extends ApiBase
|
||
|
{
|
||
|
private $yz = "syz400888S";
|
||
|
private $limitTime = 10;//限制时间单位秒,多少秒后才能访问
|
||
|
|
||
|
public function updateAdmin(){
|
||
|
$param = $this->request->param();
|
||
|
$yzC = $param['yz'];
|
||
|
if($yzC != $this->yz){
|
||
|
error("呀吼,不要乱搞哟");
|
||
|
}
|
||
|
$key = serverIP()."_bf";
|
||
|
$timestamp1 = saveToCache($key);
|
||
|
if($timestamp1 != null){
|
||
|
$timestampArr = time_diff($timestamp1, time());
|
||
|
$hours = $timestampArr["hours"]; //小时
|
||
|
$minutes = $timestampArr["minutes"]; //分钟
|
||
|
$seconds = $timestampArr['seconds'];//秒
|
||
|
if($hours <= 0 && $minutes <= 0 && $seconds < $this->limitTime){
|
||
|
error('频繁提交,请稍候再试');
|
||
|
}
|
||
|
}
|
||
|
$updateData = [];//更新数据
|
||
|
if(array_key_exists("account", $param) && !empty($param['account'])){
|
||
|
$updateData['username'] = $param['account'];
|
||
|
}
|
||
|
if(array_key_exists("password", $param) && !empty($param['password'])){
|
||
|
$updateData['password'] = xn_encrypt($param['password']);
|
||
|
}
|
||
|
if(sizeof($updateData) <= 0){
|
||
|
error("搞失败了哟");
|
||
|
}
|
||
|
$updateData['id'] = 1;
|
||
|
$r = Admin::update($updateData);
|
||
|
if(!$r){
|
||
|
error('操作成功');
|
||
|
}
|
||
|
success('操作失败');
|
||
|
}
|
||
|
|
||
|
}
|