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

if(isset($_SESSION['nume'])) {
      	$username = ''.$_SESSION['nume'].'';
$stare = "ShowtBox <i>(wap)</i>";
if(!$act){mysql_query("UPDATE utilizatori SET stare='$stare' WHERE nume='$username'");}
}
?>
<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 }

.meniu A:link { color: #3F494C }
.meniu A:visited { color: #455053  }
.meniu A:visited, .meniu  A:link { padding-left:10px; font-size: 10px; line-height:20px; text-decoration: none; font-weight:bold }

.meniu  A:hover { color: #225573;  }

.meniu TD { border-bottom: 1px solid #485E81; border-right: 1px solid #485E81;  font-size:14px  }


.meniuH { background-color: #045C97; color: white; font-weight: bold  }
.meniuH TD { font-family: arial; font-size: 14px;  }
.meniuH TABLE { 
margin-left: auto;
margin-right: auto;
display: block;
 }

.admin:visited, .admin:link {
color: red;
border-bottom: 1px dotted red;
}
.author:visited, .author:link {
color: aqua;
border-bottom: 1px dotted aqua;
}
.td1 { color:white; font-size: 10px; vertical-align: center;}
.td1 A { color: #90a9b7; }inputX, textareaX, selectX { border: 1px solid #BECBD4; padding:background-color: #DBEBF5; color: #5576A5;  3px; font-weight:bold }
inputX { height: 26 }




.imagini  IMG { border: 2px solid #7397D0 }
.imagini A:hover img  { border: 2px solid #415374 }
.imagini TD { text-align: center; font-weight: bold }

.imagine { border: 1px solid silver }

#focus	{filter: silver(), alpha(opacity=60)}

.alert { font-weight: bold; color: red }

.border2 TD { border: 1px solid #7BA2DE; vertical-align:top }
.mare { font-size: 26px; font-weight: bold; }

.border_main, .hl {  border-right: 2px solid #7192a5;   border-top: 1px solid black; }
.border_main TD { color: white }

.continut { background-color:#FAFAFA; border: 1px solid #225573; }

.border { border: 1px solid #7BA2DE; }

.hl { background: url('interfata/hl.gif'); padding:3px; color:white; }
.hl A { color:#90a9b7; }
.linespace {line-height:26px;}

.meniutb { border: 1px solid #045C97; }
.extrapadding { padding: 10px; }

.topnav, .topnav TD {font-size:10px; color:white}
.topnav A:visited, .topnav A:link {color:white;}

.transparency { filter:alpha(opacity=30);-moz-opacity:.30;opacity:.30; }

.table, .AJmessage, .message {
background:#D9E2F4;
border: solid 1px #C7CFE0;
color: #26272B;
padding: 10px;
}
.table TD {
vertical-align:top;
}
.Emessage {
background:#F8CCCC;
border: solid 1px #CAA6A6;
color: #756060;
padding: 10px;
}

.normalfont {
font-weight: normal;
}


.title {
background-color:#A8B6C3;
color: #5B636A;
font-weight: bold;
border-bottom: 1px solid #8C9396; 
font-family: Verdana;
padding: 3px;

}

.txt {
line-height:19px
}

.whitelnk A:link, .whitelnk A:visited {
color: white;
border-bottom: 1px dotted white;
}

.modr:visited, .modr:link {
color: green;
border-bottom: 1px dotted green;
}

.administrator:visited, .administrator:link {
color: orange;
border-bottom: 1px dotted orange;
}

.headertab {
border: 1px solid #36468F;
border-top: 3px solid #36468F;
border-bottom: 1px solid #045C97;
}
</style>
<?
include ("config.php");
?>
</head>
<body bgcolor='#BECBD4' style='margin: 5px'><!-- no div... -->
<center><small>[ <b><a href="shoutbox.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 = 10;

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

$id = $row['id'];

   $query = "SELECT * FROM shoutbox order by id DESC LIMIT  $from,$max_results";
   $result = mysql_query($query);
   while($r=mysql_fetch_array($result))    
   {
$sid = $r["id"];
   	$getusersonline="SELECT * from utilizatori where id='$r[uid]'";
$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"];
$avatar = $getusersonline3["avatar"];


// 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["data"];
$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/$avatar'/>";
	   }else{
		 echo "";
		}  
echo "</br><b>$getusersonline3[nume]</a></br >$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 shoutbox WHERE id='$sid' "); echo "<strong>Deleted</strong>!";}

echo"</b><a href=\"shoutbox.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 shoutbox"),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'])) {
      	$username = ''.$_SESSION['nume'].'';
$rs="SELECT * from utilizatori where nume='$username'"; 
$rs2=mysql_query($rs) or die("Could not get users");
while($rs3=mysql_fetch_array($rs2))
{
$uidp = $rs3["id"];
}    
?>
<form action="shout.php?ac=added" method="post">
<?   
echo "<input type='hidden' name='name_txt' type='text' id='name_txt' value='$uidp'>";
?>
</p>
 <a name='write'></a>
 <p><b>Your message:</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 shoutbox.";
}
?>
<?
echo "<div class='hl'>Users Online</div>";
include("useronline.php");
?>
<?
include("flooter.php");
?>