<?php
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.1//EN"'.
' "http://www.wapforum.org/DTD/wml_1.1.xml">'.
'<wml><head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>';

include "../ini.php";

$login = autorize();

print '<card title="Inbox">'.
'<p>';

if($login) {
if(empty($start)) $start = 0;
if($start < 0) $start = 0;
// Posts counter
$pnumber = 5;
// poct coding

if($del=="1") {(mysql_query("delete from `".$px.$ltable."` where to_user='".$login['login']."' and ci='$ci';")); print 'Empty Inbox Now !<br/>'; }
if($del=="2") {(mysql_query("delete from `".$px.$ltable."` where to_user='".$login['login']."' and new='' and ci='$ci';")); print 'Readed Mess Deleted Now !<br/>'; }
if($del=="3") {(mysql_query("delete from `".$px.$ltable."` where id='$no' and ci='$ci';")); print 'Mess Removed Now !<br/>'; }
$tot = @mysql_query("select count(*) from `".$px.$ltable."` where to_user='".$login['login']."' and ci='$ci';");
$lets = @mysql_query("select * from `".$px.$ltable."` where to_user='".$login['login']."' and ci='$ci' order by time desc limit ".$start.",".$pnumber.";");
if($tot && $lets) {
$total = @mysql_fetch_array($tot);
$count = $total['count(*)'];
print 'INBOX: '.$count.'<br/>';
while($data = @mysql_fetch_array($lets))
{
$from=$data['from_user'];
$to=$data['to_user'];
$time=$data['time'];
$subject=$data['subject'];
$letter=$data['letter'];
$new=$data['new'];
$id_letter=$data['id'];
$no=$data['id'];
$time=date("d.m.Y H:i", $time);
if($new) {
        print "<img src=\"new.gif\" alt=\"\"/> <b><a href=\"view.php?ci=$ci&amp;id=$id&amp;pass=$pass&amp;id_letter=$id_letter\">$from</a></b> $subject ($time)<br/>";
        }
else {
        print "<img src=\"old.gif\" alt=\"\"/> <a href=\"view.php?ci=$ci&amp;id=$id&amp;pass=$pass&amp;id_letter=$id_letter\">$from</a> $subject ($time) <a href=\"inbox.php?ci=$ci&amp;id=$id&amp;pass=$pass&amp;no=$nO&amp;del=3\">[x]</a><br/>";
        }
} 
}
if($start > 0)
print "<a href=\"?ci=$ci&amp;id=$id&amp;pass=$pass&amp;room=$room&amp;start=".($start-$pnumber)."\"><br/>Backward</a>";
if($count > $start + $pnumber)
print "<a href=\"?ci=$ci&amp;id=$id&amp;pass=$pass&amp;room=$room&amp;start=".($start+$pnumber)."\"><br/>Forward</a>";
print "<br/>---<br/><a href=\"inbox.php?ci=$ci&amp;id=$id&amp;pass=$pass&amp;del=1\">Delete All PM's</a><br/><a href=\"inbox.php?ci=$ci&amp;id=$id&amp;pass=$pass&amp;del=1\">Delete Read PM's</a><br/>---<br/><anchor>Back<prev/></anchor><br/>";
print "<a href=\"../enter.php?ci=$ci&amp;id=$id&amp;pass=$pass\">Hall</a><br/>";
                } else { print "Sorry Nt Login , Try Again !"; }
print '</p>'.
'</card>'.
'</wml>';
ob_end_flush();
?>
