GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Mar-2003, 15:31
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough

A very good sitemap script


I was looking around for some PHP scripts for my site to play about with and I found this: (I'm not expecting you to read it all lol just skip past it)
PHP Code:

<?
//(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&nbsp;<input type=radio name=display value=HTML>HTMLs&nbsp;<input type=radio name=display value=both checked=yes>both&nbsp;&nbsp;&nbsp;
<input type=submit value=Select>
</form>
<p>

<?

$stime = gettimeofday();

$root = getcwd();

$pre = explode("/", $REQUEST_URI);
array_pop($pre);
$prefix = join("/", $pre);

echo "<table cellspacing=0 cellpadding=0 border=0>";
echo "<tr><td><img align=absmiddle src=server.gif> http://$SERVER_NAME$prefix/</td></tr><tr><td><img align=absmiddle src=vertical.gif></td></tr>";

function list_dir($chdir)
{
          global $root, $display, $prefix, $PHP_SELF;
          unset($sdirs);
          unset($sfiles);
          chdir($chdir);
          $self = basename($PHP_SELF);
          $handle = opendir('.');
          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; }
          }
          
          $dir = getcwd();
          $dir1 = str_replace($root, "", $dir);
          $count = substr_count($dir1, "/") + substr_count($dir1, "\\\\");
                
          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>&nbsp;&nbsp;&nbsp;"; }
                                  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>";
                                  $cwd1[0] = $dir;
                                    $cwd1[1] = $sdirs[$y];
                                  $chdir = join("/", $cwd1);
                                  list_dir($chdir);
                             }
          }
                   
          chdir($chdir);
          
          if(is_array($sfiles))
          {
                                sort($sfiles);
                              reset($sfiles);
                             
                             if(!isset($display))
                             { $display = "both"; }
                             
                             $sizeof = sizeof($sfiles);
                             
                             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>&nbsp;&nbsp;&nbsp;"; }
                                   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>&nbsp;&nbsp;&nbsp;"; }
                                   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>";
                             }
                             }
                               echo "<tr><td>";
                             for($z=1; $z<=$count; $z++)
                               { echo "<img align=absmiddle src=vertical.gif>&nbsp;&nbsp;&nbsp;"; }
                             echo "</td></tr>"; 
          }
}

list_dir($root);

echo "</table>";

$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>";

?>


</body>
</html>

Okay that was quite long. The problem is I want to use this as a sitemap for my site but I want to protect many files and folders from being seen. My question is what do I put in to the code in order to hide them? If you like the code you can get it from http://www.metalhead.ws/phpbin/. Cheers very much. Rob
  #2  
Old 02-Mar-2003, 15:44
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
I will check this code out later today and if no one has replied before that, I'll tell you what I find out.

I imagine this code even dishes out all your include files, if any?

What's with the form bit? That's definitely NOT SE friendly - not something you'd want on your sitemap these days...

If you have a test page already set up, please PM it to me if you don't want to link to it from here.
  #3  
Old 02-Mar-2003, 16:50
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
I've decided that although it is a good sitemap for your own reference, its not especially good for others to use since it seems to be quite a download just to check each time. Thanks for offerning to check the script JDS but don't worry about it I'll think before I jump next time.
  #4  
Old 03-Mar-2003, 01:07
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Yeah, gimme a tough one next time
 

Recent GIDBlogThe bogus security of airport screening by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I find web statistics script / software? rhino1616 Web Design Forum 2 02-Jan-2004 20:31
JavaScript Tutorial Part 1 pcxgamer Web Design Forum 2 01-Dec-2003 09:16
VALIDATING file types on an PHP upload script? JdS MySQL / PHP Forum 0 02-Jan-2003 07:58
A good pop-under script? JdS Web Design Forum 4 18-Jun-2002 08:39
Searching for a good webstat script JdS Free Web Hosting 2 24-Oct-2001 20:16

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:39.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.