Файл: ka4ka/index.php
Строк: 82
<?
include 'sys/bd.php';
include 'sys/func.php';
include 'sys/conf.php';
$log = mysql_fetch_array(mysql_query("select * from `parser`"));
if($log != 0) {
$err = true;
}else{
$titles= 'Ошибка';
include 'head.php';
echo 'Ошибка ! ПУСТОТА И ПОРЯДОК)! ';
include 'foot.php';
exit;
}
switch($_GET['m']){
default:
$titles= 'Анекдоты бля';
include 'head.php';
echo '<div id="cont">
<div id="raz">База анекдотов</div>
<div id="links">
<a href="'.$domain.'?m=top">ТОП</a>
</div>';
$cop = 5;
$ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `parser` order by `id`"),0);
$cp = ceil($ca/$cop);
if(isset($_GET['p']) && is_numeric($_GET['p'])){
$p =abs(intval($_GET['p']));
if($_GET['p']>$cp) $p = $cp;
if($_GET['p']<1)$p = 1;
}else{
$p = 1;
}
$start = $p*$cop-$cop;
$result = mysql_query("select * from `parser` order by `id` DESC limit $start,$cop");
while ($categ=mysql_fetch_assoc($result)) {
echo '<div id="con"><font color="red">('.times($categ['date']).')</font> - <b>'.$categ['text'].'</b> <br/>
<font color="green">Голосов : <b>'.$categ['rating'].'</b></font> ';
$log = mysql_fetch_array(mysql_query('select * from `ip` where `file_id` = "'.mysql_real_escape_string($categ['id']).'" and `ip_user` = "'.mysql_real_escape_string($_SERVER['REMOTE_ADDR']).'" limit 1'));
if($log != 0) {
$err = true;
}else{
echo '<a href="'.$domain.'?like&p='.$p.'"><img src="'.$domain.'img/like.png" alt=""/></a>
<br/>';
if(isset($_GET['like']))
{
mysql_query("UPDATE `parser` SET `rating`= `rating` +1 WHERE `id`='".mysql_real_escape_string($categ['id'])."'");
mysql_query("INSERT INTO `ip`(
`ip_user`,
`file_id`
)VALUES(
'".$_SERVER['REMOTE_ADDR']."',
'".mysql_real_escape_string($categ['id'])."'
)");
header ('Location: '.$_SERVER['HTTP_REFERER'].'');
exit;
}
}
echo '</div>';
}
echo '<center>';
if($p-2>0) echo '<a href="'.$domain.'?p=1"><<</a> ';
if($p-1>0) echo '<a href="'.$domain.'?p='.($p-1).'"><</a> ';
if($p-3>0) echo '<a href="'.$domain.'?p='.($p-3).'">'.($p-3).'</a> ';
if($p-2>0) echo '<a href="'.$domain.'?p='.($p-2).'">'.($p-2).'</a> ';
if($p-1>0) echo '<a href="'.$domain.'?p='.($p-1).'">'.($p-1).'</a> ';
echo ' '.$p.' ';
if($p+1<=$cp) echo '<a href="'.$domain.'?p='.($p+1).'">'.($p+1).'</a> ';
if($p+2<=$cp) echo '<a href="'.$domain.'?p='.($p+2).'">'.($p+2).'</a> ';
if($p+3<=$cp) echo '<a href="'.$domain.'?p='.($p+3).'">'.($p+3).'</a> ';
if($p+1<=$cp) echo ' <a href="'.$domain.'?p='.($p+1).'">></a> ';
if($p+2<=$cp) echo ' <a href="'.$domain.'?p='.ceil($ca/$cop).'">>></a> ';
echo '</center>';
echo '</div>';
include 'foot.php';
break;
case 'top':
$titles= 'ТОП Анекдоты бля';
include 'head.php';
echo '<div id="cont">
<div id="raz">ТОП</div>';
$cop = 5;
$ca = mysql_result(mysql_query("SELECT COUNT(*) FROM `parser` order by `rating`"),0);
$cp = ceil($ca/$cop);
if(isset($_GET['p']) && is_numeric($_GET['p'])){
$p =abs(intval($_GET['p']));
if($_GET['p']>$cp) $p = $cp;
if($_GET['p']<1)$p = 1;
}else{
$p = 1;
}
$start = $p*$cop-$cop;
$result = mysql_query("select * from `parser` order by `rating` DESC limit $start,$cop");
while ($categ=mysql_fetch_assoc($result)) {
echo '<div id="con"><font color="red">('.times($categ['date']).')</font> - <b>'.$categ['text'].'</b> <br/>
<font color="green">Голосов : <b>'.$categ['rating'].'</b></font> ';
$log = mysql_fetch_array(mysql_query('select * from `ip` where `file_id` = "'.mysql_real_escape_string($categ['id']).'" and `ip_user` = "'.mysql_real_escape_string($_SERVER['REMOTE_ADDR']).'" limit 1'));
if($log != 0) {
$err = true;
}else{
echo '<a href="'.$domain.'?m=top&like&p='.$p.'"><img src="'.$domain.'img/like.png" alt=""/></a>
<br/>';
if(isset($_GET['like']))
{
mysql_query("UPDATE `parser` SET `rating`= `rating` +1 WHERE `id`='".mysql_real_escape_string($categ['id'])."'");
mysql_query("INSERT INTO `ip`(
`ip_user`,
`file_id`
)VALUES(
'".$_SERVER['REMOTE_ADDR']."',
'".mysql_real_escape_string($categ['id'])."'
)");
header ('Location: '.$_SERVER['HTTP_REFERER'].'');
exit;
}
}
echo '</div>';
}
echo '<center>';
if($p-2>0) echo '<a href="'.$domain.'?m=top&p=1"><<</a> ';
if($p-1>0) echo '<a href="'.$domain.'?m=top&p='.($p-1).'"><</a> ';
if($p-3>0) echo '<a href="'.$domain.'?m=top&p='.($p-3).'">'.($p-3).'</a> ';
if($p-2>0) echo '<a href="'.$domain.'?m=top&p='.($p-2).'">'.($p-2).'</a> ';
if($p-1>0) echo '<a href="'.$domain.'?m=top&p='.($p-1).'">'.($p-1).'</a> ';
echo ' '.$p.' ';
if($p+1<=$cp) echo '<a href="'.$domain.'?m=top&p='.($p+1).'">'.($p+1).'</a> ';
if($p+2<=$cp) echo '<a href="'.$domain.'?m=top&p='.($p+2).'">'.($p+2).'</a> ';
if($p+3<=$cp) echo '<a href="'.$domain.'?m=top&p='.($p+3).'">'.($p+3).'</a> ';
if($p+1<=$cp) echo ' <a href="'.$domain.'?m=top&p='.($p+1).'">></a> ';
if($p+2<=$cp) echo ' <a href="'.$domain.'?m=top&p='.ceil($ca/$cop).'">>></a> ';
echo '</center>';
echo '</div>';
include 'foot.php';
break;
}
?>