<?php

$FileName = "checksums.md5";
$ChecksumsFileHash = "8b94149712299ab272fe241b642dc1e4";
$maxMD5Line = 4096;

$statmsg['ok'] = "<strong>OK</strong>";
$statmsg['fail'] = "<font color=\"red\"><strong>FAIL</strong></font>";
$statmsg['no'] = "<font color=\"yellow\"><strong>Not our's</strong></font>";
$statmsg['del'] = "<font color=\"#0000FF\"><strong>Deleted!</strong></font>";

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>DGT Release Checker</title>
<style type="text/css">
body {
padding-top: 0;
padding-right: 0;
padding-left: 0;
padding-bottom: 0;
margin: 0;
color: #DDDDDD;
background-color: #000000;
font-family:Courier New, monospace;
}
table {
border: 1px dashed #FFFFFF;
}
td {
border-top: 1px dotted #DDDDDD;
font-size:16px;
}


h2 {
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
}
</style>
</head>
<body>
<h2>DGT Release Checker</h2>
<?php
if (!file_exists($FileName)) {
    print ("<h2>Can not to open file $FileName<h2>");
    exit;
}
if (md5_file($FileName) != strtolower($ChecksumsFileHash)) {
    print ("<h2>File $FileName corrupted<h2>");
    exit;
}

$handle = fopen($FileName, "r");
while (!feof ($handle)) {
    $line = trim(fgets($handle, $maxMD5Line));
    if ($line) {
        if (strlen($line) > 34) {
            $a = explode('*', $line);
            $hash = strtolower(trim($a[0]));
            $file = trim($a[1]);
            $Result[$file] = $hash;
        } else {
            return false;
        }
    }
}
fclose($handle);

?>

<table align="center">
  <tr>
    <th scope="col">File</th>
    <th scope="col">Check</th>
  </tr>
<?php

    function chkmd5($dir)
    {
        global $Result, $statmsg, $FileName;
        $output_md5 = "";
        $files = array ();
        $dh  = opendir($dir);
        while (false !== ($filename = readdir($dh))) { $files[] = $filename; }
        sort($files);
        foreach($files as $lol)
        {
            if (($lol != ".") && ($lol != "..") && ($lol != $FileName) && ($lol != "validator.php"))
            {
                $newpath = $dir."/".$lol;
                if (!is_dir($newpath))
                {
                    $md5fn = substr($newpath, 2);
                    if (!empty($Result[$md5fn]))
                    {
                        if((strtolower(md5_file($newpath)) == $Result[$md5fn]))
                        {
                              $Result[$md5fn] = $statmsg['ok'];
                        }
                        else
                        {
                            $Result[$md5fn] = $statmsg['fail'];
                        }
                    }
                    else
                    {
                        $Result[$md5fn] = $statmsg['no'];
                    }
                }
                else
                {
                    chkmd5($newpath);
                }
            }
        }
    }

chkmd5(".");
ksort($Result);

foreach($Result as $file => $status)
{
    if (($status != $statmsg['ok']) && ($status != $statmsg['no']) && ($status != $statmsg['fail']))
    {
        $status = $statmsg['del'];
    }
    echo <<<TABLE
    <tr>
        <td>$file&nbsp;</td>
        <td align="center">&nbsp;$status</td>
      </tr>
TABLE;

}

    ?>
</table>

</body>
</html>
DGT'nin validator'ı Merak etme DGT yamuk yapmaz.