curtis Posted May 25, 2003 Posted May 25, 2003 OK, This is my first try with anything php so please bear with me. I found a php Sitemap I would like to use. The file has sitemap.php and several gif images. Should I create a new file in the public_html and put all files in it or just upload all files to the public_html folder. If you need to see the sitemap.php file let me know and I'll post it. curtis Quote
curtis Posted May 25, 2003 Author Posted May 25, 2003 I got it. Now to figure out how to exclude stuff I don't want listed. curtis Quote
Lianna Posted May 25, 2003 Posted May 25, 2003 Hey Curtis, can you show us what it looks like? There's another post here looking for a site map. Thanks. Quote
curtis Posted May 25, 2003 Author Posted May 25, 2003 OK Lianna here is the sitemap.php file. My problem using this sitemap is it shows ALL files and folders. When using CSB it shows all the HTMLobj folders ><?php //(C) copyright Metalhead 2002 //This script is released under the terms of the GNU General Public License. A copy of the GPL is included with this script. ?> <html> <head> <title>Sitemap</title> </head> <body> <b>Sitemap</b><p> <form action=<? echo $PHP_SELF; ?> method=post> Display <input type=radio name=display value=PHP>PHPs <input type=radio name=display value=HTML>HTMLs <input type=radio name=display value=both checked=yes>both <input type=submit value=Select> </form> <p> <? $stime = gettimeofday(); /* some preliminaries... */ $root = getcwd(); $pre = explode("/", $REQUEST_URI); array_pop($pre); $prefix = join("/", $pre); /* Uncomment the line below to create a tree of all files and directories on your webserver if the script * is in a subdirectory */ /* $root = str_replace($prefix, "", $root); */ $root .= "/"; /* Display server name and directory */ echo "<table cellspacing=0 cellpadding=0 border=0>\n"; echo "<tr><td><img align=absmiddle src=server.gif> http://$SERVER_NAME"; if($root == getcwd()."/") { echo "$prefix/"; } else { echo "/"; } echo "</td></tr><tr><td><img align=absmiddle src=vertical.gif></td></tr>\n"; /* Recursion, here we go.. */ function list_dir($chdir) { /* some globals, some cleaning */ global $root, $display, $prefix, $PHP_SELF; unset($sdirs); unset($sfiles); chdir($chdir); $self = basename($PHP_SELF); /* open current directory */ $handle = opendir('.'); /* read directory. If the item is a directory, place it in $sdirs, if it's a file of the type * php, htm, html or shtml and not this file, put it in $sfiles */ while ($file = readdir($handle)) { if(is_dir($file) && $file != "." && $file != "..") { $sdirs[] = $file; } elseif(is_file($file) && $file != "$self" && ereg("(php|htm|html|shtml)$", $file)) { $sfiles[] = $file; } } /* count the slashes to determine how deep we're in the directory tree and how many * nice bars we need to add */ $dir = getcwd(); $dir1 = str_replace($root, "", $dir."/"); $count = substr_count($dir1, "/") + substr_count($dir1, "\\"); /* display directory names and recursively list all of them */ if(is_array($sdirs)) { sort($sdirs); reset($sdirs); for($y=0; $y<sizeof($sdirs); $y++) { echo "<tr><td>"; for($z=1; $z<=$count; $z++) { echo "<img align=absmiddle src=vertical.gif> "; } if(is_array($sfiles)) { echo "<img align=absmiddle src=verhor.gif>"; } else { echo "<img align=absmiddle src=verhor1.gif>"; } echo "<img align=absmiddle src=folder.gif> $sdirs[$y]</td></tr>\n"; $cwd1[0] = $dir; $cwd1[1] = $sdirs[$y]; $chdir = join("/", $cwd1); list_dir($chdir); } } chdir($chdir); /* iterate through the array of files and display them */ if(is_array($sfiles)) { sort($sfiles); reset($sfiles); if(!isset($display)) { $display = "both"; } $sizeof = sizeof($sfiles); /* what file types shall be displayed? */ for($y=0; $y<$sizeof; $y++) { if(ereg("php$", $sfiles[$y]) && ($display == "both" || $display == "PHP")) { echo "<tr><td>"; for($z=1; $z<=$count; $z++) { echo "<img align=absmiddle src=vertical.gif> "; } if($y == ($sizeof -1)) { echo "<img align=absmiddle src=verhor1.gif>"; } else { echo "<img align=absmiddle src=verhor.gif>"; } echo "<img align=absmiddle src=php.gif> "; echo "<a href=\"$prefix$dir1/$sfiles[$y]\">$sfiles[$y]</a></td></tr>"; } elseif(ereg("(html|htm|shtml)$", $sfiles[$y]) && ($display == "both" || $display == "HTML")){ echo "<tr><td>"; for($z=1; $z<=$count; $z++) { echo "<img align=absmiddle src=vertical.gif> "; } if($y == ($sizeof -1)) { echo "<img align=absmiddle src=verhor1.gif>"; } else { echo "<img align=absmiddle src=verhor.gif>"; } echo "<img align=absmiddle src=html.gif> "; echo "<a href=\"$prefix$dir1/$sfiles[$y]\">$sfiles[$y]</a></td></tr>\n"; } } echo "<tr><td>"; for($z=1; $z<=$count; $z++) { echo "<img align=absmiddle src=vertical.gif> "; } echo "</td></tr>\n"; } } list_dir($root); echo "</table>\n"; /* How long did that need..? */ $ftime = gettimeofday(); $time = round(($ftime[sec] + $ftime[usec] / 1000000) - ($stime[sec] + $stime[usec] / 1000000), 5); echo "<center>This page was generated in $time seconds.</center>\n"; ?> </body> </html> I really like the way it looks using folder ans file icons but if I can't edit out the unwanted stuff I'll find something else. On the bright side I did install my first php and get it to work. curtis Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.