<?
include("../includes/config.php");
$adminuser = @mysql_db_query("$dbName", "select *  from admin where  admin_id = '1'") ;
while  ($ab = mysql_fetch_array($adminuser)){
$adminu = $ab['admin_name'];
$adminp = $ab['admin_password'];
}
$loguser= $_COOKIE['adminuser'];
$logipass= $_COOKIE['adminpassword'];



if ( $adminp == $logipass  && $adminu == $loguser ){

?>
<html dir="rtl">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<meta http-equiv="Content-Language" content="ar-sa">
<meta name="GENERATOR" content="Traidnt.com">
<script type="text/javascript">
function del(confirmation_message)
{
	var ht = document.getElementsByTagName("html")[0];
	ht.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	if (confirm(confirmation_message))
	{
		return true;
	}
	else
	{
		ht.style.filter = "";
		return false;
	}
}
</script>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<script>
function TraidntPopUp(URLStr, left, top, width, height)
{
  window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
//	document.location=URLStr;
}
</script>
<title>لوحة تحكم الادارة</title>
</head>
<body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FCFAF7" text="#000000" >

<div align="left">
  <table border="0" cellpadding="0" cellspacing="0" width="100%" height="41">
    <tr>
      <td width="150%" bgcolor="#000000" height="1"></td>
    </tr>
    <tr >
      <td width="100%" align="left" valign="bottom" bgcolor="#FFFFFF" class="topheader"  >
        <p align="right"><a href="index.php">واجهة الادارة - </a>
		<a target="_blank" href="../index.php"><font color="#000000">&nbsp;واجهة
		الموقع</font></a></td>
    </tr>
  </table>
</div>

<div align="left">
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td width="20%" valign="top">
        <? include("links.php"); ?>
      </td>
      <td width="80%" valign="top" align="center">
  <br>
  <?
  if (($_GET['do'])==('addnew')){
  ?>
<script language="JavaScript" src="./js/globtrax.js" type="text/javascript"></script>
<br>
<?
if (($_GET['go'])==('add')){
$catname = trim($_POST['catname']);
$catmeta = trim($_POST['catmeta']);
$catpic = trim($_POST['catpic']);
if (($catpic)==('')){
$catimg = 'images/nopic.gif';
}else{$catimg = $catpic;}
$catuser = $_POST['allow'];
$dispaly = trim($_POST[dispaly]);
$catgroup = '1';
 $addcat = @mysql_db_query("$dbName", "INSERT INTO `cat` ( `cat_id` , `cat_name` , `cat_meta` , `cat_pic` , `cat_user` , `cat_group` , `cat_count`, `cat_display` )
VALUES (
'', '$catname', '$catmeta', '$catimg', '$catuser', '$catgroup', '1','$dispaly'
);") ;
if ($addcat){
print ("<META HTTP-EQUIV='Refresh' CONTENT='1; url=cat.php?do=addnew'>");
?>
  <table width="21%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
      <div align="center">
          <table width="304" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="298" class="backtablemun">
				<p align="center"><span lang="ar-sa">الرسالة</span></td>
            </tr>
            <tr>
              <td width="298" class="submun">
				<p align="center"><span lang="ar-sa">تم أضافه القسم بنجاح</span></td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
  <?
  }else{
  	print ("<META HTTP-EQUIV='Refresh' CONTENT='1; url=cat.php?do=addnew'>");
  ?>
  <br>
  <table width="21%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
      <div align="center">
          <table width="304" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="298" class="backtablemun">
				<p align="center"><span lang="ar-sa">الرسالة</span></td>
            </tr>
            <tr>
              <td width="298" class="submun">
				<p align="center"><span lang="ar-sa">عفوا هذا القسم موجود من قبل</span></td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>

  <?
  }
  }
  ?>
  <br>
  <table width="20%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
<form name="traid" action="cat.php?do=addnew&go=add" method="post">
      <div align="center">
          <table width="497" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="491" class="backtablemun" colspan="2">
				<p align="center">إضافة قسم جديد</td>
            </tr>
            <tr>
              <td width="133" class="submun">
				<p align="center">اسم القسـم :</td>
              <td width="354" class="subsub" >
				<font color="#FF0000">
				<input name="catname" type="text" value="" size="33" dir="rtl"></font></td>
            </tr>
            <tr>
              <td width="133" class="submun">
				<p align="center">وصف القسم : </td>
              <td width="354" class="subsub" >
				<font color="#FF0000">
				<input name="catmeta" type="text" value="" size="33" dir="ltr"></font></td>
            </tr>
            <tr>
              <td width="133"  class="submun">
				<p align="center">صورة&nbsp; القسم : </td>
              <td width="354" class="subsub">
				<font color="#FF0000">
				<input name="catpic" type="text" value="" size="33" dir="rtl"></font></td>
            </tr>
            <tr>
              <td width="133"  class="submun">
				<p align="center">السماح للأعضاء بإضافة قصائد:</td>
              <td width="354" class="subsub">
				<input name="allow" type="radio" id="2" value="yes"><label for="2"><span lang="en-us">
				</span>نعم</label><br>
				<input name="allow" type="radio" id="3" value="no" checked><label for="3"><span lang="en-us">
				</span>لا</label></td>
            </tr>
               <tr>
              <td width="133"  class="submun">
				<p align="center">ترتيب &nbsp;العرض  : </td>
              <td width="354" class="subsub">
				<font color="#FF0000">
				<input name="dispaly" type="text" value="" size="33" dir="ltr">&nbsp;&nbsp;اكتب رقم ترتيب القسم</font></td>
            </tr>
            <tr>
              <td width="133"  class="submun">
				&nbsp;</td>
              <td width="354" class="subsub">
				<p align="center">&nbsp;<input type="submit" value="اضافه"></td>
            </tr>
            </table>
        </div>
        </form>
         <script language="JavaScript" type="text/javascript">
  var frmvalidator  = new Validator("traid");
  frmvalidator.addValidation("catname","req","من فضلك ادخل اسم القسم");
 frmvalidator.addValidation("catmeta","req","من فضلك ادخل وصف القسم");

   frmvalidator.addValidation("dispaly","req","من فضلك ادخل ترتيب العرض");
  frmvalidator.addValidation("dispaly","numeric","عفوا ترتيب العرض لابد ان يكون رقم");
</script>
        </td>
    </tr>
  </table>
  <?
  }elseif (
  ($_GET['do'])==('editcat')){
   $getall = @mysql_db_query("$dbName", "SELECT * FROM `cat` ORDER BY `cat`.`cat_display` ASC ") ;
   $total = mysql_affected_rows();
   if(($total)==('0')){
    ?>
    <br>
  <table width="21%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
      <div align="center">
          <table width="304" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="298" class="backtablemun">
				<p align="center"><span lang="ar-sa">الرسالة</span></td>
            </tr>
            <tr>
              <td width="298" class="submun">
				<p align="center"><span lang="ar-sa">عفوا لم تقم باضافه اقسام</span></td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
    <?
   }else{
  ?>
  <br>
  <?
  if(($_GET['go'])==('hide')){
  $hided = @mysql_db_query("$dbName", "UPDATE `cat` SET `cat_group` = '2' WHERE `cat_id` ='$_GET[id]' ;") ;
   print ("<META HTTP-EQUIV='Refresh' CONTENT='0; url=cat.php?do=editcat'>");
  }elseif(($_GET['go'])==('view')){
    $viewd = @mysql_db_query("$dbName", "UPDATE `cat` SET `cat_group` = '1' WHERE `cat_id` ='$_GET[id]' ;") ;
   print ("<META HTTP-EQUIV='Refresh' CONTENT='0; url=cat.php?do=editcat'>");
  }elseif(($_GET['go'])==('del')){
	$delc = @mysql_db_query("$dbName", "DELETE from cat WHERE cat_id= '$_GET[id]'") ;
	 print ("<META HTTP-EQUIV='Refresh' CONTENT='0; url=cat.php?do=editcat'>");
  }
  ?>
  <br>
    <table width="20%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
      <div align="center">
          <table width="733" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="727" class="backtablemun" colspan="4">
				<p align="center"><span lang="ar-sa">مشاهده تعديل الأقسام </span></td>
            </tr>
            <tr>
              <td width="190" class="submun">
				<p align="center">اسم القسم </td>
              <td width="187" class="submun" >
				<p align="center">وصف القسم</td>
              <td width="176" class="submun" >
				<p align="center"><span lang="ar-sa">حالة القسم</span></td>
              <td width="162" class="submun" >
				<p align="center">تعديل / حذف </td>
            </tr>
            <?
            while  ($cat = mysql_fetch_array($getall)){
            ?>
            <tr>
              <td width="190" class="subsub">
				<p align="center"><?echo $cat[cat_name]?></td>
              <td width="187" class="subsub" >
				<p align="center"><?echo $cat[cat_meta]?>&nbsp;&nbsp; </td>
              <td width="176" class="subsub" >
				<p align="center">
                <?
                if (($cat[cat_group])==('1')){
                echo "<a href='cat.php?do=editcat&go=hide&id=$cat[cat_id]'><span style='text-decoration: none'>ظاهر</span></a>";
                }else{
                echo "<a href='cat.php?do=editcat&go=view&id=$cat[cat_id]'><span style='text-decoration: none'><font color='#FF0000'><b>مخفي</b></font></span></a>";

                }
                 ?>
				</td>
              <td width="162" class="subsub" >
				<p align="center"><a href="editcat.php?id=<?echo $cat[cat_id]?>">تعديل</a> /
				<a href="cat.php?do=editcat&go=del&id=<?echo $cat[cat_id]?>" onclick="return del('هل انت متاكد من حذف <?echo $cat[cat_name]?>?');">حذف</a></td>
            </tr>
            <?
            }
            ?>
            </table>
        </div>
        </td>
    </tr>
  </table>
  <?
  }
  }
  ?>

  <br>
        <br>
      </td>
    </tr>

  </table>
</div>
</body>

</html>
<?
}else {
include("login.php");
	}
?>