You are here: PHP - Creating site map file challenge indeed ... HELP!!! « All PHP « IT news, forums, messages
PHP - Creating site map file challenge indeed ... HELP!!!

Posted by Gary on 11/15/05 18:37

Hi all

Finally seeking some expert advice please. With the following code
segment I'm hoping to update a predefined htm template page with some
links that are generated via another php script. However when I look at
the MySiteMap.htm file it seems to contain what seems to be buffered
screen data. Not only do I get the link inserted as designed I also get
all sorts of other screen displays inserts as well.

Can anyone see anything that is obviously wrong with the following code
segment???

Many thanks, Gary


<my code start>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<?php

//Set up variables.
$WebsiteURL = 'http://www.SomeSite.com/index.php'; //Some Web
address.
$MySiteMapTemplate = './MySiteMapTemplate.htm';
//MySiteMapTemplate.htm is a predefined htm page that I want to add the
links to.
$MySiteMap = './MySiteMap.htm'; //The target htm Site Map file.
$url_MySiteMapTemplate = $WebsiteURL . '/SEO/MySiteMapTemplate.htm';
//The url of the MySiteMapTemplate.htm file.

//NOTE!: $url_links is populated with a whole lot of link that are
concatenated together and not jsut the one link shown.
$url_links = '<a href="SomeLinkFile.htm" title="title"
target="_blank">text</a>';

//Create the Site Map File.
//First ready the MySiteMap.htm file for input.
if (file_exists($MySiteMap)){
unlink($MySiteMap);
copy ($MySiteMapTemplate, $MySiteMap);
}else{
copy ($MySiteMapTemplate, $MySiteMap);
}

//open the file with handle $file.
$file = fopen($MySiteMap, w) or die("can't open file");

//Read the MySiteMapTemplate.htm file into an array denoted as
$url_MySiteMap_lines.
$url_MySiteMap_lines = file($url_MySiteMapTemplate);

//Update the links in the MySiteMap.htm file.
foreach($url_MySiteMap_lines as $MySiteMap_line) {
if (substr(trim($MySiteMap_line),0,6) == '<body>'){
$MySiteMap_line = "<body><br>" . $url_links;
}
fwrite($file, $MySiteMap_line);
}

//Close the MySiteMap.htm filehandle.
fclose($file);

?>
<body>

</body>
</html>

<my code end>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация