微信小程序会话管理服务器
This commit is contained in:
322
application/controllers/qcloud/minaauth/Auth.php
Normal file
322
application/controllers/qcloud/minaauth/Auth.php
Normal file
@@ -0,0 +1,322 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ayisun
|
||||
* Date: 2016/10/1
|
||||
* Time: 15:06
|
||||
*/
|
||||
class Auth
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
require_once('application/services/qcloud/minaauth/Cappinfo_Service.php');
|
||||
require_once('application/services/qcloud/minaauth/Csessioninfo_Service.php');
|
||||
require_once('system/decrypt_data.php');
|
||||
require_once('system/return_code.php');
|
||||
require_once('system/report_data/ready_for_report_data.php');
|
||||
require_once('system/http_util.php');
|
||||
require_once('system/db/init_db.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $code
|
||||
* @param $appid
|
||||
* @param $secret
|
||||
* @return array|int
|
||||
* 描述:登录校验,返回id和skey
|
||||
*/
|
||||
public function get_id_skey($code, $encrypt_data)
|
||||
{
|
||||
$cappinfo_service = new Cappinfo_Service();
|
||||
$cappinfo_data = $cappinfo_service->select_cappinfo();
|
||||
if (empty($cappinfo_data) || ($cappinfo_data == false)) {
|
||||
$ret['returnCode'] = return_code::MA_NO_APPID;
|
||||
$ret['returnMessage'] = 'NO_APPID';
|
||||
$ret['returnData'] = '';
|
||||
} else {
|
||||
$appid = $cappinfo_data['appid'];
|
||||
$secret = $cappinfo_data['secret'];
|
||||
$ip = $cappinfo_data['ip'];
|
||||
$qcloud_appid = $cappinfo_data['qcloud_appid'];
|
||||
$login_duration = $cappinfo_data['login_duration'];
|
||||
$url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' . $appid . '&secret=' . $secret . '&js_code=' . $code . '&grant_type=authorization_code';
|
||||
$http_util = new http_util();
|
||||
$return_message = $http_util->http_get($url);
|
||||
if ($return_message!=false) {
|
||||
$json_message = json_decode($return_message, true);
|
||||
if (isset($json_message['openid']) && isset($json_message['session_key']) && isset($json_message['expires_in'])) {
|
||||
$skey = md5(time() . mt_rand(1, 1000000));
|
||||
$create_time = time();
|
||||
$last_visit_time = time();
|
||||
$openid = $json_message['openid'];
|
||||
$session_key = $json_message['session_key'];
|
||||
$decrypt_data = new decrypt_data();
|
||||
$user_info = $decrypt_data->aes128cbc_Decrypt($encrypt_data, $session_key);
|
||||
|
||||
if ($user_info === false) {
|
||||
$ret['returnCode'] = return_code::MA_DECRYPT_ERR;
|
||||
$ret['returnMessage'] = 'DECRYPT_FAIL';
|
||||
$ret['returnData'] = '';
|
||||
} else {
|
||||
|
||||
$params = array(
|
||||
"skey" => $skey,
|
||||
"create_time" => $create_time,
|
||||
"last_visit_time" => $last_visit_time,
|
||||
"openid" => $openid,
|
||||
"session_key" => $session_key,
|
||||
"user_info" => $user_info,
|
||||
"login_duration" => $login_duration
|
||||
);
|
||||
|
||||
$csessioninfo_service = new Csessioninfo_Service();
|
||||
$change_result = $csessioninfo_service->change_csessioninfo($params);
|
||||
if ($change_result === true) {
|
||||
$id = $csessioninfo_service->get_id_csessioninfo($openid);
|
||||
$arr_result['id'] = $id;
|
||||
$arr_result['skey'] = $skey;
|
||||
$arr_result['user_info'] = json_decode($user_info);
|
||||
$arr_result['duration'] = $json_message['expires_in'];
|
||||
$ret['returnCode'] = return_code::MA_OK;
|
||||
$ret['returnMessage'] = 'NEW_SESSION_SUCCESS';
|
||||
$ret['returnData'] = $arr_result;
|
||||
} else if ($change_result === false) {
|
||||
$ret['returnCode'] = return_code::MA_CHANGE_SESSION_ERR;
|
||||
$ret['returnMessage'] = 'CHANGE_SESSION_ERR';
|
||||
$ret['returnData'] = '';
|
||||
} else {
|
||||
$arr_result['id'] = $change_result;
|
||||
$arr_result['skey'] = $skey;
|
||||
$arr_result['user_info'] = json_decode($user_info);
|
||||
$arr_result['duration'] = $json_message['expires_in'];
|
||||
$ret['returnCode'] = return_code::MA_OK;
|
||||
$ret['returnMessage'] = 'UPDATE_SESSION_SUCCESS';
|
||||
$ret['returnData'] = $arr_result;
|
||||
}
|
||||
}
|
||||
} else if (isset($json_message['errcode']) && isset($json_message['errmsg'])) {
|
||||
$ret['returnCode'] = return_code::MA_WEIXIN_CODE_ERR;
|
||||
$ret['returnMessage'] = 'WEIXIN_CODE_ERR';
|
||||
$ret['returnData'] = '';
|
||||
} else {
|
||||
$ret['returnCode'] = return_code::MA_WEIXIN_RETURN_ERR;
|
||||
$ret['returnMessage'] = 'WEIXIN_RETURN_ERR';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
} else {
|
||||
$ret['returnCode'] = return_code::MA_WEIXIN_NET_ERR;
|
||||
$ret['returnMessage'] = 'WEIXIN_NET_ERR';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报数据部分
|
||||
*/
|
||||
$report_data = new ready_for_report_data();
|
||||
|
||||
$arr_report_data = array(
|
||||
"ip"=>$ip,
|
||||
"appid"=>$qcloud_appid,
|
||||
"login_count"=>0,
|
||||
"login_sucess"=>0,
|
||||
"auth_count"=>0,
|
||||
"auth_sucess"=>0
|
||||
);
|
||||
|
||||
if($report_data->check_data()){
|
||||
$report_data->ready_data("login_count");
|
||||
}else{
|
||||
$arr_report_data['login_count']=1;
|
||||
$report_data->write_report_data(json_encode($arr_report_data));
|
||||
}
|
||||
if($ret['returnCode']==0){
|
||||
if($report_data->check_data()){
|
||||
$report_data->ready_data("login_sucess");
|
||||
}else{
|
||||
$arr_report_data['login_count']=1;
|
||||
$arr_report_data['login_sucess']=1;
|
||||
$report_data->write_report_data(json_encode($arr_report_data));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $skey
|
||||
* @return bool
|
||||
* 描述:登录态验证
|
||||
*/
|
||||
public function auth($id, $skey)
|
||||
{
|
||||
//根据Id和skey 在cSessionInfo中进行鉴权,返回鉴权失败和密钥过期
|
||||
$cappinfo_service = new Cappinfo_Service();
|
||||
$cappinfo_data = $cappinfo_service->select_cappinfo();
|
||||
if (empty($cappinfo_data) || ($cappinfo_data == false)) {
|
||||
$ret['returnCode'] = return_code::MA_NO_APPID;
|
||||
$ret['returnMessage'] = 'NO_APPID';
|
||||
$ret['returnData'] = '';
|
||||
} else {
|
||||
$login_duration = $cappinfo_data['login_duration'];
|
||||
$session_duration = $cappinfo_data['session_duration'];
|
||||
$ip = $cappinfo_data['ip'];
|
||||
$qcloud_appid = $cappinfo_data['qcloud_appid'];
|
||||
|
||||
$params = array(
|
||||
"id" => $id,
|
||||
"skey" => $skey,
|
||||
"login_duration" => $login_duration,
|
||||
"session_duration" => $session_duration
|
||||
);
|
||||
|
||||
$csessioninfo_service = new Csessioninfo_Service();
|
||||
$auth_result = $csessioninfo_service->check_session_for_auth($params);
|
||||
if ($auth_result!==false) {
|
||||
$arr_result['user_info'] = json_decode($auth_result);
|
||||
$ret['returnCode'] = return_code::MA_OK;
|
||||
$ret['returnMessage'] = 'AUTH_SUCCESS';
|
||||
$ret['returnData'] = $arr_result;
|
||||
} else {
|
||||
$ret['returnCode'] = return_code::MA_AUTH_ERR;
|
||||
$ret['returnMessage'] = 'AUTH_FAIL';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报数据部分
|
||||
*/
|
||||
$report_data = new ready_for_report_data();
|
||||
|
||||
$arr_report_data = array(
|
||||
"ip"=>$ip,
|
||||
"appid"=>$qcloud_appid,
|
||||
"login_count"=>0,
|
||||
"login_sucess"=>0,
|
||||
"auth_count"=>0,
|
||||
"auth_sucess"=>0
|
||||
);
|
||||
|
||||
if($report_data->check_data()){
|
||||
$report_data->ready_data("auth_count");
|
||||
}else{
|
||||
$arr_report_data['auth_count']=1;
|
||||
$report_data->write_report_data(json_encode($arr_report_data));
|
||||
}
|
||||
if($ret['returnCode']==0){
|
||||
if($report_data->check_data()){
|
||||
$report_data->ready_data("auth_sucess");
|
||||
}else{
|
||||
$arr_report_data['auth_count']=1;
|
||||
$arr_report_data['auth_sucess']=1;
|
||||
$report_data->write_report_data(json_encode($arr_report_data));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $skey
|
||||
* @param $encrypt_data
|
||||
* @return bool|string
|
||||
* 描述:解密数据
|
||||
*/
|
||||
public function decrypt($id, $skey, $encrypt_data)
|
||||
{
|
||||
//1、根据id和skey获取session_key。
|
||||
//2、session_key获取成功则正常解密,可能解密失败。
|
||||
//3、获取不成功则解密失败。
|
||||
$csessioninfo_service = new Csessioninfo_Service();
|
||||
$params = array(
|
||||
"id" => $id,
|
||||
"skey" => $skey
|
||||
);
|
||||
$result = $csessioninfo_service->select_csessioninfo($params);
|
||||
if ($result !== false && count($result) != 0 && isset($result['session_key'])) {
|
||||
$session_key = $result['session_key'];
|
||||
$decrypt_data = new decrypt_data();
|
||||
$data = $decrypt_data->aes128cbc_Decrypt($encrypt_data, $session_key);
|
||||
if ($data !== false) {
|
||||
$ret['returnCode'] = return_code::MA_OK;
|
||||
$ret['returnMessage'] = 'DECRYPT_SUCCESS';
|
||||
$ret['returnData'] = $data;
|
||||
} else {
|
||||
$ret['returnCode'] = return_code::MA_DECRYPT_ERR;
|
||||
$ret['returnMessage'] = 'GET_SESSION_KEY_SUCCESS_BUT_DECRYPT_FAIL';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
} else {
|
||||
$ret['returnCode'] = return_code::MA_DECRYPT_ERR;
|
||||
$ret['returnMessage'] = 'GET_SESSION_KEY_FAIL';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function init_data($appid,$secret,$qcloud_appid,$ip,$cdb_ip,$cdb_port,$cdb_user_name,$cdb_pass_wd){
|
||||
$init_db = new init_db();
|
||||
$params_db = array(
|
||||
"cdb_ip"=>$cdb_ip,
|
||||
"cdb_port"=>$cdb_port,
|
||||
"cdb_user_name" => $cdb_user_name,
|
||||
"cdb_pass_wd" => $cdb_pass_wd
|
||||
);
|
||||
if($init_db->init_db_config($params_db)){
|
||||
if($init_db->init_db_table()){
|
||||
$cappinfo_service = new Cappinfo_Service();
|
||||
$cappinfo_data = $cappinfo_service->select_cappinfo();
|
||||
$params = array(
|
||||
"appid"=>$appid,
|
||||
"secret"=>$secret,
|
||||
"qcloud_appid"=>$qcloud_appid,
|
||||
"ip"=>$ip
|
||||
);
|
||||
|
||||
if(empty($cappinfo_data)){
|
||||
if($cappinfo_service->insert_cappinfo($params))
|
||||
{
|
||||
$ret['returnCode'] = return_code::MA_OK;
|
||||
$ret['returnMessage'] = 'INIT_APPINFO_SUCCESS';
|
||||
$ret['returnData'] = '';
|
||||
}else{
|
||||
$ret['returnCode'] = return_code::MA_INIT_APPINFO_ERR;
|
||||
$ret['returnMessage'] = 'INIT_APPINFO_FAIL';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
}else if($cappinfo_data != false){
|
||||
$cappinfo_service->delete_cappinfo();
|
||||
if($cappinfo_service->insert_cappinfo($params))
|
||||
{
|
||||
$ret['returnCode'] = return_code::MA_OK;
|
||||
$ret['returnMessage'] = 'INIT_APPINFO_SUCCESS';
|
||||
$ret['returnData'] = '';
|
||||
}else{
|
||||
$ret['returnCode'] = return_code::MA_INIT_APPINFO_ERR;
|
||||
$ret['returnMessage'] = 'INIT_APPINFO_FAIL';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
}else{
|
||||
$ret['returnCode'] = return_code::MA_MYSQL_ERR;
|
||||
$ret['returnMessage'] = 'MYSQL_ERR';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
}
|
||||
else{
|
||||
$ret['returnCode'] = return_code::MA_INIT_APPINFO_ERR;
|
||||
$ret['returnMessage'] = 'INIT_APPINFO_FAIL';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
|
||||
}else{
|
||||
$ret['returnCode'] = return_code::MA_INIT_APPINFO_ERR;
|
||||
$ret['returnMessage'] = 'INIT_APPINFO_FAIL';
|
||||
$ret['returnData'] = '';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
81
application/services/qcloud/minaauth/Cappinfo_Service.php
Normal file
81
application/services/qcloud/minaauth/Cappinfo_Service.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ayisun
|
||||
* Date: 2016/10/1
|
||||
* Time: 15:14
|
||||
*/
|
||||
class Cappinfo_Service
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
require_once('system/db/mysql_db.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $appid
|
||||
* @param $secret
|
||||
* @param int $login_duration
|
||||
* @param int $session_duration
|
||||
* @return bool
|
||||
*/
|
||||
public function insert_cappinfo($params)
|
||||
{
|
||||
$insert_sql = 'insert into cAppinfo SET appid = "' . $params['appid'] . '",secret = "' . $params['secret'] . '",qcloud_appid = "'.$params['qcloud_appid'].'",ip="'.$params['ip'].'"';
|
||||
$mysql_insert = new mysql_db();
|
||||
return $mysql_insert->query_db($insert_sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $appid
|
||||
* @param $secret
|
||||
* @param $login_duration
|
||||
* @param $session_duration
|
||||
* @return bool
|
||||
*/
|
||||
public function update_cappinfo($params)
|
||||
{
|
||||
$update_sql = 'update cAppinfo set login_duration = ' . $params['login_duration'] . ',session_duration=' . $params['session_duration'] . ',$secret = "' . $params['secret'] . '" where appid = "' . $params['appid'] . '"';
|
||||
$mysql_update = new mysql_db();
|
||||
return $mysql_update->query_db($update_sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $appid
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_cappinfo()
|
||||
{
|
||||
$delete_sql = 'delete from cAppinfo';
|
||||
$mysql_delete = new mysql_db();
|
||||
return $mysql_delete->query_db($delete_sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $appid
|
||||
* @return array|bool
|
||||
*/
|
||||
public function select_cappinfo()
|
||||
{
|
||||
$select_sql = 'select * from cAppinfo';
|
||||
$mysql_select = new mysql_db();
|
||||
$result = $mysql_select->select_db($select_sql);
|
||||
if ($result !== false && !empty($result)) {
|
||||
$arr_result = array();
|
||||
while ($row = mysql_fetch_array($result)) {
|
||||
$arr_result['appid'] = $row['appid'];
|
||||
$arr_result['secret'] = $row['secret'];
|
||||
$arr_result['login_duration'] = $row['login_duration'];
|
||||
$arr_result['session_duration'] = $row['session_duration'];
|
||||
$arr_result['qcloud_appid'] = $row['qcloud_appid'];
|
||||
$arr_result['ip'] = $row['ip'];
|
||||
}
|
||||
return $arr_result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
190
application/services/qcloud/minaauth/Csessioninfo_Service.php
Normal file
190
application/services/qcloud/minaauth/Csessioninfo_Service.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ayisun
|
||||
* Date: 2016/10/1
|
||||
* Time: 15:15
|
||||
*/
|
||||
class Csessioninfo_Service
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
require_once('system/db/mysql_db.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $skey
|
||||
* @param $create_time
|
||||
* @param $last_visit_time
|
||||
* @param $open_id
|
||||
* @param $session_key
|
||||
* @return bool
|
||||
*/
|
||||
public function insert_csessioninfo($params)
|
||||
{
|
||||
$insert_sql = 'insert into cSessioninfo SET skey = "' . $params['skey'] . '",create_time = ' . $params['create_time'] . ',last_visit_time = ' . $params['last_visit_time'] . ',open_id = "' . $params['openid'] . '",session_key="' . $params['session_key'] . '",user_info=\''.$params['user_info'].'\'';
|
||||
$mysql_insert = new mysql_db();
|
||||
return $mysql_insert->query_db($insert_sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $skey
|
||||
* @param $last_visit_time
|
||||
* @return bool
|
||||
*/
|
||||
public function update_csessioninfo_time($params)
|
||||
{
|
||||
$update_sql = 'update cSessioninfo set last_visit_time = ' . $params['last_visit_time'] . ' where id = ' . $params['id'];
|
||||
$mysql_update = new mysql_db();
|
||||
return $mysql_update->query_db($update_sql);
|
||||
}
|
||||
|
||||
public function update_csessioninfo($params)
|
||||
{
|
||||
$update_sql = 'update cSessioninfo set last_visit_time = ' . $params['last_visit_time'] . ',skey = "' . $params['skey'] .'",user_info=\''.$params['user_info'].'\' where id = ' . $params['id'];
|
||||
$mysql_update = new mysql_db();
|
||||
return $mysql_update->query_db($update_sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $skey
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_csessioninfo($open_id)
|
||||
{
|
||||
$delete_sql = 'delete from cSessioninfo where open_id = "' . $open_id . '"';
|
||||
$mysql_delete = new mysql_db();
|
||||
return $mysql_delete->query_db($delete_sql);
|
||||
}
|
||||
|
||||
public function delete_csessioninfo_by_id_skey($params)
|
||||
{
|
||||
$delete_sql = 'delete from cSessioninfo where id = ' . $params['id'];
|
||||
$mysql_delete = new mysql_db();
|
||||
return $mysql_delete->query_db($delete_sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $skey
|
||||
* @return array|bool
|
||||
*/
|
||||
public function select_csessioninfo($params)
|
||||
{
|
||||
$select_sql = 'select * from cSessioninfo where id = ' . $params['id'] . ' and skey = "' . $params['skey'] . '"';
|
||||
$mysql_select = new mysql_db();
|
||||
$result = $mysql_select->select_db($select_sql);
|
||||
if ($result !== false && !empty($result)) {
|
||||
$arr_result = array();
|
||||
while ($row = mysql_fetch_array($result)) {
|
||||
$arr_result['id'] = $row['id'];
|
||||
$arr_result['skey'] = $row['skey'];
|
||||
$arr_result['create_time'] = $row['create_time'];
|
||||
$arr_result['last_visit_time'] = $row['last_visit_time'];
|
||||
$arr_result['open_id'] = $row['open_id'];
|
||||
$arr_result['session_key'] = $row['session_key'];
|
||||
$arr_result['user_info'] = $row['user_info'];
|
||||
}
|
||||
return $arr_result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $open_id
|
||||
* @return bool
|
||||
*/
|
||||
public function get_id_csessioninfo($open_id)
|
||||
{
|
||||
$select_sql = 'select id from cSessioninfo where open_id = "' . $open_id . '"';
|
||||
$mysql_select = new mysql_db();
|
||||
$result = $mysql_select->select_db($select_sql);
|
||||
if ($result !== false && !empty($result)) {
|
||||
$id = false;
|
||||
while ($row = mysql_fetch_array($result)) {
|
||||
$id = $row['id'];
|
||||
}
|
||||
return $id;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function check_session_for_login($params){
|
||||
$select_sql = 'select *_time from cSessioninfo where open_id = "' . $params['openid'] . '"';
|
||||
$mysql_select = new mysql_db();
|
||||
$result = $mysql_select->select_db($select_sql);
|
||||
if ($result !== false && !empty($result)) {
|
||||
$create_time = false;
|
||||
while ($row = mysql_fetch_array($result)) {
|
||||
$create_time = $row['create_time'];
|
||||
}
|
||||
if($create_time == false){
|
||||
return false;
|
||||
}else{
|
||||
$now_time = time();
|
||||
if(($now_time-$create_time)/86400>$params['login_duration']){
|
||||
$this->delete_csessioninfo($params['openid']);
|
||||
return true;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function check_session_for_auth($params){
|
||||
$result = $this->select_csessioninfo($params);
|
||||
if(!empty($result) && $result !== false && count($result) != 0){
|
||||
$now_time = time();
|
||||
$create_time = $result['create_time'];
|
||||
$last_visit_time = $result['last_visit_time'];
|
||||
if(($now_time-$create_time)/86400>$params['login_duration']) {
|
||||
$this->delete_csessioninfo_by_id_skey($params);
|
||||
return false;
|
||||
}else if(($now_time-$last_visit_time)>$params['session_duration']){
|
||||
return false;
|
||||
}else{
|
||||
$params['last_visit_time'] = $now_time;
|
||||
$this->update_csessioninfo_time($params);
|
||||
return $result['user_info'];
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $skey
|
||||
* @param $create_time
|
||||
* @param $last_visit_time
|
||||
* @param $open_id
|
||||
* @param $session_key
|
||||
* @return bool
|
||||
*/
|
||||
public function change_csessioninfo($params)
|
||||
{
|
||||
if($this->check_session_for_login($params)){
|
||||
$id = $this->get_id_csessioninfo($params['openid']);
|
||||
if ($id != false) {
|
||||
$params['id'] = $id;
|
||||
if ($this->update_csessioninfo($params))
|
||||
return $id;
|
||||
else
|
||||
return false;
|
||||
} else {
|
||||
return $this->insert_csessioninfo($params);
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user