Просмотр файла chat_servis/history.php

Размер файла: 6.16Kb
<?
Error_Reporting(E_ALL & ~E_NOTICE);          /////////////// игнорируем ошибки

header ("Content-type:text/vnd.wap.wml; charset=utf-8");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-relative");

list($msec,$sec)=explode(chr(32),microtime()); 
$HeadTime=$sec+$msec;		
require("conf.inc.php");

$ref=rand(10000,1000000);

$link=@mysql_pconnect ($DB_HOST, $DB_USER, $DB_PASS)
                or die ("<wml>
<card id=\"error\" title=\"Ошибка\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">Can not connect to db...</p>
</card>
</wml>");
     
     @mysql_select_db($DB_NAME) or die ("<wml>
<card id=\"error\" title=\"Ошибка\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">error in selecting of the database...</p>
</card>
</wml>");
         
        $result = @mysql_query ("Select * from users where cid='".$cid."' AND id='".$id."'");
         if (mysql_affected_rows() == 0) {
          echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"index.php?cid=$cid&amp;ref=$ref\"><timer value=\"15\"/>\n";
echo "<p align=\"center\">\n";
echo "User was not found\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close ($link);

} else {
$row = mysql_fetch_array ($result);
if ($pass !== $row["pass"]){
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"index.php?cid=$cid&amp;ref=$ref\"><timer value=\"15\"/>\n";
echo "<p align=\"center\">\n";
echo "Your login failed\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
mysql_close ($link);

} else {
$id = UrlEncode($id);    
$login=$row['login'];
$smile=$row['smile'];
$max = $row["num_msgs"];    
$time=date ("H:i");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<card id=\"history\" title=\"История\">\n";
echo "<do type=\"options\" name=\"refresh\" label=\"Обновить\"><go href=\"room.php?id=$id&amp;pass=$pass&amp;room=$room&amp;cid=$cid&amp;ref=$ref\"/></do>\n";
echo "<p mode=\"wrap\">\n"; 

echo "<a href=\"#add\">Сказать</a><br/>\n";
echo "<a href=\"room.php?id=$id&amp;pass=$pass&amp;room=$room&amp;cid=$cid&amp;ref=$ref\">Обновить</a>\n";

$res = @mysql_query ("Select * from room where cid='".$cid."' AND room='".$room."' AND ((`pr_to` = '-' AND `pr_from` = '-') OR (`pr_from` = '".$id."' OR `pr_to` = '".$id."')) order by id desc limit 60");
$kol = mysql_affected_rows();   


@$total=$kol-1;
if (!isset($num)) $num=0; 
$mread = $num; 
for ($i = 1; $i<=$num; $i++) $data = mysql_fetch_array ($res); 
$i = $num;


while (($mread < $num+$max)&&($i<=$total)){ 
	$data = mysql_fetch_array ($res);	
			
	$dblogin=$data['login'];
	$dbid=$data['dbid'];
	$dbmsg=$data['msg'];
	$dbtime=$data['time'];
	$pr_from=$data['pr_from'];
	$pr_to=$data['pr_to'];

	++$i;
 					if($smile==0)
					{
						$dbmsgearch = array (
                 				"'<[\/\!]*?[^<>]*?>'si");
						$replace = array (
                  			"*&#x432;&#x44B;&#x440;&#x435;&#x437;&#x430;&#x43D;o*");
						$dbmsg = preg_replace ($dbmsgearch, $replace, $dbmsg);
													
						$dbmsg=preg_replace("/\[!\[/","<",$dbmsg);
						$dbmsg=preg_replace("/\]!\]/",">",$dbmsg);
					}

					if(($pr_from=="-")&&($pr_to=="-")) { 				
					echo "<br/><b><a href=\"user.php?id=$id&amp;pass=$pass&amp;room=$room&amp;dbid=$dbid&amp;cid=$cid&amp;ref=$ref\">$dblogin</a></b>&nbsp;[$dbtime]<br/>$dbmsg";++$mread; 
					} else { 
					echo "<br/><b><a href=\"user.php?id=$id&amp;pass=$pass&amp;room=$room&amp;dbid=$dbid&amp;cid=$cid&amp;ref=$ref\">$dblogin</a>[!]</b>&nbsp;[$dbtime]<br/>$dbmsg";++$mread;
					}
     }
mysql_close ($link);
$total=$kol+($mread-$i); 
$page_next = $num + $max-1;
$page_prev = $num - $max+1;
if ($num + $max < $total) {
echo "<br/><a href=\"history.php?id=$id&amp;pass=$pass&amp;room=$room&amp;num=$page_next&amp;cid=$cid&amp;ref=$ref\">След. $max</a>";
}
if ($num >= $max) {
echo "<br/><a href=\"history.php?id=$id&amp;pass=$pass&amp;room=$room&amp;num=$page_prev&amp;cid=$cid&amp;ref=$ref\">Пред. $max</a>\n";
}
echo "<br/><a href=\"enter.php?id=$id&amp;pass=$pass&amp;room=$room&amp;cid=$cid&amp;ref=$ref\">Прихожая</a><br/>\n";
list($msec,$sec)=explode(chr(32),microtime());
echo "[".round(($sec+$msec)-$HeadTime,4)."]";
echo "</p>\n";
echo "</card>\n";
echo "<card id=\"add\" title=\"Написать\">\n";
echo "<p mode=\"wrap\">\n";
echo "<input name=\"msg$ref\" maxlength=\"200\" title=\"Текст\"/><br/>\n";
echo "<anchor title=\"send\">Сказать<go href=\"room.php?id=$id&amp;pass=$pass&amp;room=$room&amp;cid=$cid&amp;ref=$ref\" method=\"post\">\n";
echo "<postfield name=\"msg\" value=\"$(msg$ref)\"/>\n";
echo "<postfield name=\"private\" value=\"-.-\"/>\n";
echo "</go></anchor>\n";
echo "<br/>\n";
echo "<a href=\"room.php?id=$id&amp;pass=$pass&amp;room=$room&amp;cid=$cid&amp;ref=$ref\">В чат</a>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
}
}
?>