Просмотр файла GuestBook_by_storm/gb/index.php

Размер файла: 5.81Kb
<?php
//////////////////////////
//  Автор: -=Storm=-    //
//  Сайт: xwap.nov.ru   //
//  icq: 4073300        //
//////////////////////////
include_once "ini.php";
if(isset($_GET['page']))
{
$page=$_GET['page'];
}
else
{
$page="";
}
if($page != "gb" && $page != "add")
{
$page = "gb";
}
switch($page)
{
case'gb':
echo "<div>Гостевая</div>";
echo '<a href="index.php?page=add">Добавить сообщение</a><br/>';

class Navigator
{
function __construct($all,$pnumber,$query='')
{
$this->all=$all;
$this->pnumber=$pnumber;
$this->query=$query;
$this->page=isset($_GET['page']) ? (int)$_GET['page'] : 1;
}
function start()
{
$this->num_pages=ceil($this->all/$this->pnumber);
if (isset($_GET['last']))
$this->page=$this->num_pages;
$this->start=$this->page*$this->pnumber-$this->pnumber;
if ($this->page > $this->num_pages || $this->page < 1)
{
$this->page=1;
$this->start=0;
}
return $this->start;
}
function navi()
{
if ($this->num_pages<2)
return '';
$buff='';
for($pr = '', $i =1; $i <= $this->num_pages; $i++)
{
$buff.=
$pr=(($i == 1 || $i == $this->num_pages || abs($i-$this->page) < 3) ? ($i == $this->page ? " [$i] " : ' <a href="'.$_SERVER['SCRIPT_NAME'].'?page='.$i.'&amp;'.$this->query.'">'.$i.'</a> ') : (($pr == ' ... ' || $pr == '')? '' : ' ... '));
}
return $buff.'';
}
}

$q=mysql_query(" SELECT count(*) FROM posts");
$all=mysql_result($q,0,0);
if ($all)
{
$n=new Navigator($all,$pnumber);
$q=mysql_query("SELECT * FROM posts ORDER BY id DESC LIMIT {$n->start()},$pnumber");
while (false!==($res=mysql_fetch_assoc($q)))
{
$res['name'] = str_ireplace('.ru','',$res['name']);
$res['name'] = str_ireplace('.su','',$res['name']);
$res['name'] = str_ireplace('.com','',$res['name']);
$res['name'] = str_ireplace('.org','',$res['name']);
$res['name'] = str_ireplace('.wen','',$res['name']);
$res['name'] = str_ireplace('.net','',$res['name']);
$res['name'] = str_ireplace('.in','',$res['name']);
$res['name'] = str_ireplace('.mobi','',$res['name']);
$res['name'] = str_ireplace('.biz','',$res['name']);
$res['name'] = str_ireplace('.us','',$res['name']);
$res['name'] = str_ireplace(',ru','',$res['name']);
$res['name'] = str_ireplace(',su','',$res['name']);
$res['name'] = str_ireplace(',com','',$res['name']);
$res['name'] = str_ireplace(',org','',$res['name']);
$res['name'] = str_ireplace(',wen','',$res['name']);
$res['name'] = str_ireplace(',net','',$res['name']);
$res['name'] = str_ireplace(',in','',$res['name']);
$res['name'] = str_ireplace(',mobi','',$res['name']);
$res['name'] = str_ireplace(',biz','',$res['name']);
$res['name'] = str_ireplace(',us','',$res['name']);

$res['post'] = str_ireplace('.ru','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.su','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.com','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.org','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.wen','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.net','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.in','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.mobi','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.biz','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.us','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('.fiz','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('http://','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('. r u','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('. w e n','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',ru','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',su','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',com','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',org','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',wen','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',net','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',in','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',mobi','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',biz','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',us','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(',fiz','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace('http://','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(', r u','<u>Реклама!</u>',$res['post']);
$res['post'] = str_ireplace(', w e n','<u>Реклама!</u>',$res['post']);

echo '<div class="post">';
echo '<b>'.$res['name'].'</b> <small>(';
echo ''.$res['time'].')</small><br/>';
echo ''.$res['post'].'<br/>';
if ($res['otvet']) echo '<u>Ответ: '.$res['otvet'].'</u>';
else;
echo '</div>';
}
echo $n->navi();
echo "<br/>Всего сообщений: $all<br/><br/>";
}
echo "<br/><a href=\"/\">На главную</a><br/>";
break;

case'add':
$kod = rand(1000,9999);
echo "<div>Добавить Сообщие</div>";
echo '<form action="add.php" method="post">
Ваше имя:<br/><input type="text" name="name" maxlength="15" size="20" value=""/><br/>
Сообщение:<br/><input type="text" maxlength="300" name="text" value=""/><br/>
Проверочный код: '.$kod.'<br/>
<input type="text" name="kod" size="4" maxlength="4" value=""/><br/>
<input type="hidden" name="kod2" value="'.$kod.'"/>
<input type="checkbox" name="tr" value="1"/>Транслит<br/>
<input type="submit" value="Ок"/></form>
<a href="index.php">В гостевую<a/><br/>
<a href="/">На главную</a><br/>';
break;
}
?>
</body></html>