王总上门按摩后台代码
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.
 
 
 
 
 

58 lines
2.3 KiB

<?php
class Long
{
public function __construct()
{
}
public function isAuthPa()
{
}
private function getSiginDataByHash($data)
{
$data["token"] = $data["token"] ? $data["token"] : "";
$this->log("getSiginDataByHash data ", $data);
$data = is_array($data) ? json_encode($data) : (is_string($data) ? $data : time() . "") . "LongbingShuixian";
$siginStr = hash("sha256", $data);
return $siginStr;
}
private function getPublicPostData()
{
$app_model_name = config("app.AdminModelList")["app_model_name"];
$token = @file_get_contents($this->token_path);
$token = $token ? json_decode($token, true) : "";
if (!empty($token)) {
$token = $token["token"];
}
$data = ["uniacid" => $this->uniacid, "app_model_name" => $app_model_name, "goods_name" => $this->goods_name, "http_host" => $this->http_host, "server_name" => $this->server_name, "request_time" => $this->request_time, "token" => $token];
return $data;
}
private function writein_token($token)
{
$resultWriteToken = false;
if (is_array($token)) {
$resultWriteToken = file_put_contents($this->token_path, json_encode($token));
} else {
$token = @file_get_contents($this->token_path);
$token = $token ? json_decode($token, true) : "";
if (!empty($token) && $token["token_expiration_time"] < time()) {
$token["token"] = "";
$resultWriteToken = file_put_contents($this->token_path, json_encode($token));
}
}
return $resultWriteToken ? true : false;
}
private function clearUp()
{
$token = @file_get_contents($this->token_path);
$token = $token ? json_decode($token, true) : "";
if (!empty($token) && ($token["token_expiration_time"] < time() || !$token["token"])) {
$this->public_key = $this->getPublicKey();
$siginStr = $this->getSiginData([]);
$result = $this->curl_post($this->clear_up_token, $this->getPostData($siginStr));
$result = json_decode($result, true);
if ($result["data"]["clear"]) {
$this->public_key = NULL;
}
}
}
}