|
- <?php
- /*
- Author:XM
- Compeny:Spiders Travel
- */
- function writeLog($log){
- $dir=__DIR__."/../Log/";
- if (!is_dir($dir)){
- mkdir($dir);
- }
- $filename=$dir.date("Y-m-d").".log";
- file_put_contents($filename, date("Y-m-d H:i:s")."\t".$log.PHP_EOL,FILE_APPEND);
- }
- function makeSign($array){
- $str='';
- foreach ($array as $v){
- $str.=$v;
- }
- return sha1($str.TOKEN);
- }
- function getUserId(){
- if (isset($_COOKIE['xm_data'])){
- $xm_data=$_COOKIE['xm_data'];
- $data=unserialize($xm_data);
- $id=$data['id'];
- $user=$data['user'];
- $checkToken=$data['token'];
- $list=$data['list'];
- $token=makeSign(array($id,$user,serialize($list)));
- if ($checkToken == $token){
- return $id;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
|