<?
include ("header.php");
?>
<?
include ("config.php");
session_start();
?>

<html>
<link href="style_c.css" rel="stylesheet" type="text/css" />
<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;
}
@import url(style.css);
#eXTReMe { display:inline }

.HR {width: 90%; height: 1px; color:#455053; text-align:left }
.border1 { border-left: 1px solid #7BA2DE; border-right: 1px solid #7BA2DE }

.border_jos2 TD { border-bottom:1px solid #5A76A3; }

.stanga {  vertical-align: top; height: 370px; border-right: 1px solid #7BA2DE }
 A:link, A:visited { color: #225573; text-decoration: none; font-weight:bold }
 /* #3F494C */

 A:hover { color: RGB(0,0,0); text-decoration: underline }


.table TD {
vertical-align:top;
}
.Emessage {
background:#F8CCCC;
border: solid 1px #CAA6A6;
color: #756060;
padding: 10px;
}

.normalfont {
font-weight: normal;
}

.admin:visited, .admin:link {
color: red;
border-bottom: 1px dotted red;
}

</style>
<?
include ("../var.php");
?>
</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]'"; //grab from sql users on in last 15 minutes
$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"];


// 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_format = date('H:i:s 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_format</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>Cererea Ta:</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!!! --> 
<?
include ("flooter.php");
?>