-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patharchive.php
More file actions
129 lines (121 loc) · 4.54 KB
/
archive.php
File metadata and controls
129 lines (121 loc) · 4.54 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
// browserarchive.org aka browsers.evolt.org
// Copyright (c) 1999-2013 Adrian Roselli, William Anderson
$headertext = "browsers.evolt.org: ";
$path=urldecode($_GET["file"]); //remove url encoding.
$path=str_replace("..","",$path); // disallow directory up.
$path=preg_replace("/\/+/", "/", $path); // remove duplicate slashes.
if($path == "/") { $path = ""; }
if($path[0]=="/"){ $path=substr($path,1,strlen($path)-1); } // Remove leading slash.
if(substr($path,strlen($path)-1,1) =="/"){ $path=substr($path,0,strlen($path)-1);} // Remove trailling slash.
$filerequest = $path;
if ( $filerequest == "" || $filerequest == "archive" ) { header("Location: /",302); }
include "assets/inc/00-functions.inc";
include "data.inc";
$browserreq = array_slice(explode("/",$filerequest),1,1);
$browsercode = $browserreq[0];
$site_name = "browsers.evolt.org";
$html_title = $browsers[$browsercode]["name"];
if ( $browsercode != "" ) {
$page_title = $browsers[$browsercode]["name"];
} else {
$page_title = $site_name;
}
$short_title = $browsers[$browsercode]["name"];
$page_type = "page";
$upstairs_uri = "/";
$upstairs_title = "Browser Archive";
include "assets/inc/10-header.inc";
include "assets/inc/20-message.inc";
function getFileList($dir)
{
// array to hold return value
$retval = array();
// add trailing slash if missing
if(substr($dir, -1) != "/") $dir .= "/";
// open pointer to directory and read list of files
$d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading");
while(false !== ($entry = $d->read())) {
// skip hidden files
if($entry[0] == ".") continue;
if(is_dir("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry/",
"type" => filetype("$dir$entry"),
"size" => 0,
"lastmod" => filemtime("$dir$entry")
);
} elseif(is_readable("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry",
"type" => mime_content_type("$dir$entry"),
"size" => filesize("$dir$entry"),
"lastmod" => filemtime("$dir$entry")
);
}
}
$d->close();
return $retval;
}
?>
<div class="wrapper">
<section id="content" class="full-width" role="main">
<div class="p100">
<p class="notice error"><strong>Pardon our dust!</strong> This iteration of <strong>browsers.evolt.org</strong> is under test, containing content which has not yet been finalized.</p>
</div>
<div class="p66">
<h2><?php echo $filerequest ?></h2>
<table>
<tr><td><img src="/assets/img/null.png" style="vertical-align:middle" height="32" width="32" alt="[ UP]" /></td><td><a href="../">..</a></td><td></td><td></td></tr>
<?php
$dirlist = getFileList($_SERVER['DOCUMENT_ROOT']."/".$filerequest);
//echo "<pre>".print_r($dirlist)."</pre>";
foreach($dirlist as $file) {
if ( $file['type'] == "dir" ) {
$file['name'] = str_replace($_SERVER['DOCUMENT_ROOT'],"",$file['name']);
?>
<tr>
<td><img src="/assets/img/null.png" style="vertical-align:middle" height="32" width="32" alt="[DIR]" /></td>
<td><a href="<?php echo "/browsers".$file['name'] ?>"><?php
$display_name = explode("/",$file['name']);
end($display_name);
echo prev($display_name);
?></a><br /><small class="small"><font color="#888888"><?php echo date('Y-m-d H:m', $file['lastmod']) ?></font></small></td>
<td> </td>
<td></td>
</tr>
<?php
}
}
foreach($dirlist as $file) {
if ( $file['type'] != "dir" ) {
$file['name'] = str_replace($_SERVER['DOCUMENT_ROOT'],"",$file['name']);
?>
<tr>
<td><?php
$fileext = end(explode(".",$file['name']));
if ( file_exists($_SERVER['DOCUMENT_ROOT']."/assets/img/mime-icons/file_extension_".$fileext.".png") ) {
?><img src="/assets/img/mime-icons/file_extension_<?php echo $fileext ?>.png" style="vertical-align:middle" height="32" width="32" alt="[<?php echo strtoupper($fileext) ?>]" /><?php
} else {
?><img src="/assets/img/mime-icons/file_extension_unknown.png" style="vertical-align:middle" height="32" width="32" alt="[???]" /><?php
}
?></td>
<td><a href="<?php echo $file['name'] ?>"><?php
$display_name = explode("/",$file['name']);
echo end($display_name);
?></a><br /><small class="small"><font color="#888888"><?php echo date('Y-m-d H:m', $file['lastmod']) ?> <?php echo $file['size'] ?></font></small></td>
<td> </td>
<td></td>
</tr>
<?php
}
}
?>
</table>
</div>
<?php include "assets/inc/30-adsense.inc" ?>
</section>
</div>
<?
include "assets/inc/99-footer.inc";
?>