Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Report all errors
- error_reporting(E_ALL);
- ini_set('display_errors','On');
- // Set memory limit and time out period
- ini_set('memory_limit','64M');
- set_time_limit(600);
- // Scan hash strings for files
- if ($_GET['action'] == 'scan') {
- $filemd5 = array();
- getdir(dirname(__FILE__));
- include_once(dirname(__FILE__).'/filehashes.php');
- $fh = fopen("scanresults.txt", 'w');
- foreach ($filemd5 as $file) {
- if (empty($filehashes[$file[0]])) {
- fwrite($fh, "F: ".$file[0]."\r\n");
- } else
- if ($filehashes[$file[0]] != $file[1]) {
- fwrite($fh, "M: ".$file[0]."\r\n");
- }
- }
- fclose($fh);
- }
- // Generate hash strings for files
- if ($_GET['action'] == 'generate') {
- $filemd5 = array();
- getdir(dirname(__FILE__));
- $fh = fopen("filehashes.php", 'w') or die("can't open file");
- fwrite($fh, '<?php $filehashes = array('."\r\n");
- foreach ($filemd5 as $file) {
- fwrite($fh, "'".$file[0]."' => '".$file[1]."',\r\n");
- }
- fwrite($fh, '); ?>');
- fclose($fh);
- }
- // Recursively read directory
- function getdir( $path, $level = 0 ){
- global $filemd5;
- $ignore = array('.','..');
- $dh = @opendir( $path );
- while( false !== ( $file = readdir( $dh ) ) ){
- if( !in_array( $file, $ignore ) ){
- $spaces = str_repeat( '-', ( $level * 4 ) );
- if( is_dir( "$path/$file" ) ){
- getdir( "$path/$file", ($level+1) );
- } else {
- $filemd5[] = array(str_replace(dirname(__FILE__).'/','',"$path/$file"),md5_file("$path/$file"));
- }
- }
- }
- closedir( $dh );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement