| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- /**
- *
- */
- namespace BaseController;
- include ROOT_PATH . '/Config/Services.php';
- class Controller {
- protected $logger = "";
- protected $assignArray = array();
- function __construct() {
- $post = file_get_contents("php://input");
- $post = json_decode($post, 1);
- if (count($post) > 0 && count($post) > 0) {
- $_POST = array_merge($_POST, $post);
- }
-
- global $logger;
- $this->logger = $logger;
- //获取当前数据源
- // $source = lm('setinfo','Sports')->where('infoname','体育比分数据源设置')->value('infocontent');
- //
- // $this->source = [
- // 'source' => $source
- // ];
- $this->source = require "Config/ControlData.php";
- if (method_exists($this, 'beforeInit')) {
- $this->beforeInit();
- }
- if (method_exists($this, 'init')) {
- $this->init();
- }
-
- }
- /**
- * 自定义初始化前置功能
- *
- * @return void
- */
- function beforeInit(){
- }
- /**
- * 自定义初始化功能
- *
- * @return void
- */
- function init(){
-
- }
- // protected function Upload($FILES, $A = "", $B = "") {
- // $ReturnFILE = array();
- // $FILES = array_keys($FILES);
- // foreach ($FILES as $K => $V) {
- // $FlodName = "Updata/" . date("Y-m-d");
- // if (!is_dir($FlodName)) {
- // mkdir($FlodName, 777, true);
- // }
- // if ($_FILES[$FILES[$K]]["error"] > 0) {
- // return false;
- // }
- // $tempEXT = strstr($_FILES[$FILES[$K]]["name"], ".");
- // $FileName = date("YmdHis") . UUID() . $tempEXT;
- // move_uploaded_file($_FILES[$FILES[$K]]["tmp_name"], "{$FlodName}/" . $FileName);
- // $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
- // $FileName = $FlodName . "/" . $FileName;
- // $ReturnFILE[] = $FileName;
- // }
- // return $ReturnFILE;
- // }
- // protected function CURL($URI, $Data = "", $header = "") {
- // if (is_array($Data)) {
- // $Data = json_encode($Data);
- // }
- // $ch = curl_init();
- // $res = curl_setopt($ch, CURLOPT_URL, $URI);
- // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- // curl_setopt($ch, CURLOPT_HEADER, 0);
- // curl_setopt($ch, CURLOPT_POST, 1);
- // curl_setopt($ch, CURLOPT_POSTFIELDS, $Data);
- // curl_setopt($ch, CURLOPT_HTTPHEADER, array($header, 'Content-Type: application/json'));
- // $result = curl_exec($ch);
- // curl_close($ch);
- // if ($result == NULL) {
- // return 0;
- // }
- // return $result;
- // }
- protected function assign($key, $value) {
- $this->assignArray[$key] = $value;
- }
- protected function display($View = "") {
- $smarty = new \Smarty;
- global $ViewPath;
- $ViewPath = explode("\\", $ViewPath);
- $ViewPath[3] = explode("Controller", $ViewPath[3]);
- $ViewPath[3] = $ViewPath[3][0];
- $ViewPath[1] = S('CUR_PROJECT');
- $ViewPath[3] = S('CUR_CONTROLLER');
- $ViewPath[4] = S('CUR_METHOD');
- if ($View == "") {
- $View = APP_PATH . "/" . $ViewPath[1] . "/View/" . $ViewPath[3] . "/";
- }
- $smarty->setTemplateDir($View); //设置模板目录
- $smarty->setCompileDir(ROOT_PATH . '/Cache/Smarty/compile/');
- $smarty->setConfigDir(ROOT_PATH . '/Cache/Smarty/smarty_configs/');
- $smarty->setCacheDir(ROOT_PATH . '/Cache/Smarty/cache/');
- if (APP_DEBUG) {
- //$smarty->debugging = true;
- $smarty->caching = false;
- $smarty->cache_lifetime = 0;
- } else {
- //$smarty->debugging = false;
- // $smarty->caching = true;
- // $smarty->cache_lifetime = 120;
- $smarty->caching = false;
- $smarty->cache_lifetime = 0;
- }
- foreach ($this->assignArray as $key => $value) {
- $smarty->assign($key, $value);
- }
- $smarty->display($View . $ViewPath[4] . ".blade.php");
-
- }
- }
|