Skip to content

Commit

Permalink
Modified output in index.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdelgados committed Jun 2, 2020
1 parent 76324f6 commit 7ec3e2a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
$files = scandir('scripts');
if($files) {
foreach($files as $file) {
echo 'File: '.$file.'<br />';

unset($output);
if(preg_match('/.php$/i', $file)){
$output = exec('php scripts/'.$file);
Expand All @@ -10,14 +12,23 @@
} elseif(preg_match('/.js$/i', $file)) {
$output = exec('node scripts/'.$file);
}

if(isset($output)) {
echo 'Output: '.$output.'<br />';
$result = [];
preg_match('/^Hello World, this is ([a-zA-Z ]*) with HNGi7 ID ([0-9]{1,5}) using (Python|PHP|JavaScript) for stage 2 task$/i', $output, $result);
preg_match('/^Hello World, this is ([a-zA-Z -]*) with HNGi7 ID ((HNG-|)[0-9]{1,5}) using (Python|PHP|JavaScript|Node.js) for stage 2 task(.|)$/i', $output, $result);
if(count($result) > 0) {
print_r($result);
echo 'Passed!!! Congrats!!!';
echo 'Name: '.$result[1].'<br />';
echo 'HNGi7 ID: '.$result[2].'<br />';
echo 'Language: '.$result[4].'<br />';
echo 'Result: Passed, congrats!!!';
} else {
echo 'Result: Fail :(';
}
echo '<br /><br />';
} else {
echo 'Result: Fail :(';
}

echo '<br /><br />';
}
}

0 comments on commit 7ec3e2a

Please sign in to comment.