<?
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>

<br>
<script language="JavaScript" src="./js/globtrax.js" type="text/javascript"></script>


<br>
 <?
  $getpoem = @mysql_db_query("$dbName", "SELECT * FROM `divan` WHERE `divan_id` = '$_GET[id]'") ;
  $mawgod = mysql_affected_rows();
  while  ($poem = mysql_fetch_array($getpoem)){
  $poemtitle = $poem[divan_title];
  $poemcon = $poem[divan_containing];
  $poemback = $poem[divan_back];
  $poemcat = $poem[cat_id];
  $sound = $poem[divan_sound];
  $format = $poem[poem_format];
  }
  if (($mawgod)==('0')){
   echo"عفوا القصيدة غير متوفرة ";
   exit();
  }

  if(($_GET['go'])==('update')){
  $dtitle = trim($_POST['title']);
  $devtitl = trim($_POST['title']);
  $dcon =  $_POST['message'];
  $dcatid = $_POST['catname'];
  $dback = $_POST['back'];
  $dformat = $_POST[format];
  $dsound = $_POST[sound];
  function short_string(&$a,$h)
{
if(strlen($a)>$h )
{
$a = "".substr($a,0,$h)." ...";
}
return $a;
  }
$shorttitle = short_string($devtitl,20);

  if(($dtitle)==('')){
	echo"لم تقم بكتابة عنوان القصيدة";
  }else{
  $updatepoem = @mysql_db_query("$dbName", "UPDATE `divan` SET
  `divan_title` = '$dtitle',
 `divan_short` = '$shorttitle',
`divan_containing` = '$dcon',`divan_back` = '$dback',`cat_id` = '$dcatid',`divan_sound` = '$dsound',`poem_format` = '$dformat' WHERE `divan`.`divan_id` ='$_GET[id]' LIMIT 1 ;") ;
if($updatepoem){
echo "<b>تم تعديل القصيدة بنجاح</b>";
echo"<META HTTP-EQUIV='Refresh' CONTENT='1; url=divan.php?do=search'>";
}else{
echo"هناك مشكلة بتعديل القصيدة";
}



  	}
  }
 ?>


 <p align="center">&nbsp;</p>
  <form name="vbform" action="editdivan.php?id=<?echo $_GET['id']?>&go=update" 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="4">
				<p align="center"> تعديل القصيدة</td>
            </tr>
            <tr>
              <td width="190" class="submun">
				<p align="center">القسم : </td>
              <td width="525" class="subsub" colspan="3" >
				&nbsp;<select size="1" name="catname">
				<?
            $getall = @mysql_db_query("$dbName", "SELECT * FROM `cat` ORDER BY `cat_id` ASC ") ;
			while  ($cat = mysql_fetch_array($getall)){
  echo "<option value='$cat[cat_id]'";if(($cat[cat_id])==($poemcat)){
echo "selected";
  } echo">$cat[cat_name]</option>";
  }
 				 ?>
</select></td>
            </tr>
            <tr>
              <td width="190" class="submun">
				<p align="center">عنوان القصيدة : </td>
              <td width="525" class="subsub" colspan="3" >
				<input name="title" type="text" value="<?echo $poemtitle;?>" size="51"></td>
            </tr>
                                                <tr>
              <td width="190" class="submun">
				<p align="center">خلفية القصيدة :</td>
              <td width="525" class="subsub" colspan="3" >
				<input name="back" type="text" value="<?echo $poemback;?>" size="51"> ضع رابط صورة لخلفية القصيدة&nbsp;&nbsp;<i>"اختياري"</i></td>
            </tr>
            <tr>
              <td width="190" class="submun" align="center">
				ملف صوتي : </td>
              <td width="525" class="subsub" align="center" colspan="3" >

				<p align="right">

				<input name="sound" size="51" style="float: right" value="<?echo $sound?>">ضع رابط القصيدة الصوتية&nbsp;
				<i>&quot;اختياري&quot;</i></td>
            </tr>

            <tr>
              <td width="190" class="submun" align="center">
				نوع التنسيق : </td>
              <td width="167" class="subsub" align="center" >
               <input name="format" type="radio" id="2" value="2" <? if(($format)==(2)){echo "checked";}?>><label for="2">متداخل</label>
				</td>
              <td width="182" class="subsub" align="center" >
               <input name="format" type="radio" id="1" value="1" <? if(($format)==(1)){echo "checked";}?>><label for="1">متباعد</label></td>
              <td width="175" class="subsub" align="center" >
               <input name="format" type="radio" id="0" value="0" <? if(($format)==(0)){echo "checked";}?>><label for="0">عمودين</label></td>
            </tr>

            <tr>
              <td width="190" class="submun">
				<p align="center">محتوي القصيدة : <br><font color="red"><b>افصل بين كل شطر بعلامة "="</b></font></td>
              <td width="525" class="subsub" colspan="3" >
               <table  scellpadding="0" cellspacing="0" border="0" bgcolor="#FDFEFF" width="459">
<tr valign="top">
        <td class="controlbar">

        <!-- edit text area -->

<textarea name="message" rows="15" cols="54"><?echo $poemcon;?></textarea><br>
        <!-- / edit text area -->

   </td>

</tr>
</table>

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

            <tr>
              <td width="190" class="submun">
				&nbsp;</td>
              <td width="525" class="subsub" colspan="3" >
				<p align="center">&nbsp;<input type="submit" value="تعديل القصيدة"></td>
            </tr>

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




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

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

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