serverman Posted May 24, 2008 Share Posted May 24, 2008 Ok i wrote (mainly form random snippets) a site map tool... but i have pages i want it not to read (like my quiz grader and the add member stuff here is the code <?php // starting directory. Dot means current directory $BD = "."; $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Site Map</title> </head> <body>'; // function to count depth of directory function depth($fn){ return (($p = strpos($fn, "/")) === false) ? 0 : (1 + depth(substr($fn, $p+1))); } // main function that scans the directory tree for web pages function listdir($BD){ if ($handle = @opendir($BD)) { while (false !== ($fn = readdir($handle))){ if ($fn != '.' && $fn != '..'){ // ignore these $dir = $BD."/".$fn; if (is_dir($dir)){ listdir($dir); // recursive call to this function } else { //only consider .html etc. files if (preg_match("/[^.\/].+\.(htm|html|php)$/",$dir,$fname)) { printlink($fname[0]); //generate the html code } } } } closedir($handle); } } // function to print a line of html for the indented hyperlink function printlink($fn){ $indent = depth($fn); // get indent value for ($i = 1; $i <= $indent; $i++) { echo " "; } echo "<a href=\"$fn\">"; //print url $handle = fopen($fn, "r"); //open web page file $filestr = fread($handle, 1024); //read top part of html fclose($handle); //clos web page file if (preg_match("/<title>.+<\/title>/i",$filestr,$title)) { //get page title echo substr($title[0], 7, strpos($title[0], '/')-; //print title } else { echo "No title"; } echo "</a><br />\n"; //finish html } // function call listdir($BD); //this line starts the ball rolling //timer end $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); echo '<p>Page generated in '.$total_time.' seconds.</p>'."\n"; echo' </body> </html> '; ?> here is my idea how to do it (i just don't know how to make my idea work ) in code tell to not read page if the page has <?php $r = n; ?> and read it if $r = y(so i would add <?php $r = n; ?> in the header of every page i don't want it to print in the site map and i would put <?php $r = y; ?> on all the other pages) ... i hope i made sense ... but i really have no idea how to get that to work! lol im a noob!!!!! oh one last thing if where i got the snippet from doesn't put a copyright do i need to add a copyright to it for them(add //copy right = website i got it from) or just leave it be ... hehe i forgot about all the notes i wrote to myself in there Link to comment https://forums.phpfreaks.com/topic/107032-solved-blocking-my-sitemap-from-viewing-files/ Share on other sites More sharing options...
serverman Posted May 24, 2008 Author Share Posted May 24, 2008 any one got any ideas it would be a big help! please and thank you!!! Link to comment https://forums.phpfreaks.com/topic/107032-solved-blocking-my-sitemap-from-viewing-files/#findComment-548688 Share on other sites More sharing options...
sasa Posted May 24, 2008 Share Posted May 24, 2008 ad tag <!-- no show --> just after </title> tag in same line change your functio to function printlink($fn){ $handle = fopen($fn, "r"); //open web page file $filestr = fread($handle, 1024); //read top part of html fclose($handle); //clos web page file if(strpos($filestr,'<!-- no show -->')) return false; $indent = depth($fn); // get indent value for ($i = 1; $i <= $indent; $i++) { echo " "; } echo "<a href=\"$fn\">"; //print url if (preg_match("/<title>.+<\/title>/i",$filestr,$title)) { //get page title echo substr($title[0], 7, strpos($title[0], '/')-; //print title etc. Link to comment https://forums.phpfreaks.com/topic/107032-solved-blocking-my-sitemap-from-viewing-files/#findComment-548704 Share on other sites More sharing options...
serverman Posted May 24, 2008 Author Share Posted May 24, 2008 Sweet thanks that works great! Link to comment https://forums.phpfreaks.com/topic/107032-solved-blocking-my-sitemap-from-viewing-files/#findComment-548996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.