File size: 3.55Kb
<?php
include_once 'lang.php';
include_once 'cfg.php';
include_once 'filtro.php';
$act=$_GET['act'];
$text=filtro(iconv('Windows-1251','UTF-8',substr(iconv('UTF-8','Windows-1251',$_POST['text']),0,250)));
$name=filtro(iconv('Windows-1251','UTF-8',substr(iconv('UTF-8','Windows-1251',$_POST['name']),0,20)));
$id=intval($_REQUEST['id']);
$op=$_GET['op'];
$s=intval($_GET['s']);
header('Cache-Control:no-cache');
header('Content-type:text/vnd.wap.wml; charset=utf-8');
print '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml"><wml>
<card title="'.$lang['news'].'">
<p align="left"><small>';
$fl='false';
if(empty($id)){echo 'Новость не выбрана!';}else{
if(@$act=='add')
if(empty($text)){
print '<b>'.$lang['opinion'].'</b><br/>'.$lang['name'].':<br/></small>
<input title="Name" name="name" maxlength="20"/><small><br/>'.
$lang['text'].':<br/></small><input title="Text" name="text" maxlength="255"/><small><br/><anchor>'.
$lang['add'].
'<go href="opinion.php?act=add" method="post"><postfield name="name" value="$(name)"/><postfield name="text" value="$(text)"/><postfield name="id" value="'.$id.'"/></go></anchor>';
}else{
$q2=mysql_query("select id from `news_com` where text='$text';");
if(mysql_num_rows($q2)<1)
mysql_query("insert into `news_com` values(0,'$id','".time()."','$name','$text');");
$fl='true';
}
else if(@$act=='golos')
if(empty($op)){
print '<b>'.$lang['que'].'</b><br/>
<a href="opinion.php?act=golos&id='.$id.'&op=plus">'.$lang['good'].'</a><br/>
<a href="opinion.php?act=golos&id='.$id.'&op=minus">'.$lang['bad'].'</a><br/>';
}else
{
$ipsoft=$_SERVER['REMOTE_ADDR'].'**'.$_SERVER['HTTP_USER_AGENT'];
$ipsoft=filtro(iconv('Windows-1251','UTF-8',substr(iconv('UTF-8','Windows-1251',$_POST['ipsoft']),0,200)));
$q3=mysql_query("select plus, minus, ipsoft from news where id='$id'");
$r3=mysql_fetch_array($q3);
if($ipsoft!=$r3['ipsoft']) mysql_query("update news set $op='".($r3[$op]+1)."', ipsoft='$ipsoft' where id=$id;");
$fl=true;
};
if((empty($act))||$fl=='true'){
if(!@$s) $s=0;
$q=mysql_query("select count(id) from `news_com` where nid='$id';");
$r=mysql_fetch_array($q);
$count=$r['count(id)'];
if($s*$lim+$lim>$count) $limit=$count-$s*$lim; else $limit=$lim;
print $lang['que1'].'<br/>';
$q3=mysql_query("select plus, minus, ipsoft from news where id='$id'");
$r3=mysql_fetch_array($q3);
if($r3['plus']+$r3['minus']>0) { $prplus=round(($r3['plus']/($r3['plus']+$r3['minus']))*100,2); $prminus=round(($r3['minus']/($r3['plus']+$r3['minus']))*100,2);}
else {$prplus=0; $prminus=0;}
print $lang['good'].': '.$r3['plus'].'('.$prplus.'%)<br/>'.$lang['bad'].': '.$r3['minus'].'('.$prminus.'%)<br/>
<a href="opinion.php?act=golos&id='.$id.'">'.$lang['golos'].'</a><br/>
---<br/>';
if((@$act!='add')&&(empty($text))) print '<a href="opinion.php?act=add&id='.$id.'">'.$lang['add'].'</a><br/>';
print $lang['showop'].' '.$count.'<br/>';
$q=mysql_query("select * from `news_com` where nid='$id' order by id desc limit ".($s*$lim).", $limit");
while($data = @mysql_fetch_array($q)){
$date=date('h:i d ',$data['date']).' '.$lang[date('m',$data['date'])];
print '<b>'.$data['name'].'</b>('.$date.'):<br/> '.$data['text'].'<br/>';
}
$razd='';
if($s!=0){ print '<a href="opinion.php?s='.($s-1).'&id='.$id.'">'.$lang['back'].'</a>'; $razd=' | ';};
if($count>$s*$lim+$lim) print $razd.'<a href="opinion.php?s='.($s+1).'&id='.$id.'">'.$lang['next'].'</a>';
}}
print '<br/>---<br/>
<a href="index.php">'.$lang['news'].'</a><br/>
<a href="/">На главную</a><br/>
</small></p></card></wml>';
?>