PDA

View Full Version : Help Combining "Simple Tree Menu" With My PHP Script



Jesse B
08-21-2010, 01:36 AM
Simple Tree Menu
http://www.dynamicdrive.com/dynamicindex1/navigate1.htm

For awhile now I've been working on writing a series of scripts to allow me to remotely and securely log into my media server from outside of my network, and browse/download files. I wanted to have collapsible directories, as my current script directs you to a new page displaying said directory's contents.

Anyways, I ran into this script this morning, and it's pretty much exactly what I wanted. I tried to combine it with my current PHP script, but every attempt I've made has failed. I was just looking for some possible pointers to help me out.

I've pasted my php script below:


<HTML>
<HEAD>

<TITLE>
File Index
</TITLE>

<?php include('menu.html'); ?>

</HEAD>

<FONT size = "2">

<?php

$myDirectory = opendir(".");

while($entryName = readdir($myDirectory))
{
$dirArray[] = $entryName;
}

closedir($myDirectory);

$indexCount = count($dirArray);
Print("$indexCount files<br>\n");

sort($dirArray);

print("<TABLE border=0 cellpadding=5 cellspacing=0 class=whitelinks>\n");
print("<TR><TH>File Name</TH><TH>File Type</TH><TH>File Size</TH></TR>\n");

for ($index = 0; $index < $indexCount; $index++)
{
if (substr("$dirArray[$index]", 0, 1) != ".")
{
print("<TR><TD><a href =\"$dirArray[$index]\">$dirArray[$index]</a></TD>");
print("<TD>");
print(filetype($dirArray[$index]));
print("</TD>");
print("<TD>");
$filesize_kb = ((filesize($dirArray[$index])) / 1000);
$filesize = substr("$filesize_kb", 0, -1); // May not work with files larger than 10kB, unsure yet
print $filesize;
print(" kB");
print("</TD>");
print("</TR>\n");
}
}

print("</TABLE>\n");

?>

</FONT>
</BODY>
</HTML>

Thanks guys,


- Jesse