-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult.php
More file actions
33 lines (25 loc) · 811 Bytes
/
result.php
File metadata and controls
33 lines (25 loc) · 811 Bytes
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
<?php
if (! isset($_FILES['git-log']['tmp_name']) || ! is_uploaded_file($_FILES['git-log']['tmp_name'])) {
header("location: index.php?error=The file was not submitted. Please send a file with a log of the Git");
exit;
}
$arrayLines = file($_FILES['git-log']['tmp_name']);
$output = [];
$stringToConsider = isset($_POST['string-to-grep']) ? $_POST['string-to-grep'] : "@";
foreach ($arrayLines as $line) {
if (strpos($line, $stringToConsider) > -1) {
$content = substr($line, 8, -1);
if (array_key_exists($content, $output)) {
$output[$content]++;
} else {
$output[$content] = 1;
}
}
}
arsort($output);
$viewVars['output'] = $output;
file_put_contents(
'commiters.txt',
serialize($output)
);
require "views/result.php";