Exemplo n.º 1
0
 static function readSingleMail($name)
 {
     $ret['message'] = lxshell_output("__path_program_root/bin/misc/qmHandle", "-m{$name}");
     $oldtime = time() - 7200;
     $newtime = time() - 500;
     $fp = fopen("/var/log/kloxo/maillog", "r");
     $fsize = lxfile_size("/var/log/kloxo/maillog");
     $ot = date("Y-m-d:H-i");
     dprint("Start time: {$ot}\n");
     $res = FindRightPosition($fp, $fsize, $oldtime, $newtime, array("mailtraffic", "getTimeFromOriginalQmailString"));
     if ($res < 0) {
         $ret['log'] = null;
         return $ret;
     }
     //$s = fgets($fp);
     dprint("here {$s}\n");
     takeToStartOfLine($fp);
     takeToStartOfLine($fp);
     //$s = fgets($fp);
     dprint("here {$s}\n");
     $delivery = null;
     while (!feof($fp)) {
         $s = fgets($fp);
         if (!$delivery) {
             if (csa($s, "starting delivery") && csa($s, "msg {$name}")) {
                 $delivery = preg_replace("/.*delivery ([^:]*):.*/", "\$1", $s);
                 $delivery = trim($delivery);
                 dprint("Deliver num: {$delivery}*\n");
                 continue;
             }
         } else {
             dprint("{$s}\n");
             if (csa($s, "delivery {$delivery}:")) {
                 dprint("{$s}\n");
                 $ret['log'] = $s;
                 break;
             }
         }
     }
     return $ret;
 }
Exemplo n.º 2
0
function lxlabs_marker_firstofline($fp)
{
    global $gbl, $sgbl, $login, $ghtml;
    while (!feof($fp)) {
        if (ftell($fp) <= 2) {
            return;
        }
        takeToStartOfLine($fp);
        takeToStartOfLine($fp);
        $string = fgets($fp);
        if (csa($string, $sgbl->__var_lxlabs_marker)) {
            takeToStartOfLine($fp);
            return;
        }
    }
}
Exemplo n.º 3
0
function tail_func($file, $lines)
{
    $fp = fopen($file, "r");
    if (!$fp) {
        return null;
    }
    dprint("in Tail Func\n");
    fseek($fp, 0, SEEK_END);
    // Go back onece and read the line.
    takeToStartOfLine($fp);
    $arr[] = fgets($fp);
    $n = 0;
    while ($n < $lines && ftell($fp) !== 1) {
        $n++;
        //dprint($n . "\n");
        // You have to go back twice.
        print ' Before: ' . ftell($fp) . "\n";
        fseek($fp, -3, SEEK_CUR);
        takeToStartOfLine($fp);
        fseek($fp, -3, SEEK_CUR);
        print ' aaFter: ' . ftell($fp) . "\n";
        takeToStartOfLine($fp);
        print ' aaaaFter: ' . ftell($fp) . "\n";
        $arr[] = fgets($fp);
    }
    return implode("", array_reverse($arr));
}