<?php
include('header.php');
if($xg15 != 1){
echo $h;
echo $LANGAUGE_CP[626];
echo $f;
exit;
}
echo $h;

$action = $_GET['action'];
if(!isset($action)) $action = "add";

IF ($action=="addcat"){

?>
<form name="vbform" method="post" action="box_cp.php?action=insertcat">

<table class='xtable' width="100%" id="AutoNumber1">
     <tr>
      <td width="100%" colspan="2" class='xtx' align="center"><?php echo $LANGAUGE_CP[175]; ?></td>
    </tr>
    <tr>
      <td width="35%" class='xtr'><?php echo $LANGAUGE_CP[156]; ?></td>
      <td width="65%" class='xtd'><input size="50" name="name" /></td>
    </tr>

     <tr>
      <td width="100%" colspan="2" class='xtr' align="center">
<input type="submit" value=" <?php echo $LANGAUGE_CP[18]; ?> " name="cmdAdd" /></td>
    </tr>
  </table>
</form>

<?php
$queryx = mysql_query("SELECT * FROM msg_cat order by id desc");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo "";
}else{

echo "<br />
<table class='xtable' width='100%' id='AutoN4umber15'>

<tr>
<td width='100%' colspan='3' class='xtt' align='center'>".$LANGAUGE_CP[97]."</td>
</tr>

  <tr>
      <td width='86%' align='center' class='xtr'>".$LANGAUGE_CP[158]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[26]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[27]."</td>
  </tr>";
while($p = mysql_fetch_array($queryx))
{
$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

echo "<tr>
      <td width='86%' class='xtd'>» ".$p['name']."</td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=editcat&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$p['name']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=deletecat&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['name']."' /></a></td>
    </tr>";
}
echo "</table>";
}

}ELSEIF ($action=="insertcat"){

$name = addslashes($_POST['name']);

if (empty($name)){
echo $LANGAUGE_CP[159];
}else{
$query =  mysql_query ("INSERT INTO msg_cat (name) VALUES ('$name')") or die ("إستعلام خاطيء");
print $LANGAUGE_CP[21];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=box_cp.php?action=addcat' />";
}

}ELSEIF ($action=="editcat"){
$id = intval($_GET['id']);
$query = mysql_query("SELECT * FROM msg_cat where id='$id'");
$p= mysql_fetch_array($query);

$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

echo "<form name='vbform' method='POST' action='box_cp.php?action=editcatok'>
<input type='hidden' name='id' value='$p[id]' />

<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='2' class='xtx' align='center'>".$LANGAUGE_CP[32]."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[156]."</td>
<td width='70%' class='xtd'><input name='name' size='60' value='".$p['name']."' /></td>
</tr>

<tr>
<td width='100%' colspan='2' align='center' class='xtr'><input type='submit' value=' ".$LANGAUGE_CP[33]." ' name='B1' /></td>
</tr>

</table>
</form>";

}ELSEIF ($action=="editcatok"){

$id   = intval($_POST['id']);
$name = addslashes($_POST['name']);


if (empty($name)){
echo $LANGAUGE_CP[159];
}else{
$query =  mysql_query("UPDATE msg_cat SET name='$name' where id='$id'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=box_cp.php?action=addcat' />";
}

}ELSEIF ($action=="deletecat"){
$id = intval($_GET['id']);
$query =  mysql_query("DELETE FROM msg_cat WHERE id='$id'");
echo $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=box_cp.php?action=addcat' />";


}ELSEIF ($action=="add"){
$string = mt_rand();
$string = substr(sha1($string), 0, 6);
$string = str_replace(array('0', 'O', 'o', '9', 'g', 'G'), rand(1, 8), $string);
$datex = time();
$codemembers = $datex.$string;
$codemembers = MD5($codemembers);
$codemembers = substr($codemembers, 0, 15);
?>
<form name="vbform" method="post" action="box_cp.php?action=insert">
<input type="hidden" name="codenumber" value="<?php echo "$codemembers"; ?>" />

<table class='xtable' width="100%" id="AutoNumber1">

     <tr>
      <td width="100%" colspan="2" class='xtt' align="center"><?php echo $LANGAUGE_CP[176]; ?></td>
    </tr>

    <tr>
      <td width="35%" class='xtr'><?php echo $LANGAUGE_CP[177]; ?></td>
      <td width="65%" class='xtd'><input size="50" name="name" /></td>
    </tr>

    <tr>
      <td width="35%" class='xtr'><?php echo $LANGAUGE_CP[178]; ?></td>
      <td width="65%" class='xtd'><input size="50" name="emails" /></td>
    </tr>

<tr>
<td width='35%' class='xtr'><?php echo $LANGAUGE_CP[95]; ?></td>
<td width='65%' class='xtd'>
<select  size='1' name='cat'>";
<?php
$sql = mysql_query ("SELECT * FROM  msg_cat order by id desc");
while($cat=mysql_fetch_array($sql))
{
echo "<OPTION value='".$cat['id']."'>".$cat['name']."</OPTION>";
}
echo "</select>";
echo "</td>
</tr>";
?>

<tr>
      <td width="35%" class='xtr'><?php echo $LANGAUGE_CP[179]; ?></td>
      <td width="65%" class='xtd'><input size="50" name="title" /></td>
</tr>

    <tr>
      <td width="100%" class='xtd' colspan="2" align="center">

<script type='text/javascript'>edToolbar('mytxtarea'); </script>
<textarea name='message' id='mytxtarea' rows='15' cols='100'></textarea>

      </td>
    </tr>

     <tr>
      <td width="100%" colspan="2" class='xtr' align="center">
      <input type="submit" value=" <?php echo $LANGAUGE_CP[18]; ?> " name="cmdAdd" /></td>
    </tr>
  </table>
</form>
<?php
}ELSEIF ($action=="insert"){

$name = addslashes($_POST['name']);
$title = addslashes($_POST['title']);
$emails = addslashes($_POST['emails']);
$text = addslashes($_POST['message']);
$cat = $_POST['cat'];
$codenumber = addslashes($_POST['codenumber']);
$d = time();
$ip = $_SERVER['REMOTE_ADDR'];

if (empty($name)){
echo $LANGAUGE_CP[180];
}else{
$query =  mysql_query ("INSERT INTO msg_box (name,title,emails,date,text,cat,ip,showadmin,replayadmin,showuser,closemsg,code) VALUES ('$name','$title','$emails','$d','$text','$cat','$ip',0,0,0,0,'$codenumber')") or die ("error");
print $LANGAUGE_CP[21];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=box_cp.php?action=add' />";
}


}ELSEIF ($action=="edit"){
$id = intval($_GET['id']);
$query = mysql_query("SELECT * FROM msg_box where id='$id'");
$p= mysql_fetch_array($query);

$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

$p['title'] = stripslashes($p['title']);
$p['title'] = htmlspecialchars($p['title']);

$p['text'] = stripslashes($p['text']);
$p['text'] = htmlspecialchars($p['text']);

$p['emails'] = stripslashes($p['emails']);
$p['emails'] = htmlspecialchars($p['emails']);

echo "<form name='vbform' method='POST' action='box_cp.php?action=editok'>
<input type='hidden' name='id' value='$p[id]' />

<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='2' class='xtx' align='center'>".$LANGAUGE_CP[32]."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[177]."/td>
<td width='70%' class='xtd'><input name='name' size='60' value='".$p['name']."' /></td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[178]."</td>
<td width='70%' class='xtd'><input name='emails' size='60' value='".$p['emails']."' /></td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[179]."</td>
<td width='70%' class='xtd'><input name='title' size='60' value='".$p['title']."' /></td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[181]."</td>
<td width='70%' class='xtd'>

<select size='1' name='closemsg'>";

if($p['closemsg'] == 0){
echo "<option value='0' selected='selected'>".$LANGAUGE_CP[140]."</option>
<option value='1'>".$LANGAUGE_CP[139]."</option>";
}else{
echo "<option value='0'>".$LANGAUGE_CP[140]."</option>
<option value='1' selected='selected'>".$LANGAUGE_CP[139]."</option>";
}

echo "</select>
</td>
</tr>

<tr>
<td width='100%' class='xtd' colspan='2' align='center'>";
?>
<script type='text/javascript'>edToolbar('mytxtarea'); </script>
<textarea name='message' id='mytxtarea' rows='15' cols='100'><?php echo $p['text']; ?></textarea>
<?php
echo "</td>
</tr>

<tr>
<td width='100%' colspan='2' align='center' class='xtr'><input type='submit' value=' ".$LANGAUGE_CP[33]." ' name='B1' /></td>
</tr>

</table>

</form>";

}ELSEIF ($action=="editok"){

$id    = intval($_POST['id']);
$name = addslashes($_POST['name']);
$title = addslashes($_POST['title']);
$emails = addslashes($_POST['emails']);
$text = addslashes($_POST['message']);
$closemsg = intval($_POST['closemsg']);

if (empty($name)){
echo $LANGAUGE_CP[180];
}else{
$query =  mysql_query("UPDATE msg_box SET name='$name',title='$title',emails='$emails',text='$text',closemsg='$closemsg' where id='$id'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=box_cp.php?action=box' />";
}

}ELSEIF ($action=="delete"){
$id = intval($_GET['id']);
$query =  mysql_query("DELETE FROM msg_box WHERE id='$id'");
echo $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=box_cp.php?action=box' />";


}ELSEIF ($action=="re"){
if(isset($_POST['id']) AND intval($_POST['id']) != 0){
$id = intval($_POST['id']);
}else{
$id = intval($_GET['id']);
}

$query = mysql_query("SELECT * FROM msg_box where id='$id'");
$p = mysql_fetch_array($query);

$p['title'] = stripslashes($p['title']);
$p['title'] = htmlspecialchars($p['title']);

echo "<form name='vbform' method='POST' action='box_cp.php?action=insertreplay'>
<input type='hidden' name='idmsg' value='$id' />

<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='2' align='center' class='xtt'>".$LANGAUGE_CP[182]." ".$p['title']."</td>
</tr>

<tr>
<td width='100%' class='xtd' align='center'>";
?>
<script type='text/javascript'>edToolbar('mytxtarea'); </script>
<textarea name='message' id='mytxtarea' rows='15' cols='100'></textarea>
<?php
echo "</td>
</tr>

<tr>
<td width='100%' colspan='2' align='center' class='xtr'><input type='submit' value=' ".$LANGAUGE_CP[183]." ' name='B1' /></td>
</tr>

</table>
</form>";


}ELSEIF ($action=="insertreplay"){
$idmsg = intval($_POST['idmsg']);
$text = addslashes($_POST['message']);
$d = time();


if (empty($text)){
echo $LANGAUGE_CP[184];
}else{
$query =  mysql_query ("INSERT INTO msg_replay (text,useroradmin,idmsg,date) VALUES ('$text','1','$idmsg','$d')") or die ("error");
$query2 =  mysql_query("UPDATE msg_box SET showadmin='1',replayadmin='1' where id='$idmsg'");

print $LANGAUGE_CP[21];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=box_cp.php?action=show&id=$idmsg' />";
}




}ELSEIF ($action=="box"){

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = 20;
$startpoint = ($page * $perpage) - $perpage;

$queryx = mysql_query("SELECT * FROM msg_box order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo $LANGAUGE_CP[185];
}else{
echo "<form name='xxx'action='box_cp.php?action=deletemsg' method='post'>

<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='8' class='xtt' align='center'>".$LANGAUGE_CP[186]."</td>
</tr>

<tr>
<td width='100%' colspan='8' class='xtd' align='center'>".$LANGAUGE_CP[187]."</td>
</tr>

  <tr>
  <td width='5%' align='center' class='xtr'>#</td>
      <td width='30%' align='center' class='xtr'>".$LANGAUGE_CP[188]."</td>
      <td width='20%' align='center' class='xtr'>".$LANGAUGE_CP[189]."</td>
      <td width='5%' align='center' class='xtr'>".$LANGAUGE_CP[190]."</td>
      <td width='19%' align='center' class='xtr'>".$LANGAUGE_CP[57]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[191]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[26]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[27]."</td>
    </tr>";
$i = 0;
while($p = mysql_fetch_array($queryx))
{
$queryx2 = mysql_query("SELECT * FROM msg_replay where idmsg='".$p['id']."'");
$xx2 = mysql_num_rows($queryx2);

$i++;
$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

$p['title'] = stripslashes($p['title']);
$p['title'] = htmlspecialchars($p['title']);

$p['emails'] = stripslashes($p['emails']);
$p['emails'] = htmlspecialchars($p['emails']);

$d = date("j/n/Y",$p['date']);

if($p['showadmin'] == 0 AND $p['replayadmin'] == 0){
$dd = "<font color='#000000'>".$p['title']."</font>";
}elseif($p['showadmin'] == 1 AND $p['replayadmin'] == 1){
$dd = "<font color='#CC0000'>".$p['title']."</font>";
}elseif($p['showadmin'] == 1 AND $p['replayadmin'] == 0){
$dd = "<font color='#3333CC'>".$p['title']."</font>";
}


if($p['showuser'] == 1){
$uu = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='images/on.gif' alt='".$LANGAUGE_CP[192]."' border='0' />";
}else{
$uu = "";
}


echo "<tr>
      <td width='5%' class='xtr' align='center'><input type='checkbox' name='del[$i]' value='$p[id]' /></td>
      <td width='30%' class='xtd'><a target='_blank' href='../box.php?action=show&code=".$p['code']."'>» ".$dd."$uu</a></td>
      <td width='20%' align='center' class='xtd'><a href='mailto:".$p['emails']."'>".$p['name']."</a></td>
      <td width='5%' class='xtd' align='center'>".$xx2."</td>
      <td width='19%' align='center' class='xtd'>$d</td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=show&id=$p[id]'><img border='0' src='images/show.gif' alt='".$p['title']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=edit&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$p['title']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=delete&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['title']."' /></a></td>
    </tr>";
}

echo "<tr>
<td colspan='8' align='center' class='xtr'><input name='delete' type='submit' id='delete' value=' ".$LANGAUGE_CP[193]." ' /> <input name='close' type='submit' value=' ".$LANGAUGE_CP[194]." ' /></td>
</tr>

<tr>
<td colspan='8' align='center' class='xtd'>".$LANGAUGE_CP[195]."</td>
</tr>
</table>
</form>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("SELECT id FROM msg_box")) / $perpage);
if($pagesnum > 1){
echo "<p align='center'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {
$z = "[<a href='box_cp.php?action=box&page=$i'>$i</a>] ";
} else {
$z = "[<u>$i</u>]";
}
echo "$z";
}
echo "</p>";
}
}



}ELSEIF ($action=="deletemsg"){


if(isset($_POST['delete'])){

if(count($_POST['del']) > 0){
$del_id = join(',',$_POST['del']);
$sql = mysql_query("DELETE FROM msg_box WHERE id IN($del_id)");
$sql2 = mysql_query("DELETE FROM msg_replay WHERE idmsg IN($del_id)");
print $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=box_cp.php?action=box' />";
}else{
echo $LANGAUGE_CP[63];
}

}


if(isset($_POST['close'])){

if(count($_POST['del']) > 0){
$del_id = join(',',$_POST['del']);
$sql = mysql_query("UPDATE msg_box SET closemsg='1' WHERE id IN($del_id)");
print $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='refresh' CONTENT='1; URL=box_cp.php?action=box' />";
}else{
echo $LANGAUGE_CP[63];
}

}



}ELSEIF ($action=="show"){
include('../includes/bbcode.php');

$id = intval($_GET['id']);

$query2 = mysql_query("UPDATE msg_box SET showadmin='1' where id='$id'");

$query = mysql_query("SELECT * FROM msg_box where id='$id'");
$p= mysql_fetch_array($query);

$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

$text = $p['text'];
$text = htmlspecialchars($text);
$text = stripslashes($text);
$text = str_replace( "&lt;", "<", $text );
$text = str_replace( "&gt;", ">", $text );
$text = str_replace( "&#092;"   , "\\", $text);
$text = str_replace( "&#39;"   , "'", $text);
$text = str_replace( "&#33;"   , "!", $text);
$text = str_replace( "&#036;"   , "$", $text);
$text = str_replace( "&#124;"  , "|", $text);
$text = str_replace( "&amp;"   , "&", $text);
$text = str_replace( '&quot;'  , '"', $text);
$text = str_replace( "&#153;", "(tm)", $text );
$text = Replace($text);
$text = str_replace("[LIST]","<ul>",$text);
$text = str_replace("[/LIST]","</ul>",$text);
$text = str_replace("[LIST1]","<ol>",$text);
$text = str_replace("[/LIST1]","</ol>",$text);
$text = str_replace("[*]","<li>",$text);

$p['title'] = stripslashes($p['title']);
$p['title'] = htmlspecialchars($p['title']);

$p['emails'] = stripslashes($p['emails']);
$p['emails'] = htmlspecialchars($p['emails']);

$d = date("j/n/Y",$p['date']);

$query3 = mysql_query("SELECT * FROM msg_cat where id='".$p['cat']."'");
$p3 = mysql_fetch_array($query3);

echo "<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='2' class='xtx' align='center'>".$LANGAUGE_CP[196]."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[179]."</td>
<td width='70%' class='xtd'>".$p['title']."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[197]."</td>
<td width='70%' class='xtd'>".$p['name']."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[198]."</td>
<td width='70%' class='xtd'>".$p['emails']."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[199]."</td>
<td width='70%' class='xtd'>".$p['ip']."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[200]."</td>
<td width='70%' class='xtd'>".$p['code']."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[201]."</td>
<td width='70%' class='xtd'>".$d."</td>
</tr>

<tr>
<td width='30%' class='xtr'>".$LANGAUGE_CP[95]."</td>
<td width='70%' class='xtd'>".$p3['name']."</td>
</tr>

<tr>
<td width='100%' colspan='2' class='xtd'>".$text."</td>
</tr>

</table><br />";





$query4 = mysql_query("SELECT * FROM msg_replay where idmsg='".$p['id']."' order by id desc");
$xx = mysql_num_rows($query4);
if($xx == 0){
echo "<div align='center'><form method='POST' action='box_cp.php?action=re'>
<input type='hidden' name='id' value='".$p['id']."' />
<input name='delete' type='submit' value=' ".$LANGAUGE_CP[182]." ".$p['title']." '></form><br /></div>";
}else{

while($ps = mysql_fetch_array($query4))
{
$text2 = $ps['text'];
$text2 = htmlspecialchars($text2);
$text2 = stripslashes($text2);
$text2 = str_replace( "&lt;", "<", $text2 );
$text2 = str_replace( "&gt;", ">", $text2 );
$text2 = str_replace( "&#092;"   , "\\", $text2);
$text2 = str_replace( "&#39;"   , "'", $text2);
$text2 = str_replace( "&#33;"   , "!", $text2);
$text2 = str_replace( "&#036;"   , "$", $text2);
$text2 = str_replace( "&#124;"  , "|", $text2);
$text2 = str_replace( "&amp;"   , "&", $text2);
$text2 = str_replace( '&quot;'  , '"', $text2);
$text2 = str_replace( "&#153;", "(tm)", $text2 );
$text2 = Replace($text2);
$text2 = str_replace("[LIST]","<ul>",$text2);
$text2 = str_replace("[/LIST]","</ul>",$text2);
$text2 = str_replace("[LIST1]","<ol>",$text2);
$text2 = str_replace("[/LIST1]","</ol>",$text2);
$text2 = str_replace("[*]","<li>",$text2);

$d = date("j/n/Y",$ps['date']);

if($ps['useroradmin']==1){
$j = $LANGAUGE_CP[202];
$rtr = "xtr";
}else{
$j = "";
$rtr = "xtd";
}

$div = "<div style='width:50px; position:relative; top:3px; left:0; float:left;'><a href='box_cp.php?action=editreplay&id=".$ps['id']."&show=$id'><img border='0' src='images/edit.gif' alt='".$LANGAUGE_CP[26]."' /></a> <a href='box_cp.php?action=deletereplay&id=".$ps['id']."&show=$id'><img border='0' src='images/delete.gif' alt='".$LANGAUGE_CP[27]."' /></a></div>";

echo "<br />
<table class='xtable' width='100%' id='AutoNumber115'>

<tr>
<td width='100%' class='xtt' align='center'>".$LANGAUGE_CP[203]." $d".$j."</td>
</tr>

<tr>
<td class='$rtr'>$div".$text2."</td>
</tr>
</table>";

}

echo "<div align='center'><br /><form method='POST' action='box_cp.php?action=re'>
<input type='hidden' name='id' value='".$p['id']."' />
<input name='delete' type='submit' value=' ".$LANGAUGE_CP[204]." ".$p['title']." ' /></form><br /></div>";

}

}ELSEIF ($action=="read"){

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = 20;
$startpoint = ($page * $perpage) - $perpage;

$queryx = mysql_query("SELECT * FROM msg_box where showadmin=1 order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo $LANGAUGE_CP[205];
}else{

echo "<table class='xtable' width='100%' id='AutoNumber415'>

<tr>
<td width='100%' colspan='7' class='xtt' align='center'>".$LANGAUGE_CP[206]."</td>
</tr>

  <tr>
      <td width='33%' align='center' class='xtr'>".$LANGAUGE_CP[188]."</td>
      <td width='20%' align='center' class='xtr'>".$LANGAUGE_CP[189]."</td>
      <td width='19%' align='center' class='xtr'>".$LANGAUGE_CP[57]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[207]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[191]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[26]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[27]."</td>
  </tr>";
while($p = mysql_fetch_array($queryx))
{

$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

$p['title'] = stripslashes($p['title']);
$p['title'] = htmlspecialchars($p['title']);

$p['emails'] = stripslashes($p['emails']);
$p['emails'] = htmlspecialchars($p['emails']);

$d = date("j/n/Y",$p['date']);

$activ = "<a href='box_cp.php?action=re&id=$p[id]'><img border='0' src='images/replay.gif' alt='".$LANGAUGE_CP[182]." ".$p['title']."' /></a>";

echo "<tr>
      <td width='33%' class='xtd'>» ".$p['title']."</td>
      <td width='20%' align='center' class='xtd'><a href='mailto:".$p['emails']."'>".$p['name']."</a></td>
      <td width='19%' align='center' class='xtd'>$d</td>
      <td width='7%' align='center' class='xtd'>$activ</td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=show&id=$p[id]'><img border='0' src='images/show.gif' alt='".$p['title']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=edit&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$p['title']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=delete&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['title']."' /></a></td>
    </tr>";
}

echo "</table>
  </center>
</div><br>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("SELECT id FROM msg_box where showadmin=1 AND closemsg='0'")) / $perpage);
if($pagesnum > 1){
echo "<p align='center'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {
$z = "[<a href='box_cp.php?action=read&page=$i'>$i</a>] ";
} else {
$z = "[<u>$i</u>]";
}
echo "$z";
}
echo "</p>";
}
}


}ELSEIF ($action=="sending"){

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = 20;
$startpoint = ($page * $perpage) - $perpage;

$queryx = mysql_query("SELECT * FROM msg_box where replayadmin=1 order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo $LANGAUGE_CP[208];
}else{

echo "<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='7' class='xtt' align='center'>".$LANGAUGE_CP[209]."</td>
</tr>

  <tr>
      <td width='33%' align='center' class='xtr'>".$LANGAUGE_CP[188]."</td>
      <td width='20%' align='center' class='xtr'>".$LANGAUGE_CP[189]."</td>
      <td width='19%' align='center' class='xtr'>".$LANGAUGE_CP[57]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[207]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[191]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[26]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[27]."</td>
    </tr>";
while($p = mysql_fetch_array($queryx))
{

$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

$p['title'] = stripslashes($p['title']);
$p['title'] = htmlspecialchars($p['title']);

$p['emails'] = stripslashes($p['emails']);
$p['emails'] = htmlspecialchars($p['emails']);

$d = date("j/n/Y",$p['date']);

$activ = "<a href='box_cp.php?action=re&id=$p[id]'><img border='0' src='images/replay.gif' alt='".$LANGAUGE_CP[182]." ".$p['title']."' /></a>";

echo "<tr>
      <td width='33%' class='xtd'>» ".$p['title']."</td>
      <td width='20%' align='center' class='xtd'><a href='mailto:".$p['emails']."'>".$p['name']."</a></td>
      <td width='19%' align='center' class='xtd'>$d</td>
      <td width='7%' align='center' class='xtd'>$activ</td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=show&id=$p[id]'><img border='0' src='images/show.gif' alt='".$p['title']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=edit&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$p['title']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=delete&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['title']."' /></a></td>
    </tr>";
}

echo "</table>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("SELECT id FROM msg_box where replayadmin=1 AND closemsg='0'")) / $perpage);
if($pagesnum > 1){
echo "<p align='center'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {
$z = "[<a href='box_cp.php?action=sending&page=$i'>$i</a>] ";
} else {
$z = "[<u>$i</u>]";
}
echo "$z";
}
echo "</p>";
}
}

}ELSEIF ($action=="close"){

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = 20;
$startpoint = ($page * $perpage) - $perpage;

$queryx = mysql_query("SELECT * FROM msg_box where closemsg=1 order by id desc LIMIT $startpoint,$perpage");
$xx = mysql_num_rows($queryx);
if($xx == 0){
echo $LANGAUGE_CP[210];
}else{

echo "<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='7' class='xtt' align='center'>".$LANGAUGE_CP[211]."</td>
</tr>

  <tr>
      <td width='33%' align='center' class='xtr'>".$LANGAUGE_CP[188]."</td>
      <td width='20%' align='center' class='xtr'>".$LANGAUGE_CP[189]."</td>
      <td width='19%' align='center' class='xtr'>".$LANGAUGE_CP[57]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[207]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[191]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[26]."</td>
      <td width='7%' align='center' class='xtr'>".$LANGAUGE_CP[27]."</td>
    </tr>";
while($p = mysql_fetch_array($queryx))
{

$p['name'] = stripslashes($p['name']);
$p['name'] = htmlspecialchars($p['name']);

$p['title'] = stripslashes($p['title']);
$p['title'] = htmlspecialchars($p['title']);

$p['emails'] = stripslashes($p['emails']);
$p['emails'] = htmlspecialchars($p['emails']);

$d = date("j/n/Y",$p['date']);

$activ = "<a href='box_cp.php?action=re&id=$p[id]'><img border='0' src='images/replay.gif' alt='".$LANGAUGE_CP[182]." ".$p['title']."' /></a>";

echo "<tr>
      <td width='33%' class='xtd'>» ".$p['title']."</td>
      <td width='20%' align='center' class='xtd'><a href='mailto:".$p['emails']."'>".$p['name']."</a></td>
      <td width='19%' align='center' class='xtd'>$d</td>
      <td width='7%' align='center' class='xtd'>$activ</td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=show&id=$p[id]'><img border='0' src='images/show.gif' alt='".$p['title']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=edit&id=$p[id]'><img border='0' src='images/edit.gif' alt='".$p['title']."' /></a></td>
      <td width='7%' align='center' class='xtd'><a href='box_cp.php?action=delete&id=$p[id]'><img border='0' src='images/delete.gif' alt='".$p['title']."' /></a></td>
    </tr>";
}

echo "</table>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("SELECT id FROM msg_box where closemsg=1")) / $perpage);
if($pagesnum > 1){
echo "<p align='center'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {
$z = "[<a href='box_cp.php?action=close&page=$i'>$i</a>] ";
} else {
$z = "[<u>$i</u>]";
}
echo "$z";
}
echo "</p>";
}
}


}ELSEIF ($action=="editreplay"){
$id = intval($_GET['id']);
$show = intval($_GET['show']);
$query = mysql_query("SELECT * FROM msg_replay where id='$id'");
$p = mysql_fetch_array($query);

$p['text'] = stripslashes($p['text']);
$p['text'] = htmlspecialchars($p['text']);

echo "<form name='vbform' method='POST' action='box_cp.php?action=editreplayok'>
<input type='hidden' name='id' value='$p[id]' />
<input type='hidden' name='show' value='$show' />

<table class='xtable' width='100%' id='AutoNumber15'>

<tr>
<td width='100%' colspan='2' class='xtx' align='center'>".$LANGAUGE_CP[32]."</td>
</tr>


<tr>
<td width='100%' class='xtd' align='center'>
<script type='text/javascript'>edToolbar('mytxtarea'); </script>
<textarea name='message' id='mytxtarea' rows='15' cols='100'>".$p['text']."</textarea>
</td>
</tr>

<tr>
<td width='100%' colspan='2' align='center' class='xtr'><input type='submit' value=' ".$LANGAUGE_CP[33]." ' name='B1' /></td>
</tr>

</table>
</form>";

}ELSEIF ($action=="editreplayok"){

$id = intval($_POST['id']);
$show = intval($_POST['show']);
$message = addslashes($_POST['message']);


if (empty($message)){
echo $LANGAUGE_CP[184];
}else{
$query =  mysql_query("UPDATE msg_replay SET text='$message' where id='$id'");
echo $LANGAUGE_CP[34];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=box_cp.php?action=show&id=$show' />";
}

}ELSEIF ($action=="deletereplay"){
$id = intval($_GET['id']);
$show = intval($_GET['show']);
$query =  mysql_query("DELETE FROM msg_replay WHERE id='$id'");
echo $LANGAUGE_CP[35];
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=box_cp.php?action=show&id=$show' />";
}

echo $f;
?>