<?php
/*2010-08 johnpfeiffer
index pages Search Engine Optimised, title, etc. will be the current dir
"bread crumb" listing for site navigation at the top
*/
$servername = $_SERVER['SERVER_NAME'];
$page = $_SERVER['PHP_SELF']; //get the url of the resource (webpage)
$dirs = dirname( $page ); //get the dirs that lead to the urls
$querystring = $_SERVER['QUERY_STRING'];
//HEAD SETUP
$title = explode( "/" , $page ); //break the url into pieces
$currentfile = end( $title ); //the name of the current file (last piece)
$currentdirectory = prev( $title ); //find the current directory
$currentdirectory = explode( "-" , $currentdirectory ); //the directory name into array of words
$seocontent = implode( " " , $currentdirectory ); //create a string from words (with spaces)
//$title = array_reverse( $title ); //attempt to add more words in title?
print "<head><title>$seocontent</title>" .
"\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>" .
"\n<meta name=\"description\" content=\"$seocontent\"/>" .
"\n<meta name=\"keywords\" content=\"$seocontent\"/>";
print "\n";
$cssfile = $_SERVER["DOCUMENT_ROOT"] . "/includes/john-index.css";
print '<link rel="stylesheet" type="text/css" href="' . $cssfile . '">';
print "\n</head><body>\n";
/* ########## begin section on BREADCRUMBS so users can quickly navigate ######### */
$path = 'http://' . $servername;
print '<a href="' . $path . '">' . $servername . "</a>";
print "\n";
$dirs_array = explode("/", $dirs);
for( $i=1; $i < count($dirs_array); $i++ )
{
$path .= '/';
$path .= $dirs_array[$i];
print " / ";
print '<a href="' . $path . '">' . $dirs_array[$i] . "</a>";
print " \n";
}
/* ########## end section on BREADCRUMBS so users can quickly navigate ######### */
print "<h3>$seocontent</h3>\n";
$dh = opendir( getcwd() ); //get current working directory
$filecount = 0;
$directorycount = 0;
while (false !== ($file = readdir($dh)))
{
if( $file != "." && $file != ".." ) //don't test the root directories
{
if( is_file($file) )
{
$filelist[$filecount]['filename'] = $file;
$filelist[$filecount]['filesize'] = filesize($file) ;
$filelist[$filecount]['lastmodified'] = filemtime($file) ;
$filecount++;
}
else
{ $dirlist[] = $file; }
}
}
print count($dirlist) . " directories and " . $filecount . " files.";
print "\n<br />";
print "\n<br />";
print "<table>\n"; //a table for our dir/file names & sizes
/*
if( $dirlist[0] != NULL ) //maybe there are no directories
{
sort($dirlist);
foreach ($dirlist as $value)
{
print "<tr>";
print "<td><a href=\"" . $value . "\"><b>" . $value . "</b></a></td>\n";
print "<td> </td>";
print "<td>" .date("Y-m-d H:i T", filemtime($value)) . "</td>";
print "</tr>\n";
}
print "</b>";
}
*/
sort( $filelist );
for( $i = 0; $i < count( $filelist ) ; $i++)
{
print "<tr>" .
"<td><a href=\"" . $filelist[$i]['filename'] . "\">" . $filelist[$i]['filename'] . "</a></td>";
print "<td> </td>";
print "<td>" . number_format( $filelist[$i]['filesize'] ) . " bytes</td>";
print "<td> </td>";
print "<td>" . date("Y-m-d H:i T", $filelist[$i]['lastmodified'] ) . "</td>";
print "</tr>\n";
}
print "</table>";
array_multisort($filelist, $filelist[1]
);
print "<pre>";
print_r( $filelist );
print "<\pre>";
print "\n<br />";
closedir($dh);
?>
</body>
</html>