modified 优化用户体验,完善JPush逻辑漏洞

This commit is contained in:
zhaoxiang 2017-04-18 13:22:15 +08:00
parent d5c62f945e
commit 2bb4110990
3 changed files with 35 additions and 27 deletions

View File

@ -22,7 +22,7 @@
<tr>
<td>{$i}</td>
<td>{$vo['apiName']}</td>
<td>{$vo['hash']}</td>
<td><a style="color: #01AAED;" target="_blank" href="{:U('/wiki/'.$vo['hash'])}">{$vo['hash']}</a></td>
<td>
<if condition="$vo['status']">
<span style="border-radius: 2px;background-color: #5FB878;padding:5px 10px;color: #ffffff">生效</span>

View File

@ -9,12 +9,13 @@ namespace Home\ORG;
class ApiLog {
private static $appInfo = null;
private static $apiInfo = null;
private static $request = null;
private static $requestAfterFilter = null;
private static $response = null;
private static $header = null;
private static $appInfo = 'null';
private static $apiInfo = 'null';
private static $request = 'null';
private static $requestAfterFilter = 'null';
private static $response = 'null';
private static $header = 'null';
private static $userInfo = 'null';
public static function setAppInfo($data) {
self::$appInfo = $data['app_id'] . "({$data['app_name']}) {$data['device_id']}";
@ -30,6 +31,13 @@ class ApiLog {
self::$apiInfo = $data['apiName'] . ' ' . $data['hash'];
}
public static function setUserInfo($data) {
if (is_array($data)) {
$data = json_encode($data);
}
self::$userInfo = $data;
}
public static function setRequest($data) {
if (is_array($data)) {
$data = json_encode($data);
@ -54,7 +62,7 @@ class ApiLog {
public static function save() {
$logPath = APP_PATH . '/ApiLog/' . date('YmdH') . '.log';
$logStr = self::$apiInfo . ' ' . date('H:i:s') . ' ' . self::$request . ' ' . self::$header . ' '
. self::$response . ' ' . self::$requestAfterFilter . ' ' . self::$appInfo."\n";
. self::$response . ' ' . self::$requestAfterFilter . ' ' . self::$appInfo.' '.self::$userInfo."\n";
@file_put_contents($logPath, $logStr, FILE_APPEND);
}

View File

@ -221,9 +221,11 @@ class Push {
* @author zhaoxiang <zhaoxiang051405@gmail.com>
* @return $this
*/
public function iosNotification($alert, $notification = array()) {
public function iosNotification($alert = null, $notification = array()) {
$ios = array();
$ios['alert'] = (is_string($alert) || is_array($alert)) ? $alert : '';
if (!is_null($alert)) {
$ios['alert'] = (is_string($alert) || is_array($alert)) ? $alert : '';
}
if (!empty($notification)) {
if (isset($notification['sound']) && is_string($notification['sound'])) {
$ios['sound'] = $notification['sound'];
@ -262,9 +264,11 @@ class Push {
* @author zhaoxiang <zhaoxiang051405@gmail.com>
* @return $this
*/
public function androidNotification($alert, array $notification = array()) {
public function androidNotification($alert = null, array $notification = array()) {
$android = array();
$android['alert'] = is_string($alert) ? $alert : '';
if (!is_null($alert)) {
$android['alert'] = is_string($alert) ? $alert : '';
}
if (!empty($notification)) {
if (isset($notification['title']) && is_string($notification['title'])) {
$android['title'] = $notification['title'];
@ -394,43 +398,39 @@ class Push {
if (is_null($this->androidNotification['alert'])) {
if (is_null($this->notificationAlert)) {
Response::error(ReturnCode::EXCEPTION, 'Android alert can not be null');
} else {
$notification['android']['alert'] = $this->notificationAlert;
}
}
} else {
if (!is_null($this->extras)) {
$notification['android']['extras'] = $this->extras;
} else {
$notification['android']['alert'] = $this->androidNotification['alert'];
}
}
if (!is_null($this->extras)) {
$notification['android']['extras'] = $this->extras;
}
if (!is_null($this->iosNotification)) {
$notification['ios'] = $this->iosNotification;
if (is_null($this->iosNotification['alert'])) {
if (is_null($this->notificationAlert)) {
Response::error(ReturnCode::EXCEPTION, 'iOS alert can not be null');
} else {
$notification['ios']['alert'] = $this->notificationAlert;
}
} else {
$notification['ios']['alert'] = $this->iosNotification['alert'];
}
} else {
if (!is_null($this->extras)) {
$notification['ios']['extras'] = $this->extras;
}
}
if (!is_null($this->extras)) {
$notification['ios']['extras'] = $this->extras;
}
if (count($notification) > 0) {
$payload['notification'] = $notification;
}
if (count($this->message) > 0) {
$payload['message'] = $this->message;
}
if (!array_key_exists('notification', $payload) && !array_key_exists('message', $payload)) {
Response::error(ReturnCode::EXCEPTION, 'notification and message can not all be null');
}
if (!is_null($this->options)) {
$payload['options'] = $this->options;
}