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.
 
 
 
 
 

38 lines
736 B

  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. function writeLog($log){
  7. $dir=__DIR__."/../Log/";
  8. if (!is_dir($dir)){
  9. mkdir($dir);
  10. }
  11. $filename=$dir.date("Y-m-d").".log";
  12. file_put_contents($filename, date("Y-m-d H:i:s")."\t".$log.PHP_EOL,FILE_APPEND);
  13. }
  14. function makeSign($array){
  15. $str='';
  16. foreach ($array as $v){
  17. $str.=$v;
  18. }
  19. return sha1($str.TOKEN);
  20. }
  21. function getUserId(){
  22. if (isset($_COOKIE['xm_data'])){
  23. $xm_data=$_COOKIE['xm_data'];
  24. $data=unserialize($xm_data);
  25. $id=$data['id'];
  26. $user=$data['user'];
  27. $checkToken=$data['token'];
  28. $list=$data['list'];
  29. $token=makeSign(array($id,$user,serialize($list)));
  30. if ($checkToken == $token){
  31. return $id;
  32. }else{
  33. return false;
  34. }
  35. }else{
  36. return false;
  37. }
  38. }