Can someone take a look at my code below and see if they notice any problems. I've been trying to get this program to work for the past 3 days, but am stuck. I think it has something to due with my php or apache settings, but I want to make sure my code is ok. It may be a problem with my fopen settings too. At this point I'm clueless. I'm running php & apache on win2k. If you know of any settings in apache or php that need to be set to allow this type of file manipulation, plz let me know. Thanks for any help.
<?
$filename = "$DOCUMENT_ROOT/files/alice/fetchurl.php";
$fp = fopen ($filename, "r+");
$pattern = "|(<TITLE>[ a-zA-Z0-9/\"'._?&=:,-]*</TITLE>)|";
$text = "";
while($line = fgets($fp, 1024)){
$text .= $line;
}
preg_match_all($pattern, $text, $matches);
for ($i = 0; $i < count($matches[1]); $i++) {
print "Link Found: ".$matches[1][$i]."<br>\n";
$newname = strip_tags($matches[1][$i]).".htm";
rename($filename, $newname);
}
echo $newname;
fclose($fp);
?>
Output:
Link Found:
Warning: Rename failed (Permission denied) in c:\program files\apache group\apache\htdocs\files\rename3.php on line 28
brush_away.tab.htm