test.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <meta charset="utf-8">
  2. <?php
  3. /*
  4. 方倍工作室 http://www.cnblogs.com/txw1958/
  5. CopyRight 2014 All Rights Reserved
  6. */
  7. $uniacid=144;
  8. $chaoshi=600;
  9. echo "当前时间:".time();
  10. echo "<br>";
  11. echo "超时时间:".time()+$chaoshi;
  12. echo "<br>";
  13. chaoshile($uniacid,$chaoshi,$website,$url);
  14. function chaoshile($uniacid,$chaoshi,$website,$url){
  15. //超时自动退出 读取时间表 读取客服表 判断时间 超过的 ->设置成空闲 .给用户发消息超时退出.
  16. $json = file_get_contents('json/'.$uniacid.'_time.json');//读取key列表
  17. $kefutime = json_decode($json,true);
  18. print_r($kefutime);
  19. echo "<br>";
  20. $json = file_get_contents('json/'.$uniacid.'_kefu.json');//读取数字key列表
  21. $kefustr = json_decode($json,true);
  22. print_r($kefustr);
  23. echo "<br>";
  24. $arr = array_keys($kefutime);//openid
  25. foreach ($arr as $arr){
  26. $kftime=$kefutime[$arr]+$chaoshi;
  27. if ($kftime<time()){
  28. //给老客户发信息
  29. //设置新标签
  30. $kefustr[$arr]='空闲';
  31. }
  32. }
  33. print_r($kefustr);
  34. // $res=file_put_contents("json/".$uniacid."_kefu.json", json_encode($kefustr));
  35. }
  36. ?>