  <?
if (!defined("_VALID_ACCESS_") || _VALID_ACCESS_ !=1) {
	die("Foot Bokra");
}
echo '<link type="text/css" href="./style/style.css" rel="stylesheet" />	';
$mysqlQuery=new mysqlQueryClass();
$action=addslashes($_GET[action]);


function noway($do) {
$noway="ليس ليدك صلاحية للقيام $do";
return $noway;
}
$Alevel = $_SESSION["level"];
$ADID   = $_SESSION["adminid"] ;

switch ($action)
{
/**********************************************************************************************
- Config - Config - Config - Config - Config - Config - Config - Config - Config - Config -
**********************************************************************************************/

case "config" :

$configv = $_POST['configv'];
if( isset($configv) && $configv == 1 )
{

$sitename = $_POST['sitename'];
$siteurl  = $_POST['siteurl'] ;
$forumurl = $_POST['forumurl'];
$keywords = $_POST['keywords'];
$pagesnum = $_POST['pagesnum'];
$style = $_POST['style'];

  $query="UPDATE `config` SET `sitename`='$sitename' , `siteurl`='$siteurl' , `forum` = '$forumurl' , `keywords`='$keywords' , `pagesnum`='$pagesnum' , `style`='$style'
          WHERE `id` = '1' ";
	$mysqlQuery->mysqlQueryUpdate($query);

  $main .= "تم تعديل الاعدادات بنجاح <br /> سيتم تحويلك".refresh("config");
}


else
{
    $query="SELECT `sitename`,`siteurl`,`forum`,`keywords`,`pagesnum`,`style` FROM `config` ";
    $mysqlQuery->mysqlQuery($query);
    list($sitename,$siteurl,$forumurl,$keywords,$pagesnum,$style)=$mysqlQuery->result;

 
$main .="
        <div align='center'>

        <form id='form1' name='form1' method='POST' action='./admin.php?action=config'>
        <input type='hidden' name='configv' value='1' />
          <table width='50%' border='0' style='text-align :right;' cellspacing='0' cellpadding='5' class='content'>


            <tr>

   
              <td colspan='2' align='center'> <h3> الإعدادات العامة </h3> </td>
            </tr>
            <tr>

              <td> اسم الموقع </td>
              <td><input name='sitename' type='text' value='$sitename' size='30' /></td>
            </tr>
            <tr>
              <td> رابط الموقع </td>
              <td><input name='siteurl' type='text' value='$siteurl' size='30' /></td>
            </tr>
			<tr>
              <td> رابط المنتدي </td>
              <td><input name='forumurl' type='text' value='$forumurl' size='30' /></td>
            </tr>
            <tr>
              <td> عدد المقالات فى كل صفحة </td>
              <td><input name='pagesnum' type='text' value='$pagesnum' size='30' /></td>
            </tr>
            <tr>
              <td> الكلمات الدليليه </td>
              <td><textarea name='keywords' cols='28' rows='3' > $keywords </textarea> </td>
            </tr>
			<tr>
              <td> مجلد الاستايل </td>
              <td><input name='style' type='text' value='$style' size='30' /></td>
            </tr>

            <tr><td colspan='2'>&nbsp;</td></tr>

            <tr> <td colspan='2' align='center'><input name='button' type='submit'  value='حفظ جميع البيانات' /> </td> </tr>
            </table> </form> </div>
        ";
}

break;

/**********************************************************************************************
- Admins Data - Admins Data - Admins Data - Admins Data - Admins Data - Admins Data - Admins Data
**********************************************************************************************/

case "mydata" :

$Adata = $_POST['Adata'];

if( isset($Adata) && $Adata == 1 )
{

$name=$_POST['name'];
$pass=$_POST['pass'];
$vpass=$_POST['vpass'];

if ($pass==$vpass) {

 if(empty($_POST['pass'])) {
        $query="SELECT `password` FROM `admins` WHERE `admin_id` = '$ADID' LIMIT 1";
					$mysqlQuery->mysqlQuery($query);
					list($pass)=$mysqlQuery->result;

				}else{
				$pass=md5($_POST['pass']);
				}

	
    $adquery = "UPDATE `admins` SET `name` = '$name', `password` = '$pass'  WHERE `admin_id` = '$ADID' ";
    $mysqlQuery->mysqlQueryUpdate($adquery);

  $main .= "تم تعديل الاعدادات بنجاح <br /> سيتم تحويلك".refresh("mydata");
}else {
$main .= "كلمة المرور غير متطابقة<br /> سيتم تحويلك".refresh("mydata");

}

}else
{
  $query="SELECT `name`, `password` FROM `admins` WHERE `admin_id` = '$ADID' LIMIT 1";
					$mysqlQuery->mysqlQuery($query);
					list($name,$pass)=$mysqlQuery->result;

		
$main .="
        <div align='center'>
        <form  method='POST' action='./admin.php?action=mydata'>
        <input type='hidden' name='Adata' value='1' />
        <table width='50%' border='0' style='text-align :right;' cellspacing='0' cellpadding='5' class='content'>
            <tr>
              <td colspan='2' align='center'> <h3> بيانات المدير عند اضافته لمقالات </h3> </td>
            </tr>
             <tr>
              <td> الاسم </td>
              <td><input name='name' type='text' value='$name' size='30' /></td>
            </tr>
            <tr>
              <td> كلمة السر الجديدة </td>
              <td>
              <input name='pass' type='password'  size='26' />
			  <a rel='passhint'>
              <div id='passhint' class='balloonstyle' style='width:150px;'>
              <div class='content'> اتركها فارغة وستبقي كما كانت ، <br /> او قم بكتابة كلمة المرور الجديدة </div>
                  </div>
              <font color='red' size='5'>!</font></a>
              </td>
			  </tr>
			  <td> تاكيد كلمة المرور </td>
			  <td>
			  <input name='vpass' type='password' size='26' />
			  </td>
			  </tr>
            </tr>
            <tr> <td colspan='2' align='center'><input name='button' type='submit'  value='حفظ جميع البيانات' /> </td> </tr>
            </table> </form> </div>";
  }

  break;

/**********************************************************************************************
- Products - Products - Products - Products - Products - Products - Products - Products -
**********************************************************************************************/

case "addProds" :
include_once("Products.php");
break;
/*********/
case "editProds" :
include_once("Products.php");
break;
/*********/
case "viewProds" :
include_once("Products.php");
break;
/*********/
case "uprods" :
include_once("Products.php");
break;
/*********/
case "valid" :
include_once("Products.php");
break;

/*********/
case "confirm":
include_once("Products.php");
break;


case "searchProds" :
include_once("Products.php");
break;

/**********************************************************************************************
- Products Cats - Products Cats - Products Cats - Products Cats - Products Cats - Products Cats
**********************************************************************************************/

case "addCatagories":
include_once("CProducts.php");
break;
/**********/
case "editCatagories":
include_once("CProducts.php");
break;

/**********************************************************************************************
- Admins - Admins - Admins - Admins - Admins - Admins - Admins - Admins - Admins - Admins - Admins
**********************************************************************************************/

case "addAdmins" :
include_once("admins.php");
break;
/*********/
case "editAdmins" :
include_once("admins.php");
break;

/**********************************************************************************************
- Banners - Banners - Banners - Banners - Banners - Banners - Banners - Banners - Banners
**********************************************************************************************/

case "addBans" :
include_once("Banners.php");
break;
/*********/
case "editBans" :
include_once("Banners.php");
break;

/**********************************************************************************************
- Default - Default - Default - Default - Default - Default - Default - Default - Default -
**********************************************************************************************/

default:

  	if (isset($_POST[notesid]) && $_POST[notesid] == 1 )
  	{
    $id=$_POST[id];
    $notes=$_POST[notes];

    $query="UPDATE `config` SET `notes`='$notes' WHERE `id`='$id' ";
    $mysqlQuery->mysqlQueryUpdate($query);

    $main .= " تم تعديل الملاحظات ".refresh("");
		}
		else
		{
	$query="SELECT `id`,`notes` FROM `config` WHERE `id` = '1' ";
	$mysqlQuery->mysqlQuery($query);
  list($id,$notes)=$mysqlQuery->result;

  $main .= '
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      <div align="center" >
      <form id="form1" name="form1" method="POST" action="./admin.php">
        <table width="100%" border="0" cellspacing="10" cellpadding="0" class="content">
		<tr>
            <td>


    <div id="cont">         


</br>
	 <h3> بسم الله الرحمن الرحيم </h3>   </br>

    	  <h3> اهلا وسهلا بك فى لوحة تحكم المقالات</h3></br>
	 
	<h3>تم تخصيص هذه اللوحة لتسهيل عملية ادارة وتنظيم المقالات والاعلانات</h3></br>

                <h3>تصميم وتكويد شبكة افلام فوكس</h3></br>

               <h3>Powered and Desigend By : AFLAMFOX</h3></br>
	<h3>alon_de_loco & DsignStar</h3></br>
</br>



</div>


      <td><div align="center"><br></div></td>
    </tr>';
  if($Alevel == 1 && $ADID == 1)
  { $main .='

</div>

    <div id="cont1">

      <div id="cont3">
        <h4> ضع مدوناتك في هذا الجدول</h4>


      <div align="center">

            <label>
              <textarea name="notes" cols="40" rows="4"  id="anotes" style="text-align:center;" dir="rtl" lang="ar">'.trim($notes).'</textarea>
            </label>
            <input name="id" type="hidden" id="id" value="'.$id.'" />

	<div align="center">
                <label><br>
                </label>
                <label>&nbsp;<input name="button" type="submit"  id="button" value=" حفظ التدوينات" />
                <input type="hidden" name="notesid" value="1" />
                </label>
                <input class="search-btn" type="reset" value="مسح الحقول" name="Enter"></div> </div></div>
            </tr>';
  }
  else { }

  $query="SELECT * FROM `products` ";
	$mysqlQuery->mysqlQueryWOF($query);
  $Allp =$mysqlQuery->resultNoRows;
  
 $query="SELECT * FROM `products` WHERE `valid` = 0 ";
	$mysqlQuery->mysqlQueryWOF($query);
  $Allz =$mysqlQuery->resultNoRows;



  $query="SELECT `visits` FROM `config` WHERE `id` = 1";
   $mysqlQuery->mysqlQuery($query);
    list($visits) = $mysqlQuery->result;
$main .='
        </table>
<div style="text-align:right;" align="center"><h3 style="text-align: center"> 
  <br />

';


$main .=' </h3>

</div>
        </form>
      </div>';

     }

break;

}

?>

  <body style="background-image: url('images/Page-BgGradient.jpg')">