示例#1
0
function send_notify_emails()
{
    $db = BoincDb::get();
    $t = time() - (86400 + 3600);
    // 1-hour slop factor
    $query = "select notify.* from " . $db->db_name . ".notify, " . $db->db_name . ".forum_preferences where forum_preferences.pm_notification=2 and notify.userid = forum_preferences.userid and notify.create_time > {$t}";
    $notifies = BoincNotify::enum_general($query);
    $userid = 0;
    $message = "";
    $i = 1;
    foreach ($notifies as $notify) {
        if ($userid && $notify->userid != $userid) {
            send_notify_email($userid, $message);
            $message = "";
            $i = 1;
        }
        $userid = $notify->userid;
        $message .= "{$i}) ";
        switch ($notify->type) {
            case NOTIFY_FRIEND_REQ:
                $message .= friend_notify_req_email_line($notify);
                break;
            case NOTIFY_FRIEND_ACCEPT:
                $message .= friend_notify_accept_email_line($notify);
                break;
            case NOTIFY_PM:
                $message .= pm_email_line($notify);
                break;
            case NOTIFY_SUBSCRIBED_POST:
                $message .= subscribed_post_email_line($notify);
                break;
        }
        $message .= "\n";
        $i++;
    }
    if ($userid) {
        send_notify_email($userid, $message);
    }
}
    foreach ($row_tmp as $key_url => $value_array) {
        $stmt->bindParam(':url', $key_url);
        $stmt->bindParam(':last_check', $value_array['last_check']);
        $stmt->bindParam(':remaining', $value_array['remaining']);
        $stmt->bindParam(':push_count', $value_array['push_count']);
        $stmt->execute();
        echo $stmt->rowCount() . " records UPDATED successfully <br>";
    }
} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
}
// 關閉資料庫連線
$conn = null;
// 檢查是否要寄信
if ($mail_message != null) {
    send_notify_email($mail_receiver, $mail_message);
} else {
    echo "您追蹤的文章都沒有新推文。";
}
function handle_row($row, $conn)
{
    global $row_tmp;
    $url = $row['url'];
    $content = get_url_content($url);
    if ($content == null) {
        return;
    } else {
        $row_tmp[$url] = array();
        // 更新最後檢查的時間,先存入暫時的陣列
        date_default_timezone_set('Asia/Taipei');
        $row_tmp[$url]['last_check'] = date('Y/m/d l H:i:s', time());