$tmp_name = $_FILES['file']['tmp_name']; $a = new SplFileInfo($name); $extension = $a->getExtension(); if ($extension != "zip") { echo "upload only zip files"; } else { $files = glob("uploads/*"); foreach ($files as $file) { echo $file; if (is_file($file)) { unlink($file); } } move_uploaded_file($tmp_name, $location . $name); include_once 'DB_FUNCTIONS.php'; $db = new DB_FUNCTIONS(); $db->delete_fingerprints(); $db->delete_result(); header("Location:checking.php"); } } else { echo "choose a file"; } } ?> <form action="checkplag.php" method="POST" enctype="multipart/form-data"> <input type="file" name="file"><br><br> <input type="submit" name="submit"> </form>
public function query_fingerprint() { unlink("result.zip"); unlink("result.txt"); $handle = fopen("result.txt", 'a'); $db = new DB_FUNCTIONS(); $files = scandir("uploads/ffcp/"); $x = count($files) - 2; for ($i = 1; $i <= $x; $i++) { $a = $db->selectFingerPrint($i); $b = explode("\$", $a['fingerprint']); $count = $a['count']; for ($j = $i + 1; $j <= $x; $j++) { $n = 0; $c = $db->selectFingerPrint($j); $d = explode("\$", $c['fingerprint']); foreach ($d as $cd) { foreach ($b as $ab) { if ($ab == $cd) { $n += 1; } } } if ($n >= 0) { $percentage = $n / $count * 100; $db->storeResult($a['filename'], $c['filename'], $percentage); } } } $result = $db->getResult(); while ($r = mysqli_fetch_assoc($result)) { fwrite($handle, $r['file1'] . "\r\n" . $r['file2'] . "\r\n" . $r['percentage'] . "\r\n"); } $db->delete_result(); $db->delete_fingerprints(); $zip = new ZipArchive(); $zip->open('result.zip', ZipArchive::CREATE); $zip->addFile("result.txt"); $zip->close(); header("Location:download.php"); }