Thanks so much for taking the time to look at this.
The purpose of the code is to update another web page dynamically.
If you want to see it in action, go to stthaddaeus.etdiocese.net/news.php and click on the fleur-de-lis at the bottom of the page.
Here is the code (The error occurs in line 35 (the echo command) and keeps the code from executing, but the gethostbyaddr function is used several times):
<?php
if((!$_POST || !$_POST['pass'] || strcmp($_POST['pass'], "snick") !== 0) &&
(!$_POST['items']) ||
(!strstr($HTTP_SERVER_VARS["HTTP_REFERER"], "update.php")))
$count = 1;
else if($_POST && $_POST['pass'] && strcmp($_POST['pass'], "snick") !== 0)
$count = 1;
else
$count = 0;
include('header.php');
?>
<form name="form1" method="post" action="update.php">
<?php
if($_POST && $_POST['pass'] && strcmp($_POST['pass'], "snick") !== 0) {
$filename = "log.txt";
$handle = fopen($filename, "r+");
rewind($handle);
$logged = date("M d Y, H:i O", strtotime("now")) . " --- " .
gethostbyaddr($HTTP_SERVER_VARS["REMOTE_ADDR"]) . " --- " .
""" . $_POST['pass'] . ""n";
$oldfile = fread($handle, filesize($filename));
ftruncate($handle, 0);
rewind($handle);
fwrite($handle, $logged);
fwrite($handle, $oldfile);
fclose($handle);
}
echo date("M d Y, H:i O", strtotime("now")) . "
n";
echo gethostbyaddr($HTTP_SERVER_VARS["REMOTE_ADDR"]) . "
n";
if((!$_POST || !$_POST['pass'] || strcmp($_POST['pass'], "snick") !== 0) &&
(!$_POST['items']) ||
(!strstr($HTTP_SERVER_VARS["HTTP_REFERER"], "update.php"))) {
echo "<input type='password' size='20' name='pass'>n";
echo " <input type='submit' value='Log in'>n";
echo "<script language='JavaScript'>document.form1.pass.focus();</script>n";
echo "
A password is required to access this page. All access attempts are logged.n";
$fleur = 0;
}
else {
echo "<div>The current pageload count is: ";
echo "<span style='position:relative; top:3px'>";
echo "n";
echo "</span></div> Statistics on the last 100 hits can be seen ";
echo "<a href='http://my.statcounter.com/project/standard/stats.php?project_id=362930&guest=1'>here</a>.
";
echo "From this page, you can update the newsletter listings using the form below. Or, you can <a href='calendar.php'>edit</a> the online calendar.
n";
echo "<b>Format</b>
n";
echo "<b>(</b>filename<b> : </b>link text<b>)</b>
n";
echo "<i>e.g.,</i> <b>(</b>documents/temp.pdf<b> : </b>Week of January 1, 2005<b>)</b>
n";
echo "<textarea name='items' rows='7' cols='46'>n";
$filename = "data.txt";
$handle = fopen($filename, "r+");
rewind($handle);
if($_POST && $_POST['items']) {
ftruncate($handle, 0);
rewind($handle);
fwrite($handle, $_POST['items']);
$_POST['items'] = NULL;
$_POST = NULL;
}
rewind($handle);
echo stripslashes(fread($handle, filesize($filename)));
echo "</textarea>
n";
echo "<input type='submit' value='Update news'>n";
echo "<input type='button' value='View password error log'
onClick=" window.open('log.php?pass=acceptable','winwin',
'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0,width=750,height=250')">n";
echo "<input type='button' value='Log out' onClick="window.location='news.php'">n";
echo "
";
rewind($handle);
$buf = stripslashes(fread($handle, filesize($filename)));
$buf = str_replace("(", "<li><a href='", $buf);
$buf = str_replace(":", "'>", $buf);
$buf = str_replace(")", "</a></li>", $buf);
echo $buf;
}
?>
</form>
<?php
$blueimg = "blueflowerd.jpg";
include('footer.php');
?>