'); if ($tagstr) { $pagelen = strlen($page); $firstlen = $pagelen - strlen($tagstr); $firstpart = substr($page, 0, $firstlen); $lastpart = substr($page, $firstlen, $pagelen - $firstlen); $textbody = stristr($text, '')) + 2; $textbodylen = $textlen - $textskiplen - strlen(stristr($text, '')); $text = substr($text, $textskiplen, $textbodylen); $page = $firstpart . $text . $lastpart; return($result); } } /* Do not escape all double-quotes literally */ set_magic_quotes_runtime(0); /* The document's real name */ $replacename = $mainframedoc . '_noframe.html'; /* Manage file title cache */ $titledirname = '../../php4/tmp/titles/'; if (file_exists($titledirname) && filetype($titledirname) == 'dir') { $cachename = $titledirname . $mainframedoc . '_title.txt'; if (file_exists($cachename) && filectime($cachename) > filectime($replacename)) { $fd = fopen($cachename, 'r'); $title = fread($fd, filesize($cachename)); fclose ($fd); } else if (file_exists($replacename)) { $fd = fopen($replacename, 'r'); $title = fread($fd, filesize($replacename)); fclose ($fd); FindBetween(&$title, '', ''); $fd = fopen($cachename, 'w'); fwrite($fd, $title); fclose ($fd); } } /* Read document into the $contents variable */ $filename = 'index.html'; $fd = fopen($filename, 'r'); /* This is the normal way of reading from a file */ /* However, this will escape all double-quotes literally " -> \" */ /* if magic_quotes_runtime has been enabled */ $contents = fread($fd, filesize($filename)); /* This is a performance killer; but it works, if /* magic_quotes_runtime has been enabled */ /* while (!feof ($fd)) */ /* $contents = $contents . fgetc($fd); */ fclose($fd); if (file_exists($replacename)) { ExchangeTag(&$contents, 'person_noframe.html', $replacename); $oldtitle = $contents; FindBetween(&$oldtitle, '', ''); ExchangeTag(&$contents, $oldtitle, $title); InsertText(&$contents, $replacename); } echo $contents; ?>