-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathreadLogs.php
92 lines (79 loc) · 2.28 KB
/
readLogs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
if(empty($_GET['file']))
{
return;
}
$handle = fopen("temp/".$_GET['file'], "r");
$string = fread($handle, filesize("temp/".$_GET['file']));
// echo $string;
$string = str_replace("Uh Oh!
Plagiarism-Checker encountered an error!:", "<p class='text-info'> <b>Uh Oh!
Plagiarism-Checker encountered an error!:</b></p><p class='text-error'>", $string);
$string = str_replace("\r", "<br>", $string);
// echo $string;
if(strpos($string, "Done!"))
{
echo "stop";
$parts = explode("_",$_GET['file']);
$filename = "output_$parts[1]";
$handle = fopen("temp/$filename", "r");
$count = 1;
$links = array();
while(!feof($handle))
{
$line = fgets($handle);
if(trim($line) == "")
continue;
$parts = explode(" ",$line);
$end = strpos($parts[1],".");
$tempSimilarity = substr($parts[1], 0, $end + 3);
if(intval($tempSimilarity) == 0)
continue;
$similarity[] = $tempSimilarity;
$links[] = "<a href='$parts[0]'>Document $count</a>";
$start = strpos($parts[0], "//");
$end = strpos($parts[0], "/", $start + 3);
$temp = substr($parts[0], $start+2, $end - $start - 2);
$website[] = $temp;
$count++;
}
$colors = array("","danger","success","warning","info");
$color = 0;
if(!$count)
{
echo "<h4> No Documents Found.</h4>";
}
else
{
echo "<h4>Similarity: Top ".count($links)." documents:</h4>";
for($i=0;$i<count($links);$i++,$color++)
{
if($color > 4)
$color = 0;
echo "<h4>$links[$i] - Hosted on <u>$website[$i]</u> - $similarity[$i]%</h4>
<div class='progress progress-striped active progress-$colors[$color]'>
<div class='bar' style='width:".intval($similarity[$i])."%'></div>
</div>";
}
}
$string = str_replace("...", "...<br>", $string);
echo "~DELIM~$string";
fclose($handle);
return;
}
$parts = explode("<br>", $string);
foreach ($parts as $part)
{
$nums = explode("/",$part);
if(count($nums) < 2)
continue;
else
{
$numerator = $nums[0];
$denominator = intval($nums[1]);
$value = (int)($numerator/$denominator*100);
}
}
$string = str_replace("...", "...<br>", $string);
echo "<h2 class='text-info'>$value% Completed</h2><br><div class='progress progress-danger active progress-striped'> <div class='bar' style='width:$value%'></div></div>~DELIM~$string";
?>