include_once "../lib/knowledge_base.php"; list_text_files($_POST['categories']); echo "<a href=\"/knowledge_base/index.php\"><font color=\"navy\">Back</font></a>\n"; } if ($_POST['phrase']) { // use this function for security purposes; $phrase = htmlentities($_POST['phrase']); // call the function that will search the database by phrase; echo "<center>\n\n"; include_once "../lib/knowledge_base.php"; list_by_phrase($phrase); echo "<a href=\"/knowledge_base/index.php\"><font color=\"navy\">Back</font></a>\n"; } } if (isset($_POST['all'])) { // list all text_files as a hyperlink; echo "<center>\n\n"; include_once "../lib/knowledge_base.php"; list_all_files(); echo "<a href=\"/knowledge_base/index.php\"><font color=\"navy\">Back</font></a>\n"; } ?> <html> <body link="olive" alink="olive" vlink="olive"> </body> </html>
$files = new \RegexIterator($ite, $pattern, \RegexIterator::GET_MATCH); $fileList = []; foreach ($files as $file) { if (\is_array($file)) { foreach ($file as $i => $f) { // Prevent . and .. from being treated as valid files: $check = \preg_replace('#^(.+?)/([^/]+)$#', '$2', $f); if ($check === '.' || $check === '..') { unset($file[$i]); } } } $fileList = \array_merge($fileList, $file); } return $fileList; } if ($argc > 1) { $extensions = \array_slice($argv, 1); } else { $extensions = ['php', 'twig']; } $fileList = []; foreach ($extensions as $ex) { foreach (list_all_files(\dirname(__DIR__) . '/src/', $ex) as $file) { $fileList[] = $file; } } $choice = \random_int(0, \count($fileList) - 1); echo "Audit this file:\n\t"; $l = \strlen(\dirname(__DIR__)); echo \substr($fileList[$choice], $l), "\n";