Last active
February 2, 2016 14:32
-
-
Save jmesserli/9032826 to your computer and use it in GitHub Desktop.
https://school.jmnw.me (Outdated!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$time_start = microtime(true); | |
$colors = array(0 => "default", 1 => "primary", 2 => "success", 3 => "info", 4 => "warning", 5 => "danger"); | |
$fileicons = array(0 => "file", "text" => "file-text", "table" => "table", "compressed" => "archive", "image" => "picture-o", "exec" => "terminal", "music" => "music", "src" => "code", "link" => "link"); | |
$filetypeicon = array( | |
"pdf" => "text", "docx" => "text", "doc" => "text", "odt" => "text", "txt" => "text", "log" => "text", "md" => "text", | |
"xlsx" => "table", "xls" => "table", "ods" => "table", | |
"zip" => "compressed", "rar" => "compressed", "gz" => "compressed", "tar" => "compressed", | |
"png" => "image", "jpg" => "image", "jpeg" => "image", "tiff" => "image", "gif" => "image", "ico" => "image", | |
"jar" => "exec", "exe" => "exec", "msi" => "exec", "bat" => "exec", | |
"mp3" => "music", "ogg" => "music", "aac" => "music", "wav" => "music", | |
"xml" => "src", "java" => "src", "cpp" => "src", "py" => "src", | |
"php" => "link" | |
); | |
$filetypecolor = array(); | |
$nextfree = 0; | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Joel's Schulzeug</title> | |
<?php | |
//THEMESWITCHER | |
$mytheme = filter_input(INPUT_GET, "style"); | |
if ($mytheme != null) { | |
if ($mytheme === "amelia") { | |
echo '<link href="//netdna.bootstrapcdn.com/bootswatch/3.1.0/amelia/bootstrap.min.css" rel="stylesheet">'; | |
} elseif ($mytheme === "simplex") { | |
echo '<link href = "//netdna.bootstrapcdn.com/bootswatch/3.1.0/simplex/bootstrap.min.css" rel = "stylesheet">'; | |
} elseif ($mytheme === "superhero") { | |
echo '<link href = "//netdna.bootstrapcdn.com/bootswatch/3.1.0/superhero/bootstrap.min.css" rel = "stylesheet">'; | |
} elseif ($mytheme === "cosmo") { | |
echo '<link href = "//netdna.bootstrapcdn.com/bootswatch/3.1.0/cosmo/bootstrap.min.css" rel = "stylesheet">'; | |
} elseif ($mytheme === "cyborg") { | |
echo '<link href = "//netdna.bootstrapcdn.com/bootswatch/3.1.0/cyborg/bootstrap.min.css" rel = "stylesheet">'; | |
} elseif ($mytheme === "lumen") { | |
echo '<link href = "//netdna.bootstrapcdn.com/bootswatch/3.1.0/lumen/bootstrap.min.css" rel = "stylesheet">'; | |
} else { | |
echo '<link href="//netdna.bootstrapcdn.com/bootswatch/3.1.0/flatly/bootstrap.min.css" rel="stylesheet">'; | |
} | |
} else { | |
echo '<link href="//netdna.bootstrapcdn.com/bootswatch/3.1.0/flatly/bootstrap.min.css" rel="stylesheet">'; | |
} | |
?> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<link href="/css/animate.min.css" rel="stylesheet"/> | |
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet"> | |
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> | |
</head> | |
<body class="animated fadeIn"> | |
<div class="navbar navbar-default navbar-fixed-top" role="navigation"> | |
<div class="container"> | |
<div class="navbar-header"> | |
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | |
<span class="sr-only">Toggle navigation</span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> | |
<a class="navbar-brand" href="/"><i class="fa fa-book"></i> Joel's Schulzeug</a> | |
</div> | |
<div class="navbar-collapse collapse"> | |
<ul class="nav navbar-nav"> | |
<li id="us-item" class="active"><a href="#">Übersicht</a></li> | |
</ul> | |
<form class="navbar-form navbar-right" role="search" method="get"> | |
<div class="form-group"> | |
<input type="text" name="search" class="form-control" placeholder="Suchen"> | |
</div> | |
<button type="submit" class="btn btn-default">Los!</button> | |
</form> | |
<ul class="nav navbar-nav navbar-right"> | |
<li class="dropdown"> | |
<a href="#" class="dropdown-toggle" data-toggle="dropdown">JMNetwork <b class="caret"></b></a> | |
<ul class="dropdown-menu"> | |
<li><a class="active" href="//jmnetwork.ch"><i class="fa fa-home"></i> JMNetwork.ch</a></li> | |
<li><a href="/upload.php"><i class="fa fa-cloud-upload"></i> Upload (Password)</a></li> | |
<!-- DISABLED <li><a href="//go.jmnetwork.ch/status"><i class="fa fa-wrench"></i> JMNetwork Status</a></li>--> | |
</ul> | |
</li> | |
</ul> | |
</div><!--/.nav-collapse --> | |
</div> | |
</div> | |
<div class="container" style="padding-top: 60px"> | |
<div class="page-header"> | |
<h1>Nützliche Sachen <small>für die Schule</small></h1> | |
</div> | |
<?php | |
if ((filter_input(INPUT_GET, "search") != null || filter_input(INPUT_GET, "filetype") != null)) { | |
$search = filter_input(INPUT_GET, "search") != null; | |
$filetype = filter_input(INPUT_GET, "filetype") != null; | |
$filename = 'Dateiname <span class="label label-warning">' . filter_input(INPUT_GET, "search") . '</span>'; | |
$thefiletype = 'Dateityp <span class="label label-danger">' . filter_input(INPUT_GET, "filetype") . '</span>'; | |
echo '<div class="well well-sm">'; | |
echo ($search ? $filetype ? $filename . ' / ' . $thefiletype : $filename : $thefiletype); | |
echo '</div>'; | |
} | |
?> | |
<div class="list-group"> | |
<?php | |
if ($handle = opendir('/var/www/schule/files')) { | |
while (false !== ($file = readdir($handle))) { | |
if ($file != "." && $file != "..") { | |
$file_array = split("\.", $file); | |
$filetype = $file_array[count($file_array) - 1]; | |
$filetype = strtolower($filetype); | |
if ($filetypecolor[$filetype] === null) { | |
$filetypecolor[$filetype] = $nextfree; | |
$nextfree++; | |
$nextfree %= 6; | |
} | |
unset($file_array[count($file_array) - 1]); | |
$filename = join(".", $file_array); | |
$mycolor = $colors[$filetypecolor[$filetype]]; | |
$myicon = $filetypeicon[$filetype] != null ? $fileicons[$filetypeicon[$filetype]] : $fileicons[0]; | |
if (filter_input(INPUT_GET, "search") != null) { | |
if (strpos(strtolower($filename), strtolower(filter_input(INPUT_GET, "search"))) === FALSE) { | |
continue; | |
} | |
} | |
if (filter_input(INPUT_GET, "filetype") != null) { | |
if (strpos($filetype, strtolower(filter_input(INPUT_GET, "filetype"))) === FALSE) { | |
continue; | |
} | |
} | |
echo '<a href = "files/' . $file . '" class = "list-group-item">'; | |
echo '<i class="fa fa-' . $myicon . '"></i> '; | |
echo $filename; | |
echo '<span class = "label label-' . $mycolor . ' pull-right">'; | |
echo $filetype; | |
echo '</span>'; | |
echo '</a>'; | |
} | |
} | |
closedir($handle); | |
} | |
?> | |
</div><!-- Single button --> | |
<div class="btn-group"> | |
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Dateityp<span class="caret"></span> | |
</button> | |
<ul class="dropdown-menu" role="menu"> | |
<?php | |
foreach ($filetypecolor as $key => $value) { | |
echo '<li><a href = "?filetype=' . $key . '">' . $key . '</a></li>'; | |
} | |
$time_end = microtime(true); | |
?> | |
</ul> | |
</div> | |
</div> | |
<div class="container"> | |
<hr> | |
<footer> | |
<p class="pull-left"><a href='https://gist.github.com/jmesserli/9032826'><i class="fa fa-code"></i> Sourcecode</a></p> | |
<p class="pull-right">Seite generiert in <?php echo round($time_end - $time_start, 4) ?> Sekunden</p> | |
</footer> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment