JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-}JFIFICC_PROFILElcmsmntrRGB XYZ  acspMSFTsawsctrl-hand=@=@t," desc_cprt wtptrXYZ,gXYZ@bXYZTrTRCh`gTRCh`bTRCh`descuRGBtextCC0XYZ TXYZ o8XYZ bXYZ $curv*|uN  bj. C$)j.~39?FWM6Tv\dluV~,6۾ewC    #%$""!&+7/&)4)!"0A149;>>>%.DIC;C  ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?|WH?cS?Ne.r˿ޱ5\YYhFOejT7PZ[qs2c/$Ep[Gqo(Nù=QHci;OipX=Ģ8d^mQeӴm1OsL/x2];i6p!zU -/uX!=<-} .
LIBYA CYBER ARMY
Logo of a company Instagram@3g86    Server : Apache
System : Linux uta-edu.server.ly 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : utripoli ( 1001)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /home/utripoli/public_html/cp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/utripoli/public_html/cp/edit_news.php
<?php 
// اتصال بقاعدة بيانات 
require_once("../connection/connect.php");
 $page_title = "تعديل خبر"; 
 $page_select = "2"; 
require_once("include/header.php"); 
require_once("include/check.php");
require_once("include/locked.php");

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


// استجلاب بيانات التخصصات
$dirsa->select_db($database_dirsa);
$query_new_details = sprintf("SELECT * FROM news where news_id=%s",
                   GetSQLValueString($_GET['id'], "int"));
$new_details = $dirsa->query($query_new_details) or die($dirsa->error);
$row_new_details = $new_details->fetch_assoc();
$totalRows_new_details = $new_details->num_rows;


if($row_users22['usr_section'] == '0') {
// استجلاب بيانات التخصصات
$dirsa->select_db($database_dirsa);
$query_section = sprintf("SELECT * FROM section where section_start_or_stop=%s",
                   GetSQLValueString(1, "int"));
$section = $dirsa->query($query_section) or die($dirsa->error);
$row_section = $section->fetch_assoc();
$totalRows_section = $section->num_rows;
} else {
    // استجلاب بيانات التخصصات
$dirsa->select_db($database_dirsa);
$query_section = sprintf("SELECT * FROM section where section_id=%s and section_start_or_stop=%s",
                   GetSQLValueString($row_users22['usr_section'], "int"),
                   GetSQLValueString(1, "int"));
$section = $dirsa->query($query_section) or die($dirsa->error);
$row_section = $section->fetch_assoc();
$totalRows_section = $section->num_rows;
}


// استجلاب بيانات المكاتب المتخصصة
$dirsa->select_db($database_dirsa);
$query_office = sprintf("SELECT * FROM offices where office_state=%s",
                    GetSQLValueString(1, "int"));
$office = $dirsa->query($query_office) or die($dirsa->error);
$row_office = $office->fetch_assoc();
$totalRows_office = $office->num_rows;

// استجلاب بيانات المكاتب المتخصصة
$dirsa->select_db($database_dirsa);
$query_newsid = sprintf("SELECT * FROM gallery_news where news_id=%s",
                    GetSQLValueString($_GET['id'], "int"));
$newsid = $dirsa->query($query_newsid) or die($dirsa->error);
$row_newsid = $newsid->fetch_assoc();
$totalRows_newsid = $newsid->num_rows;




//امر اضافة بيانات 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_news")) {
    
    if(isset($_FILES['image_head']) ){
    $errors= array();
    $file_name = $_FILES['image_head']['name'];
    $file_size =$_FILES['image_head']['size'];
    $file_tmp =$_FILES['image_head']['tmp_name'];
    $file_type=$_FILES['image_head']['type'];   
    $file_ext=strtolower(end(explode('.',$_FILES['image_head']['name'])));
    
    $expensions= array("jpeg","jpg","png"); 		
    if(in_array($file_ext,$expensions)=== false){
        $errors[]="extension not allowed, please choose a JPEG or PNG file.";
    }
    if($file_size > 2097152){
    $errors[]='File size must be excately 2 MB';
    }				
    if(empty($errors)==true){
        
            $name = pathinfo($_FILES['image_head']['name'], PATHINFO_FILENAME);
$extension = pathinfo($_FILES['image_head']['name'], PATHINFO_EXTENSION);

$increment = 0; 
$pname = $name . '.' . $extension;
while(is_file("uploads/news/".'/'.$pname)) {
 $increment++;
 $pname = $name . $increment . '.' . $extension;
}
        move_uploaded_file($file_tmp,"uploads/news/".$pname);
        
    } 
}

if(isset($_FILES['image_another'])){
    $errors2= array();
    $file_name2 = $_FILES['image_another']['name'];
    $file_size2 =$_FILES['image_another']['size'];
    $file_tmp2 =$_FILES['image_another']['tmp_name'];
    $file_type2=$_FILES['image_another']['type'];   
    $file_ext2=strtolower(end(explode('.',$_FILES['image_another']['name'])));
    
    $expensions2= array("jpeg","jpg","png"); 		
    if(in_array($file_ext2,$expensions2)=== false){
        $errors2[]="extension not allowed, please choose a JPEG or PNG file.";
    }
    if($file_size2 > 2097152){
    $errors2[]='File size must be excately 2 MB';
    }				
    if(empty($errors2)==true){
        
            $name2 = pathinfo($_FILES['image_another']['name'], PATHINFO_FILENAME);
$extension2 = pathinfo($_FILES['image_another']['name'], PATHINFO_EXTENSION);

$increment2 = 0; 
$pname2 = $name2 . '.' . $extension2;
while(is_file("uploads/news/".'/'.$pname2)) {
 $increment2++;
 $pname2 = $name2 . $increment2 . '.' . $extension2;
}
        move_uploaded_file($file_tmp2,"uploads/news/".$pname2);
        
    } 
} 

if(isset($_FILES['image_another1'])){
    $errors3= array();
    $file_name3 = $_FILES['image_another1']['name'];
    $file_size3 =$_FILES['image_another1']['size'];
    $file_tmp3 =$_FILES['image_another1']['tmp_name'];
    $file_type3=$_FILES['image_another1']['type'];   
    $file_ext3=strtolower(end(explode('.',$_FILES['image_another1']['name'])));
    
    $expensions3= array("jpeg","jpg","png"); 		
    if(in_array($file_ext3,$expensions3)=== false){
        $errors3[]="extension not allowed, please choose a JPEG or PNG file.";
    }
    if($file_size3 > 2097152){
    $errors3[]='File size must be excately 2 MB';
    }				
    if(empty($errors3)==true){
        
            $name3 = pathinfo($_FILES['image_another1']['name'], PATHINFO_FILENAME);
$extension3 = pathinfo($_FILES['image_another1']['name'], PATHINFO_EXTENSION);

$increment3 = 0; 
$pname3 = $name3 . '.' . $extension3;
while(is_file("uploads/news/".'/'.$pname3)) {
 $increment3++;
 $pname3 = $name3 . $increment3 . '.' . $extension3;
}
        move_uploaded_file($file_tmp3,"uploads/news/".$pname3);
        
    } 
} 

if(isset($_FILES['image_another2'])){
    $errors4= array();
    $file_name4 = $_FILES['image_another2']['name'];
    $file_size4 =$_FILES['image_another2']['size'];
    $file_tmp4 =$_FILES['image_another2image_head']['tmp_name'];
    $file_type4=$_FILES['image_another2']['type'];   
    $file_ext4=strtolower(end(explode('.',$_FILES['image_another2']['name'])));
    
    $expensions4= array("jpeg","jpg","png"); 		
    if(in_array($file_ext4,$expensions4)=== false){
        $errors4[]="extension not allowed, please choose a JPEG or PNG file.";
    }
    if($file_size4 > 2097152){
    $errors4[]='File size must be excately 2 MB';
    }				
    if(empty($errors4)==true){
        
            $name4 = pathinfo($_FILES['image_another2']['name'], PATHINFO_FILENAME);
$extension4 = pathinfo($_FILES['image_another2']['name'], PATHINFO_EXTENSION);

$increment4 = 0; 
$pname4 = $name4 . '.' . $extension4;
while(is_file("uploads/news/".'/'.$pname4)) {
 $increment4++;
 $pname4 = $name4 . $increment4 . '.' . $extension4;
}
        move_uploaded_file($file_tmp4,"uploads/news/".$pname4);
        
    } 
} 

if(isset($_FILES['image_another3'])){
    $errors5= array();
    $file_name5 = $_FILES['image_another3']['name'];
    $file_size5 =$_FILES['image_another3']['size'];
    $file_tmp5 =$_FILES['image_another3']['tmp_name'];
    $file_type5=$_FILES['image_another3']['type'];   
    $file_ext5=strtolower(end(explode('.',$_FILES['image_another3']['name'])));
    
    $expensions5= array("jpeg","jpg","png"); 		
    if(in_array($file_ext5,$expensions5)=== false){
        $errors5[]="extension not allowed, please choose a JPEG or PNG file.";
    }
    if($file_size5 > 2097152){
    $errors5[]='File size must be excately 2 MB';
    }				
    if(empty($errors5)==true){
        
            $name5 = pathinfo($_FILES['image_another3']['name'], PATHINFO_FILENAME);
$extension5 = pathinfo($_FILES['image_another3']['name'], PATHINFO_EXTENSION);

$increment5 = 0; 
$pname5 = $name5 . '.' . $extension5;
while(is_file("uploads/news/".'/'.$pname5)) {
 $increment5++;
 $pname5 = $name5 . $increment5 . '.' . $extension5;
}
        move_uploaded_file($file_tmp5,"uploads/news/".$pname5);
        
    } 
} 


if(isset($_POST['news_start_or_stop'])) {
    $news_start_or_stop = $_POST['news_start_or_stop'];
} else {
    $news_start_or_stop = "0";
}

if(isset($_POST['site_view'])) {
    $site_view = $_POST['site_view'];
} else {
    $site_view = "0";
}


if(isset($_POST['all_manasht'])) {
    $all_manasht = $_POST['all_manasht'];
} else {
    $all_manasht = "0";
}

if(isset($_POST['all_kedma'])) {
    $all_kedma = $_POST['all_kedma'];
} else {
    $all_kedma = "0";
}

    $insertSQL = sprintf("UPDATE news set news_title=%s, news_des=%s, news_date=%s, news_start_or_stop=%s, news_emp=%s, news_office=%s,news_section=%s, site_view=%s, all_manasht=%s, all_kedma=%s where news_id=%s",
                         GetSQLValueString($_POST['news_title'], "text"),
                         GetSQLValueString($_POST['news_des'], "text"),
                         GetSQLValueString($_POST['news_date'], "text"),
                         GetSQLValueString($news_start_or_stop, "text"),
                         GetSQLValueString($row_users22['user_id'], "int"),
                         GetSQLValueString($_POST['news_office'], "text"),
                         GetSQLValueString($_POST['news_section'], "text"),
                         GetSQLValueString($site_view, "text"),
                         GetSQLValueString($all_manasht, "text"),
                         GetSQLValueString($all_kedma, "text"),
                         GetSQLValueString($row_new_details['news_id'], "int"));
  
    $dirsa->select_db($database_dirsa);
    $Result1 = $dirsa->query($insertSQL) or die($dirsa->error);
  
    $insertGoTo = "news.php";
    if (isset($_SERVER['QUERY_STRING'])) {
      $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
      $insertGoTo .= $_SERVER['QUERY_STRING'];
    if($file_size > 0){
          $insertSQL1 = sprintf("UPDATE news set image_head=%s where news_id=%s",
                         GetSQLValueString($pname, "text"),
                         GetSQLValueString($row_new_details['news_id'], "int"));
  
    $dirsa->select_db($database_dirsa);
    $Result11 = $dirsa->query($insertSQL1) or die($dirsa->error);
    }
    if($file_size2 > 0) {
            $insertSQL2 = sprintf("UPDATE news set image_another=%s where news_id=%s",
                         GetSQLValueString($pname2, "text"),
                         GetSQLValueString($row_new_details['news_id'], "int"));
  
    $dirsa->select_db($database_dirsa);
    $Result22 = $dirsa->query($insertSQL2) or die($dirsa->error);
    }
        if($file_size3 > 0) {
            $insertSQL3 = sprintf("UPDATE news set image_another1=%s where news_id=%s",
                         GetSQLValueString($pname3, "text"),
                         GetSQLValueString($row_new_details['news_id'], "int"));
  
    $dirsa->select_db($database_dirsa);
    $Result33 = $dirsa->query($insertSQL3) or die($dirsa->error);
    }
            if($file_size4 > 0) {
            $insertSQL4 = sprintf("UPDATE news set image_another2=%s where news_id=%s",
                         GetSQLValueString($pname4, "text"),
                         GetSQLValueString($row_new_details['news_id'], "int"));
  
    $dirsa->select_db($database_dirsa);
    $Result44 = $dirsa->query($insertSQL4) or die($dirsa->error);
    }
            if($file_size5 > 0) {
            $insertSQL5 = sprintf("UPDATE news set image_another3=%s where news_id=%s",
                         GetSQLValueString($pname5, "text"),
                         GetSQLValueString($row_new_details['news_id'], "int"));
  
    $dirsa->select_db($database_dirsa);
    $Result55 = $dirsa->query($insertSQL5) or die($dirsa->error);
    }

    if(isset($_FILES['image_url'])){
      foreach($_FILES['image_url']['name'] as $key=>$val){ 
     $errors= array();
     $file_name = $_FILES['image_url']['name'][$key];
     $file_size =$_FILES['image_url']['size'][$key];
     $file_tmp =$_FILES['image_url']['tmp_name'][$key];
     $file_type=$_FILES['image_url']['type'][$key];   
     $file_ext=strtolower(end(explode('.',$_FILES['image_url']['name'][$key])));
     
     $expensions= array("jpg","png","gif"); 		
     if(in_array($file_ext,$expensions)=== false){
         $errors[]="extension not allowed, please choose a JPEG or PNG file.";
     }
     if($file_size > 2097152){
     $errors[]='File size must be excately 2 MB';
     }				
     if(empty($errors)==true){
         
             $name = pathinfo($_FILES['image_url']['name'][$key], PATHINFO_FILENAME);
 $extension = pathinfo($_FILES['image_url']['name'][$key], PATHINFO_EXTENSION);
 
 $increment = 0; 
 $pname = $name . '.' . $extension;
 while(is_file("uploads/news/".'/'.$pname)) {
  $increment++;
  $pname = $name . $increment . '.' . $extension;
 }
 $increment = 0; 
 $pname = $name . '.' . $extension;
 while(is_file("uploads/news/".'/'.$pname)) {
  $increment++;
  $pname = $name . $increment . '.' . $extension;
 }
         move_uploaded_file($file_tmp,"uploads/news/".$pname);
   $insertSQL = sprintf("INSERT INTO gallery_news (image_url, news_id) VALUES (%s, %s)",
                          GetSQLValueString($pname, "text"),
                          GetSQLValueString($row_new_details['news_id'],"int"));
   
     $dirsa->select_db($database_dirsa);
     $Result1 = $dirsa->query($insertSQL) or die($dirsa->error);      
     } else {
     // الصورة الإفتراضية للخبر
     $pname = "default.jpg";	
         
     }
      }
 }

    $insertGoTo = "news.php";
    if (isset($_SERVER['QUERY_STRING'])) {
      $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
      $insertGoTo .= $_SERVER['QUERY_STRING'];  
        
    }
      
    }
    header(sprintf("Location: %s", $insertGoTo));
  }

?>

   <script language="JavaScript">
function toggle(source) {
    var checkboxes = document.querySelectorAll('input[type="checkbox"]');
    for (var i = 0; i < checkboxes.length; i++) {
        if (checkboxes[i] != source)
            checkboxes[i].checked = source.checked;
    }
}
</script>
          <!-- / Navbar -->

          <!-- Content wrapper -->
          <div class="content-wrapper">
            <!-- Content -->
            <div class="container-xxl flex-grow-1 container-p-y">
              <div class="card">
                <div class="card-body">
                       <form action="<?php echo $editFormAction; ?>" role="form" method="POST"
                                    name="add_news" enctype="multipart/form-data">
                    <div class="row">
                      <div class="col-md-5 mb-4">
                        <label for="news-title" class="form-label"
                          >العنوان</label
                        >
                        <input
                          name="news_title"
                          type="text"
                          class="form-control"
                          id="news-title"
                          placeholder="ادخل عنوان الخبر"
                          aria-describedby="defaultFormControlHelp"
                          value="<?php echo $row_new_details['news_title']; ?>"
                        />
                      </div>

                      <div class="col mb-4">
                        <label for="news-state" class="form-label"
                          >الحالة</label
                        >
                        <select
                          name="news_start_or_stop"
                          class="form-select"
                          id="news-state"
                          aria-label="Default select example"
                        >
                          <option selected value="1" <?php if (!(strcmp(1,$row_new_details['news_start_or_stop']))) {echo "selected=\"selected\"";} ?>>مفعل</option>
                          <option value="0" <?php if (!(strcmp(0,$row_new_details['news_start_or_stop']))) {echo "selected=\"selected\"";} ?>>متوقف</option>
                        </select>
                      </div>
                      <div class="col-md-5 mb-4">
                        <div class="row">
                          <label for="" class="form-label"
                            >إضافة الخبر إلى:</label
                          >
                          <div class="col-auto">
                            <label for="news-title" class="form-label"
                              >موقع العام للجامعة
                            </label>
                            <input
                              name="site_view"
                              class="form-check-input me-1"
                              type="checkbox"
                              id="checkbox-1"
                              value="1"
                              <?php if (!(strcmp("1",$row_new_details['site_view']))) {echo "checked";} ?>
                            />
                          </div>
                           <div class="col-auto">
                            <label for="news-title" class="form-label"
                              >مناشط قسم الجودة للأقسام 
                            </label>
                            <input
                              name="all_manasht"
                              class="form-check-input me-1"
                              type="checkbox"
                              id="checkbox-2"
                              value="1"
                              <?php if (!(strcmp("1",$row_new_details['all_manasht']))) {echo "checked";} ?>
                            />
                          </div>
                           <div class="col-auto">
                            <label for="news-title" class="form-label"
                              > خدمة المجتمع للأقسام
                            </label>
                            <input
                              name="all_kedma"
                              class="form-check-input me-1"
                              type="checkbox"
                              id="checkbox-3"
                              value="1"
                              <?php if (!(strcmp("1",$row_new_details['all_kedma']))) {echo "checked";} ?>
                            />
                          </div>
                          <div class="col-auto">
                            <label for="news-title" class="form-label"
                              >تحديد الكل
                            </label>
                            <input
                              class="form-check-input me-1"
                              type="checkbox"
                              value=""
                              onclick="toggle(this);"
                            />
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="row">
                          <?php if($row_users22['usr_section'] == '0') { ?>
                        <div class="col mb-4">
                            <label for="news-state" class="form-label"
                          >القسم</label
                        >
                        <select
                          name="news_section"
                          class="form-select"
                          id="news-state"
                          aria-label="Default select example"
                        > 
                        <option value="0">لا يوجد قسم محدد</option>
                          <?php do {  ?>
                        <option value="<?php echo $row_section['section_id']; ?>"
                        <?php if (!(strcmp($row_section['section_id'],$row_new_details['news_section']))) {echo "selected=\"selected\"";} ?>>
                        <?php echo $row_section['section_name']; ?></option>
                        <?php } while ($row_section = $section->fetch_assoc()); ?>
                        </select>
                        </div>
                        <?php } else { ?>
                                               <div class="col mb-4">
                            <label for="news-state" class="form-label"
                          >القسم</label
                        >
                        <select
                          name="news_section"
                          class="form-select"
                          id="news-state"
                          aria-label="Default select example"
                        > 
                        <option value="0">لا يوجد قسم محدد</option>
                        <option value="<?php echo $row_section['section_id']; ?>"
                        <?php if (!(strcmp($row_section['section_id'],$row_new_details['news_section']))) {echo "selected=\"selected\"";} ?>>
                        <?php echo $row_section['section_name']; ?></option>
                        </select>
                        </div>
                        <?php } ?>
                        
                                                <div class="col mb-4">
                            <label for="news-state" class="form-label"
                          >المكتب</label
                        >
                        <select
                          name="news_office"
                          class="form-select"
                          id="news-state"
                          aria-label="Default select example"
                        >
                        <option value="0">لا يوجد مكتب محدد</option> 
                        <?php do {  ?>
                        <option value="<?php echo $row_office['office_id']; ?>"
                        <?php if (!(strcmp($row_office['office_id'],$row_new_details['news_office']))) {echo "selected=\"selected\"";} ?>>
                        <?php echo $row_office['office_name']; ?></option>
                        <?php } while ($row_office = $office->fetch_assoc()); ?>
                        </select>
                        </div>
                    </div>
                    <div class="row">
                      <div class="col mb-4">
                        <textarea name="news_des" class="w-100" id="mytextarea"><?php echo $row_new_details['news_des']; ?></textarea>
                      </div>
                    </div>
                    <div class="row">
                      <div class="col-md-4 mb-4">
                        <label for="news-cover" class="form-label"
                          >صورة الغلاف</label
                        >
                        <input
                          name="image_head"
                          type="file"
                          class="form-control"
                          id="news-cover"
                          value="<?php echo $row_new_details['image_head']; ?>"
                        />
                      </div>
                                                                                            <div class="col-md-4 mb-4">
                        <label for="news-images" class="form-label"
                          >صور إضافية 1</label
                        >
                        <input
                          name="image_another"
                          type="file"
                          multiple
                          class="form-control"
                          id="news-images"
                          value="<?php echo $row_new_details['image_another']; ?>"
                        />
                        </div>
                                                                                              <div class="col-md-4 mb-4">
                        <label for="news-images" class="form-label"
                          >صور إضافية 2</label
                        >
                        <input
                          name="image_another1"
                          type="file"
                          multiple
                          class="form-control"
                          id="news-images"
                           value="<?php echo $row_new_details['image_another1']; ?>"
                        />
                    </div>
                    </div>
                    <div class="row">
                                              <div class="col-md-4 mb-4">
                        <label for="news-images" class="form-label"
                          >صور إضافية 3</label
                        >
                        <input
                          name="image_another2"
                          type="file"
                          multiple
                          class="form-control"
                          id="news-images"
                          value="<?php echo $row_new_details['image_another2']; ?>"
                        />
                        
                      </div>
                                                                    <div class="col-md-4 mb-4">
                        <label for="news-images" class="form-label"
                          >صور إضافية 4</label
                        >
                        <input
                          name="image_another3"
                          type="file"
                          multiple
                          class="form-control"
                          id="news-images"
                          value="<?php echo $row_new_details['image_another3']; ?>"
                        />
                        
                      </div>
                      
                                      <div class="col-md-4 mb-4">
                        <label for="news-date" class="form-label"
                          >تاريخ النشر</label
                        >
                        <input
                          name="news_date"
                          type="date"
                          multiple
                          class="form-control"
                          id="news-date"
                          value="<?php echo $row_new_details['news_date']; ?>"
                        />
                      </div>                          
                    </div>

                    <div class="col-md-4 mb-4">
                        <label for="research-file" class="form-label"
                          >صور اخرى متعددة الاختيار
                        </label>
                        <input
                          name="image_url[]"
                          type="file"
                          class="form-control"
                          id="research-file"
                          multiple
                        />
                      </div>
                      <style>
                        ul {
       list-style-type: none;
       display: contents;
   }

ul > li {

        padding: 0;
        margin: 0 2px; 
   }
                        </style>
                        <?php if($totalRows_newsid > 0) { ?>
                      <?php do { ?>
                       <ul>
                        <li><?php echo $row_newsid['image_url']; ?> <a href="uploads/news/<?php echo $row_newsid['image_url']; ?>">عرض</a>  <a href="delete_m.php?id=<?php echo $row_newsid['galleryimageid']; ?>">حذف</a></li>
                      </ul>
                      <?php }while($row_newsid = $newsid->fetch_assoc()); ?>
                      <?php } ?>
                   
                    </div>
                    <input type="hidden" name="MM_insert" value="add_news">
                    <div class="card-footer text-center text-sm-end">
                      <button type="submit" name="submit" class="btn btn-primary">حفظ</button>
                      <button class="btn btn-secondary">إلغاء</button>
                    </div>
                  </form>
                </div>
              </div>
            </div>
            <!-- / Content -->

            <!-- Footer -->
 <?php require_once("include/footer.php"); ?>

3g86 2022