function parse_log($seekfile, $slogfile, $seeknum)
{
    $bufpath = "/data0/apache/gateway/print/INSERT/";
    $fd = fopen($slogfile, 'r');
    echo $file . "\n";
    if (!$fd) {
        trans_w_log('/data0/apache/gateway/withdb/logdb/mtlog2buf.log', "Content file open error!!!!\n");
        return;
    }
    $i = 0;
    $nowsec = time();
    /*-----fseek到文件传输开始位置-----*/
    fseek($fd, $seeknum);
    while ($data = fgets($fd, 1024)) {
        $data = chop($data);
        $data = addslashes($data);
        if (substr($data, 0, 1) !== "[" or substr($data, 9, 1) !== "]") {
            echo "日志格式错误:{$i行} {$data}\n";
            $i++;
            continue;
        }
        //循环控制
        //1.获取单条日志时间;
        //2.当日志时间($logsec)大于程序执行时间($nowsec) 循环结束
        $logarr = explode(',', $data);
        $timetmp1 = explode('[', $logarr[0]);
        $timetmp2 = explode(']', $timetmp1[1]);
        $logtimestr = date("Y-m-d") . " {$timetmp2['0']}";
        $logsec = strtotime($logtimestr);
        $gatewaytmp = explode(' ', $logarr[0]);
        $gateway = $gatewaytmp[1];
        //分析日志,日志各个字段分隔符为","  短信内容中可能会有逗号
        $count = count($logarr) . "\n";
        $content = "";
        if ($count == 16) {
            $linkid = $logarr[15];
            $content = $logarr[14];
        } else {
            $linkid = $logarr[$count - 1];
            for ($j = 14; $j < $count - 1; $j++) {
                $content .= $logarr[$j];
            }
        }
        if (substr($content, 0, 6) == "050003") {
            $len = strlen($content) - 12;
            $tmpcontent = pack("H{$len}", substr($content, 12));
            $tmpcontent = iconv("UCS-2", "GBK", $tmpcontent);
            $content = substr($content, 0, 12) . $tmpcontent;
        }
        $buf = "{$timetmp2['0']}|||{$gateway}|||{$logarr['1']}|||{$logarr['2']}|||{$logarr['3']}|||{$logarr['4']}|||{$logarr['5']}|||{$logarr['6']}|||{$logarr['7']}|||{$logarr['8']}|||{$logarr['9']}|||{$logarr['10']}|||{$logarr['11']}|||{$logarr['12']}|||{$logarr['13']}|||{$content}|||{$linkid}\n";
        genSMSbuf($bufpath, $gateway, $logarr[2], $buf);
        //echo $buf;
        $i++;
        if ($i > 10000) {
            break;
        }
    }
    /*-----获取seek-----*/
    $seeklast = ftell($fd);
    fclose($fd);
    $fdseek = fopen($seekfile, 'w');
    fwrite($fdseek, "{$seeklast}");
    fclose($fdseek);
}
function parse_log($seekfile, $slogfile, $seeknum)
{
    $bufpath = "/data0/apache/gateway/print/PLOGBUF/";
    $fd = fopen($slogfile, 'r');
    echo $file . "\n";
    if (!$fd) {
        trans_w_log('/data0/apache/gateway/withdb/logdb/plog2buf.log', "Content file open error!!!!\n");
        return;
    }
    $i = 0;
    $nowsec = time();
    /*-----fseek到文件传输开始位置-----*/
    fseek($fd, $seeknum);
    while ($data = fgets($fd, 1024)) {
        //[09:52:30] 101010,02100952332130722499,02100952300100310062,0,0,0,13801628611,201202100952,201202100952
        $data = chop($data);
        $data = addslashes($data);
        if (substr($data, 0, 1) !== "[" or substr($data, 9, 1) !== "]") {
            echo "日志格式错误:{$i行} {$data}\n";
            $i++;
            continue;
        }
        //循环控制
        //1.获取单条日志时间;
        //2.当日志时间($logsec)大于程序执行时间($nowsec) 循环结束
        $logarr = explode(',', $data);
        $timetmp1 = explode('[', $logarr[0]);
        $timetmp2 = explode(']', $timetmp1[1]);
        $logtimestr = date("Y-m-d") . " {$timetmp2['0']}";
        $logsec = strtotime($logtimestr);
        $gatewaytmp = explode(' ', $logarr[0]);
        $gateway = $gatewaytmp[1];
        //分析日志,日志各个字段分隔符为","  短信内容中可能会有逗号
        $count = count($logarr) . "\n";
        $buf = "{$timetmp2['0']}|||{$gateway}|||{$logarr['2']}|||{$logarr['3']}|||{$logarr['4']}|||{$logarr['5']}|||{$logarr['6']}\n";
        if ($i > 10000) {
            break;
        }
        genSMSbuf($bufpath, $gateway, $logarr[2], $buf);
        //echo $buf;
        $i++;
    }
    $seeklast = ftell($fd);
    fclose($fd);
    $fdseek = fopen($seekfile, 'w');
    fwrite($fdseek, "{$seeklast}");
    fclose($fdseek);
}