as I have been looking in to a md5 checksum of files being left out of indexscans search I notiched I have difficulties getting the checksum.php to work as I expected.
I "Stole" the md5check.php from the xoopsCore to reuse and created a indexscan.md5 file to compare against.
However as it worked fine on my server, it failed on my local test server..
First it failed on my wamp server with the $sum & and the md5($txt) having same value.
I then modified a little to use the md5_file function and then worked. But only worked on my testing server if I ran a create md5 files "on_server" and didnt work on uploading the ready made one.
My Create md5 function
IndexScanCreateMd5('.');
function IndexScanCreateMd5($dir)
{
// Open .md5 file for appending
$fh = fopen('indexscan.md5', 'a') or die("can't open file");
// We open the file
if ($url = opendir($dir)) {
// It searches all folders and files it contains
while ($folder = readdir($url)) {
// The path of current folder
$path = $dir . '/' . $folder;
// If we find a folder, then relaunch it function to search
// Once all the files and folders it contains
if ($folder != '.' && $folder != '..' && is_dir($path))
IndexScanCreateMd5($path);
// If we are dealing with a file
elseif ($folder != '.' && $folder != '..' && !is_dir($path)) {
$stringData = $path . ':' . md5_file($path);
echo $path . ':' . md5_file($path).'
';
// We insert the path of the file and its MD5 hash
fwrite($fh, $stringData."n");
}
}
closedir($url);
}
}
?>
My modified XOOPS checksum
if (file_exists('indexscan.md5')) {
/**
* XOOPS installation md5 checksumminig script
*
* This script allows you to check that the XOOPS system files have been correctly uploaded.
* It reads all the XOOPS files and reports missing or invalid ones.
*
* Instructions:
* - Upload this script and xoops.md5 to your XOOPS documents root
* - Access it using a browser
* - Re-upload missing/invalid files
*
* @copyright The XOOPS project https://xoops.org/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Skalpa Keo
* @since 2.0.14
* @version $Id: md5check.php 808 2006-11-15 16:22:22Z skalpa $
* @package xoops
*/
error_reporting( 0 );
header( "Content-type: text/plain" );
if ( !is_file( "indexscan.md5" ) || !is_readable( "indexscan.md5" ) ) {
echo "xoops.md5 file not found.n";
exit();
}
$sums = explode( "n", rtrim( file_get_contents( "indexscan.md5" ) ) );
foreach ( $sums as $line ) {
list( $file, $sum ) = explode( ":", $line, 2 );
if ( !file_exists( $file ) ) {
echo "$file missing !n";
} else {
$txt = $file;
if ( md5_file($txt) != $sum ) {
echo "$file content invalidn";
}
}
}
echo "Files are verified";
} else {
Echo "indexscan.md5 is missingnPlease upload";
}
?>
website server usingXOOPS Version XOOPS 2.4.2
PHP Version 5.2.10
mySQL Version 5.0.32-Debian_7etch11-log
Local serverXOOPS Version XOOPS 2.4.2
PHP Version 5.3.0
mySQL Version 5.1.33-community-log
Server API apache2handler
OS WINNT
Any pointers on how to include the indexscan.md5 file with the values so the can be used allround?
I create them on installing the module ? or is there a work-around method ?