/** * 通知(JSON) */ public function pushJson($argDeviceIdentifier, $argDeviceType, $argments) { $this->_init(); $newEndpoint = NULL; $deviceEndpoint = $argDeviceIdentifier; logging('endpoint=' . $deviceEndpoint, 'push'); if (FALSE === strpos('arn:aws:sns:', $argDeviceIdentifier)) { // エンドポイント指定では無いので、先ずはAESにEndpoint登録をする logging('create endpoint:' . $deviceEndpoint . ':' . $argDeviceType, 'push'); $res = $this->createPlatformEndpoint($argDeviceIdentifier, $argDeviceType); logging('pushJson for create endpoint res=', 'push'); logging($res, 'push'); if (FALSE !== $res) { $newEndpoint = $res['EndpointArn']; $deviceEndpoint = $newEndpoint; } } try { $targetPratform = 'APNS_SANDBOX'; if (TRUE !== isTest() && TRUE === ('iOS' === $argDeviceType || 'iPhone' === $argDeviceType || 'iPad' === $argDeviceType || 'iPod' === $argDeviceType)) { // 本番用のiOSPush通知 $targetPratform = 'APNS'; } else { // Android用はココ! } $json = array('MessageStructure' => 'json', 'TargetArn' => trim($deviceEndpoint)); $json['Message'] = json_encode(array($targetPratform => json_encode(array('aps' => $argments)))); logging($json, 'push'); $res = $this->_AWS->publish($json); } catch (Exception $e) { logging($e->__toString(), 'push'); return FALSE; } if (!is_array($res)) { $res = array('res' => $res); } if (NULL !== $newEndpoint) { $res['endpoint'] = $newEndpoint; } return $res; }
/** * 現在設定されているデバッグモードフラグを返す */ function getDebugEnabled($argProjectName = NULL, $argHost = NULL) { static $enabled = NULL; if (NULL === $enabled || !isset($enabled[$argProjectName])) { $debugEnabled = 0; $enabled = array(); if (TRUE === isTest(FALSE, $argProjectName, $argHost)) { $debugEnabled = 1; } else { if (NULL !== $argProjectName) { $debugEnabledFilepath = dirname(dirname(dirname(__FILE__))) . '/' . $argProjectName . '/.debug'; if (TRUE !== is_file($debugEnabledFilepath)) { $debugEnabledFilepath = dirname(dirname(dirname(__FILE__))) . '/' . $argProjectName . 'Package/.debug'; } } elseif (NULL !== defined('PROJECT_NAME')) { // 併設されている事を前提とする! $debugEnabledFilepath = dirname(dirname(dirname(__FILE__))) . '/' . PROJECT_NAME . '/.debug'; if (TRUE !== is_file($debugEnabledFilepath)) { $debugEnabledFilepath = dirname(dirname(dirname(__FILE__))) . '/' . PROJECT_NAME . 'Package/.debug'; } } else { $corefilename = corefilename(); $debugEnabledFilepath = dirname(dirname(__FILE__)) . '/.debug'; if (defined($corefilename . '_DEBUG_MODE_ENABLED')) { $debugEnabledFilepath = constant($corefilename . '_DEBUG_MODE_ENABLED'); } } if (isset($debugEnabledFilepath)) { // フラグファイルからフラグをセット $debugEnabled = 0; if (file_exists($debugEnabledFilepath)) { $debugEnabled = 1; } } // 一応$_SERVERを探す if (isset($_SERVER['debug_mode']) && 1 === (int) $_SERVER['debug_mode']) { // $_SERVERが最強 $_SERVERがあれば$_SERVERに必ず従う $debugEnabled = 1; } else { if (isset($_SERVER['debugmode']) && 1 === (int) $_SERVER['debugmode']) { $debugEnabled = 1; } } if (NULL === $debugEnabled) { // フラグ設定が見つからなかったのでdisabledで設定 $debugEnabled = 0; } } $enabled[$argProjectName] = $debugEnabled; } return $enabled[$argProjectName]; }