douren6874 2010-10-17 05:16
浏览 72
已采纳

跟踪电子邮件的读取时间

Greeting Overflowers,

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 "
";
    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 ?

Regards

  • 写回答

2条回答 默认 最新

  • douwei1944 2010-10-18 10:36
    关注

    I'm afraid there's no sensible way of telling how long somebody has spent looking at an email. Mail clients simply aren't designed with that kind of data gathering in mind, and trying to force a network connection to stay open will merely cause the kind of problems you've run into.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题