Bir e-posta Oku edildi How Long için Takip

0 Cevap php

Overflowers Tebrik,

I am asked to code an email tracker using PHP. Email clients request my PHP script thinking it is an image (BODY's background). However, the client (namely Outlook 2007) hangs then (showing nothing) until my PHP script reaches its timeout.

<?php
define("DB_FILE", "sqlite:C:\wamp\www\database.sdb");
define("QUERY", "INSERT INTO Receipt (counter_id, reader_id, start_time, end_time) VALUES (%s, \"%s\", %d, %d)");
define("TIME_OUT", "10");

function track() {
    global $counter_id;
    global $reader_id;
    global $start_time;

    $end_time = time();

    $db = new PDO(DB_FILE);
    $db->exec(sprintf(QUERY, $counter_id, $reader_id, $start_time, $end_time));
}

$counter_id = $_GET["counter_id"];
$reader_id  = $_SERVER["REMOTE_ADDR"];
$start_time = time();

set_time_limit(TIME_OUT);
register_shutdown_function("track");

while(!connection_aborted()) {
    echo "\n";
    ob_flush();
}
?>

It is the loop which should keep the HTTP connection alive for the period of client's reading the tracked email. Any thoughts on how to solve this ?

Selamlar

0 Cevap