コード例 #1
0
ファイル: AnyliseServerComm.php プロジェクト: svn2github/ybtx
function ReadServerCommFile($filename, $network_flag)
{
    $fp = fopen($filename, 'r');
    if (!$fp) {
        echo "{$filename} 文件不存在";
        return;
    }
    $server_guid = "";
    $server_name = "";
    $version = "";
    $head_info = array();
    $head_num = 0;
    while ($head_num < 3) {
        $line = fgets($fp);
        $line = substr($line, 0, strlen($line) - 1);
        $pos = strpos($line, ":");
        $key = substr($line, 0, $pos);
        $val = substr($line, $pos + 1);
        $head_info[$key] = $val;
        $head_num++;
    }
    $server_name = $head_info["Process Name"];
    $server_guid = $head_info["Process GUID"];
    $version = $head_info["Version"];
    InsertGuidInfo($server_guid, $server_name);
    while (!feof($fp)) {
        $content["UserName"] = "";
        $content["RoleName"] = "";
        $content["Client Addr"] = "";
        $content["Conn Guid"] = "";
        $content["msg"] = "";
        $line = fgets($fp);
        if (strlen($line) < 5) {
            continue;
        }
        $line = substr($line, 0, strlen($line) - 1);
        $content = array();
        $offset = 0;
        $index = 0;
        while ($pos = strpos($line, "\t", $offset)) {
            if ($index < 3) {
                $content[$index] = substr($line, $offset, $pos - $offset);
            } else {
                $str = substr($line, $offset - 1);
                $p1 = 0;
                while ($p1 < strlen($str)) {
                    $begin = strpos($str, "[", $p1);
                    if (!$begin) {
                        $offset = $begin;
                        break;
                    }
                    $end = strpos($str, "]", $begin);
                    if (!$end) {
                        $offset = $begin;
                        break;
                    }
                    $pairs = substr($str, $begin + 1, $end - $begin - 1);
                    $code_pos = strpos($pairs, ":");
                    $content[substr($pairs, 0, $code_pos)] = substr($pairs, $code_pos + 1);
                    $p1 = $end + 1;
                }
            }
            $offset = $pos + 1;
            $index++;
        }
        $content["msg"] = substr($line, $offset);
        InsertServerLogCommon($content[0], $content[1], intval($content[2]), $content["UserName"], $content["RoleName"], $content["Client Addr"], $server_guid, $content["Conn Guid"], $content["msg"], $version, $network_flag);
    }
}
コード例 #2
0
ファイル: AnyliseClientComm.php プロジェクト: svn2github/ybtx
function ReadClientCommFile($filename, $network_flag)
{
    $fp = fopen($filename, 'r');
    if (!$fp) {
        echo "{$filename} Îļþ²»´æÔÚ";
        return;
    }
    $line = "";
    $head_info = array();
    $head_info["D3D Desc"] = "";
    $head_info["D3D Mem"] = "";
    while (!feof($fp)) {
        $line = fgets($fp);
        $line = substr($line, 0, strlen($line) - 1);
        $pos = strpos($line, ":");
        if ($pos > 20) {
            break;
        }
        $key = substr($line, 0, $pos);
        $val = substr($line, $pos + 1);
        $head_info[$key] = $val;
    }
    InsertGuidInfo($head_info["Process GUID"], $head_info["Process Name"]);
    if (array_key_exists('OS', $head_info)) {
        InsertHarewareInfo($head_info["Process GUID"], $head_info["OS"], $head_info["HD"], $head_info["CPU"], $head_info["VIDEO"], $head_info["DX"], $head_info["MEM"], $head_info["D3D Desc"], $head_info["D3D Mem"]);
    }
    while (!feof($fp)) {
        $code = "";
        $happened_time = "";
        $msg = "";
        $times = 1;
        if (strlen($line) < 5) {
            continue;
        }
        $line = substr($line, 0, strlen($line) - 1);
        $pos = strpos($line, ":");
        if ($pos > 20) {
            $pos1 = strpos($line, "\t");
            $code = substr($line, 0, $pos1);
            $pos2 = strpos($line, "\t", $pos1 + 1);
            $happened_time = substr($line, $pos1 + 1, $pos2 - $pos1 - 1);
            if ($pos3 = strpos($line, "\t", $pos2 + 1)) {
                $times = intval(substr($line, $pos2 + 1, $pos3 - $pos2));
                $msg = substr($line, $pos3);
            } else {
                $times = intval(substr($line, $pos2));
            }
        } else {
            $key = substr($line, 0, $pos);
            $val = substr($line, $pos + 1);
            $head_info[$key] = $val;
            if ($key == "Conn Guid") {
                InsertGuidInfo($val, $client_name);
                $head_info["RoleName"] = "";
                $head_info["UserName"] = "";
            }
            $line = fgets($fp);
            continue;
        }
        InsertClientLogCommon($code, $happened_time, $times, $head_info["UserName"], $head_info["RoleName"], $head_info["Server Addr"], $head_info["Server GUID"], $head_info["Process GUID"], $head_info["Conn Guid"], $msg, $head_info["Version"], $network_flag);
        $line = fgets($fp);
    }
}