Ejemplo n.º 1
0
 /**
  * @brief 创建当前的Controller对象
  * @return object Controller对象
  */
 public function createController()
 {
     $controller = IUrl::getInfo("controller");
     if ($controller === null) {
         $controller = $this->defaultController;
     }
     if (class_exists($controller)) {
         $controllerClass = new $controller($this, $controller);
     } else {
         $controllerClass = new IController($this, $controller);
     }
     $this->controller = $controllerClass;
     return $controllerClass;
 }
Ejemplo n.º 2
0
 /**
  * @brief 创建当前的Controller对象
  * @return object Controller对象
  */
 public function createController()
 {
     $ctrlId = IUrl::getInfo("controller");
     if ($ctrlId == '') {
         $ctrlId = $this->defaultController;
     }
     if (class_exists($ctrlId)) {
         $ctrlObject = new $ctrlId($this, $ctrlId);
     } else {
         $ctrlObject = new IController($this, $ctrlId);
     }
     $this->controller = $ctrlObject;
     return $this->controller;
 }
Ejemplo n.º 3
0
 /**
  * @brief 创建action动作
  * @return object 返回action动作对象
  */
 public function createAction()
 {
     //获取action的标识符
     $actionId = IUrl::getInfo('action');
     //设置默认的action动作
     if ($actionId == '') {
         $actionId = $this->defaultAction;
     }
     /*创建action对象流程
      *1,控制器内部动作
      *2,配置动作
      *3,视图动作*/
     //1,控制器内部动作
     if (method_exists($this, $actionId)) {
         $this->action = new IInlineAction($this, $actionId);
     } else {
         if (($actions = $this->actions()) && isset($actions[$actionId])) {
             //自定义类名
             $className = $actions[$actionId]['class'];
             $this->action = new $className($this, $actionId);
         } else {
             $this->action = new IViewAction($this, $actionId);
         }
     }
     return $this->action;
 }
Ejemplo n.º 4
0
 public function run($setindex = '')
 {
     IUrl::beginUrl();
     $controller = IUrl::getInfo('controller');
     $action = IUrl::getInfo('action');
     $Taction = empty($action) ? $this->defaultAction : $action;
     $info = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
     $sitekey = isset($this->config['sitekey']) ? $this->config['sitekey'] : '';
     //if ($this->getkey() != $sitekey) {
     //	echo 'error! 关注好资源222-www.mx800.com';
     //	exit();
     //}
     /*
     		$hostcheck = array('wmr.xiaoshuhaochi.com', 'wmr.xiaoshuhaochi.com', 'xiaoshuhaochi.com');
     
     		if (!in_array($info, $hostcheck)) {
     			echo 'error! 关注好资源111-www.mx800.com';
     			exit();
     		}*/
     if ($controller === NULL) {
         $controller = $this->defaultController;
     }
     $this->controller = $controller;
     $this->Taction = $Taction;
     if ($controller == 'site' && $Taction == 'index') {
         if (is_mobile_request()) {
             $this->controller = 'html5';
         }
     }
     spl_autoload_register('Mysite::autoload');
     $filePath = hopedir . '/lib/Smarty/libs/Smarty.class.php';
     if (!class_exists('smarty')) {
         include_once $filePath;
     }
     if ($controller == 'adminpage') {
         $smarty = new Smarty();
         $smarty->assign('siteurl', Mysite::$app->config['siteurl']);
         $smarty->cache_lifetime = 0;
         $smarty->caching = false;
         $smarty->template_dir = hopedir . '/templates/';
         $smarty->compile_dir = hopedir . '/templates_c/adminpage';
         $smarty->cache_dir = hopedir . '/smarty_cache';
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         $module = IUrl::getInfo('module');
         $module = empty($module) ? 'index' : $module;
         $doaction = Mysite::$app->getAction() == 'index' ? 'system' : Mysite::$app->getAction();
         $this->Taction = $doaction;
         $this->siteset();
         if (!file_exists(hopedir . '/module/' . Mysite::$app->getAction() . '/adminmethod.php')) {
         } else {
             include hopedir . '/module/' . Mysite::$app->getAction() . '/adminmethod.php';
             $method = new method();
             $method->init();
             if (method_exists($method, $module)) {
                 call_user_func(array($method, $module));
             }
         }
         $datas = $this->getdata();
         if (is_array($datas)) {
             foreach ($datas as $key => $value) {
                 $smarty->assign($key, $value);
             }
         }
         $nowID = ICookie::get('myaddress');
         $lng = ICookie::get('lng');
         $lat = ICookie::get('lat');
         $mapname = ICookie::get('mapname');
         $adminshopid = ICookie::get('adminshopid');
         $smarty->assign('myaddress', $nowID);
         $smarty->assign('mapname', $mapname);
         $smarty->assign('adminshopid', $adminshopid);
         $smarty->assign('lng', $lng);
         $smarty->assign('lat', $lat);
         $smarty->assign('controlname', Mysite::$app->getController());
         $smarty->assign('Taction', Mysite::$app->getAction());
         $smarty->assign('urlshort', Mysite::$app->getController() . '/' . Mysite::$app->getAction());
         $templtepach = hopedir . '/templates/adminpage/' . Mysite::$app->getAction() . '/' . $module . '.html';
         if (file_exists($templtepach)) {
         } else {
             if (file_exists(hopedir . '/module/' . Mysite::$app->getAction() . '/adminpage/' . $module . '.html')) {
                 $smarty->compile_dir = hopedir . '/templates_c/adminpage/' . Mysite::$app->getAction();
                 $templtepach = hopedir . '/module/' . Mysite::$app->getAction() . '/adminpage/' . $module . '.html';
             } else {
                 logwrite('模板不存在 ');
                 $smarty->assign('msg', '模板文件不存在');
                 $smarty->assign('sitetitle', '错误提示');
                 $errorlink = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
                 $smarty->assign('errorlink', $errorlink);
                 $templtepach = hopedir . '/templates/adminpage/public/error.html';
             }
         }
         $smarty->assign('tmodule', $module);
         $smarty->assign('tempdir', 'adminpage');
         $smarty->registerPlugin('function', 'ofunc', 'FUNC_function');
         $smarty->registerPlugin('block', 'oblock', 'FUNC_block');
         $smarty->display($templtepach);
         exit;
     } else {
         $smarty = new Smarty();
         $smarty->assign('siteurl', Mysite::$app->config['siteurl']);
         $smarty->cache_lifetime = 0;
         $smarty->caching = false;
         $smarty->template_dir = hopedir . '/templates';
         $smarty->compile_dir = hopedir . '/templates_c/' . Mysite::$app->config['sitetemp'];
         $smarty->cache_dir = hopedir . '/smarty_cache';
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         $this->siteset();
         if (!file_exists(hopedir . 'module/' . Mysite::$app->getController() . '/method.php')) {
             $this->setController = 'site';
             $this->setAction = 'error';
         } else {
             include hopedir . 'module/' . Mysite::$app->getController() . '/method.php';
             $method = new method();
             $method->init();
             if (method_exists($method, $Taction)) {
                 call_user_func(array($method, $Taction));
             }
         }
         $datas = $this->getdata();
         if (is_array($datas)) {
             foreach ($datas as $key => $value) {
                 $smarty->assign($key, $value);
             }
         }
         $nowID = ICookie::get('myaddress');
         $lng = ICookie::get('lng');
         $lat = ICookie::get('lat');
         $mapname = ICookie::get('mapname');
         $adminshopid = ICookie::get('adminshopid');
         $smarty->assign('myaddress', $nowID);
         $smarty->assign('mapname', $mapname);
         $smarty->assign('adminshopid', $adminshopid);
         $smarty->assign('lng', $lng);
         $smarty->assign('lat', $lat);
         $smarty->assign('controlname', Mysite::$app->getController());
         $smarty->assign('Taction', Mysite::$app->getAction());
         $smarty->assign('urlshort', Mysite::$app->getController() . '/' . Mysite::$app->getAction());
         $templtepach = hopedir . '/templates/' . Mysite::$app->config['sitetemp'] . '/' . Mysite::$app->getController() . '/' . Mysite::$app->getAction() . '.html';
         if (file_exists($templtepach)) {
         } else {
             if (file_exists(hopedir . '/module/' . Mysite::$app->getController() . '/template/' . Mysite::$app->getAction() . '.html')) {
                 $smarty->compile_dir = hopedir . '/templates_c/system';
                 $templtepach = hopedir . '/module/' . Mysite::$app->getController() . '/template/' . Mysite::$app->getAction() . '.html';
             } else {
                 logwrite('模板不存在 ');
                 $smarty->assign('msg', '模板文件不存在');
                 $smarty->assign('sitetitle', '错误提示');
                 $errorlink = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
                 $smarty->assign('errorlink', $errorlink);
                 $templtepach = hopedir . '/templates/' . Mysite::$app->config['sitetemp'] . '/public/error.html';
             }
         }
         $smarty->assign('tempdir', Mysite::$app->config['sitetemp']);
         $smarty->registerPlugin('function', 'ofunc', 'FUNC_function');
         $smarty->registerPlugin('block', 'oblock', 'FUNC_block');
         $smarty->display($templtepach);
     }
 }