Tema: borrar txt
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/08/2003, 10:21
Avatar de pumpkinpie
pumpkinpie
 
Fecha de Ingreso: abril-2002
Mensajes: 309
Antigüedad: 22 años
Puntos: 0
gracias a ambos,
manoloweb, como puedo hacer eso que dices???, de hecho creo que mi script tiene esa funcion, pero no funciona, o no se que este mal, voy a poner el script aki, mo podrias hacer el favor de corregirlo si tiene un problema y agregarle la funcion que borre cuando se pase de 100 lineas, pero si se puede que borre las lineas necesarias o algo asi, porque es de un chat y no kiero que se borre derepente todo el mensaje.

Aki esta el codigo: Gracias de antemano!!!


<?
header("Expires: ".gmdate("D, d M Y H:i:s")."GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
?>
<?

?>

<?
$nickname = str_replace ("\n"," ", $nickname);
$nickname = str_replace ("<", " ", $nickname);
$nickname = str_replace (">", " ", $nickname);
$nickname = stripslashes ($nickname);
?>
<?
$chat_file2 = "login.txt";
$lines2 = file($chat_file2);
$count = count($lines2);
echo "&count=$count";
$deleted = unlink($chat_file2);
?>
&output=
<?
$chat_file = "chat.txt";
$chat_lenght = 80;
$max_single_msg_lenght = 100000;
$max_file_size = $chat_lenght * $max_single_msg_lenght;
$file_size= filesize($chat_file);
if ($file_size > $max_file_size) {
$lines = file($chat_file);
$a = count($lines);
$u = $a - $chat_lenght;
for($i = $a; $i >= $u ;$i--){
$msg_old = $lines[$i] . $msg_old;
}
$deleted = unlink($chat_file);
$fp = fopen($chat_file, "a+");
$fw = fwrite($fp, $msg_old);
fclose($fp);
}
$msg = str_replace ("\\","", $message);
//
//IF THE FORGOT TO ADD HTTP:THIS WILL DO IT FOR THEM
$webStart = Array ('WWW', 'www');
$changeWebstart = 'http://www';
$msg = str_replace ($webStart, $changeWebstart, $msg);

//this will take away the double http part
$webDouble = Array ('http://http://www');
$changeWebSingle = 'http://www';
$msg = str_replace ($webDouble, $changeWebSingle, $msg);
// BOLD, ITALICS, UNDERLINE AND PRE PARSER
$searchFor = Array ('', '', '[pre]', '[/pre]', '', '', '', '', '<', '&');
$replaceWith = Array ('<b>', '</b>', '<pre>', '</pre>', '<i>', '</i>', '<u>', '</u>', '', '');
$msg = str_replace ($searchFor, $replaceWith, $msg);
// Swear Word Filtering Section

$badwords = Array ("verga", "puto", "puta", "chinga", "melga","joto", "puñal", "fuck" ,"FUCK","bitch" ,"BITCH","SHIT", "slut", "SLUT", "shit","pendejo", "culo", "panocha", "cabron", "culero", "monda", "pendeja" , "JOTO", "PUÑAL","PUTO","MELGA", "CHINGA", "CABRON", "CULERO" , "PENDEJO", "PUTA", "PANOCHA", "CULO", "MONDA", "PENDEJA","fuck", "shit", "bastard", "fucker", "fucking", "bitch", "cunt", "pussy", "dick", "ass", "nigger", "whore");
$changeto = '<font color="#ff3300">******</font>';
$msg = str_replace ($badwords, $changeto, $msg);

// EMAIL PARSER
$msg = ereg_replace("[[:alpha:]]+@[^<>[:space:]]+[[:alnum:]]","<font color=\"#0033ff\"><u><a href=\"mailto:\\0\">\\0</a></u></font>", $msg);

//
// URL PARSER FOR MESSAGE
$msg = ereg_replace ("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]]", "<font color=\"#0033ff\"><u><a href=\"\\0\"target=\"_blank\">\\0</a></u></font>", $msg);
//$msg = ereg_replace("\[url\]([^\[]+)\[/url\]", "<font color=\"#FFFF00\"><u><a href=\"\\1\"target=\"_blank\">\\1</a></u></font>", $msg);

//


//
// END PARSING SECTION


$msg = stripslashes($msg);
if ($msg != ""){
$fp = fopen($chat_file, "a+");
$fw = fwrite($fp, "$nickname : <font color=\"$color\"> $msg\n</font>");
fclose($fp);}
$lines = file($chat_file);
$a = count($lines);
$u = $a - $chat_lenght;
for($i = $a; $i >= $u ;$i--){
echo $lines[$i];
}

?>
__________________
:pirata: :arriba:
E-ClipseMx Sistemas & Web...Tus ideas en linea!