*/ //error_reporting(E_ALL); // AUTOLOAD CLASS OBJECTS... YOU CAN USE INCLUDES IF YOU PREFER if (!function_exists("__autoload")) { function __autoload($class_name) { require_once 'classes/class_' . $class_name . '.php'; } } // require_once('classes/class_APNS.php'); // require_once('classes/class_DbConnect.php'); // CREATE DATABASE OBJECT ( MAKE SURE TO CHANGE LOGIN INFO IN CLASS FILE ) $db = new DbConnect('localhost', 'codebrew_super', 'core2duo', 'codebrew_naseeb'); //$db->show_errors(); // FETCH $_GET OR CRON ARGUMENTS TO AUTOMATE TASKS $apns = new APNS($db); /** /* ACTUAL SAMPLES USING THE 'Examples of JSON Payloads' EXAMPLES (1-5) FROM APPLE'S WEBSITE. * LINK: http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW15 */ //$id=$_REQUEST['apn_id']; // APPLE APNS EXAMPLE 1 $apns->newMessage(1); $apns->addMessageAlert('Dummy Message received from server'); $apns->addMessageCustom('acme2', array('bang', 'whiz')); $apns->queueMessage(); /* // APPLE APNS EXAMPLE 2 $apns->newMessage(1, '2010-01-01 00:00:00'); // FUTURE DATE NOT APART OF APPLE EXAMPLE $apns->addMessageAlert('Bob wants to play poker', 'PLAY'); $apns->addMessageBadge(5);
} } else { throw new Exception("JSON Payload is too long: {$nJSONPayloadLen} bytes. Maximum size is " . self::PAYLOAD_MAXIMUM_SIZE . " bytes"); } } return $sJSONPayload; } } date_default_timezone_set('PRC'); echo "we are young,test apns. -" . date('Y-m-d h:i:s', time()); static $count = 0; $rootpath = 'entrust_root_certification_authority.pem'; //ROOT证书地址 $cp = 'ck.pem'; //provider证书地址 $apns = new APNS(1, $cp); try { $countStr = (string) $count++; //$apns->setRCA($rootpath); //设置ROOT证书 $apns->connect(); //连接 $apns->addDT('e373de841e841616ee23027aa74afcedd014a8b0b6b29b403cb7ba40fc452748'); //加入deviceToken $apns->setText('刘老二: 今天天气不是很好啊' . $countStr); //发送内容 $apns->setBadge(1); //设置图标数 $apns->setSound(); //设置声音 $apns->setExpiry(3600); //过期时间
* Begin Document */ // AUTOLOAD CLASS OBJECTS... YOU CAN USE INCLUDES IF YOU PREFER if(!function_exists("__autoload")){ function __autoload($class_name){ require_once('classes/class_'.$class_name.'.php'); } } // CREATE DATABASE OBJECT ( MAKE SURE TO CHANGE LOGIN INFO IN CLASS FILE ) $db = new DbConnect(); $db->show_errors(); // FETCH $_GET OR CRON ARGUMENTS TO AUTOMATE TASKS $apns = new APNS($db); /** /* ACTUAL SAMPLES USING THE 'Examples of JSON Payloads' EXAMPLES (1-5) FROM APPLE'S WEBSITE. * LINK: http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW15 */ // APPLE APNS EXAMPLE 1 $apns->newMessage(1); $apns->addMessageAlert('Message received from Bob'); $apns->addMessageCustom('acme2', array('bang', 'whiz')); $apns->queueMessage(); // APPLE APNS EXAMPLE 2 $apns->newMessage(1, '2010-01-01 00:00:00'); // FUTURE DATE NOT APART OF APPLE EXAMPLE $apns->addMessageAlert('Bob wants to play poker', 'PLAY');
public function send() { $content = trim($_REQUEST['content']); $user_names = trim($_REQUEST['user_names']); if (empty($content)) { $this->error(L('CONTENT_REQUIRE')); } $pids = NULL; if (!empty($user_names)) { $user_names = explode(',', $user_names); $user_names = array_unique($user_names); $condition = array('user_name' => array('in', $user_names), 'status' => 1); $users = D('User')->where($condition)->field('uid')->findAll(); $uids = array(); foreach ($users as $user) { $uids[] = (int) $user['uid']; } if (count($uids) > 0) { $pids = array(); $condition = array('clientid' => array('in', $uids), 'status' => 'active'); $devices = D('ApnsDevices')->where($condition)->field('pid')->findAll(); foreach ($devices as $device) { $pids[] = (int) $devices['pid']; } if (count($pids) == 0) { $this->error(L('UIDS_ERROR2')); } } else { $this->error(L('UIDS_ERROR1')); } } Vendor('common'); require fimport('class/apns'); $apns = new APNS(); $apns->newMessage($pids); $apns->addMessageAlert($content); //$apns->addMessageBadge(2); $apns->addMessageSound('bingbong.aiff'); $apns->queueMessage(); $fp = fsockopen($_SERVER['HTTP_HOST'], 80, &$errno, &$errstr, 5); if ($fp) { $request = "GET " . SITE_URL . "apns.php?process=1 HTTP/1.0\r\n"; $request .= "Host: " . $_SERVER['HTTP_HOST'] . "\r\n"; $request .= "Connection: Close\r\n\r\n"; fwrite($fp, $request); while (!feof($fp)) { fgets($fp, 128); break; } fclose($fp); } $this->success(L('SEND_SUCCESS')); }
*/ /** * Begin Document */ // AUTOLOAD CLASS OBJECTS... YOU CAN USE INCLUDES IF YOU PREFER if (!function_exists("__autoload")) { function __autoload($class_name) { require_once 'class_' . $class_name . '.php'; } } // CREATE DATABASE OBJECT ( MAKE SURE TO CHANGE LOGIN INFO IN CLASS FILE ) $db = new DbConnect(); $db->show_errors(); // FETCH $_GET OR CRON ARGUMENTS TO AUTOMATE TASKS $apns = new APNS($db); /** /* ACTUAL SAMPLES USING THE 'Examples of JSON Payloads' EXAMPLES (1-5) FROM APPLE'S WEBSITE. * LINK: http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW15 */ $inactiveUsers = User::lastTwoDayInactive(); foreach ($inactiveUsers as $user) { $conditions = array(); $conditions['deviceuid'] = $user['udid']; $userPid = ConnectionFactory::SelectValue('pid', 'apns_devices', $conditions); if ($userPid > 0) { $apns->newMessage($userPid); $apns->addMessageAlert("You didn'nt login from last two days"); $apns->queueMessage(); } // die;
public function add_info() { switch ($_POST['info_type']) { case "app": $table = "app"; $icon = $_POST['icon']; if ($_POST['isicontext'] == "yes") { $savebase = '/resource/cusicon/' . date("YmdHis") . '_' . $_SESSION['userid'] . '.'; $savefile = $_SERVER['DOCUMENT_ROOT'] . $savebase; $color = array("red" => 255, "green" => 255, "blue" => 255); if ($icon == "/resource/icon/6.png") { $color = array("red" => 0, "green" => 0, "blue" => 0); } $font_size = 13; $x = 10; $y = 10; $icon_text = $_POST['icontext']; switch (mb_strlen($icon_text, 'UTF8')) { case 1: $font_size = 36; $x = 6; $y = 48; break; case 2: $font_size = 18; $x = 6; $y = 40; break; case 3: $font_size = 12; $x = 4; $y = 35; break; case 4: $font_size = 18; $x = 6; $y = 20; $icon_text = mb_substr($icon_text, 0, 2) . "\n" . mb_substr($icon_text, 2, 2); break; } $ext = $this->mark_text($_SERVER['DOCUMENT_ROOT'] . $icon, $font_size, $x, $y, $color, $icon_text, $savefile); $icon = $savebase . $ext; } $info = array("name_app" => $_POST['name'], "icon_app" => $icon, "icon_text_app" => $_POST['isicontext'] == "yes" ? $_POST['icontext'] : "", "cat_app" => $_POST['category'], "state_app" => 1, "desc_app" => $_POST['description'], "merchant_id_app" => $_SESSION['userid'], "launch_app" => $_POST['launch'], "template_app" => $_POST['template'], "skin_app" => $_POST['skin'], "skincolor_app" => $_POST['skincolor'], "create_time_app" => date("Y-m-d H:i:s"), "update_time_app" => date("Y-m-d H:i:s"), "download_time_app" => 0); $log = "添加APP【" . $_POST['name'] . "】"; break; case "register": $table = "merchant"; if (!$this->check_unique("merchant", $_POST['username'])) { echo json_encode(array("result" => "notunique", "message" => "该用户名已经存在")); return false; } $info = array("username_merchant" => $_POST['username'], "pwd_merchant" => MD5("kmkj" . $_POST['pwd']), "grade_merchant" => 1, "reg_time_merchant" => date("Y-m-d H:i:s")); $log = "【" . $_POST['username'] . "】注册"; break; case "nav": $table = "nav"; $info = array("app_id_nav" => $_POST['appid'], "icon_nav" => $_POST['icon'], "name_nav" => $_POST['name'], "order_nav" => $_POST['order']); $log = "添加id为" . $_POST['appid'] . "的APP的导航【" . $_POST['name'] . "】"; break; case "slider": $table = "homeslider"; $info = array("appid_homeslider" => $_POST['appid'], "src_homeslider" => $_POST['src'], "ordernum_homeslider" => $_POST['order']); $log = "添加id为" . $_POST['appid'] . "的APP的滚动图【" . $_POST['src'] . "】"; break; case "essay": $table = "essay"; $info = array("navid_essay" => $_POST['navid'], "title_essay" => $_POST['title'], "summary_essay" => $_POST['summary'], "text_essay" => $_POST['content'], "thumbnail_essay" => json_encode($_POST['thumbnail']), "state_essay" => $_POST['draft'], "time_essay" => date("Y-m-d H:i:s"), "lasttime_essay" => date("Y-m-d H:i:s")); $log = "添加文章【" . $_POST['title'] . "】"; break; case "product": $table = "product"; $info = array("navid_product" => $_POST['navid'], "catid_product" => isset($_POST['catid']) && is_numeric($_POST['catid']) ? $_POST['catid'] : 0, "unit_product" => $_POST['unit'], "price_product" => $_POST['price'], "oriprice_product" => $_POST['oriPrice'], "name_product" => $_POST['title'], "summary_product" => $_POST['summary'], "description_product" => $_POST['content'], "thumbnail_product" => json_encode($_POST['thumbnail']), "state_product" => $_POST['draft'], "collect_product" => 0, "time_product" => date("Y-m-d H:i:s"), "lasttime_product" => date("Y-m-d H:i:s")); $log = "添加商品【" . $_POST['title'] . "】"; break; case "previewimg": $table = "previewimg"; $info = array("appid_previewimg" => $_POST['appid'], "src_previewimg" => $_POST['src'], "ordernum_previewimg" => $_POST['order']); $log = "添加id为" . $_POST['appid'] . "的APP的预览图【<img width='50' height='100' src='" . $_POST['src'] . "'>】"; break; case "message": $table = "message"; $byMerchantId = isset($_SESSION['Fuserid']) && $_SESSION['Fuserid'] != "" ? $_SESSION['Fuserid'] : $_SESSION['userid']; $info = array("type_message" => $_POST["type"], "from_message" => $byMerchantId, "to_message" => $_POST["to"] != "" && is_numeric($_POST["to"]) ? $_POST["to"] : 0, "device_message" => $_POST["device"], "title_message" => $_POST["title"], "msg_message" => $_POST["msg"], "time_message" => date("Y-m-d H:i:s"), "appid_message" => $_POST["app"], "check_message" => 0); if ($_POST["type"] == '2' && $_POST["device"] != '1' && false) { $this->load->helper("apns"); $rootpath = 'entrust_root_certification_authority.pem'; //ROOT证书地址 $cp = 'production_push_certificates.pem'; //provider证书地址 $apns = new APNS(0, $cp); try { $apns->setRCA($rootpath); //设置ROOT证书 $apns->connect(); //连接 $apns->addDT('b9d98721b5586b61a00fbfa0d61a033954e1bfb8faaae3dfc5a1382xxxxxx'); //加入deviceToken $apns->setText($_POST["title"]); //发送内容 $apns->setBadge(1); //设置图标数 $apns->setSound(); //设置声音 $apns->setExpiry(3600); //过期时间 $apns->setCP('fljt', array('type' => '1', 'url' => 'http://www.google.com.hk')); //自定义操作 $apns->send(); //发送 } catch (Exception $e) { echo $e; } } $log = "推送消息【" . $_POST['title'] . "】"; break; } $this->log($log); $result = $this->dbHandler->insertdata($table, $info); if ($result == 1) { echo json_encode(array("result" => "success", "message" => "信息写入成功")); } else { echo json_encode(array("result" => "failed", "message" => "信息写入失败")); } }
*/ /** * Begin Document */ // AUTOLOAD CLASS OBJECTS... YOU CAN USE INCLUDES IF YOU PREFER if (!function_exists("__autoload")) { function __autoload($class_name) { require_once 'classes/class_' . $class_name . '.php'; } } // CREATE DATABASE OBJECT ( MAKE SURE TO CHANGE LOGIN INFO IN CLASS FILE ) $db = new DbConnect('localhost', 'nuthan', 'tritone123', 'vts'); $db->show_errors(); // FETCH $_GET OR CRON ARGUMENTS TO AUTOMATE TASKS $apns = new APNS($db); /** /* ACTUAL SAMPLES USING THE 'Examples of JSON Payloads' EXAMPLES (1-5) FROM APPLE'S WEBSITE. * LINK: http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW15 */ // APPLE APNS EXAMPLE 1 $apns->newMessage(1); $apns->addMessageAlert('Message received from Nuthan-VTS'); $apns->addMessageSound('chime'); $apns->addMessageBadge(5); $apns->addMessageCustom('acme2', array('bang', 'whiz')); $apns->queueMessage(); /* // APPLE APNS EXAMPLE 2 $apns->newMessage(1, '2010-01-01 00:00:00'); // FUTURE DATE NOT APART OF APPLE EXAMPLE $apns->addMessageAlert('Bob wants to play poker', 'PLAY');
/** * Begin Document */ error_reporting(E_ALL); // AUTOLOAD CLASS OBJECTS... YOU CAN USE INCLUDES IF YOU PREFER if (!function_exists("__autoload")) { function __autoload($class_name) { require_once 'classes/class_' . $class_name . '.php'; } } // CREATE DATABASE OBJECT ( MAKE SURE TO CHANGE LOGIN INFO IN CLASS FILE ) $db = new DbConnect('localhost', 'sergey', 'CE6h2WK2atWyfHHR', 'my_photo_app'); $db->show_errors(); // FETCH $_GET OR CRON ARGUMENTS TO AUTOMATE TASKS $apns = new APNS($db); /** /* ACTUAL SAMPLES USING THE 'Examples of JSON Payloads' EXAMPLES (1-5) FROM APPLE'S WEBSITE. * LINK: http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW15 */ $apns->newMessage(array(1, 2)); $apns->addMessageAlert('A message to Canadian customer'); $apns->queueMessage(); /* // APPLE APNS EXAMPLE 1 $apns->newMessage(1); $apns->addMessageAlert('Message received from Bob'); $apns->addMessageCustom('acme2', array('bang', 'whiz')); $apns->queueMessage(); // APPLE APNS EXAMPLE 2