<?phpini_set('display_errors', 1);ini_set('log_errors', 1);ini_set('error_log', dirname(__FILE__) . '/error_log.txt');error_reporting(E_ALL);echo "<html>";echo "<h1>File Comparison Report</h1> <br>";echo "<head> <title>File Comparer</title> <LINK REL = StyleSheet HREF = 'style.css' TYPE = 'text/css' MEDIA = screen></head>";echo "<body>";$dir = "../FileCompare/upload"; //directory of files to compare//$obj = new Compare();Compare::saveFile($dir);echo "File Compared: ".Compare::getFile1(0)."<br><br>"; //displays the uploaded file so we know what file we are comparin foreach (Compare::getFile2($dir) as $key => $value) { //takes the files from the array of the directory of file2 //for($i = 0; $i<count($_FILES); $i++) //{ if (Compare::convertFile(Compare::getFile1(0)!==Compare::convertFile($value)) { //compares the 2 files // files not the same echo "no: ".$value."<br>"; } else { // files the same echo "<div class= 'yes'>"; echo "yes: ".$value."<br>"; echo "</div>"; } //} }//echo "<FORM class='savebutton'><INPUT TYPE='button' VALUE='Save' onClick='".Compare::saveFile($dir)."'></FORM>"; //back buttonecho "<FORM class='backbutton'><INPUT TYPE='button' VALUE='Back' onClick='history.go(-1);return true;'></FORM>"; //back buttonecho "</body>";echo "</html>";class Compare{ static function compareFiles($dir, $file11, $files22) { $files22 = scandir($dir, 1); //read the directory of files to compare and put it into an array } static function getFile1($i) { return $_FILES[$i]['name']; } static function convertFile($fileName) { global $dir; if (file_exists($dir . '/' . $fileName)) { $crc = @crc32($dir . '/' . $fileName); return $crc; } else { echo "failed to find($fileName)"; } } static function getFile2($dir) { $files22 = scandir($dir, 1); //read the directory of files to compare and put it into an array array_pop($files22); array_pop($files22); return $files22; } static function saveFile($dir) { array_shift($_FILES); $_FILES = array_values($_FILES); //print_r($_FILES); foreach($_FILES as $key => $value) { $target_path = $dir."/".basename($value['name']); if(move_uploaded_file($value['tmp_name'], $target_path)) { echo "The file ". basename($value['name'])." has been uploaded<br />"; } else{ echo "There was an error uploading the file, please try again!<br />"; } } }}?>