My News Script
<?
function News()
{
if (!isset($_GET['do']))
{
$local_file = 'news.nfo';
$file = fopen($local_file , 'r') or die("Couldn't open first place");
while (!(feof($file)))
{
$news[] = fgets($file, 1000); //Slap each line upto 1000 chars into an array
}
$servertime = time();
echo date("H:i:s, d M, Y", $servertime) . "\r\n";
$numitems = count($news);
echo "Count : $numitems\r\n";
for($x=0; $x < $numitems; $x++)
{
echo $news[$x] . "";
}
fclose($file);
}
elseif ($_GET['do'] == "new")
{
echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . "?do=add\">\n" .
"Author" .
'<input type="text" size="15" name="author">' .
"Message To add :\n" .
'<textarea rows="20" cols="60" name="new_news">' .
'</textarea>' .
'<input type="submit" name="submit" value="Add News">' .
'</form>';
}
elseif ($_GET['do'] == "add")
{
$time = time();
$read_time = date("H:i:s, d M, Y", $time);
$unstripped_news = $_POST['new_news'];
$new_news = stripslashes($unstripped_news);
$author = $_POST['author'];
$fpnews = fopen('news.nfo', 'r');
$old_content = fread($fpnews, filesize('news.nfo'));
$fp = fopen('news.nfo', 'w');
fwrite($fp, "\r\n$time\r\n$author\r\n$new_news\r\n$old_content", (strlen($time) + strlen($new_news) + strlen($author) + strlen($old_content) + 16));
echo "Message added successfully. Here is what you posted.\n" .
"Submitted on $read_time\n" .
"By : $author \n" .
"Message : \n$new_news \n";
echo "Back to <a href=" . $_SERVER['PHP_SELF'] . ">Message Broad</a>";
fclose($fpnews);
fclose($fp);
}
}
echo "<a href=" . $_SERVER['PHP_SELF'] . "?do=new>Add A Message</a>\n";
?>
How To Make It Show That Users Ip By The Message They Wrote?