<?php
session_start();
require_once "includes/common.inc.php";
function js_unescape($str)
{
$ret = '';
$len = strlen($str);
for ($i = 0; $i < $len; $i++)
{
if (($str[$i] == '\\' && $str[$i+1] == 'u') || $str[$i] == '%' && $str[$i+1] == 'u')
{
$val = hexdec(substr($str, $i+2, 4));
if ($val < 0x7f) $ret .= chr($val);
else if($val < 0x800) $ret .= chr(0xc0|($val>>6)).chr(0x80|($val&0x3f));
else $ret .= chr(0xe0|($val>>12)).chr(0x80|(($val>>6)&0x3f)).chr(0x80|($val&0x3f));
$i += 5;
}
else if ($str[$i] == '\\')
{
$ret .= urldecode(substr($str, $i, 3));
$i += 2;
}
else $ret .= $str[$i];
}
return iconv('utf-8', 'gb2312', $ret);
}

if($uid){
if($y=="ok"){
$seccode=$_SESSION['pingcode'];
if(intval($seccodeverify) == intval($seccode)) {
$pid=htmlconvert($pid);
$uid=htmlconvert($uid);
$uname=js_unescape(htmlconvert($name));
$face=htmlconvert($face);
if($face==""){
$face="/css/face/f10.gif";
}
$pingl=js_unescape(htmlconvert($content));
$uip=$_SERVER['REMOTE_ADDR'];
$time=date("Y-m-d H:i:s");
if($uname == '' || $pingl=='' || $pid=='' || $uid==''){
echo "no";
} else {
$db -> query("INSERT INTO {$tablepre}ping  (pid, uid, uname, uip, face, pingl, time) VALUES ('$pid', '$uid', '$uname', '$uip', '$face', '$pingl', '$time')");
}
echo "ok";
				} else {
					echo "no";					
				}
}else{
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"$charset\"?>";
$CurPage=$page;
if (!isset($CurPage) && $CurPage<1){
$CurPage = 1;}
$PerPage=5;
$query = $db -> query("select count(*) from {$tablepre}ping where uid in (".$uid.")");
$numrows = $db -> result($query, 0);
//计算总页数
$P_Nums=ceil($numrows/$PerPage);
$D_Nums=$numrows;
$offset=$PerPage*($CurPage-1);
if($numrows =='0'){
echo "<data page=\"0\" P_Nums=\"0\">";
echo "<content>还没有评论!</content>";
}else{
echo "<data page=\"$CurPage\" P_Nums=\"$P_Nums\" D_Nums=\"$D_Nums\">";
}
$query = $db -> query("select * from {$tablepre}ping where uid in (".$uid.") order by id desc limit $offset,$PerPage");
while($rs = $db->fetch_array($query)){
echo "<name><![CDATA[$rs[uname]]]></name>";
echo "<ip><![CDATA[$rs[uip]]]></ip>";
echo "<sj><![CDATA[$rs[time]]]></sj>";
echo "<content><![CDATA[$rs[pingl]]]></content>";
echo "<face><![CDATA[$rs[face]]]></face>";
echo "<id><![CDATA[$rs[id]]]></id>";
}
echo "</data>";
}
}
?>