
Ich möchte in meine Seite eine kleine Shoutbox einbauen.. Allerdings ist der Code teils PHP und teils HTML.. Sehr komfortabel wäre es über einen benutzerdefinierten Tag gewesen, dort lässt sich allerdings nur PHP verwenden.
Was gibt es denn da für eine Möglichkeit? Hier mal der Code:
Code: Select all
<table width=135>
<font face="Geneva,Verdana,Arial,Helvetica,Geneva" style="font-size:9px;">
<?
$person = str_replace ("\n"," ", $person);
$person = str_replace ("<", " ", $person);
$person = str_replace (">", " ", $person);
$person = stripslashes ($person);
?>
<form action="index.php" method="post">
Nick:<br><input type="text" name="person" class=textfeld size="20" maxlength="20" value="<? echo $person; ?>"><br><br>
Message:<br><input type="text" name="message" class=textfeld size="20" maxlength="90"><br><br>
<input type="submit" value="send/refresh" class=button>
</form>
<?
$chat_file_ok = "msg.txt";
$chat_lenght = 7;
$max_single_msg_lenght = 512;
$max_file_size = $chat_lenght * $max_single_msg_lenght;
$file_size= filesize($chat_file_ok);
if ($file_size > $max_file_size) {
$lines = file($chat_file_ok);
$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);
fclose($fp);
}
$msg = str_replace ("\n"," ", $message);
$msg = str_replace ("\n"," ", $message);
$msg = str_replace ("<", " ", $msg);
$msg = str_replace (">", " ", $msg);
$msg = stripslashes ($msg);
if ($msg != ""){
$fp = fopen($chat_file_ok, "a+");
$fw = fwrite($fp, "\n<b>$person :</b> $msg<br>");
fclose($fp);
}
$lines = file($chat_file_ok);
$a = count($lines);
$u = $a - $chat_lenght;
for($i = $a; $i >= $u ;$i--){
echo $lines[$i] . "<br>";
}
?>
</table>