Apidsyskxcx.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. defined('BASEPATH') or exit('No direct script access allowed');
  3. /**
  4. * 此类是为了解决erp没有队列的问题,为了解决这个问题,先写一下这个类,避免后期写那么多定时任务类 这里只能解决每间隔多少时间执行一会的
  5. */
  6. class Apidsyskxcx extends Start_Controller
  7. {
  8. private $serect_str = "yskxcx";
  9. private $user_agent = 'Xcly251618/Yskxcx (Erp)';
  10. private $api = "Yskxcx25.424";
  11. private $ip = ['127.0.0.1','47.105.156.18'];
  12. public function __construct()
  13. {
  14. parent::__construct();
  15. $this->load->_model('Model_fullorder','fullorder');
  16. }
  17. public function _remap($arg, $arg_array)
  18. {
  19. $ip = $_SERVER['REMOTE_ADDR'];
  20. if(!in_array($ip,$this->ip)){
  21. exit("Unauthorized access");
  22. }
  23. $user_agent = empty($_SERVER['HTTP_USER_AGENT'])?"":$_SERVER['HTTP_USER_AGENT'];
  24. $token = empty($_SERVER['HTTP_X_AUTH_TOKEN'])?"":$_SERVER['HTTP_X_AUTH_TOKEN'];
  25. $time = $this->input->get('time',true);
  26. $api = $this->input->get('api',true);
  27. $this->checkAuth($user_agent,$token,$time,$api);
  28. if ($arg == 'jobs') //调出单
  29. {
  30. $this->_doRenwu();
  31. } else {
  32. $this->_index();
  33. }
  34. }
  35. /**
  36. * 校验是否有权限可以执行
  37. * $user_agent 自定义的请求客户端名称
  38. * $token 自定义的清华客户端的token
  39. * $time 请求的时间
  40. *
  41. */
  42. private function checkAuth($user_agent,$token,$time,$api){
  43. if($api != $this->api){
  44. exit("Access denied due to insufficient permissions");
  45. }
  46. $check_str = date("Ymd")."¥_".$this->serect_str."_¥".$time;
  47. if(empty($user_agent)){
  48. exit('No direct script access allowed');
  49. }
  50. if($user_agent != $this->user_agent){
  51. exit('Illegal request');
  52. }
  53. if(empty($token)){
  54. exit('No access permission');
  55. }
  56. $sercet_str = md5($check_str);
  57. if($sercet_str != $token){
  58. exit("Request permission is illegal");
  59. }
  60. }
  61. private function _index() {}
  62. private function _doRenwu(){
  63. //必须是云尚快线 打印
  64. $list = $this->fullorder->find_all("express = 71 and print = 3 and library = 2 and expressstate < 6");
  65. print_r(count($list));
  66. }
  67. }