<?php
$id = $_GET["id"];
$mobile = "xhtml/cereri.php";
$text = $_SERVER['HTTP_USER_AGENT'];
$var[2] = "AvantGo";
$var[3] = "ProxiNet";
$var[4] = "Danger hiptop 1.0";
$var[5] = "DoCoMo/";
$var[6] = "Google CHTML Proxy/";
$var[7] = "UP.Browser/";
$var[8] = "SEMC-Browser/";
$var[9] = "J-PHONE/";
$var[10] = "PDXGW/";
$var[11] = "ASTEL/";
$var[13] = "Handspring";
$var[14] = "Windows CE";
$var[15] = "PPC";
$var[17] = "Blazer/";
$var[18] = "Palm";
$var[19] = "WebPro/";
$var[20] = "EPOC32-WTL/";
$var[21] = "Tungsten";
$var[22] = "Netfront/";
$var[23] = "Mobile Content Viewer/";
$var[24] = "PDA";
$var[25] = "MMP/2.0";
$var[26] = "Embedix/";
$var[27] = "Qtopia/";
$var[28] = "Xiino/";
$var[29] = "BlackBerry";
$var[30] = "Gecko/20031007";
$var[31] = "MOT-";
$var[32] = "UP.Link/";
$var[33] = "Smartphone";
$var[34] = "portalmmm/";
$var[35] = "Nokia";
$var[36] = "Symbian";
$var[37] = "AppleWebKit/413";
$var[38] = "UPG1 UP/";
$var[39] = "RegKing";
$var[40] = "STNC-WTL/";
$var[41] = "J2ME";
$var[42] = "Opera Mini/";
$var[43] = "SEC-";
$var[44] = "ReqwirelessWeb/";
$var[45] = "AU-MIC/";
$var[46] = "Sharp";
$var[47] = "SIE-";
$var[48] = "SonyEricsson";
$var[49] = "Elaine/";
$var[50] = "SAMSUNG-";
$var[51] = "Panasonic";
$var[52] = "Siemens";
$var[53] = "Sony";
$var[54] = "Verizon";
$var[55] = "Cingular";
$var[56] = "Sprint";
$var[57] = "AT&T";
$var[58] = "Nextel";
$var[59] = "Pocket PC";
$var[60] = "T-Mobile";
$var[61] = "Orange";
$var[62] = "Casio";
$var[63] = "HTC";
$var[64] = "Motorola";
$var[65] = "Samsung";
$var[66] = "NEC";

$result = count($var);

for ($i=0;$i<$result;$i++)
{
$ausg = stristr($text, $var[$i]);
if(strlen($ausg)>0)
{
header("location: $mobile");
break;
}

}
?>
<?
include ("config.php");
session_start();
?>
<html>
<link href="style_c.css" rel="stylesheet" type="text/css" />
<?
include ("header.html");
?>
<table width='950' cellspacing='0' cellpadding='0' align='center'>

<?
include ("right.html");
?>
<td width='760' valign='top' class='continut'>

<table cellspacing='0' cellpadding='10'  width='100%'>
<tr>
<td>
<!-- CONTINUTUL !!!! -->

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style>
FORM { margin:0px; }
.micro TD, .micro2 TD {   font-size:12px; }
.micro {
border: 1px solid silver; }
.micro2 {
border: 1px solid #485E81;
}
</style>

</head>
<body bgcolor='#BECBD4' style='margin: 5px'><!-- no div... -->
<center><small>[ <b><a href="cereri.php">Refresh </b></a>] [<b><a href='#write'> Write</b></a>]</small></center>
<?
if(!isset($_GET['p'])){
$page = 1;
} else {
$page = $_GET['p'];
}

$max_results = 50;

$from = (($page * $max_results) - $max_results);

$id = $row['id'];

   $query = "SELECT * FROM cereri order by id DESC LIMIT  $from,$max_results";
   $result = mysql_query($query);
   while($r=mysql_fetch_array($result))    
   {
$sid = $r["id"];
   	$getusersonline="SELECT id,nume,color,avatar,setavatar from utilizatori where nume='$r[name]'";
$getusersonline2=mysql_query($getusersonline) or die("Could not get users");
while($getusersonline3=mysql_fetch_array($getusersonline2))
{
$avat = $getusersonline3["setavatar"];
$id = $getusersonline3["id"];
$mod = $getusersonline3["color"];
$message =$r["message"];
$message=str_replace(":O","<img src='/interfata/smilies/o.gif'>",$message);
$message=str_replace("B-)","<img src='/interfata/smilies/cool.gif'>",$message);
$message=str_replace(":P","<img src='/interfata/smilies/p.gif'>",$message);
$message=str_replace(":X","<img src='/interfata/smilies/love.gif'>",$message);
$message=str_replace(":D","<img src='/interfata/smilies/d.gif'>",$message);
$message=str_replace("=D&gt;","<img src='/interfata/smilies/bv.gif'>",$message);

$message=str_replace(":o","<img src='/interfata/smilies/o.gif'>",$message);
$message=str_replace("b-)","<img src='/interfata/smilies/cool.gif'>",$message);
$message=str_replace(":p","<img src='/interfata/smilies/p.gif'>",$message);
$message=str_replace(":x","<img src='/interfata/smilies/love.gif'>",$message);
$message=str_replace(":d","<img src='/interfata/smilies/d.gif'>",$message);
$message=str_replace("=d&gt;","<img src='/interfata/smilies/bv.gif'>",$message);

$message=str_replace(":*","<img src='/interfata/smilies/kiss.gif'>",$message);
$message=str_replace(":))","<img src='/interfata/smilies/ras.gif'>",$message);
$message=str_replace("=))","<img src='/interfata/smilies/ras2.gif'>",$message);
$message=str_replace(":)","<img src='/interfata/smilies/smilie.gif'>",$message);
$message=str_replace(":(","<img src='/interfata/smilies/supi.gif'>",$message);
$message=str_replace(";)","<img src='/interfata/smilies/yes.gif'>",$message);
$message=str_replace("|-)","<img src='/interfata/smilies/dorm.gif'>",$message);
$message=str_replace("[-)","<img src='/interfata/smilies/nu.gif'>",$message);
$message=str_replace("=((","<img src='/interfata/smilies/dez.gif'>",$message);
$message=str_replace(":>","<img src='/interfata/smilies/yep.gif'>",$message);
$message=str_replace("X-(","<img src='/interfata/smilies/nervi.gif'>",$message);
$message=str_replace(">:)","<img src='/interfata/smilies/rad.gif'>",$message);
$message=str_replace("8-|","<img src='/interfata/smilies/eh.gif'>",$message);
$message=str_replace("L-)","<img src='/interfata/smilies/stai.gif'>",$message);
$message=str_replace(":-&","<img src='/interfata/smilies/bleach.gif'>",$message);
$message=str_replace(":&gt;","<img src='/interfata/smilies/yep.gif'>",$message);


// The Regular Expression filter
$pattern = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";

// convert URLs into Links
$message= preg_replace($pattern, "<a href=\"\\0\"?phpMyAdmin=uMSzDU7o3aUDmXyBqXX6JVQaIO3 rel=\"nofollow\">\\0</a>", $message);

$date = $r["date"];
$date_formated = date('H:i d/m', $date);



       echo "<div style='font-size:1px;line-height:2px;'>&nbsp;</div>
	   <table cellspacing='0' cellpadding='2' class='micro2' width='100%'>
     <tr><td bgcolor='white'>     
      <table cellspacing='0' cellpadding='2' class='micro' align='left'>
     <tr><td bgcolor='white'>";  
echo "<a href='profile.php?id=$id' target='_parent'  class='$mod'><br/>";
if($avat[0]=="1")
	  {
		echo "<img src='avatar.php?id=$id'/>";
	   }else{
		 echo "";
		}  
echo "</br><b>$r[name]</br ></a>$date_formated</b></td></tr>
     </table>
$message";
 if(isset($_SESSION['nume'])) {
      	$userb = ''.$_SESSION['nume'].'';
 $getuser="SELECT * from utilizatori WHERE nume='$userb'";
  $getuser2=mysql_query($getuser) or die("COuld not draw cookies");
  $getuser3=mysql_fetch_array($getuser2);
  if(strlen($getuser3[nume])>1)
  {
    $_SESSION['user']=$getuser3[nume];        
if($getuser3[status]>=2)
    {
$act = $_GET["act"];
$del = $_GET["id"];
if(($del=="$sid") && ($act=="delete")){
mysql_query("DELETE FROM cereri WHERE id='$sid' "); echo "<strong>Deleted</strong>!";}

echo"</b><a href=\"cereri.php?id=$sid&amp;act=delete\" class='modr'><b>&nbsp;X</b></a></br>";

}}}
echo"</td></tr></table>";
 }}
 
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as id FROM cereri"),0);
$total_pages = ceil($total_results / $max_results);
echo "</a><hr/>";
echo "<div align=center>";
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?p=$prev\">&#171;Prev </a> |";
}
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?p=$next\"> Next&#187;</a>";
}

$i = 1; $i <= $total_pages; $i++ ;
if ($total_pages>2)
{
echo "<br/><small>$total_results shouts ( $page of $total_pages):</small>
<br/>";
echo "<form action=\"shoutbox.php\" method=\"get\">
<input type=\"text\" name=\"p\" style='-wap-input-format: \"5N\"' value=\"$page\" size=\"2\"/>
<input type=\"submit\"  value=\"Go!\"/>
</form>";
}
?>
<?
if(isset($_SESSION['nume'])) {
      	$poster = ''.$_SESSION['nume'].'';
?>
<form action="cer.php" method="post">
<?   
echo "<input type='hidden' name='name_txt' type='text' id='name_txt' value='$poster'>";
?>
</p>
 <a name='write'></a>
 <p><b>Your Request:</b><br>
   <textarea name="message_txt" id="message_txt" cols='15' rows='3'></textarea>
 </p>
</p>
 <p>
 <small> Note: posting URLS is forbidden! Message may be deleted. </small>
   <input type="submit" name="Submit" value="Send">  
 </p>
</form>
<?
}else{
echo "Only registered and logged users can post to request.";
}
?>
<!-- SFARSIT CONTINUT!!! -->      <center>

	</center>


</td></tr></table>
</tr>

<tr>
<td width='180'>&nbsp;
</td>
<?
include ("flooter.html");
?>

</td>
</tr>
</table>
<body>
</html>