Файл: l2ps_v5/news.php
Строк: 270
<?php
include_once("files/zag.php");
include_once("files/ini.php");
$polz=mysql_query("SELECT * FROM `users` WHERE `udata0`='$log' AND `udata1`='$pas' LIMIT 1");
if(mysql_num_rows($polz)==0){
header ("Location: index.php?error");
}else{
switch($_GET[mod]){
default:
function smiles($string){
$dir = opendir ("l2pic/smiles");
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="l2pic/smiles/'.$file.'" alt="">',$string);
}}
closedir ($dir);
return $string; }
$num = mysql_fetch_array(mysql_query("select count(id) as num from news"));
echo "Новостей (<b> ".$num[0]." </b>)";
echo'<div class="bts"></div>';
if($go == 'plus')
{
$avt=mysql_query("SELECT * FROM `news_komm` WHERE `id_news`='$id' AND `log`='$log' LIMIT 1");
if(mysql_num_rows($avt)==0){
mysql_query("INSERT INTO
`news_komm` SET
`id` = '',
`id_news` = '$id',
`log` = '$log',
`var` = '1'");
echo 'Вы успешно проголосовали!<br>';
}else{
echo'Вы уже голосовали за эту новость!</br>';}
}
if($go == 'minus')
{
$avt=mysql_query("SELECT * FROM `news_komm` WHERE `id_news`='$id' AND `log`='$log' LIMIT 1");
if(mysql_num_rows($avt)==0){
mysql_query("INSERT INTO
`news_komm` SET
`id` = '',
`id_news` = '$id',
`log` = '$log',
`var` = '2'");
echo 'Вы успешно проголосовали!<br>';
}else{
echo'Вы уже голосовали за эту новость!</br>';}
}
if(empty($startan)) $startan = 0;
$startan=intval($startan);
if($startan<0) $startan=0; $num_msgs_an=5;
$qi = mysql_query("SELECT * FROM `news` ORDER by `id` DESC LIMIT $startan,$num_msgs_an");
$i=$startan+1;
while($row=mysql_fetch_array($qi))
{
echo ''.$i++.') <b><font color="red">'.$row['title'].'</font></b> ('.$row['time'].')<br/>'.$row['text'].'<br/>Всем приятной игры <img src="l2pic/smiles/meeting.gif" alt="*"/>! С ув. Администрация l2pirates.ru <img src="favicon.ico" alt="*"/><br/>Опубликовал: ';
$req = mysql_query("SELECT `prava`,`udata91` FROM `users` WHERE `udata0` = '$row[usr]'");
$pic = mysql_fetch_array($req);
if ($usdata['udata91']==0)echo "<img src='/l2pic/status/on.gif' alt='' class='icon'/>";
else if ($usdata['udata91']==1)echo "<img src='/l2pic/status/gotov_boltat.png' alt='' class='icon'/>";
else if ($usdata['udata91']==2)echo "<img src='/l2pic/status/zaniat.png' alt='' class='icon'/>";
else if ($usdata['udata91']==3)echo "<img src='/l2pic/status/boleu.png' alt='' class='icon'/>";
else if ($usdata['udata91']==4)echo "<img src='/l2pic/status/depressia.png' alt='' class='icon'/>";
else if ($usdata['udata91']==5)echo "<img src='/l2pic/status/dumau.png' alt='' class='icon'/>";
else if ($usdata['udata91']==6)echo "<img src='/l2pic/status/kuru.png' alt='' class='icon'/>";
else if ($usdata['udata91']==7)echo "<img src='/l2pic/status/kushau.png' alt='' class='icon'/>";
else if ($usdata['udata91']==8)echo "<img src='/l2pic/status/love.png' alt='' class='icon'/>";
else if ($usdata['udata91']==9)echo "<img src='/l2pic/status/tv.png' alt='' class='icon'/>";
else if ($usdata['udata91']==10)echo "<img src='/l2pic/status/music.png' alt='' class='icon'/>";
else if ($usdata['udata91']==11)echo "<img src='/l2pic/status/vanna.png' alt='' class='icon'/>";
else if ($usdata['udata91']==12)echo "<img src='/l2pic/status/tualet.png' alt='' class='icon'/>";
else if ($usdata['udata91']==13)echo "<img src='/l2pic/status/sex.png' alt='' class='icon'/>";
else if ($usdata['udata91']==14)echo "<img src='/l2pic/status/igrau.png' alt='' class='icon'/>";
else if ($usdata['udata91']==15)echo "<img src='/l2pic/status/pivo.png' alt='' class='icon'/>";
else if ($usdata['udata91']==16)echo "<img src='/l2pic/status/sonni.png' alt='' class='icon'/>";
////////
else if ($usdata['udata91']==17)echo "<img src='/l2pic/status/1.png' alt='' class='icon'/>";
else if ($usdata['udata91']==18)echo "<img src='/l2pic/status/12.png' alt='' class='icon'/>";
else if ($usdata['udata91']==19)echo "<img src='/l2pic/status/13.png' alt='' class='icon'/>";
else if ($usdata['udata91']==20)echo "<img src='/l2pic/status/14.png' alt='' class='icon'/>";
else if ($usdata['udata91']==21)echo "<img src='/l2pic/status/18.png' alt='' class='icon'/>";
else if ($usdata['udata91']==22)echo "<img src='/l2pic/status/19.png' alt='' class='icon'/>";
else if ($usdata['udata91']==23)echo "<img src='/l2pic/status/31.png' alt='' class='icon'/>";
else if ($usdata['udata91']==24)echo "<img src='/l2pic/status/7.png' alt='' class='icon'/>";
echo '<a href='search.php?nick='.$row['usr'].'&go=go'><font color="lime">'.$row['usr'].'</a></font></i></a><br/>';
$q = mysql_query("SELECT COUNT(`id`) FROM `l2pirates_news_koments` WHERE `news`='$row[id]'"); $kol = mysql_result($q, 0);
echo '<img src="/l2pic/logo/komments.png" alt="*"/> <a href="news.php?mod=koments&id='.$row['id'].'">Комментарии</a> ('.$kol.')<br/>';
$a = mysql_fetch_array(@mysql_query("select count(id) as num from news_komm where id_news='".$row['id']."' and var='1'"));
echo"<img src='/l2pic/logo/oke.png' alt='*'/> <a href="news?go=plus&id=".$row['id']."">Мне нравиться</a> ($a[0])<br/>";
$a1 = mysql_fetch_array(@mysql_query("select count(id) as num from news_komm where id_news='".$row['id']."' and var='2'"));
echo"<img src='/l2pic/logo/nou.png' alt='*'/> <a href="news?go=minus&id=".$row['id']."">Не нравиться</a> ($a1[0])<br/>";
if ($log == "Bopo6eu")
{echo ' <a href="l2pirates.php?go=news_del_ok&id='.$row['id'].'">Удалить</a>'.$row['news'].'';}
echo'<div class="bts"></div>';
}
$q = mysql_query("SELECT COUNT(`id`) FROM `news`");
$kol = mysql_result($q, 0);
if($startan!= 0) $page2left = ' <a href= news.php?&startan='. ($startan - 5) .'&page='.($page-1).'>'. ($page - 1) .'</a> | ';
if(empty($page)){$page=1;}
if($kol > $startan + 5) $page2right = ' | <a href= news.php?&startan='. ($startan + 5) .'&page='. ($page+1) .'>'. ($page + 1) .'</a>';
echo $page2left.'<b>('.$page.')</b>'.$page1right.$page2right.'<br/>';
if ($startan != 0) {echo '<a href="news.php?&startan='.($startan - 5).'&page='.($page-1).'">Назад</a> ';}
if ($kol > $startan + 5) {echo ' <a href="news.php?&startan='.($startan + 5).'&page='.($page+1).'">Далее</a>';}
break;
case 'koments':
$g=mysql_query("SELECT * FROM `news` WHERE `id`='$id' LIMIT 1");
if(mysql_num_rows($g)==0){
header ("Location: news.php?");
exit;}
$q = mysql_query("SELECT COUNT(`id`) FROM `l2pirates_news_koments` WHERE `news`='$id'");
$kol = mysql_result($q, 0);
if($kol=="0"){
echo "<img src='/l2pic/logo/forumtext.gif' alt='*'/> Комментариев нет.<br/>";
}else{
echo "<img src='/l2pic/logo/forumtext.gif' alt='*'/> Комментарии: $kol";
echo'<div class="bts"></div>';}
if(empty($startan)) $startan = 0;
$startan=intval($startan);
if($startan<0) $startan=0; $num_msgs_an=5;
$qi = mysql_query("SELECT * FROM `l2pirates_news_koments` WHERE `news`='$id' ORDER by `id` DESC LIMIT $startan,$num_msgs_an");
while($row=mysql_fetch_array($qi)){
$req = mysql_query("SELECT `aces`,`karma` FROM `l2_user` WHERE `nick` = '$row[nick]'");
$pic = mysql_fetch_array($req);
if($pic[karma]>"0"){
echo "<a href="l2_pers_nick.php?nick=$row[nick]&go=go"><font color=red>$row[nick]</font></a>";
}else{
if($pic['aces']==5){
echo "<a href="l2_pers_nick.php?nick=$row[nick]&go=go"><font color=lime>$row[nick]</font></a>";
}else{
if($pic['aces']==2){
echo "<a href="l2_pers_nick.php?nick=$row[nick]&go=go"><font color=DeepSkyBlue>$row[nick]</font></a>";
}else{
if($pic['aces']==3){
echo "<a href="l2_pers_nick.php?nick=$row[nick]&go=go"><font color=gold>$row[nick]</font></a>";
}else{
if($pic['aces']==0){
echo "<a href="search.php?nick=$row[nick]&go=go">$row[nick]</a>";
}}}}}
echo " - $row[msg] <small><font color=#999999>($row[time])</font></small>";
if($udata67="200" or $udata67="100" or $udata67="500" or $udata67="501" or $log="Bopo6eu"){
echo" <a href="news.php?mod=post&id=$id&nam=$row[id]">[X]</a>";}
echo "<br/>";}
$q = mysql_query("SELECT COUNT(`id`) FROM `l2pirates_news_koments` WHERE `news`='$id'");
$kol = mysql_result($q, 0);
if($startan!= 0) $page2left = ' <a href= news.php?mod=koments&startan='. ($startan - 5) .'&page='.($page-1).'&id='.$id.'>'. ($page - 1) .'</a> | ';
echo'<div class="bts"></div>';
echo'Страницы: ';
if(empty($page)){$page=1;}
if($kol > $startan + 5) $page2right = ' | <a href=news.php?mod=koments&startan='. ($startan + 5) .'&page='. ($page+1) .'&id='.$id.'>'. ($page + 1) .'</a>';
echo $page2left.'<b>('.$page.')</b>'.$page1right.$page2right.'<br/>';
echo'<div class="bts"></div>';
echo'<form method="post" action="news.php?mod=save&id='.$id.'">';
echo "<br/>Комментарий:<br/>";
echo "<input class="button" name="msg" maxlength="300" title="Комментарий" emptyok="true"/><br/>";
echo '<input class="button" type="submit" value="Добавить"/></form>';
break;
case 'save':
$g=mysql_query("SELECT * FROM `news` WHERE `id`='$id' LIMIT 1");
if(mysql_num_rows($g)==0){
header ("Location: news.php?");
include ("files/down.php");
exit;}
if($udata9<"10"){
echo'Писать отзывы доступно с 10-го уровня.';
include ("files/down.php");
exit;}
if($msg==""){
header ("Location: news.php?mod=koments&id=$id");
exit;}
$time = date("H:i d.m.y");
mysql_query("INSERT INTO
`l2pirates_news_koments` SET
`news` = '$id',
`nick` = '$log',
`time` = '$time',
`msg` = '$msg'");
header ("Location: news.php?mod=koments&id=$id");
exit;
break;
case 'post':
$g=mysql_query("SELECT * FROM `news` WHERE `id`='$id' LIMIT 1");
if(mysql_num_rows($g)==0){
header ("Location: news.php?");
include ("files/down.php");
exit;}
if($udata67="200" or $udata67="100" or $udata67="500" or $udata67="501" or $log="Bopo6eu"){
if(empty($_GET[nam])){
echo"Невыбран пост!<br/>";
}else{
$asd = mysql_query("SELECT * FROM l2pirates_news_koments WHERE id='".mysql_real_escape_string($_GET['nam'])."' LIMIT 1");
$avto=mysql_num_rows($asd);
if($avto==0){
echo'Нет такого поста!<br/>';
}else{
mysql_query("DELETE FROM `l2pirates_news_koments` WHERE id='".mysql_real_escape_string($_GET['nam'])."' LIMIT 1");
header ("Location: news.php?mod=koments&id=$id");}}
}else{
header ("Location: news.php?mod=koments");}}}
include ("files/down.php");
?>