flower_svr/ajax_class/ajax_base.class.php
2021-06-11 16:09:56 +08:00

64 lines
2.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Created by PhpStorm.
* User: ddcai
* Date: 2018/6/11
* Time: 12:07
*/
class ajax_base{
public function __construct() {
}
/*
Array(
"a":字符串,
"m":字符串,
"d":数组,
"token":登陆key
)
*/
protected $arr = array();
//设置提交上来的数据
public function get_data(){
$tmp_mydata1 = get_param3("d");//数据内容
//数据内容
$this->arr['d'] = array();
if(!empty($tmp_mydata1)){
$this->arr['d'] = json_decode($tmp_mydata1,true);
}
$act_a = get_param("a");//要执行的动作
//如果不是登陆请求,则需要有token
if(isset($act_a) && $act_a!='login' && $act_a!='data_config_info') {
$sys_tmp_token = trim(get_param3("token"));//用户的登陆key
if (empty($sys_tmp_token)) {//如果是没有token值的请求则就是非法的请求了
echo("非法请求".__LINE__);
return false;
}
$sys_tmp_token = urldecode($sys_tmp_token);
$this->arr['token'] = get_login_token($sys_tmp_token);
if (empty($this->arr['token']) || empty($this->arr['token']['uid'])) {//如果token值不正确则就是非法请求了
echo("非法请求".__LINE__);
return false;
}
$this->arr['a'] = get_param("a");//要执行的动作
}else{//如果是登陆请求
if($act_a!='data_config_info'){
$this->arr['a'] = "login";//要执行的动作
}else{
$this->arr['a'] = get_param("a");//要执行的动作
}
}
$this->arr['ip'] = return_user_ip();//获取请求者的IP
$this->arr['m'] = get_param("m");//要执行的模块
if(empty($this->arr) || empty($this->arr['m']) || empty($this->arr['a']) ){
return false;
}else{
return true;
}
}
}