http://j2meground.h2m.ru/aaaphp/gb3.php
<?php
error_reporting(E_ALL);
$v=$_SERVER['REMOTE_ADDR'];
$str=$_GET['str'];
if (!isset($str)) { $str=$cnt; }
/**
* @author
* @copyright 2012
*/
echo '<html><head><title>lol</title></head><body><br><br>
<form action="gb3.php?str='.$cnt.'" method="post">
<br>
Введите ник:
<br>
<input type="text" name="nik"> <br>
Введите сообщение:
<br>
<textarea rows="5" cols="20" name="text"></textarea>
<input type=submit></form>
';
if (!$db=mysql_connect('localhost','db_j2meground','ehyYYdwC')){
die ('sdsdas');}
if (!mysql_select_db('db_j2meground')){ die( 'db!!!');}
$text=$_POST['text'];
$nik=$_POST['nik'];
$text=trim($text); $nik=trim($nik);
if ((strlen($text)>6) and (strlen($nik)>2) ){
$text=mysql_real_escape_string($text);
$nik=mysql_real_escape_string($nik);
$rec=mysql_query("select * from `aa` where `text`='" . $text . "'and `ip`='" . $v . "'");
if (mysql_num_rows($rec)>0){ echo 'Сообщение уже было добавлено!';} else {
mysql_query("insert into`aa` values ('$v' ,'$text', '$nik',null)"); unset ($text); unset($nik);
}
}
else { echo '<br><span style="color:red">Сообщение или имя меньше положенного!</span><br>';}
$res=mysql_query("select * from `aa` ");
if (mysql_num_rows($res)<1){
echo('<br><span style="color:red">Сообщений нет. Стань первым!</span><br>');
}
else {
$count=mysql_query("select count(`id`) from `aa`");
$cunt=mysql_fetch_array($count);
$cnt=floor($cunt[0]/7);
$cn=$cunt[0]/7;
if ($cn==$cnt) { $cn=$cnt;}
else $cnt++;
if ($cnt<$str) {
$str=$cnt;
}
$pi=($str-1)*7;
$po=$str*7+1;
$soo=mysql_query("select * from `aa` where `id`>" .$pi ." and `id`<". $po."");
while ($pole=mysql_fetch_array($soo)){
echo '<br><br><underline>'.htmlspecialchars($pole[2]).'</underline><br>'.htmlspecialchars($pole[1]).'<br>'.htmlspecialchars($pole[0]);
}
echo '<br><br>';
for($st=1;$st<=$cnt;$st++){
echo '<a href="gb3.php?str='.$st.'">'.$st.'</a>';
}
}
echo $cunt[0].'</body></html>';
?>