secret

  • Download Gist
gistfile1.aw
PHP
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
<?php
function dirblocks($path) {
$dir_cont = array_diff(scandir($path), array('.', '..'));
 
 
$hiddenfilepat = '/^\..+/';
 
 
$out = '';
 
foreach ($dir_cont as $elem) {
$cur_path = $path . '/' . $elem;
 
if(preg_match($hiddenfilepat, $elem))
continue;
 
if(is_dir($cur_path)) {
$out .= '<li class="folder"><a href="' . $cur_path . '">';
$out .= $elem;
$out .= ' &raquo;</a><ul>';
$out .= dirblocks($cur_path);
$out .= '</ul></li>';
} else {
$out .= '<li><a href="' . $cur_path . '">' . $elem . '</a></li>';
}
}
return $out;
}
 
function makedirtree() {
return '<ul>' . dirblocks('.') . '</ul>';
}
?>
 
<html>
<head>
<meta charset="utf-8">
<title>Dirs</title>
 
<style>
/*
* CSS Reset
*/
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
outline: 0;
vertical-align: baseline;
background: transparent;
}
body, html {
width: 100%;
height: auto;
}
body {
line-height: 1;
color: black;
background: white;
}
div, article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block;
}
input {
font-size: 100%;
font-family: inherit;
}
nav ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after, q:before, q:after {
content: '';
content: none;
}
a {
margin: 0;
padding: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
ins {
background-color: #ff9;
color: #000;
text-decoration: none;
}
mark {
background-color: #ff9;
color: #000;
font-style: italic;
font-weight: bold;
}
del {
text-decoration: line-through;
}
abbr[title], dfn[title] {
border-bottom: 1px dotted;
cursor: help;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #cccccc;
margin: 1em 0;
padding: 0;
}
input, select {
vertical-align: middle;
}
a:hover, a:active {
outline: none;
}
/* END RESET */
 
body {
font: 13px 'Open Sans';
}
 
 
ul, ul li {
list-style: none inside;
line-height: 21px;
}
 
ul {
margin-left: 1em;
}
 
a {
text-decoration: none;
color: #3479C7;
}
 
li.folder > a {
color: #1E5EA7;
font-weight: bold;
background: rgba(138,190,248,.1);
}
 
a:visited {
/*color: #043266;*/
}
 
a:hover {
color: #72A7E4;
}
 
#cont {
background: rgba(0,0,0,.05);
margin: 20px;
padding: 10px;
max-width: 350px;
}
 
#wrap {
margin: 20px;
}
 
</style>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
</head><body>
<div id="wrap">
<h1><?php echo $_SERVER['HTTP_HOST'] ?></h1>
<div id="cont">
<?php
echo makedirtree();
?>
</div>
</div>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.