Умные люди конечно обрамляют php в [/code], но [/php] однозначно нечитабелен.
PHP код:
<?php
header("Expires: ".gmdate("D, d M Y H:i:s")."GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
?>
<?php
<?php
error_reporting(7);
require ('required/config.php');
$chat_file_ok = "required/msg.txt";//message file
$users_file = "required/users.txt";//The file where you save users and passwords
if($show_without_time == "no"){//show time?
$substart=0;
}else{
$substart=19;
}
/* check banning */
/* --------------- */
$banned_file = "required/banned_ip.txt";//the file with banned ips
$text_string = join ('', file ($banned_file));
if (ereg("(.)*$password\n",$text_string)){//this user was banned
$text_string = join ('', file ($users_file));
$new_list= str_replace ("$password", " banned", $text_string);
$fcusers = fopen($users_file, "w");
$fwcusers = fwrite($fcusers, $new_list);
fclose($fcusers);
}
$person = str_replace ("\n"," ", $person);
$person = str_replace ("<", " ", $person);
$person = str_replace (">", " ", $person);
$person = trim ($person);
$person = stripslashes ($person);
?>
&output=
<?php
/* check the user */
/* --------------- */
$text_string = join ('', file ($users_file));
$valid_user= "valid";
if ((ereg("$person\n kicked\n", $text_string)) or (ereg("$person\n banned\n", $text_string))){
$valid_user = "kicked";
}
if ($valid_user == "kicked"){
if (ereg("$person\n kicked\n", $text_string)){echo urlencode($kicked_user)."\n";}
if (ereg("$person\n banned\n", $text_string)){echo urlencode($banned_user)."\n";}
if (ereg("$person\n $password\n", $text_string)){//is not in the user list
$user_is_not_here=0;
}
else
{
$user_is_not_here=1;
}
if ($user_is_not_here==1){
echo urlencode($banned_user)."\n";
}
}else{
/* limit file size of $chat_file_ok */
/* -------------------------------- */
$lines = file($chat_file_ok);
$a = count($lines);
if ($a >= $total_lenght){
$u = $a - $review_lenght;
$msg_old="";
for($i = $u; $i <= $a ;$i++){
$msg_old = $msg_old.strval($lines[$i]);
}
$fchat = fopen($chat_file_ok, "w");
$fwchat = fwrite($fchat, $msg_old);
fclose($fchat);
}
/* write message to $chat_file_ok */
/* ------------------------------ */
$msg = str_replace ("\n"," ", $message);
$msg = stripslashes ($msg);
$msg = htmlspecialchars ($msg);
//accepted tags
$msg = str_replace("<b>","<b>",$msg);
$msg = str_replace("<B>","<b>",$msg);
$msg = str_replace("</b>","</b>",$msg);
$msg = str_replace("</B>","</b>",$msg);
$msg = str_replace("<i>","<i>",$msg);
$msg = str_replace("<I>","<i>",$msg);
$msg = str_replace("</i>","</i>",$msg);
$msg = str_replace("</I>","</i>",$msg);
//close unclosed tags //
$countb=substr_count($msg, "<b>");
$count_b=substr_count($msg, "</b>");
$counti=substr_count($msg, "<i>");
$count_i=substr_count($msg, "</i>");
function strlastpos($haystack, $needle) {
if (strstr($haystack, $needle)){
return strlen($haystack) - strlen($needle) - strpos(strrev($haystack), strrev($needle));
}else{
return -1;
}
}
$lastb = strlastpos($msg,"<b>");
$lasti = strlastpos($msg,"<i>");
if ($lastb>$lasti){
for($addb = $count_b; $addb < $countb ;$addb++){
if($msg!=""){
$msg .="</b>";
}
}
for($addb = $count_i; $addb < $counti ;$addb++){
if($msg!=""){
$msg .="</i>";
}
}
}
if ($lasti>$lastb){
for($addb = $count_i; $addb < $counti ;$addb++){
if($msg!=""){
$msg .="</i>";
}
}
for($addb = $count_b; $addb < $countb ;$addb++){
if($msg!=""){
$msg .="</b>";
}
}
}
//insert links
function InsertLinks ( $Text )
{
?>