Wednesday, December 5, 2012

Too Many Dirs!

sick

Work I'm doing right now while sick as shit from home. Using this to make a landing page archive viewer, just save this as index.php and drop your landing page or newsletter folders in the same directory for a quick archive page [:


[sourcecode language="php"]
<?php
define('BD', '<INSERT PATH HERE>');

$_dirs = scandir(BD);
$x = 0;
foreach ($_dirs as $_dir) {
if (is_dir($_dir) && $_dir !== '.' && $_dir !== '..') {
$dirs[] = $_dir;
$inner_dir_contents = scandir(BD.$_dir);}
$x++;} $c = count($dirs);
?>

<!DOCTYPE HTML><html lang="en-US"><head>
<style type="text/css">
#nav ul{list-style: none;}
.left {background: #e0e0e0;}
body {height: 100%;background:#333;}
#nav ul li a{color: #555;font-size: 18px;padding: 3px;}
#nav ul li:hover, .active{color: #fff;background: #600;}
#nav ul li{border-bottom: 1px solid #777;line-height: 25px;}
.left p{text-align: center;color: #333;font-weight: bold;font-size: 22px;}
#nav {width:15%;float:left;height: 400px;overflow: scroll;background: white;}
#frame-container {width:82%;height:600px;float:left;border:solid 20px #fff;min-height: 100%;}
</style>
</head>
<body>
<div class="left">
<p>Past Promotions</p>
<div id="nav">
<ul>
<?php
for ($x = ($c - 1); $x >= 0; $x--)
echo '<li><a class="frame_nav" href="'.$dirs[$x].'/index.php">'.
ucwords(str_replace('-', ' ', str_replace('_', ' ', $dirs[$x])))
.'</a>';
?>
</ul>
</div>
</div>
<div id="frame-container">

</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('.frame_nav').click(function(e) {
$('.frame_nav').each(function(){$(this).parent().removeClass('active');});
$(this).parent().addClass('active');
e.preventDefault();
$('#frame').attr('src', $(this).attr('href'));
})
})
</script>
</body></html>
[/sourcecode]

No comments:

Post a Comment