3 if(!isset($_GET['token']) ) { //&& !isset($_GET['unread'])) {
5 } else if(isset($_GET['token'])) {
6 $deviceToks = $_GET['token'];
7 //$unread = $_GET['unread'];
11 $cookie_val = $_COOKIE['DMDM'];
12 $cookie_val2 = $_COOKIE['MDMD'];
16 'header'=>"Accept-language: en\r\n" .
17 "Cookie: DMDM=" . $cookie_val . "\r\n" .
18 "Cookie: MDMD=" . $cookie_val2
21 $context = stream_context_create($opts);
23 include('../encrypt.php');
24 $email = Decrypt($_COOKIE['DMDM'],KEY);
26 //$gotemail = file_get_contents('http://be.2ch.net/mb/ur.php', TRUE , $context);
29 $gotmessage = file_get_contents('https://be.2ch.net/mb/noti.php?un='.$email, FALSE , $context);
31 if($gotmessage >= 1) {
33 $deviceToken = $deviceToks;
34 // Put your device token here (without spaces):
35 //$deviceToken = str_replace(' ','', $deviceToks);
37 // Put your private key's passphrase here:
38 $passphrase = 'rqibemessenger';
40 // Put your alert message here:
42 /*if(!empty($unread)){
43 $countmessage = $unread . " unread messages!";
50 $message = 'あなたはBEmessengerから新しいメッセージを得た! ' . $countmessage ;
52 ////////////////////////////////////////////////////////////////////////////////
54 $ctx = stream_context_create();
56 //DISABLED THIS WHEN APP STORE AVAIL
57 stream_context_set_option($ctx, 'ssl', 'local_cert', '/home/auth/secure_html/ckDEV.pem');
59 //ENABLED THIS WHEN APP STORE AVAIL
60 //stream_context_set_option($ctx, 'ssl', 'local_cert', '/home/auth/secure_html/ckDis.pem');
63 stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
65 // Open a connection to the APNS server
66 $fp = stream_socket_client(
67 'ssl://gateway.sandbox.push.apple.com:2195', $err,
68 $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
71 exit("Failed to connect: $err $errstr" . PHP_EOL);
73 echo 'Connected to APNS' . PHP_EOL;
75 // Create the payload body
81 // Encode the payload as JSON
82 $payload = json_encode($body);
84 // Build the binary notification
85 $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
87 // Send it to the server
88 $result = fwrite($fp, $msg, strlen($msg));
91 echo 'Message not delivered' . PHP_EOL;
93 echo 'Message successfully delivered' . PHP_EOL;
95 // Close the connection to the server