浏览代码

merge control

stanley-king 9 年之前
父节点
当前提交
e5106e1471
共有 4 个文件被更改,包括 89 次插入73 次删除
  1. 0 7
      fcgi_run.php
  2. 42 28
      helper/umeng.php
  3. 44 36
      mobile/control/control.php
  4. 3 2
      mobile/control/test.php

+ 0 - 7
fcgi_run.php

@@ -10,13 +10,6 @@ require_once (BASE_ROOT_PATH . '/helper/func.php');
 require_once (BASE_ROOT_PATH . '/helper/exceptionex.php');
 require_once (BASE_ROOT_PATH . '/helper/fcgi_server.php');
 
-
 fcgi_server::instance()->run_looper();
 
-//function run_server()
-//{
-//    fcgi_server::instance()->run_looper();
-//}
-//
-//run_server();
 ?>

+ 42 - 28
helper/umeng.php

@@ -6,7 +6,6 @@
  * Date: 2016/4/15
  * Time: 16:27
  */
-
 // 发送类型,安卓还是ios
 class platform_type extends SplEnum
 {
@@ -62,13 +61,21 @@ class upush
     const APPKEY = "5631efd4e0f55a8770000027";
 
     private $platform;
-
     private $type;
     private $alias_type;
     private $alias;
+
+    // 个人信息
+    private $devices_token;
+
+    // 通知展示内容
     private $ticker;
     private $title;
     private $text;
+    private $icon;
+    private $largeIcon;
+    private $img;
+    private $sound;
 
     public function __construct()
     {
@@ -79,6 +86,22 @@ class upush
         $text = "text";
     }
 
+    // 设置属性
+    private function __set($property_name, $value)
+    {
+        $this->$property_name = $value;
+    }
+
+    // 获取属性
+    private function __get($property_name)
+    {
+        if (isset($this->$property_name)) {
+            return ($this->$property_name);
+        } else {
+            return (NULL);
+        }
+    }
+
     /**
      * post发送数据
      *
@@ -122,7 +145,7 @@ class upush
     private function android_pack()
     {
         $pack = array();
-        $pack['appkey'] = "5631efd4e0f55a8770000027";
+        $pack['appkey'] = self::APPKEY;
         $pack['timestamp'] = time();
         $pack['type'] = msg_type::unicast;
         $pack['device_tokens'] = "Aj9AympPsCha5zmPhrV0DbnOZJYF0pqKY5jdKvFy_Hbu";
@@ -132,13 +155,13 @@ class upush
         $pack['filter'] = "";
         $payload = array();
         $body = array();
-        $body['ticker'] = "通知栏提示文字";
-        $body['title'] = "通知图标";
-        $body['text'] = "通知文字描述";
-        $body['icon'] = "";
-        $body['largeIcon'] = "";
-        $body['img'] = "";
-        $body['sound'] = "";
+        $body['ticker'] = $this->ticker;
+        $body['title'] = $this->title;
+        $body['text'] = $this->text;
+        $body['icon'] = $this->icon;
+        $body['largeIcon'] = $this->largeIcon;
+        $body['img'] = $this->img;
+        $body['sound'] = $this->sound;
         $body['builder_id'] = "";
         $body['play_vibrate'] = "true";
         $body['play_lights'] = "true";
@@ -172,31 +195,22 @@ class upush
         return $pack;
     }
 
-    // ios 打包
-    private function ios_pack()
-    {
-    }
-
-//    private function make_sign(){
-//
-//        return strtolower(md5(self::METHOD.self::PUSH_URL.json_encode(self::android_pack()).self::APP_MASTER_SECRET));
-//        return strtolower(md5($http_method . $url . json_encode($post_body) . $app_master_secret));
-//    }
-
-    // android 推送
-//    public function android_push()
-//    {
-////        $sign = strtolower(md5(self::METHOD.self::PUSH_URL.self::android_pack().self::APP_MASTER_SECRET,false));
-//        return $this->http_post_data(self::PUSH_URL.'?sign='.$this->make_sign(), json_encode(self::android_pack()));
-//    }
-
     // ios 推送
     public function android_push()
     {
         $pack_body = self::android_pack();
         $url = self::PUSH_URL . '?sign=' . self::make_sign("POST", self::PUSH_URL, $pack_body, self::APP_MASTER_SECRET);
         return $this->http_post_data($url, json_encode($pack_body));
+    }
+
+    // ios 打包
+    private function ios_pack()
+    {
+    }
 
+    // ios 推送
+    public function ios_push()
+    {
     }
 
 }

+ 44 - 36
mobile/control/control.php

@@ -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();
         }
     }

+ 3 - 2
mobile/control/test.php

@@ -63,9 +63,10 @@ class testControl extends mobileHomeControl
         }
     }
 
-    public function upushOp(){
-
+    public function upushOp()
+    {
         $push = new upush();
+        $push->ticker = 'ticker';
         list($ret_code, $ret_content) = $push->android_push();
 
         $return_info = json_decode($ret_content);