Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Errors when running php site map creation script
Old 08-11-2008, 02:18 AM Errors when running php site map creation script
grownupstudent's Avatar
Experienced Talker

Posts: 48
Name: Jono
Location: Ireland
Trades: 0
I'm using a php site map creation script but every time I put in the files to exclude where its commented to do it and run the script it errors, the site I'm working on can be seen here www.topskincare.net please click on site map and tell me how to exclude the two files with no title the parser and template file in the script below i.e. the correct way to write them in on the ignore line in the script, many thanks in advance for help.


<html>
<head>
<title>Site Map</title>
<!-- A php script from TemplateTool.co.uk -->
<style>
body {font-family: verdana; line-height: 1.2 }
/* Indent Styles */
.0 { text-indent: 0px; font-size: 12pt; font-weight: bold }
.1 { text-indent: 20px; font-size: 11pt }
.2 { text-indent: 40px; font-size: 10pt }
.3 { text-indent: 50px; font-size: 8pt }
.4 { text-indent: 60px; font-size: 8pt }
.5 { text-indent: 70px; font-size: 8pt }
</style>
</head>
<body>
<?php
// starting directory. Dot means current directory
$basedir = ".";

// function to count depth of directory
function getdepth($fn){
return (($p = strpos($fn, "/")) === false) ? 0 : (1 getdepth(substr($fn, $p 1)));
}

// function to print a line of html for the indented hyperlink
function printlink($fn){
$indent = getdepth($fn); // get indent value
echo "<li class=\"$indent\"><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], '/')-8); //print title
} else {
echo "No title";
}
echo "</a></li><br>\n"; //finish html
}

// main function that scans the directory tree for web pages
function listdir($basedir){
if ($handle = @opendir($basedir)) {
while (false !== ($fn = readdir($handle))){
if ($fn != '.' && $fn != '..'){ // ignore these
$dir = $basedir."/".$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 call
listdir($basedir); //this line starts the ball rolling
?>
</body>
</html>
grownupstudent is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-11-2008, 04:49 AM Re: Errors when running php site map creation script
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
To ingnore "FeedForAll_XMLParser.inc.php" and "sample-template.html" you can change:
PHP Code:
if ( ( $fn != '.' && $fn != '..' ) && ( $fn != 'FeedForAll_XMLParser.inc.php' && $fn != 'sample-template.html ) ) // ignore these 
But if it will become more filles you want to ignore it would be easier to use an array with filenames
bas is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 05:44 AM Re: Errors when running php site map creation script
grownupstudent's Avatar
Experienced Talker

Posts: 48
Name: Jono
Location: Ireland
Trades: 0
Thanks for the reply

When I changed the code I got this error

Parse error: syntax error, unexpected '}' in /home/tra2rapu/public_html/sitemap.php on line 58

I'm not sure what to do know, maybe theres a better script to try?
I'm not a programmer so when it comes to PHP I'm at the copy and paste level, lol, anyway I'll keep trying

Thanks
grownupstudent is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 05:58 AM Re: Errors when running php site map creation script
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
My mistake, I forgot a {
and some quotes :s

Code:
if ( ( $fn != '.' && $fn != '..' ) && ( $fn != 'FeedForAll_XMLParser.inc.php' && $fn != 'sample-template.html' ) ) { // ignore these

Last edited by bas; 08-11-2008 at 06:00 AM..
bas is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 06:27 AM Re: Errors when running php site map creation script
grownupstudent's Avatar
Experienced Talker

Posts: 48
Name: Jono
Location: Ireland
Trades: 0
Just to let you know I got it fixed, I'm using a script called ezmap now which runs fine, thanks.
grownupstudent is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 10:18 AM Re: Errors when running php site map creation script
grownupstudent's Avatar
Experienced Talker

Posts: 48
Name: Jono
Location: Ireland
Trades: 0
baz your a star worked first time thank you very much.

Cheers
grownupstudent is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Errors when running php site map creation script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23315 seconds with 12 queries