rendered paste body<?php
function another_dir_list ($directory)
{
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// keep going until all files in directory have been read
while ($file = readdir($handler)) {
// if $file isn't this directory or its parent,
// add it to the results array
if ($file != '.' && $file != '..')
$results[] = $file;
}
// tidy up: close the handler
closedir($handler);
// done!
return $results;
}
function dreamhost_file_get_contents($url)
{
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
function process_file($val)
{
$file = "../".$val;
if (is_file($file))
{
$local_md5 = md5_file($file);
$remote_md5 = dreamhost_file_get_contents("http://update.indexi.eu.org/md5check.php?file=$val");
echo $file." current: $local_md5 latest: $remote_md5. ";
if (trim($local_md5) == trim($remote_md5))
{
echo "<font color=\"green\">[OK]</font>";
}else{
echo "<font color=\"red\">[FAIL]</font>";
}
echo"<br />\n";
}
elseif(is_dir($file))
{
echo "$file is directory<br />\n";
}
}
$file_array = another_dir_list("../");
print_r($file_array);
echo "<br />\n";
foreach($file_array as $key => $val);
{
echo "Processing $val<br />\n";
process_file($val);
}
?>