Browse Source

add mobile control

stanley-king 9 năm trước cách đây
mục cha
commit
daee702050
5 tập tin đã thay đổi với 86 bổ sung15 xóa
  1. 79 4
      core/framework/core/base.php
  2. 2 1
      core/framework/function/core.php
  3. 4 7
      fcgi_run.php
  4. 0 2
      fooder.php
  5. 1 1
      mobile/index.php

+ 79 - 4
core/framework/core/base.php

@@ -23,7 +23,7 @@ final class Base
 	    {
 	        if (is_numeric($setting_config['time_zone'])){
 	            @date_default_timezone_set('Asia/Shanghai');
-	        }else{
+	        } else {
 	            @date_default_timezone_set($setting_config['time_zone']);
 	        }
 	    }
@@ -45,9 +45,84 @@ final class Base
     public static function run_test()
     {
        	self::cp();
-   		self::init();
+		global $setting_config;
+		self::parse_conf($setting_config);
+		define('MD5_KEY',md5($setting_config['md5_key']));
+
+		if(function_exists('date_default_timezone_set'))
+		{
+			if (is_numeric($setting_config['time_zone'])){
+				@date_default_timezone_set('Asia/Shanghai');
+			}else{
+				@date_default_timezone_set($setting_config['time_zone']);
+			}
+		}
+		Tpl::output('setting_config',$setting_config);
+		Language::read('core_lang_index');
     }
 
+	public static function mobile_init()
+	{
+		self::cp();
+
+		global $setting_config;
+		self::parse_conf($setting_config);
+		define('MD5_KEY',md5($setting_config['md5_key']));
+
+		if(function_exists('date_default_timezone_set'))
+		{
+			if (is_numeric($setting_config['time_zone'])){
+				@date_default_timezone_set('Asia/Shanghai');
+			}else{
+				@date_default_timezone_set($setting_config['time_zone']);
+			}
+		}
+		Tpl::output('setting_config',$setting_config);
+		Language::read('core_lang_index');
+	}
+
+	public static function mobile_control()
+	{
+		if ($GLOBALS['setting_config']['enabled_subdomain'] == '1' && $_GET['act'] == 'index' && $_GET['op'] == 'index')
+		{
+			$store_id = subdomain();
+			if ($store_id > 0) $_GET['act'] = 'show_store';
+		}
+
+		$act_file = realpath(BASE_PATH.'/control/'.$_GET['act'].'.php');
+		$class_name = $_GET['act'].'Control';
+		if (!@require_once($act_file)) {
+			throw_exception("Base Error: access file isn't exists!");
+		}
+
+		static $objs = array();
+		if(array_key_exists($class_name,$objs)) {
+			$main = $objs[$class_name];
+		} else if(class_exists($class_name)) {
+			$main = new $class_name();
+			$objs[$class_name] = $main;
+		} else {
+			$error = "Base Error: class $class_name isn't exists!";
+			throw_exception($error);
+		}
+
+		if(!empty($main))
+		{
+			$function = $_GET['op'].'Op';
+			if (method_exists($main,$function)){
+				$main->$function();
+			} elseif (method_exists($main,'indexOp')){
+				$main->indexOp();
+			} else {
+				$error = "Base Error: function $function not in $class_name!";
+				throw_exception($error);
+			}
+		} else {
+			$error = "Base Error: class $class_name isn't exists!";
+			throw_exception($error);
+		}
+	}
+
 	/**
 	 * run
 	 */
@@ -187,8 +262,8 @@ final class Base
 		if (strpos(self::CPURL,'||') !== false)
         {
 			$a = explode('||',self::CPURL);
-			foreach ($a as $v) 
-                        {
+			foreach ($a as $v)
+			{
 				$d = strtolower(stristr($_SERVER['HTTP_HOST'],$v));
 				if ($d == strtolower($v)){
 					return;

+ 2 - 1
core/framework/function/core.php

@@ -133,7 +133,8 @@ function requestNotFound($act = null, $op = null) {
  * @param int $time 跳转时间,默认为2秒
  * @return string 字符串类型的返回结果
  */
-function showMessage($msg,$url='',$show_type='html',$msg_type='succ',$is_show=1,$time=2000){
+function showMessage($msg,$url='',$show_type='html',$msg_type='succ',$is_show=1,$time=2000)
+{
 	if (!class_exists('Language')) import('libraries.language');
 	Language::read('core_lang_index');
 	$lang	= Language::getLangContent();

+ 4 - 7
fcgi_run.php

@@ -14,12 +14,11 @@ function run_fcgi()
         $log_file = new SplFileObject('./php_example.txt','a+');
     }
 
-    $log_file->fwrite("before fcgi_init\r\n");
     fcgi_init('/Users/stanley-king/logs');
-    $log_file->fwrite("end fcgi_init\r\n");
 
+    require_once(BASE_ROOT_PATH.'/mobile/index.php');
+    Base::mobile_init();
 
-    $log_file->fwrite("before fcgi_accept\r\n");
     while(($ret = fcgi_accept()) >= 0)
     {    
         $log_file->fwrite("end fcgi_accept\r\n");
@@ -32,10 +31,8 @@ function run_fcgi()
         {
             init_request();
             $file = request_helper::script_file();
-            if(is_file($file)) {
-                //include $file;
-            }
-            echo 'xxx';
+            $log_file->fwrite("$file \r\n");
+            Base::mobile_control();
         } catch (Exception $ex) {
             echo $ex->getTraceAsString();
         }

+ 0 - 2
fooder.php

@@ -8,7 +8,6 @@ define('BASE_MOBILE_PATH',BASE_ROOT_PATH.'/mobile');
 define('BASE_CRONTAB_PATH',BASE_ROOT_PATH.'/crontab');
 define('BASE_UPLOAD_PATH',BASE_DATA_PATH.'/upload');
 
-
 require_once(BASE_MOBILE_PATH . '/util/errcode.php');
 require_once(BASE_ROOT_PATH . '/request_helper.php');
 require_once(BASE_ROOT_PATH . '/global.php');
@@ -31,7 +30,6 @@ require_once(BASE_CORE_PATH.'/framework/function/goods.php');
 require_once(BASE_CORE_PATH . '/framework/libraries/validate.php');
 require_once(BASE_CORE_PATH.'/framework/libraries/resizeimage.php');
 
-//$config = config_init();
 
 define('OS_TYPE','MAC');
 //define('OS_TYPE','LINUX');

+ 1 - 1
mobile/index.php

@@ -13,4 +13,4 @@ define('BASE_PATH',str_replace('\\','/',dirname(__FILE__)));
 require_once (BASE_PATH.'/framework/function/function.php');
 require_once (BASE_PATH.'/control/control.php');
 
-Base::run();
+//Base::run();