<?php
include_once("header.php");
if($login==1)
{
if($action=="edit")
{
  if(isset($submit))
  {
      if(in_array(strtolower(end(explode(".",$_FILES['pic']['name']))), $pic_types)
            && strlen($_FILES['pic']['name'])!=0
            &&move_uploaded_file($_FILES["pic"]["tmp_name"],"../up/banner/".time().$_FILES["pic"]["name"]))
              {
                $pic_name = time().$_FILES["pic"]["name"];
               }
      mysql_query("update site_word set name='$name',content='$content',
    site_pic='$pic_name'");
    $msg="تم التعديل";
    $sub = siteword();
    $sub .=sitemeta();
     header( 'refresh: 3; url=site.php' );
  }
  else
  {
    $editqu=mysql_query("select * from site_word");
    while($row=mysql_fetch_array($editqu))
    {
      extract($row);
    }
    $textarea="content";
     $sub = Template_Array("$site_template/admin/site_word.html",0);
  }
}
elseif($action=="state")
{
    $pages_query = mysql_query("SELECT * FROM site_word",$connection);
        $pages_fetch = mysql_fetch_array($pages_query);
        extract($pages_fetch);
        if($state==1)
         {
            $state=0;
            $msg = "تم التعطيل";
         }
        else
         {
           $state=1;
           $msg = "تم التنشيط ";
         }
        mysql_query("update site_word set state='$state'"); 
        $sub = siteword();
        $sub .=sitemeta();
         header( 'refresh: 3; url=site.php' );
}
else
{
  $sub = siteword();
  $sub .=sitemeta(); 
}
}
else
{
    echo Template_Array("$site_template/admin/login.html");
    die();
}
 include_once("footer.php");
 ?>