<?
include("../includes/config.php");
include("../includes/bbcode.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>
<SCRIPT LANGUAGE="JavaScript">
function goToURL() { window.location = "javascript:history.back(1)"; }
</script>
<SCRIPT language=javascript src="../javascript.js" type=text/javascript></SCRIPT>
<SCRIPT language=javascript src="../poetry.js" type=text/javascript></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>
			<script>


 function Div() {

   document.getElementById("defult").style.display="block";
   document.getElementById("newtext").style.display="block";
   document.getElementById("toolbox").style.display="none";

 }


 function hDiv() {

   document.getElementById("defult").style.display="none";
   document.getElementById("newtext").style.display="none";
   document.getElementById("toolbox").style.display="block";


 }


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

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


<br>
<?
if (($_GET['do'])==('addnew')){
if (($_GET['go'])==('')){
?>

  <p align="center">&nbsp;</p>
  <form name="vbform" action="divan.php?do=addnew&go=view" 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]'>$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="" 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="" size="51"> ضع رابط صورة لخلفية القصيدة&nbsp;&nbsp;<i>"اختياري"</i></td>
            </tr>
            <tr>
              <td width="190" class="submun" align="center">
				<span lang="ar-sa">ملف صوتي : </span></td>
              <td width="525" class="subsub" align="center" colspan="3" >

				<p align="right">

				<input name="sound" size="51" style="float: right" value="">ضع رابط القصيدة الصوتية&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" checked><label for="2">متداخل</label>
				</td>
              <td width="182" class="subsub" align="center" >
               <input name="format" type="radio" id="1" value="1"><label for="1">متباعد</label></td>
              <td width="175" class="subsub" align="center" >
               <input name="format" type="radio" id="0" value="0"><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"></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>

<?
}elseif(($_GET['go'])==('view')){


   function getsetting ($voc){
  	$voc = trim($voc);
  	$voc = strip_tags($voc);
  	return ($voc);
  	}
  function message ($message){
   echo "
      <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'>رسالة</td>
            </tr>
            <tr>
              <td width='257' class='submun'>
				<p align='center'><b>$message</b><br><a href='javascript:history.back(1)'>اضغط هنا للعوده للخلف</a></td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>";
  	}

$devtitle= getsetting($_POST['title']);
$catid = getsetting($_POST['catname']);
$conc = getsetting($_POST['message']);
$back= getsetting($_POST['back']);
$date = date('d-m-Y');
$sound = getsetting($_POST[sound]);
$format = getsetting($_POST[format]);



        function cheakpost ($devtitle,$catid,$format){
 		 if(($devtitle)==('')){
   		$alert = "عفوا لم تقم بادخال اسم القصيدة"."<br>";
  			}
 		 if(($catid)==('')){
 		 $alert = $alert."عفوا لم تقم بادخال القسم"."<br>";
  			}


  		if(($format)==('')){
 		 $alert = $alert."عفوا لم تقم بادخال طريقة التنسيق"."<br>";
  			}

			  return($alert);
  			}

       		$cheak = cheakpost($devtitle,$catid,$format);
  		if(($cheak)!=('')){
     		message($cheak);
  			exit();
  			}

 $get = @mysql_db_query("$dbName", "SELECT * FROM `divan` WHERE `divan_title` = '$devtitle' ") ;
$num = mysql_affected_rows();
if (($num) != ('0') ){
$error = "عفوا ً اسم القصيدة مطابق لقصيدة اخري متوفرة";
message($error);
exit();
}

$thispoem = $conc;
$thispoem = nl2br($thispoem);
$thispoem = "

<TABLE id=Table_01 dir=ltr cellSpacing=0 cellPadding=0 width=400 align=center border=0>
        <TBODY>
        <TR>
          <TD>
           <div class='font' tag=' font=\"Tahoma,1,sienna,normal\" bkcolor=\"transparent\" bkimage=\"\" border=\"outset,3,gray\" type=$format line=200% align=center use=ex length=0 char=\"\" num=\"0,black\" filter=\"\"' style='display:none'>
              $thispoem
				</DIV>
            <SCRIPT>doPoetry()</SCRIPT>
          </TD>
          </TR>
        </TBODY></TABLE>

";
?>
  <p align="center">&nbsp;</p>
   <form name="vbform" action="divan.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="655" height="103%" align="center" bordercolor="#006633">
            <tr>
              <td width="649" class="backtablemun">
				<p align="center"><b>مشاهده القصيدة</b></td>
            </tr>
            <tr>
              <td width="649" class="subsub">
				<table border="0" width="100%" cellspacing="0" cellpadding="0">
					<tr>
						<td class="submun">
						<p align="center"><span lang="ar-sa">
						<font color="#000080">عنوان القصيدة :</font> <?echo $devtitle;?>&nbsp;&nbsp;
						<font color="#000080">&nbsp;تاريخ الاضافه :</font> <?echo $date;?>&nbsp;&nbsp;
						<font color="#000080">&nbsp;الكاتب :</font> <?echo $adminu;?></span></td>
					</tr>
					<tr>
						<td>
						<p align="center"><?echo $thispoem;?></td>
					</tr>

										<tr>
						<td  class="submun">
						<p align="center">
						  <input name="title" type="hidden" value="<?echo $devtitle;?>">
  <input name="catname" type="hidden" value="<?echo $catid;?>">
  <textarea name="message" rows="15" cols="54" style='display:none'><?echo $conc;?></textarea>
  <input name="back" type="hidden" value="<?echo $back;?>">
  <input name="sound" type="hidden" value="<?echo $sound;?>">
  <input name="format" type="hidden" value="<?echo $format;?>">
  <input type="submit" value="اعتماد القصيدة">&nbsp;&nbsp;&nbsp;<input onClick="goToURL()" type="button" value="الرجوع للخلف">


						</td>
					</tr>
				</table>
				</td>
            </tr>

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

  </form>
<?
}elseif (($_GET['go'])==('add')){
$devtitle= trim($_POST['title']);$devtitl= trim($_POST['title']);
$catid = $_POST['catname'];
$conc = trim($_POST['message']);
$back= trim($_POST['back']);
$date = date('d-m-Y');
$sound = trim($_POST[sound]);
$format = $_POST[format];
if (($devtitle)==('')){
echo "عفوا لم تقم بكتابة عنوان القصيدة";
exit();
}

function short_string(&$a,$h)
{
if(strlen($a)>$h )
{
$a = "".substr($a,0,$h)." ...";
}
return $a;
  }
$shorttitle = short_string($devtitl,20);
//cheak for divan title
$get = @mysql_db_query("$dbName", "SELECT * FROM `divan` WHERE `divan_title` = '$devtitle' ") ;
$num = mysql_affected_rows();
if (($num) != ('0') ){
$error = "عفوا ً اسم القصيدة مطابق لقصيدة اخري متوفرة";
echo $error;
exit();
}
//$bb = bbcode($conc);
//$bb = str_ireplace("*","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&sect;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",$bb);
$add =@mysql_db_query("$dbName", "
INSERT INTO `divan` ( `divan_id` , `divan_title` ,`divan_short`, `divan_containing` , `divan_author` , `divan_date` , `divan_count` , `divan_group` , `divan_back` , `cat_id` , `divan_sound` , `poem_format` )
VALUES (NULL , '$devtitle','$shorttitle', '$conc', '$adminu', '$date', '0', '1', '$back', '$catid', '$sound', '$format');
") ;

//echo stripcslashes($conc);

if ($add){
?>
<br><br><br>
      <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>
<?
}else{
?>
<br><br><br>
      <div align="center">
          <table width="304" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="298" class="backtablemun">
				<p align="center">الرسالة</td>
            </tr>
            <tr>
              <td width="298" class="submun">
				<p align="center">عفواهناك مشكلة باضافه القصيدة  </td>
            </tr>
            </table>
        </div>
<?
}

}


}elseif (($_GET['do'])==('search')){
if(($_GET[go])==('')){
?>



  <br>
  <table width="20%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
<form name="traid" action="divan.php?do=search&go=search" 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"><span lang="ar-sa">البحث عن قصيدة</span></td>
            </tr>
            <tr>
              <td width="133" class="submun">
				<p align="center">اسم <span lang="ar-sa">القصيدة</span> :</td>
              <td width="354" class="subsub" >
				<font color="#FF0000">
				<input name="divanname" type="text" value="" size="33" dir="rtl"></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>
        <input name="go" type="hidden" value="search">
        <input name="do" type="hidden" value="search">
        </form>
         <script language="JavaScript" type="text/javascript">
  var frmvalidator  = new Validator("traid");
  frmvalidator.addValidation("divanname","req","من فضلك ادخل اسم القصيدة");
</script>
        </td>
    </tr>
  </table>
<br>
<?
}elseif (($_GET['go'])==('search')){
$name = trim($_POST['divanname']);
$get = @mysql_db_query("$dbName", "SELECT * FROM `divan` where  `divan_title` LIKE '%$name%' ") ;
$totla = mysql_affected_rows();
if (($totla) == ('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">لا يوجد نتائج للبحث حاول
				البحث بصيغة أخري</td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
<?
}else{
$get = @mysql_db_query("$dbName", "SELECT * FROM `divan` where  `divan_title` LIKE '%$name%' ") ;
while  ($div = mysql_fetch_array($get)){
$did= $div[divan_id];
$dname = $div[divan_title];
$dm = $div[divan_containing];
$dgr = $div[divan_group];
$dcat= $div[cat_id];

}

$getcat = @mysql_db_query("$dbName", "SELECT * FROM cat WHERE `cat_id` = '$dcat' ") ;
while  ($c = mysql_fetch_array($getcat)){
$catname = $c[cat_name];
}

if(($_GET['action'])==('hide')){
$id= trim($_GET[id]);
$hidedivan = @mysql_db_query("$dbName", "UPDATE divan SET divan_group = '2' WHERE divan_id = '$id' ") ;
if($hidedivan){
echo"تم اخفاء القصيدة بنجاح";
echo"<META HTTP-EQUIV='Refresh' CONTENT='2; url=divan.php?do=search'>";
}else{
echo"هناك مشكلة باخفاء القصيدة";
}

}elseif (($_GET['action'])==('view')){
$id= trim($_GET[id]);
$viewdivan = @mysql_db_query("$dbName", "UPDATE divan SET divan_group = '1' WHERE divan_id = '$id' ") ;
if($viewdivan){
echo"تم اظهار القصيدة بنجاح";
echo"<META HTTP-EQUIV='Refresh' CONTENT='2; url=divan.php?do=search'>";
}else{
echo"هناك مشكلة باظهار القصيدة";
}

}elseif (($_GET['action'])==('del')){
	$id= trim($_GET[id]);
$dele = @mysql_db_query("$dbName", "DELETE FROM  divan   WHERE divan_id = '$id' ") ;
if($dele){
echo"تم حذف القصيدة بنجاح";
echo"<META HTTP-EQUIV='Refresh' CONTENT='1; url=divan.php?do=search'>";
}else{
echo"هناك مشكلة بحذف القصيدة";
}

}
?>

  <br>
  <table width="20%" align="center"  cellpadding="0" cellspacing="0" class="mytable">
    <tr>
      <td>
      <div align="center">
          <table width="612" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="606" class="backtablemun" colspan="5">
				<p align="center"><span lang="ar-sa">نتائج البحث</span></td>
            </tr>
            <tr>
              <td width="20" class="submun">
				<p align="center">م</td>
              <td width="311" class="submun">
				<p align="center">اسم القصيدة</td>
              <td width="103" class="submun">
				<p align="center">القسم</td>
              <td width="79" class="submun">
				<p align="center">حالة القصيدة</td>
              <td width="77" class="submun">
				<p align="center">تعديل/حذف</td>
            </tr>
            <tr>
              <td width="20"  class="subsub" align="center">
				<?echo $did;?></td>
              <td width="307"  class="subsub" align="center">
				<?
				echo $dname;
				?>
				</td>
              <td width="103" class="subsub" align="center">
				<?echo $catname;?></td>
              <td width="79" class="subsub" align="center">

				<?
				 if (($dgr)==('1')){
				 echo "<a href='divan.php?do=search&go=search&action=hide&id=$did&divanname=$_GET[divanname]'><span style='text-decoration: none'>ظاهر</span></a>";
				 }else{
				  echo "<a href='divan.php?do=search&go=search&action=view&id=$did&divanname=$_GET[divanname]'><span style='text-decoration: none'><b>مخفي</b></span></a>";
				 }

				 ?>
				</td>
              <td width="77" class="subsub" align="center">
				<a href="editdivan.php?id=<?echo $did;?>">تعديل</a>/<a href="divan.php?do=search&go=search&action=del&id=<?echo $did;?>&divanname=<?echo $_GET[divanname]?>">حذف</a></td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
<?

}
}
?>

<?
}elseif (($_GET['do'])==('activation')){
 $getallpoem = @mysql_db_query("$dbName", "SELECT * FROM divan WHERE `divan_group` = '3' ") ;
 $allsel = mysql_affected_rows();
 if(($allsel)==('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-sa">قصائد بانتظار التفعيل</span></td>
            </tr>
            <tr>
              <td width="261" class="submun">
				<p align="center"><span lang="ar-sa"><b>لا يوجد قصائد بانتظار
				التفعيل</b></span></td>
            </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>



<?
 }else{
 if(($_GET['go'])==('ac')){
$viewdivan = @mysql_db_query("$dbName", "UPDATE divan SET divan_group = '1' WHERE divan_id = '$_GET[id]' ") ;
if($viewdivan){
echo"تم تفعيل القصيدة بنجاح";
echo"<META HTTP-EQUIV='Refresh' CONTENT='1; url=divan.php?do=activation'>";
	}else{
		echo"عفوا هناك مشكلة بتفعيل القصيدة";
		}
}elseif(($_GET['go'])==('del')){
 $dele = @mysql_db_query("$dbName", "DELETE FROM  divan   WHERE divan_id = '$_GET[id]' ") ;
if($dele){
echo"تم حذف القصيدة بنجاح";
echo"<META HTTP-EQUIV='Refresh' CONTENT='1; url=divan.php?do=activation'>";
}else{
echo"هناك مشكلة بحذف القصيدة";
}

}
?>
  <br>
      <div align="center">
          <table width="612" height="100%" align="center" bordercolor="#006633">
            <tr>
              <td width="606" class="backtablemun" colspan="5">
				<p align="center"><span lang="ar-sa">قصائد بانتظار التفعيل</span></td>
            </tr>
            <tr>
              <td width="20" class="submun">
				<p align="center"><b>م</b></td>
              <td width="292" class="submun">
				<p align="center"><b>اسم القصيدة</b></td>
              <td width="69" class="submun">
				<p align="center">الكاتب</td>
              <td width="69" class="submun">
				<p align="center"><b>اعتماد</b></td>
              <td width="209" class="submun">
				<p align="center"><b>مشاهده</b><i><span lang="en-us"> (</span><span lang="ar-sa">تعديل</span><span lang="en-us">)</span><span lang="ar-sa">&nbsp;
				</span></i>/&nbsp;&nbsp; <b>حذف</b></td>
            </tr>


            <?
            while  ($poem = mysql_fetch_array($getallpoem)){
            	?>

                       <tr>
              <td width="20"  class="subsub">
				<p align="center"><?echo $poem[divan_id]?></td>
              <td width="263"  class="subsub">
				<p align="center"><?echo $poem[divan_title]?></td>
              <td width="69" class="subsub">
				<p align="center"><?echo $poem[divan_author]?></td>
              <td width="69" class="subsub">
				<p align="center"><a href="divan.php?do=activation&go=ac&id=<?echo $poem[divan_id]?>">اعتماد</a></td>
              <td width="209" class="subsub">
				<p align="center"><span lang="ar-sa">
				<a href="editdivan.php?id=<?echo $poem[divan_id]?>">مشاهدة</a> /
				<a href="divan.php?do=activation&go=del&id=<?echo $poem[divan_id]?>">حذف</a></span></td>
            </tr>


            <?
            }
            ?>
            </table>
        </div>
        </td>
    </tr>
  </table>

<?
}
}elseif (($_GET['do'])==('list')){
if(($_GET['go'])==('')){

?>
  <p align="center">&nbsp;</p>
  <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="5">
				<p align="center">قائمة بكافة القصائد</td>
            </tr>
            <tr>
              <td width="217" class="submun" align="center">
				اسم القصيدة</td>
              <td width="112" class="submun" align="center">
				تاريخ الاضافه</td>
              <td width="130" class="submun" align="center">
				الكاتب</td>
              <td width="95" class="submun" align="center">
				القسم</td>
              <td width="157" class="submun" align="center">
				تعديل / حذف</td>
            </tr>
            <?
              //بداية تقسيم الصفحة
  $page = (!isset($_GET['page']) ? 1 : intval($_GET['page']));
$page =(intval($_GET['page'])<=0 ? 1 : $page );
$numpage=50; #العدد بكل صفحة
$limit=($page * $numpage) - $numpage;
//نهاية

            $select = @mysql_db_query("$dbName", "SELECT * FROM `divan` ORDER BY `divan`.`divan_id` DESC limit  $limit,$numpage") ;
            while  ($poems = mysql_fetch_array($select)){
            ?>
            <tr>
              <td width="217" class="subsub" align="center">
				<a target="_blank" href ="../poem<?echo $poems[divan_id];?>.html"><?echo $poems[divan_short];?></a></td>
              <td width="112" class="subsub" align="center">
				<?echo $poems[divan_date];?></td>
              <td width="130" class="subsub" align="center">
				<?echo $poems[divan_author];?></td>
              <td width="95" class="subsub" align="center">
				<?
     $getvatname = @mysql_db_query("$dbName", "SELECT * FROM `cat` WHERE `cat_id` = '$poems[cat_id]' ") ;
     $issetcat = mysql_affected_rows();
      while  ($cn = mysql_fetch_array($getvatname)){
      	$catnme = $cn[cat_name];
      }
      if(($issetcat) == (0)){
       echo "<b>بدون قسم</b>";
      	}else{
      	echo $catnme;
      	}

				 ?>
				</td>
              <td width="157" class="subsub" align="center">
				<a href="editdivan.php?id=<?echo $poems[divan_id];?>">تعديل</a> /
				<a href="divan.php?do=list&go=del&id=<?echo $poems[divan_id];?>">
				حذف</a> </td>
            </tr>
            <?
            }


            ?>

               </table>

        </div>
        </td>
    </tr>
  </table>
               <?
                 $all = @mysql_db_query("$dbName", "SELECT * FROM `divan` ORDER BY `divan`.`divan_id` DESC ") ;
 $total =mysql_affected_rows();
 $alluser= $total/$numpage;
 $i=0;
  echo"<p align='center'>";
echo "<div align='center'>الصفحات</div>";
while (($i)<($alluser)){
$i++;
if($page<>$i) {$n="<font face='Tahoma' size='1'><a href='divan.php?do=list&page=$i'>
<span style='text-decoration: none; font-weight: 700'>[$i]</span></a></font>";}else{$n="<font color='#008000'><b>[$i]
</b></font>";
}


echo "$n&nbsp;&nbsp;&nbsp;";


}
               ?>
<?
}elseif(($_GET['go'])==('del')){
   function message ($message){
   echo "
   <META HTTP-EQUIV='Refresh' CONTENT='1; url=divan.php?do=list'>
      <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'>رسالة</td>
            </tr>
            <tr>
              <td width='257' class='submun'>
				<p align='center'><b>$message</b>
				</td>

            </tr>

            </table>
        </div>
        </td>
    </tr>
  </table>";
  	}

  $id= trim($_GET[id]);
$dele = @mysql_db_query("$dbName", "DELETE FROM  `divan` WHERE `divan`.`divan_id` ='$id'") ;
if($dele){
	message("تم حذف القصيدة بنجاح");
	}else{
    message("عفوا هناك مشكلة باضافه القصيدة");
	}
}
}
?>
  <br>
        <br>
      </td>
    </tr>

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

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