Exemple #1
0
 /**
 * +----------------------------------------------------------
 * 运行应用实例 入口文件使用的快捷方法
 * +----------------------------------------------------------
 * @access public
 * +----------------------------------------------------------
 * @return void
     +----------------------------------------------------------
 */
 public static function run()
 {
     FApp::init();
     //if (FCache::check()) {
     //   echo FCache::getContent();
     //} else {
     FDispatcher::dispatch();
     //}
 }
Exemple #2
0
 public static function init()
 {
     global $_F;
     $dispatcher = new FDispatcher();
     if (!isset($_F['uri'])) {
         self::getURI();
     }
     $c = isset($_GET['c']) ? $_GET['c'] : null;
     $a = isset($_GET['a']) ? $_GET['a'] : null;
     if (!$c || !$a) {
         $dispatcher->_checkRouter($c, $a);
     }
     if (!$c || !$a) {
         if ($_F['uri'] == '/' || $_F['uri'] == '' || $_F['uri'] == '/index') {
             $c = 'index';
             $a = 'default';
         } else {
             $path_info = explode('/', $_F['uri']);
             if (isset($path_info[3])) {
                 $_F['app'] = $app = $path_info[1];
                 $c = $path_info[2];
                 $a = $path_info[3];
             } elseif (isset($path_info[2])) {
                 $c = $path_info[1];
                 $a = $path_info[2];
             } elseif (isset($path_info[1])) {
                 $c = $path_info[1];
                 $a = 'default';
             }
         }
     }
     if (!empty($_F['app'])) {
         $_F['controller'] = 'Controller_' . ucfirst($_F['app']) . '_' . ucfirst($c);
     } elseif ($_F['module']) {
         $_F['controller'] = 'Controller_' . ucfirst($_F['module']) . '_' . ucfirst($c);
     } else {
         $_F['controller'] = 'Controller_' . ucfirst($c);
     }
     $_F['action'] = $a;
 }
Exemple #3
0
 public function __construct(&$params, &$messages, &$fieldsbuilder)
 {
     parent::__construct($params, $messages, $fieldsbuilder);
     $this->isvalid = true;
 }
Exemple #4
0
 public static function init()
 {
     global $_F;
     $configModule = FConfig::get('global.modules');
     if ($configModule) {
         $_F['modules'] = explode(',', str_replace(' ', '', FConfig::get('global.modules')));
     }
     $dispatcher = new FDispatcher();
     if (!isset($_F['uri'])) {
         self::getURI();
     }
     $c = isset($_GET['c']) ? $_GET['c'] : null;
     $a = isset($_GET['a']) ? $_GET['a'] : null;
     if (!$c || !$a) {
         $dispatcher->_checkRouter($c, $a);
     }
     if (!$c || !$a) {
         if ($_F['uri'] == '/' || $_F['uri'] == '' || $_F['uri'] == '/index') {
             if ($_F['modules']) {
                 $_F['module'] = $app = $_F['modules'][0];
             }
             $c = 'index';
             $a = 'index';
         } else {
             $path_info = explode('/', trim($_F['uri'], '/'));
             /*
              * 处理 URL 中直接传 ID 的情况
              */
             if (is_numeric($path_info[2])) {
                 $_GET['id'] = $path_info[2];
                 unset($path_info[2]);
             } elseif (is_numeric($path_info[1])) {
                 $_GET['id'] = $path_info[1];
                 unset($path_info[1]);
             }
             if ($_F['modules']) {
                 if (in_array($path_info[0], $_F['modules'])) {
                     $_F['module'] = $app = $path_info[0];
                     /*
                      * 处理一下 URL:
                      * 情况1: /mobile
                      * 情况2: /mobile/user
                      */
                     switch (sizeof($path_info)) {
                         case 1:
                             // 情况1: /mobile
                             $path_info[1] = 'index';
                             $path_info[2] = 'index';
                             break;
                         case 2:
                             // 情况2: /mobile/user
                             $path_info[2] = 'index';
                             break;
                     }
                 } else {
                     $_F['module'] = $app = $_F['modules'][0];
                 }
             }
             if (isset($path_info[2])) {
                 $c = $path_info[1];
                 $a = $path_info[2];
             } elseif (isset($path_info[1])) {
                 $c = $path_info[0];
                 $a = $path_info[1];
             } elseif (isset($path_info[0])) {
                 $c = $path_info[0];
                 $a = 'index';
             }
         }
     }
     if (!empty($_F['app'])) {
         $_F['controller'] = 'Controller_' . ucfirst($_F['app']) . '_' . ucfirst($c);
     } elseif ($_F['module']) {
         $_F['controller'] = ucfirst($_F['module']) . ucfirst($c) . 'Ctrl';
     } else {
         $_F['controller'] = ucfirst($c) . 'Ctrl';
     }
     $_F['action'] = $a;
 }
Exemple #5
0
 public static function init()
 {
     global $_F;
     $_F['config'] = array();
     header("Content-type: text/html; charset=utf-8");
     header("Access-Control-Allow-Origin: *");
     if (!defined('FLIB_ROOT')) {
         define('FLIB_ROOT', dirname(__FILE__) . '/');
     }
     date_default_timezone_set('Asia/Chongqing');
     ini_set("error_reporting", E_ALL & ~E_NOTICE);
     if (phpversion() < '5.3.0') {
         set_magic_quotes_runtime(0);
     }
     $_F['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $_F['query_string'] = $_SERVER['QUERY_STRING'];
     $_F['http_host'] ? $_F['http_host'] : ($_F['http_host'] = $_SERVER['HTTP_HOST']);
     $last_part = substr($_F['http_host'], strrpos($_F['http_host'], '.'));
     $left_part = str_replace($last_part, '', $_F['http_host']);
     $_F['cookie_domain'] = substr($left_part, strrpos($left_part, '.')) . $last_part;
     $_F['domain'] = trim($_F['cookie_domain'], '.');
     $_F['subdomain'] = str_replace($_F['cookie_domain'], '', $_F['http_host']);
     $_F['refer'] = $_REQUEST['refer'] ? $_REQUEST['refer'] : $_SERVER['HTTP_REFERER'];
     $_F['in_ajax'] = $_REQUEST['in_ajax'] || $_GET['in_ajax'] || $_POST['in_ajax'] ? true : false;
     if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
         $_F['in_ajax'] = true;
     }
     $_F['is_post'] = $_POST ? true : false;
     $_F['run_in'] = isset($_SERVER['HTTP_HOST']) ? 'web' : 'shell';
     define('IS_POST', $_F['is_post']);
     // 注册AUTOLOAD方法,设定错误和异常处理
     spl_autoload_register(array('Flib', 'autoLoad'));
     register_shutdown_function(array('Flib', 'fatalError'));
     set_error_handler(array('Flib', 'appError'));
     set_exception_handler(array('Flib', 'appException'));
     if (FConfig::get('global.flib_compress')) {
         if (!file_exists(APP_ROOT . "data/_flib_min.php")) {
             self::createFlibMin();
         }
         include_once APP_ROOT . "data/_flib_min.php";
     }
     $sub_domain_status = FConfig::get('global.sub_domain.status');
     // 是否开了子域名
     if ($sub_domain_status == 'on') {
         foreach (FConfig::get('global.sub_domain.sub_domain_rewrite') as $key => $value) {
             if ($key == $_F['subdomain']) {
                 $_F['module'] = $value;
             }
             if ($key == '*') {
                 $default_module = $value;
             }
         }
         if (!$_F['module']) {
             $_F['module'] = $default_module;
         }
     }
     if (!$_F['uri']) {
         FDispatcher::init();
     }
 }
Exemple #6
0
 public function __construct(&$params, &$messages, &$fieldsbuilder)
 {
     parent::__construct($params, $messages, $fieldsbuilder);
 }
 public function __construct(&$params, FoxMessageBoard &$messageboard, &$fieldsbuilder)
 {
     parent::__construct($params, $messageboard, $fieldsbuilder);
 }
Exemple #8
0
 public static function init()
 {
     global $_F;
     self::checkVersion();
     self::initEnv();
     self::safe();
     $_F['config'] = array();
     !defined("F_RUN_MODE") && define('F_RUN_MODE', 'web');
     !defined('FLIB_ROOT') && define('FLIB_ROOT', dirname(__FILE__) . '/');
     if (!defined('F_APP_ROOT')) {
         if (isset($_SERVER['DOCUMENT_ROOT'])) {
             define('F_APP_ROOT', $_SERVER['DOCUMENT_ROOT'] . '/');
         } elseif (isset($_SERVER['TERM']) && isset($_SERVER['PWD'])) {
             // run in shell
             define('F_APP_ROOT', $_SERVER['PWD'] . '/');
         } else {
             define('F_APP_ROOT', getcwd() . '/');
         }
     } else {
         //exit('please define F_APP_ROOT');
     }
     !defined('WEB_ROOT_DIR') && define('WEB_ROOT_DIR', F_APP_ROOT);
     $_F['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $_F['query_string'] = $_SERVER['QUERY_STRING'];
     !isset($_F['http_host']) && ($_F['http_host'] = $_SERVER['HTTP_HOST']);
     $last_part = substr($_F['http_host'], strrpos($_F['http_host'], '.'));
     if ($last_part == '.local') {
         $_F['dev_mode'] = true;
     } elseif ($last_part == '.lan') {
         $_F['test_mode'] = true;
     }
     // 注册AUTOLOAD方法,设定错误和异常处理
     spl_autoload_register(array('Flib', 'autoLoad'));
     register_shutdown_function(array('Flib', 'fatalError'));
     restore_error_handler();
     set_error_handler(array('Flib', 'appError'));
     restore_exception_handler();
     set_exception_handler(array('Flib', 'appException'));
     $left_part = str_replace($last_part, '', $_F['http_host']);
     if ($left_part) {
         $_F['cookie_domain'] = substr($left_part, strrpos($left_part, '.')) . $last_part;
     }
     $_F['domain'] = trim($_F['cookie_domain'], '.');
     $_F['subdomain'] = str_replace($_F['cookie_domain'], '', $_F['http_host']);
     FDispatcher::getURI();
     $_F['refer'] = $_REQUEST['refer'] ? $_REQUEST['refer'] : $_SERVER['HTTP_REFERER'];
     $_F['in_ajax'] = $_REQUEST['in_ajax'] || $_GET['in_ajax'] || $_POST['in_ajax'] ? true : false;
     if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
         $_F['in_ajax'] = true;
     }
     $_F['is_post'] = $_POST ? true : false;
     $_F['run_in'] = isset($_SERVER['HTTP_HOST']) ? 'web' : 'shell';
     define('IS_POST', $_F['is_post']);
     !$_F['debug'] && ($_F['debug'] = FConfig::get("global.debug"));
     if (FConfig::get('global.f_compress')) {
         if (!file_exists(F_APP_ROOT . "data/_flib_min.php")) {
             self::createFlibMin();
         }
         @(include_once F_APP_ROOT . "data/_flib_min.php");
     }
     $sub_domain_status = FConfig::get('global.sub_domain.status');
     // 是否开了子域名
     if ($sub_domain_status) {
         $default_module = 'www';
         foreach (FConfig::get('global.sub_domain.sub_domain_rewrite') as $key => $value) {
             if ($key == $_F['subdomain']) {
                 $_F['module'] = $value;
             }
             if ($key == '*') {
                 $default_module = $value;
             }
         }
         if (!$_F['module']) {
             $_F['module'] = $default_module;
         }
     }
     if (!$_F['uri']) {
         FDispatcher::init();
     }
 }