You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1006 B
42 lines
1006 B
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\BaseController;
|
|
use app\Request;
|
|
|
|
class Index extends BaseController
|
|
{
|
|
//
|
|
public function index(Request $request)
|
|
{
|
|
$arr=[];
|
|
$head = $request->header('mkpwd');
|
|
if ($head == '7xopjJClRxTHhtAm') {
|
|
// make user password
|
|
$data = $request->post();
|
|
// 用户密码
|
|
$salt = $this->makeSalt(6);
|
|
$arr['encpass']=password($data['upass']);
|
|
$arr['salt']=$salt;
|
|
} else {
|
|
$arr = ["ver" => "00", "date" => time()];
|
|
}
|
|
$ss = json_encode($arr);
|
|
return $ss;
|
|
}
|
|
|
|
/**
|
|
* 生成随机字符串
|
|
* make salt
|
|
* @param int $len
|
|
*/
|
|
protected function makeSalt(int $len){
|
|
$ss = "abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
|
$salt = '';
|
|
for ($i = 0; $i < $len; $i++) {
|
|
$salt .= $ss[mt_rand(0, strlen($ss) - 1)];
|
|
}
|
|
return $salt;
|
|
}
|
|
}
|