-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
39 lines (38 loc) · 768 Bytes
/
index.php
File metadata and controls
39 lines (38 loc) · 768 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
34
35
36
37
38
39
<?php
$html = <<<HTML
<!doctype html>
<html>
<head>
<title>Task 2</title>
</head>
<body>
<h5>Team Storm</h5>
HTML;
$results = array();
define("PASS_TEXT",
"/^Hello World, this is (\w+\s+)+with HNGi7 ID \d+ using [^\s]+ for stage 2 task$/");
$files = scandir("./scripts");
foreach($files as $i){
if($i == "." || $i=="..")continue;
$value = file_get_contents("./scripts/".$i);
$score = preg_match(PASS_TEXT,$value);
$results[$i] = $score?"pass":"fail";
}
if (array_key_exists("json",$_GET)){
$myJSON = json_encode($results);
header('Content-Type: application/json');
echo $myJSON;
}
else{
echo $html;
foreach($results as $name=>$score){
if($score){
echo "<br/>".$name." : PASS";
}
else{
echo "<br/>".$name." :FAIL";
}
}
echo "</body></html>";
}
?>