21-07-2006, 21:04
|
|
|
חבר מתאריך: 25.03.05
הודעות: 381
|
|
תודה על הערה, תוקן
הנה הקוד נכון לעכשיו:
קוד PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <?php
@$sub = $_POST['sub']; @$pre = $_POST['pre']; @$text = $_POST['text']; @$name = $_POST['name'];
?> <html dir="rtl"> <head> <title>צאט</title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1255" /> <link rel="stylesheet" href="1/style.css" type="text/css" /> <script type="text/javascript"> function textLimit(field, maxlen) { if (field.value.length > maxlen + 1) alert('אסור לכתוב יותר מ 250 תווים!'); if (field.value.length > maxlen) field.value = field.value.substring(0, maxlen); } </script> </head> <body onload="window.scrollTo(0,99999);"> <div id="chat"> <h3 align="center">צאט</h3> <?php $file = '1/file.txt';
if ($sub) { $nam = $name; if ($nam == "") { $nam = "אנונימי"; } $fp = fopen($file, 'a') or die("ההודעה לא נשלחה"); $text = htmlspecialchars($text); $nam = htmlspecialchars($nam); $text = str_replace( "\r\n", " ", $text); fwrite($fp, "\r\n".$nam." ".$text); fclose( $fp ); }
$fp = fopen( $file, 'r' ); $file_contents = fread( $fp, filesize( $file ) ); fclose( $fp );
$lines = explode ( "\n", $file_contents ); $a = array (":)", ":(", ":D", ":P", "[b]", "[/b]", "[i]", "[/i]"); $b = array ("<img src='1/happy.gif' alt='' />", "<img src='1/sad.gif' alt='' />", "<img src='1/biggrin.gif' alt='' />", "<img src='1/tongue.gif' alt='' />", "<strong>", "</strong>", "<i>", "</i>");
foreach ( $lines as $line ) { list( $nam, $tex ) = explode( ' ', $line ); $tex = str_replace( $a, $b, $tex); echo "<div class=\"mes\"><b style=\"color: #000;\">".$nam."</b>: ".$tex."</div>"; } if ($pre) { ?> <h4>תצוגה מקדימה</h4> <?php $text = htmlspecialchars($text); $name = htmlspecialchars($name); $text = str_replace( $a, $b, $text); if ($name == "") { $name = "אנונימי"; } echo "<div class=\"mes\"><b style=\"color: #000;\">".$name."</b>: ".$text."</div>"; } ?>
<h5>הודעה חדשה</h5> <form method="post" action="" name="message"> שם <small> (מקסימום 30 תווים)</small> <br /><input type="text" name="name" class="te" value="<? echo $name; ?>" maxlength="30" /><br /> הודעה <small> (מקסימום 250 תווים)</small> <br /><textarea name="text" class="te" style="height: 70px;" id="test" onkeyup="textLimit(this.form.test, 250);"><?php if($pre) { $text = str_replace( $b, $a, $text); echo $text; } ?></textarea><br /> <input type="submit" value="תצוגה מקדימה" name="pre" class="sub" /> <input type="submit" value="שלח" name="sub" class="sub" /> </form><br /> </div>
<div class="spe"> <h3 align="center">דברים מיוחדים</h3> :) יתן <img src="1/happy.gif" alt=" " /> <hr /> :( יתן <img src="1/sad.gif" alt=" " /> <hr /> :D יתן <img src="1/biggrin.gif" alt=" " /> <hr /> :P יתן <img src="1/tongue.gif" alt=" " /> <hr /> לכתב מודגש מוסיפים בהתחלה [b] ובסוף [/b]<hr /> לכתב נטוי מוסיפים בהתחלה [i] ובסוף [/i] </div> </body> </html>
|