2
FILE chat_baixo.php
--------------------------------------------------------
<?php
include("config.php") ;
include $lang;
$glob = get_cfg_var (register_globals);
if($glob != true){
include("patch.php");
}
if(!isset($action)){
$action = "";
}
if ($action == "sair"){
print "<SCRIPT>window.top.close()</SCRIPT> \n";
}
if(!isset($mensagem)){
$mensagem = "";
}
if ($mensagem != "" ) {
$mensagem = str_replace("\'", "'", "$mensagem");
$mensagem = str_replace("\\\"", "\"", "$mensagem");
$fp = fopen ("transcricao.php", "r");
$fs = filesize ("transcricao.php");
$bytes = $fs;
$buffer = fread($fp, $bytes);
fclose ($fp);
////////////
$numero_de_linhas = $num_linhas; //aqui entra o numero de linhas desejado
$array_chat = explode("<br>", $buffer);
$counter = count ($array_chat);
if($counter <= $numero_de_linhas){
$desejo = 1;
}else{
$desejo = $counter - $numero_de_linhas;
}
//echo "<script>alert('$counter')</script>";
$texto = $array_chat[0] . "<br>"; // cabecalho
for ($i=$desejo; $i<=$counter; $i++) {
$texto .= $array_chat[$i] . "<br>";
};
$buffer = rtrim($texto,"<br>");
////////////
$mensagem_formatada = "<font color=\"#" . $cor_usuario . "\" face=\"Verdana\" size=\"2\"><b>" . $nome . "</b> : " . $mensagem . "</font><br>\n";
$fp = fopen ("transcricao.php", "w");
fwrite ($fp, $buffer);
//fwrite ($fp, "<br>\n");
fwrite ($fp, $mensagem_formatada);
fclose ($fp);
/// duplica
$fp = fopen ("transcricao2.php", "r");
$fs = filesize ("transcricao2.php");
$bytes = $fs;
$buffer = fread($fp, $bytes);
fclose ($fp);
////////////
$numero_de_linhas = $num_linhas; //aqui entra o numero de linhas desejado
$array_chat = explode("<br>", $buffer);
$counter = count ($array_chat);
if($counter <= $numero_de_linhas){
$desejo = 1;
}else{
$desejo = $counter - $numero_de_linhas;
}
//echo "<script>alert('$counter')</script>";
$texto = $array_chat[0] . "<br>"; // cabecalho
for ($i=$desejo; $i<=$counter; $i++) {
$texto .= $array_chat[$i] . "<br>";
};
$buffer = rtrim($texto,"<br>");
////////////
$mensagem_formatada = "<font color=\"#" . $cor_usuario . "\" face=\"Verdana\" size=\"2\"><b>" . $nome . "</b> : " . $mensagem . "</font><br>";
$fp = fopen ("transcricao2.php", "w");
fwrite ($fp, $buffer);
//fwrite ($fp, "<br>");
fwrite ($fp, $mensagem_formatada .
"
");
fclose ($fp);
/// Triplica
$fp = fopen ("transcricao3.php", "r");
$fs = filesize ("transcricao3.php");
$bytes = $fs;
$buffer = fread($fp, $bytes);
fclose ($fp);
$mensagem_formatada = "<font color=\"#" . $cor_usuario . "\" face=\"Verdana\" size=\"2\"><b>" . $nome . "</b> : " . $mensagem . "</font><br>";
$fp = fopen ("transcricao3.php", "w");
fwrite ($fp, $buffer);
//fwrite ($fp, "<br>");
fwrite ($fp, $mensagem_formatada .
"
");
fclose ($fp);
}
?>
<html>
<head>
<title></title>
<!-- begin codigo -->
<SCRIPT LANGUAGE="JavaScript">
function converte_string(word){
return escape(word);
}
function sair() {
window.location = 'chat_baixo.php?action=sair';
}
function chat(){
window.parent.cima.location.reload();
msg.focus();
}
</SCRIPT>
<!-- end codigo -->
<script>
function envia(){
window.location = 'chat_baixo.php?mensagem='+converte_string(msg.value) + '&nome=<? echo urlencode($nome); ?>';
}
function save() {
window.open("transcricao3.php","Save","scrollbars=yes,menubar=yes,top=100,left=200,width=420,height=300");
}
</script>
</head>
<body onload="chat();" bgcolor="#CCCCCC" text="black" link="blue" vlink="purple" alink="red" topmargin="3" marginheight="3">
<table border="0" width="384" align="center">
<tr>
<td width="374" height="26">
<p align="center"><font face="Verdana" size="2"><? echo "$string_30"; ?>:</font>
<input type="text" name="msg" style="border-width:1; border-style:solid;" size="30">
<input type="submit" name="Entrar" value="<? echo "$string_31"; ?>" onclick="envia()" style="cursor:hand; margin:1; border-width:1; border-style:solid;">
<br><br><input type="button" name="Save" value="<? echo "$string_45"; ?>" onclick="save()" style="cursor:hand; margin:1; border-width:1; border-style:solid;"> <input type="button" name="Sair" value="<? echo "$string_10"; ?>" onclick="sair()" style="cursor:hand; margin:1; border-width:1; border-style:solid;"></p>
</td>
</tr>
</table>
<p> </p>
</body>
</html>