Skip to content

@gabrielecirulli /gist:5678fa70ca4eb60d0dc3 secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.