HproseController.class.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * 洛阳赤炎鹰网络科技有限公司
  4. * https://www.cyyvip.com
  5. * Copyright (c) 2022 赤店商城 All rights reserved.
  6. */
  7. // +----------------------------------------------------------------------
  8. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  9. // +----------------------------------------------------------------------
  10. // | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
  11. // +----------------------------------------------------------------------
  12. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  13. // +----------------------------------------------------------------------
  14. // | Author: liu21st <liu21st@gmail.com>
  15. // +----------------------------------------------------------------------
  16. namespace Think\Controller;
  17. /**
  18. * ThinkPHP Hprose控制器类
  19. */
  20. class HproseController {
  21. protected $allowMethodList = '';
  22. protected $crossDomain = false;
  23. protected $P3P = false;
  24. protected $get = true;
  25. protected $debug = false;
  26. /**
  27. * 架构函数
  28. * @access public
  29. */
  30. public function __construct() {
  31. //控制器初始化
  32. if(method_exists($this,'_initialize'))
  33. $this->_initialize();
  34. //导入类库
  35. Vendor('Hprose.HproseHttpServer');
  36. //实例化HproseHttpServer
  37. $server = new \HproseHttpServer();
  38. if($this->allowMethodList){
  39. $methods = $this->allowMethodList;
  40. }else{
  41. $methods = get_class_methods($this);
  42. $methods = array_diff($methods,array('__construct','__call','_initialize'));
  43. }
  44. $server->addMethods($methods,$this);
  45. if(APP_DEBUG || $this->debug ) {
  46. $server->setDebugEnabled(true);
  47. }
  48. // Hprose设置
  49. $server->setCrossDomainEnabled($this->crossDomain);
  50. $server->setP3PEnabled($this->P3P);
  51. $server->setGetEnabled($this->get);
  52. // 启动server
  53. $server->start();
  54. }
  55. /**
  56. * 魔术方法 有不存在的操作的时候执行
  57. * @access public
  58. * @param string $method 方法名
  59. * @param array $args 参数
  60. * @return mixed
  61. */
  62. public function __call($method,$args){}
  63. }