-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource_code.php
More file actions
46 lines (33 loc) · 1.14 KB
/
source_code.php
File metadata and controls
46 lines (33 loc) · 1.14 KB
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
<?php
//endswith function (to check for php files later!)_
function endsWith($haystack, $needle) {
// search forward starting from end minus needle length characters
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
}
//read in source code files and display them...
$dir = './';
$files = preg_grep('/^([^.])/', scandir($dir));//avoid hidden files and dirs
echo "<a href='index.php'>Back to main page</a>";
echo "<h1>Files:</h1>";
//print_r($files);exit;
foreach($files as $file){
if(endsWith($file,'.php')){
echo "<a href='#{$file}'>$file</a><br><br>";
}}
echo "<br>";
echo "<a href=\"./commands.pdf\">See database structure. (not used in web version)</a>";
foreach($files as $file){
if(endsWith($file,'.php')){
echo "<hr>";
//read file
echo "<a name=\"{$file}\"></a>";
echo "<h2>File: <i>$file</i></h2>";
$sourcefile = fopen($file, "r") or die("Unable to open file!");
//format for display and print!
echo "<pre>";
echo highlight_string(fread($sourcefile,filesize("$file")));
fclose($sourcefile);
echo "</pre>";
}}
echo "<a href='index.php'>Back to main page</a>";
?>