View file chat_polifonia/history.php

File size: 4.68Kb
<?
header("Cache-Control: no-cache");
header("Content-type:text/vnd.wap.wml");  
$ref=rand(10000,1000000);
require("inc.php");
$link = @mysql_pconnect ($MySQL_Hostname, $MySQL_Username, $MySQL_Password)
                or die ("<wml>
<card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">Can not connect to MySQL</p>
</card>
</wml>");
     
     @mysql_select_db($MySQLDatabasename) or die ("<wml>
<card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">error select the database...</p>
</card>
</wml>");  

        $result = @mysql_query ("Select pass,max,smiles,ignor,level from users where 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=\"&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;\" ontimer=\"index.php?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);
exit;
}
                
$row = mysql_fetch_array ($result);
if ($ps !== $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 "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"error\" title=\"&#x041E;&#x0448;&#x0438;&#x0431;&#x043A;&#x0430;\" ontimer=\"index.php?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);   
exit;
}           

$smset = $row["smiles"]; 
  if ($rm<0||$rm>10) exit; 
  $room="room".$rm;

if($rm==10) $takep="&amp;ref=$ref&amp;pwd=$pwd";
else $takep="&amp;ref=$ref";


$max = $row["max"];    
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 "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"history\" title=\"История\">\n";
echo "<do type=\"options\" name=\"refresh\" label=\"Обновить\"><go href=\"chat.php?id=$id&amp;ps=$ps&amp;rm=$rm$takep\"/></do>\n";
echo "<p mode=\"wrap\">\n"; 
echo "<a href=\"chat.php?id=$id&amp;ps=$ps&amp;rm=$rm$takep#add\">Сказать</a><br/>\n";
echo "<a href=\"chat.php?id=$id&amp;ps=$ps&amp;rm=$rm$takep\">Обновить</a>\n";
 if (!isset($num)) $num=0; 
$bmax = $max*2; 
$bnum = $num+1;

if (empty($pwd)) $pwd=pub;

if ($rm == 10){
$res = mysql_query ("Select time,who,message,messagewosm,messagewoasm,id,towhom,hid,usid,pwd from room10 WHERE ((pwd = '".$pwd."')OR(pwd = '')) and (usid = '".$id."')OR(towhom = '".$id."')OR(towhom = '') order by id desc LIMIT $bnum,$bmax");
} else {
$res = mysql_query ("Select time,who,message,messagewosm,messagewoasm,id,towhom,hid,usid from $room WHERE (usid = '".$id."')OR(towhom = '".$id."')OR(towhom = '') order by id desc LIMIT $bnum,$bmax");
}

$kol = mysql_affected_rows();   
@$total=$kol -1;
$ignor = $row["ignor"];
$mread =0; 
while ($mread < $max){ 
$data = mysql_fetch_array ($res);
if($data===false)break;
$date = $data["time"];
$name = $data["who"];
$usid = $data["usid"];
$msg = $data["message"];
if ($smset==0&&$data["messagewosm"]!="") $msg = $data["messagewosm"]; 
if ($smset==2&&$data["messagewoasm"]!="") $msg = $data["messagewoasm"];
$time = $data["id"];
$th = $data["towhom"]; 
$hid = $data["hid"];   
 if ((strpos($ignor, $name."|") === false)&&(($hid != 2)||($id == $usid))){
if ($th == "") {
echo "<br/><b><a href=\"inside.php?id=$id&amp;ps=$ps&amp;rm=$rm&amp;nk=$usid$takep\">$name</a></b>($date)&gt;<br/>$msg\n"; $mread++;}
else if (($th == $id)||($id == $usid)){ 
echo "<br/><b><a href=\"inside.php?id=$id&amp;ps=$ps&amp;rm=$rm&amp;nk=$usid$takep\">$name</a>[P!]</b>($date)&gt;<br/>$msg\n";$mread++;}
}    
}
mysql_close ($link);
$page_next = $num + $max;
$page_prev = $num - $max;
if($num==0)$total+1;
if ($max < $total) {
echo "<br/><a href=\"history.php?id=$id&amp;ps=$ps&amp;rm=$rm&amp;num=$page_next$takep\">След. $max</a>";
}
if ($num >= $max) {
echo "<br/><a href=\"history.php?id=$id&amp;ps=$ps&amp;rm=$rm&amp;num=$page_prev$takep\">Пред. $max</a>\n";
}
echo "<br/><a href=\"enter.php?id=$id&amp;ps=$ps&amp;ref=$ref\">Прихожая</a>\n";
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n"; 
?>