FileName = $file; // Initialize array with the default values $this->Result = array("Count" => 0, "DateTime" => 0, "User" => "", "Host" => "", "Root" => "", "Values" => array()); } function GetString($Str) { $s = ""; for ($j = 0; $j < strlen($Str); $j = $j + 2) { $s = $s . chr(hexdec(substr($Str, $j, 2))); } return utf8_decode($s); } function GetLongString($Str) { $s = ""; for ($j = 0; $j < strlen($Str); $j = $j + 2) { $s = $s . chr(hexdec(substr($Str, $j, 2))); } return utf8_decode($s); } function ParseExtra($Info) { global $EXTRA_DATE_ID, $EXTRA_TIME_ID, $EXTRA_USER_ID, $EXTRA_HOST_ID; $i = 0; while ($i < strlen($Info)) { $ID = hexdec(substr($Info, $i, 2)); $Size = hexdec(substr($Info, $i + 2, 2)); $i = $i + 4; switch ($ID) { case $EXTRA_DATE_ID: $d1 = hexdec(substr($Info, $i, 2)); $d2 = hexdec(substr($Info, $i + 2, 2)); $d3 = hexdec(substr($Info, $i + 4, 4)); $this->Result['DateTime'] = mktime(0, 0, 0, $d2, $d1, $d3); break; case $EXTRA_TIME_ID: $t1 = hexdec(substr($Info, $i, 2)); $t2 = hexdec(substr($Info, $i + 2, 2)); $t3 = hexdec(substr($Info, $i + 4, 2)); $this->Result['DateTime'] = mktime($t1, $t2, $t3, $d1, $d2, $d3); break; case $EXTRA_USER_ID: $this->Result['User'] = $this->GetString(substr($Info, $i, $Size)); break; case $EXTRA_HOST_ID: $this->Result['Host'] = $this->GetString(substr($Info, $i, $Size)); break; } $i = $i + $Size; } } function GetRoot($Info) { $Size = hexdec(substr($Info, 2, 4)); return $this->GetLongString(substr($Info, 6, $Size)); } function Parse() { global $maxMD5Line, $remarkID, $extraInfoID, $rootID; $extraFound = False; $rootFound = False; $handle = fopen($this->FileName, "r") or die('Can not to open file ' . $this->FileName); while (!feof ($handle)) { $line = trim(fgets($handle, $maxMD5Line)); if ($line) { if (in_array($line[0], $remarkID)) { if (!$extraFound) { $a = explode($extraInfoID, $line); if (Count($a) > 1) { $extraFound = $this->ParseExtra(trim($a[1])); } } if (!$rootFound) { $a = explode($rootID, $line); if (Count($a) > 1) { $this->Result['Root'] = $this->GetRoot(trim($a[1])); } } } else { if (strlen($line) > 34) { $a = explode('*', $line); $hash = strtoupper(trim($a[0])); $file = trim($a[1]); $this->Result['Values'][$file] = $hash; } else { return False; } } } } fclose($handle); } } ?>