6 if(!isset($_GET['token']) ) { //&& !isset($_GET['unread'])) {
8 } else if(isset($_GET['token'])) {
9 //$deviceToks = $_GET['token'];
10 $deviceToks = filter_var($_GET['token'], FILTER_SANITIZE_STRING
, FILTER_FLAG_STRIP_LOW
);
11 //$unread = $_GET['unread'];
15 $cookie_val = $_COOKIE['DMDM'];
16 $cookie_val2 = $_COOKIE['MDMD'];
20 'header'=>"Accept-language: en\r\n" .
21 "Cookie: DMDM=" . $cookie_val . "\r\n" .
22 "Cookie: MDMD=" . $cookie_val2
25 $context = stream_context_create($opts);
27 include('../encrypt.php');
28 $email = Decrypt($_COOKIE['DMDM'],KEY
);
30 //$gotemail = file_get_contents('http://be.2ch.net/mb/ur.php', TRUE , $context);
33 $gotmessage = file_get_contents('https://be.2ch.net/mb/noti.php?un='.$email, FALSE , $context);
35 if($gotmessage >= 1) {
37 $deviceToken = $deviceToks;
38 // Put your device token here (without spaces):
39 //$deviceToken = str_replace(' ','', $deviceToks);
41 // Put your private key's passphrase here:
42 $passphrase = 'rqibemessenger';
44 // Put your alert message here:
46 /*if(!empty($unread)){
47 $countmessage = $unread . " unread messages!";
54 $message = 'あなたはBEmessengerから新しいメッセージを得た! ' . $countmessage ;
56 ////////////////////////////////////////////////////////////////////////////////
58 $ctx = stream_context_create();
60 //DISABLED THIS WHEN APP STORE AVAIL
61 stream_context_set_option($ctx, 'ssl', 'local_cert', '/home/auth/secure_html/ckDEV.pem');
63 //ENABLED THIS WHEN APP STORE AVAIL
64 // stream_context_set_option($ctx, 'ssl', 'local_cert', '/home/auth/secure_html/ckDis.pem');
67 stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
69 // Open a connection to the APNS server
70 $fp = stream_socket_client(
71 'ssl://gateway.sandbox.push.apple.com:2195', $err,
72 $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT
, $ctx);
75 exit("Failed to connect: $err $errstr" . PHP_EOL
);
77 echo 'Connected to APNS' . PHP_EOL
;
79 // Create the payload body
85 // Encode the payload as JSON
86 $payload = json_encode($body);
88 // Build the binary notification
89 $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
91 // Send it to the server
92 $result = fwrite($fp, $msg, strlen($msg));
95 echo 'Message not delivered' . PHP_EOL
;
97 echo 'Message successfully delivered' . PHP_EOL
;
99 // Close the connection to the server