<?
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">
<link rel="stylesheet" href="stylesheet.css" type="text/css">

<title>لوحة تحكم الادارة</title>
<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>
</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')){
	if(($_GET['go'])==('')){
?>
  <br>



  <p align="center">&nbsp;</p>
  <form name="vbform" action="news.php?do=addnew&go=add" method="post">
  <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="2">
				<p align="center">أضافه خبر جديد</td>
            </tr>

            <tr>
              <td width="190" class="submun">
				<p align="center">عنوان الخبر : </td>
              <td width="525" class="subsub" >
				<input name="title" type="text" value="" size="51"></td>
            </tr>

            <tr>
              <td width="190" class="submun">
				<p align="center">محتوي الخبر : <br></td>
              <td width="525" class="subsub" >
               <table  scellpadding="0" cellspacing="0" border="1" bgcolor="#FDFEFF" width="459">
             <tr valign="bottom">
        <td colspan="2" width="94%">                              <div align="center">
<img src='images/smiles/1.gif' onClick="tools(':)')">
<img src='images/smiles/2.gif' onClick="tools(':(')">
<img src='images/smiles/confused.gif' onClick="tools(':confused')">
<img src='images/smiles/cool.gif' onClick="tools(':cool')">
<img src='images/smiles/eek.gif' onClick="tools(':eek')">
<img src='images/smiles/biggrin.gif' onClick="tools(':biggrin')">
<img src='images/smiles/wink.gif' onClick="tools(':wink')">
<img src='images/smiles/mad.gif' onClick="tools(':mad')">
<img src='images/smiles/redface.gif' onClick="tools(':redface')">
<img src='images/smiles/good.gif' onClick="tools(':good')">
<img src='images/smiles/bad.gif' onClick="tools(':bad')">

 <br>
<!-- start control bar -->
<div id="controlbar">
<!-- / start control bar -->
<!-- first control row -->
<div class="controlholder">
<!-- MagicToolBox 2.5 for vB3 by Alawi BaAqeel, software@rayaheen.net -->
<script language='javascript'>
function tools(code) {
document.vbform.message.value += ' ' + code + ' ';
document.vbform.message.focus();
}
</script>
<script language="Javascript" src="js/toolbox.js"></script>
<script language="Javascript">
toolbox_backcolor = "#FDFEFF";
btn_bordercolor = "black";
btn_backcolor_over = "cornsilk";
btn_backcolor_down = "white";
statusColor = "black";
tipColor = "maroon";
</script>
<STYLE TYPE="text/css">
.cbtn{
  width:20px;
  height:18px;
  cursor:hand;
}
</STYLE>
<table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td align="center" oncontextmenu="return false" onselectstart="return false"
onmousedown="Capture(1)" onmouseup="Capture(0)" onmousemove="Capture(0)">

<script language='javascript'>
showButtons();
showKeyboard();
</script>

</td></tr></table>
<!-- end of MagicToolBox 2.5 for vB3 -->
        </div>
<!-- end control bar --></div><!-- / end control bar -->
</td>
</tr>
<tr valign="top">
        <td class="controlbar">

        <!-- edit text area -->

<textarea name="message" rows="15" cols="54"></textarea><br>
        <!-- / edit text area -->

   </td>

</tr>
</table>

	</textarea>
				</td>
            </tr>

            <tr>
              <td width="190" class="submun">
				&nbsp;</td>
              <td width="525" class="subsub" >
				<p align="center">&nbsp;<input type="submit" value="اضافه الخبر"></td>
            </tr>

            </table>
            </form>
        </div>
        </td>
    </tr>
  </table>




        <br>
        <?
        }if(($_GET['go'])==('add')){
        $newstitle = trim($_POST['title']);
        $newsvalue =  $_POST['message'];
        $br =  nl2br($newsvalue);
        $date = date("d-m-Y");
        if(($newstitle)==('')){
		echo"من فضلك ادخل عنوان للخبر";
  		exit();
        }elseif(($newsvalue)==('')){
           echo"لم تقم بكتابة الخبر ";
           exit();
        	}
        $addtodb = @mysql_db_query("$dbName", "INSERT INTO `news` ( `news_id` , `news_title` , `news_value` , `news_count` , `news_date` )
				VALUES (NULL , '$newstitle', '$newsvalue', '0', '$date');") ;

         if($addtodb){
         ?>
           <br>

  <table width="20%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
      <div align="center">
          <table width="267" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="261" class="backtablemun">
				<p align="center"><span lang="ar-sa">رسالة</span></td>
            </tr>
            <tr>
              <td width="257" class="submun">
				<p align="center">&nbsp;تم إضافة الخبر بنجاح</td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
         <?
         	}else{
         	echo"عفوا هناك مشكلة باضافه الخبر ";
         	}

        }
          }elseif(($_GET['do'])==('management')){
          $getnews = @mysql_db_query("$dbName", "SELECT * FROM `news` ORDER BY `news`.`news_id` DESC ") ;
          $totalnews = mysql_affected_rows();
          if(($totalnews)==('0')){
          ?>
           <br>

  <table width="20%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
      <div align="center">
          <table width="267" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="261" class="backtablemun">
				<p align="center"><span lang="ar-eg">رسالة</span></td>
            </tr>
            <tr>
              <td width="257" class="submun">
				<p align="center"><b>لا يوجد أخبار حالياً</b></td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
          <?
          }else{
          if(($_GET['go'])==('del')){
           $dele = @mysql_db_query("$dbName", "DELETE FROM  `news`  WHERE `news_id` = '$_GET[id]' ") ;
             if($dele){
	echo"<b>تم حذف التعليق بنجاح</b>";
    echo"<META HTTP-EQUIV='Refresh' CONTENT='1; url=news.php?do=management'>";
  }else{
  echo"هناك مشكلة بحذف التعليق";
  }
          }
          ?>
          <br>
  <table width="20%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
      <div align="center">
          <table width="692" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="686" class="backtablemun" colspan="4">
				<p align="center"><span lang="ar-eg">إدارة الأخبار</span></td>
            </tr>
            <tr>
              <td width="88" class="submun">
				<p align="center"><b>رقم الخبر</b></td>
              <td width="243" class="submun">
				<p align="center"><b>عنوان الخبر</b></td>
              <td width="127" class="submun">
				<p align="center"><b>تاريخ الإضافة</b></td>
              <td width="118" class="submun">
				<p align="center"><b>&nbsp;تعديل/حذف</b></td>
            </tr>
            <?
            while  ($ne = mysql_fetch_array($getnews)){
            ?>
            <tr>
              <td width="88"  class="subsub">
				<p align="center"><?echo $ne[news_id]?></td>
              <td width="243"  class="subsub">
				<p align="center"><?echo $ne[news_title]?></td>
              <td width="127" class="subsub">
				<p align="center"><?echo $ne[news_date]?></td>
              <td width="118" class="subsub">
				<p align="center">
				&nbsp;<a href="editnews.php?id=<?echo $ne[news_id]?>">تعديل</a>/<a onclick="return del('هل انت متاكد من حذف الخبر ؟');" href="news.php?do=management&go=del&id=<?echo $ne[news_id]?>">حذف</a></td>
            </tr>
            <?
            }
            ?>
            </table>
        </div>
        </td>
    </tr>
  </table>



          <?
          }
          }
        ?>
      </td>
    </tr>

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

</html>
<?
}else {

include("login.php");
	}
?>