|
@@ -13,8 +13,8 @@ defined('InShopNC') or exit('Access Invalid!');
|
|
|
class mobileControl
|
|
|
{
|
|
|
//客户端类型
|
|
|
- protected $client_type_array = array('android', 'wap', 'wechat', 'ios','ajax','web');
|
|
|
-
|
|
|
+ protected $client_type_array = array('android', 'wap', 'wechat', 'ios', 'ajax', 'web');
|
|
|
+
|
|
|
//列表默认分页数
|
|
|
//protected $page_size = 5;
|
|
|
protected $page = 5;
|
|
@@ -39,101 +39,109 @@ class mobileControl
|
|
|
$this->check_app_type();
|
|
|
}
|
|
|
|
|
|
- protected function page_size() {
|
|
|
+ protected function page_size()
|
|
|
+ {
|
|
|
return $this->page;
|
|
|
}
|
|
|
- protected function page_no() {
|
|
|
+
|
|
|
+ protected function page_no()
|
|
|
+ {
|
|
|
return $this->cur_page;
|
|
|
}
|
|
|
|
|
|
- private static function eclipse_time() {
|
|
|
+ private static function eclipse_time()
|
|
|
+ {
|
|
|
return (microtime(true) - self::$startime);
|
|
|
}
|
|
|
|
|
|
protected function check_app_type()
|
|
|
{
|
|
|
+ Log::record(">>>>>> check_app_type={$_SERVER['HTTP_CLIENT_TYPE']}",Log::DEBUG);
|
|
|
$client = strtolower(trim($_SERVER['HTTP_CLIENT_TYPE']));
|
|
|
$version = trim($_SERVER['HTTP_CLIENT_VERSION']);
|
|
|
|
|
|
- if(empty($client)) {
|
|
|
+ if (empty($client)) {
|
|
|
$client = $_POST['client_type'];
|
|
|
}
|
|
|
|
|
|
- if (empty($client)|| !in_array($client, $this->client_type_array)) {
|
|
|
+ if (empty($client) || !in_array($client, $this->client_type_array)) {
|
|
|
$_SESSION['client_type'] = 'wap';
|
|
|
} else {
|
|
|
$_SESSION['client_type'] = $client;
|
|
|
}
|
|
|
|
|
|
- if(!empty($version)) {
|
|
|
+ Log::record(">>>>>> client_type={$_SESSION['client_type']}",Log::DEBUG);
|
|
|
+ if (!empty($version)) {
|
|
|
$_SESSION['client_version'] = $version;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- static public function outerr($code,$msg = '',$page = '')
|
|
|
+ static public function outerr($code, $msg = '', $page = '')
|
|
|
{
|
|
|
- static $json_clients = array('android', 'ios','ajax');
|
|
|
- if(in_array($_SESSION['client_type'],$json_clients)) {
|
|
|
- joutput_error($code,$msg);
|
|
|
- }
|
|
|
- else if($_SESSION['client_type'] == 'wap')
|
|
|
- {
|
|
|
- Tpl::output("error",$msg);
|
|
|
- if(!empty($page)) {
|
|
|
+ static $json_clients = array('android', 'ios');//, 'ajax');
|
|
|
+ Log::record(">>>>>> outerr, client_type={$_SESSION['client_type']}",Log::DEBUG);
|
|
|
+
|
|
|
+ if (in_array($_SESSION['client_type'], $json_clients)) {
|
|
|
+ Log::record(">>>>>> outerr, 1",Log::DEBUG);
|
|
|
+ joutput_error($code, $msg);
|
|
|
+ } else if ($_SESSION['client_type'] == 'wap') {
|
|
|
+ Tpl::output("error", $msg);
|
|
|
+ if (!empty($page)) {
|
|
|
TPL::showpage($page);
|
|
|
}
|
|
|
}
|
|
|
+ else if ($_SESSION['client_type'] == 'ajax') {
|
|
|
+ echo "callback(";
|
|
|
+ joutput_error($code, $msg);
|
|
|
+ echo ")";
|
|
|
+ }
|
|
|
else {
|
|
|
if(empty($msg)) {
|
|
|
$msg = errcode::msg($code);
|
|
|
}
|
|
|
- echo joutput_error($code,$msg,'web') . "<br/>";
|
|
|
+ echo joutput_error($code, $msg, 'web') . "<br/>";
|
|
|
echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
|
|
|
echo "性能关键统计:<br/><br/>";
|
|
|
performance_helper::format_log();
|
|
|
|
|
|
$sqls = Log::sql_log();
|
|
|
echo "sql count = " . count($sqls) . "<br/><br/>";
|
|
|
- foreach($sqls as $sql) {
|
|
|
+ foreach ($sqls as $sql) {
|
|
|
echo "{$sql}<br/>";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- static public function outsuccess($data,$page = '')
|
|
|
+
|
|
|
+ static public function outsuccess($data, $page = '')
|
|
|
{
|
|
|
static $json_clients = array('android', 'ios'); //,'ajax'
|
|
|
- if(in_array($_SESSION['client_type'],$json_clients)) {
|
|
|
+ if (in_array($_SESSION['client_type'], $json_clients)) {
|
|
|
joutput_data($data);
|
|
|
- }
|
|
|
- else if($_SESSION['client_type'] == 'wap')
|
|
|
- {
|
|
|
- if(is_array($data)) {
|
|
|
- foreach($data as $key => $val) {
|
|
|
- TPL::output($key,$val);
|
|
|
+ } else if ($_SESSION['client_type'] == 'wap') {
|
|
|
+ if (is_array($data)) {
|
|
|
+ foreach ($data as $key => $val) {
|
|
|
+ TPL::output($key, $val);
|
|
|
}
|
|
|
}
|
|
|
- if(!empty($page)) {
|
|
|
+ if (!empty($page)) {
|
|
|
TPL::showpage($page);
|
|
|
}
|
|
|
- }
|
|
|
- else if($_SESSION['client_type'] == 'ajax') {
|
|
|
+ } else if ($_SESSION['client_type'] == 'ajax') {
|
|
|
echo "callback(";
|
|
|
joutput_data($data);
|
|
|
echo ")";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
echo 'success: return data=<br/>';
|
|
|
- joutput_data($data,'web');
|
|
|
+ joutput_data($data, 'web');
|
|
|
echo "<br/><br/>";
|
|
|
echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
|
|
|
echo "性能关键统计:<br/><br/>";
|
|
|
performance_helper::format_log();
|
|
|
$sqls = Log::sql_log();
|
|
|
echo "sql count = " . count($sqls) . "<br/><br/>";
|
|
|
- foreach($sqls as $sql) {
|
|
|
+ foreach ($sqls as $sql) {
|
|
|
echo "{$sql}<br/>";
|
|
|
}
|
|
|
}
|
|
@@ -167,7 +175,7 @@ class mbMemberControl extends mobileControl
|
|
|
{
|
|
|
parent::__construct();
|
|
|
|
|
|
- if($_SESSION['is_login'] != 1) {
|
|
|
+ if ($_SESSION['is_login'] != 1) {
|
|
|
throw new UnloginException();
|
|
|
}
|
|
|
}
|