BaseController.class.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. if (!defined('IS_INITPHP')) exit('Access Denied!');
  3. header("content-type:text/html;charset=utf-8");
  4. // 指定允许其他域名访问
  5. header('Access-Control-Allow-Origin:*');
  6. // 响应类型
  7. header('Access-Control-Allow-Methods:POST');
  8. header('Access-Control-Allow-Methods:GET');
  9. // 响应头设置
  10. header('Access-Control-Allow-Headers:x-requested-with,content-type');
  11. class BaseController extends Controller{
  12. protected function _init(){
  13. //引入Services文件
  14. includeIfExist(C('APP_FULL_PATH').'/Service/BaseService.class.php');
  15. includeIfExist(C('APP_FULL_PATH').'/Service/ApiService.class.php');
  16. includeIfExist(C('APP_FULL_PATH').'/Service/OtherService.class.php');
  17. //引入dao和common文件
  18. includeIfExist(C('APP_FULL_PATH').'/Dao/DatabaseDao.class.php');
  19. includeIfExist(C('APP_FULL_PATH').'/Lib/common.class.php');
  20. //加载配置文件
  21. include C('APP_FULL_PATH').'/FlowConfig/apiConfig.php';
  22. include C('APP_FULL_PATH').'/FlowConfig/otherConfig.php';
  23. $flowConfig = array_merge($apiConfig,$otherConfig);
  24. C($flowConfig);
  25. //引入 COMMON new 对象
  26. $_ENV["commonClass"] = new commonClass();
  27. //引入数据DAO层
  28. $_ENV["dbDao"] = new DatabaseDao();
  29. //写入参考 日志
  30. $note = "IP:".call_user_func(array($_ENV["commonClass"],"ip"))." 传入参数: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']." POST:".iconv("UTF-8","GB2312//IGNORE",file_get_contents("php://input"));
  31. //$json = json_decode(iconv("GB2312","UTF-8//IGNORE",$json));
  32. Log::getpost($note);
  33. }
  34. }