Beispiel #1
0
                $sql .= " and clientid in (" . implode(",", $uids) . ") ";
            }
            $sql .= " and pid>" . $last_id . " order by pid asc";
            $pid = intval($GLOBALS['db']->getOne($sql, true));
            if ($pid > 0) {
                //有ID
                //发送过程.....
                require_once APP_ROOT_PATH . "system/libs/apns.php";
                $pids[] = $pid;
                $apns = new apns();
                $apns->newMessage($pids);
                $apns->addMessageAlert($message['content']);
                //$apns->addMessageBadge(2);
                $apns->addMessageSound('bingbong.aiff');
                $apns->queueMessage($message['id']);
                $apns->processQueue();
                //end发送
                $GLOBALS['db']->query("update " . DB_PREFIX . "conf set value = " . intval($pid) . " where name='APNS_MSG_PAGE'");
            } else {
                $GLOBALS['db']->query("update " . DB_PREFIX . "apns_messages set status = 2 where id = " . intval($message['id']));
                $GLOBALS['db']->query("update " . DB_PREFIX . "conf set value = 0 where name='APNS_MSG_PAGE'");
            }
        }
        header("Content-Type:text/html; charset=utf-8");
        echo intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "apns_messages where status <> 2 and send_time <=" . get_gmtime()));
        $GLOBALS['db']->query("update " . DB_PREFIX . "conf set `value` = 0 where name = 'APNS_MSG_LOCK'");
    } else {
        header("Content-Type:text/html; charset=utf-8");
        echo 0;
    }
}