Показать сообщение отдельно

  #9  
Старый 22.12.2008, 21:29
Exlibris
Постоянный
Регистрация: 26.02.2007
Сообщений: 495
Провел на форуме:
3835614

Репутация: 1386
По умолчанию

делать было нех написал 2 простеньких скрипта
чат (2 файла)
guest.php
PHP код:
<html>
<body>
<form action="guest.php" method="post" name="text" terget="_top">
<input type="text" align="top" name="text">
<input type="submit" value="чик">
<a href="unlink.php">clear</a>
</body>
</html>
<?php
$tmp_file 
"tmp.txt";
$time date("d:m:y::H:i:s");
$msg $_POST['text'];

if(!
file_exists($tmp_file))
{
    echo 
"файл истории недоступен";
}
else
{
    
$file fopen($tmp_file,"a+");
    echo 
$msg;
    
fwrite($file,$time." ".$msg."\n");
    
$s file($tmp_file);
    foreach (
$s as $k => $v)
    {
        
$i++;
        if(
$i == 0)
        {
            echo 
"<table align='center' width='50%'>";
            echo 
"<tr>"."<td bgcolor='13becd'>"."<center>".$v."</center>"."</td>"."</tr>"."<br>";
        }
        else
        {
            echo 
"<table align='center' width='50%'>";
            echo 
"<tr>"."<td bgcolor='a7f97a'>"."<center>".$v."</center>"."</td>"."</tr>"."<br>";
            
        }
    }    
}
fclose($file);
?>
unlink.php
PHP код:
<?php
$file 
"tmp.txt";
unlink($file);
fopen($file,"a+");
header("location:http://127.0.0.1/code/guest.php");
fclose($file);
?>
--
генератор паролей
PHP код:
<html>
<form action="pass_gen.php" name="len" method="post">
Длина пароля: <input type="text" name="len">
<input type="submit" value="go">
</html>

<?php
//символы
$a     "abcdefghijklmnopqrstuvwxyz";
$b     strtoupper($a);
$n     "0123456789";
$s     "!@#$%^&*()[]";
$all   $a.$b.$n.$s;

$lenght $_POST['len'];//длина пароля
echo "=".$lenght."<br>";
$radio $_POST['rad'];//вид пасса
echo $radio;
$count strlen($all);

if(
$lenght<=8)
{
    
$pass '';
    for(
$i=0;$i<$lenght;$i++)
    {
        
$pass .= substr($allrand(1,$count),1);
    }
    echo 
"pass:  ".$pass;
}
else 
{
    echo 
"парель не должен привышать 8 символов";
}
?>
 
Ответить с цитированием