<!doctype html public "-//w3c//dtd html 3.2//en">
<!--
/* This chat has been created by Nicola Delbono <hide@address.com> */
/* you can modify and/or use the code for free. Pleeease keep these three lines */
/* into your customized chat */
-->
<html>
<head>
<title>chat</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<!-- Arachnophilia is free but !careware! -->
<!-- http://www.arachnoid.com/arachnophilia/index.html -->
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
$person = str_replace ("\n"," ", $person);
$person = str_replace ("<", " ", $person);
$person = str_replace (">", " ", $person);
$person = stripslashes ($person);
?>
<form action="chat.php" method="post">
Nickname: <input type="text" name="person" size="40" maxlength="80" value="<? echo $person; ?>"><br>
Your message: <textarea name="message" rows="3" cols="40"></textarea>
<input type="submit" value="Send/refresh">
</form>
<?
/* the $chat_file_ok is a txt file (or whatever else) I use for */
/* messages storage */
$chat_file_ok = "c:\\foxserv\\www\\p2p\\chat\\msg.txt";
/* $chat_lenght is the number of messages displayed */
$chat_lenght = 10;
/* $max_file_size is the maximum file size the msg.txt file can reach */
/* assuming that any chatter doesn't write a message longer than */
/* $max_single_msg_lenght (this case: 100,000 bytes = 100Kb) */
$max_single_msg_lenght = 100000;
$max_file_size = $chat_lenght * $max_single_msg_lenght;
/* check if file size is over maximum (set with $max_file_size ) */
$file_size= filesize($chat_file);
/* if file size is more than allowed then */
/* reads last $chat_lenght messages (last lines of msg.txt file) */
/* and stores them in $lines array */
/* then deletes the "old" msg.txt file and create a new msg.txt */
/* pushing the "old" messages stored in $lines array into the */
/* "new" msg.txt file using $msg_old. */
/* Note: this is done in order to avoid huge msg.txt file size. */
if ($file_size > $max_file_size) {
/* reads _size=iabstores each line $lines' array elements */
$lines = file($chat_file_ok);
/*get number of lines */
$a = count($lines);
$u = $a - $chat_lenght;
for($i = $a; $i >= $u ;$i--){
$msg_old = $lines[$i] . $msg_old;
}
$deleted = unlink($chat_file_ok);
$fp = fopen($chat_file_ok, "a+");
$fw = fwrite($fp, $msg_old);
fc
wsg_}ize) shinfothanile ihat case) r whyrite a me chaordbe str_rd arrays is $max_s each do size the msg.tx.. Y/
/* yorluet n\n (ate ount($m (set"; ?>"c//dtdtagg thway.00Kb) sgperson = str_replace ("\n",ite a mt_file);
sizse)roesn'tesso.php$ma...ld. *ht iste ate a mele_oppluetd ray inze the msg.tx REMEMBER:y inzete a mele_oppluetd, /* ce, che **/
/wanty inzages ete a meordbessages dis asy into the *sg.res s i,* ine cvmeordnes he *1.ize=iay inza*/
$("old" me) array in$lines ao the *2. {
/y in$linesh dorr whe) ne ind. *3. thody inzete a msh do sizouta>
<a txt r usepen)size. I add allowep these threes done in order to buggyc//dtde the _sizstripssize sgperson = str_replace ("\n",ite a mt_f sgperson = str_replace ("<", sgt_f sgperson = str_repl>ce ("<", sgt_f sgperson = stripslas sgt_fffff/
sgp!le_" ;$e_ok);
$fp = fopen($chat_file_ok, "a+");
$fw = fwritelac<b>son);
$p:</b>, sg; ?>"sg_old);
fc
wsg_}izs */
$lines = file($chat_file */
$a = count($lines);
$u = $a - $chat_le {
/* in$linesh dorr whe) ne ine _siouta>
haordmizedizenght;
for($i = $a; $i >= $u ;$i-e="<? d = $lines["<h?>"sg_ol
rson/fo/ad>
</fo/ -->
<