<? include_once("../includes/cmain.inc.php");

$page_id = $_REQUEST['page_id'];
$country_name = addslashes($country_name ?? '');
$parent_childs = addslashes($parent_childs ?? '');
$title = addslashes($title ?? '');
	
if(is_post_back()) {

	if($page_id!='') {		 
	    
$country_name = $_POST['country_name'] ?? '';
$parent_childs = isset($_POST['parent_childs']) ? intval($_POST['parent_childs']) : 0;
$country_status = $_POST['country_status'] ?? '0'; // Default to '0' (Inactive)
$title = $_POST['title'] ?? '';
$description = $_POST['description'] ?? '';
$keyword = $_POST['keyword'] ?? '';
$country_title =$_POST['country_title'] ?? '';
$country_descriptions = isset($_POST['country_descriptions']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions']))
    ) 
    : '';
$country_descriptions1 = isset($_POST['country_descriptions1']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions1']))
    ) 
    : '';
    $country_descriptions2 = isset($_POST['country_descriptions2']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions2']))
    ) 
    : '';
    $country_descriptions3 = isset($_POST['country_descriptions3']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions3']))
    ) 
    : '';
    $country_descriptions4 = isset($_POST['country_descriptions4']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions4']))
    ) 
    : '';
    $country_descriptions5 = isset($_POST['country_descriptions5']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions5']))
    ) 
    : '';
    $country_descriptions6 = isset($_POST['country_descriptions6']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions6']))
    ) 
    : '';
   $country_descriptions7 = isset($_POST['country_descriptions7']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions7']))
    ) 
    : '';
       $country_descriptions8 = isset($_POST['country_descriptions8']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions8']))
    ) 
    : '';

$sv_image_1 = $sv_image_1 ?? ''; 
$sv_image_2 = $sv_image_2 ?? ''; 
$sv_image_3 = $sv_image_3 ?? ''; 
$sv_image_4 = $sv_image_4 ?? ''; 
$sv_image_5 = $sv_image_5 ?? ''; 
$sv_image_6 = $sv_image_6 ?? ''; 



		
		$sql = "update `tbl_metal` set country_name='$country_name', parent_childs='$parent_childs', country_status='$country_status', title='$title', description='$description', keyword='$keyword', country_title='$country_title', country_descriptions='$country_descriptions',country_descriptions1='$country_descriptions1',country_descriptions2='$country_descriptions2',country_descriptions3='$country_descriptions3',country_descriptions4='$country_descriptions4',country_descriptions5='$country_descriptions5',country_descriptions6='$country_descriptions6' ,country_descriptions7='$country_descriptions7',country_descriptions8='$country_descriptions8' where country_id = $page_id ";
		db_query($sql);
		
		########### Uploading Image ################
		if($_FILES['sv_image']['name']!='')
		{
			if(strlen($sv_image) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$sv_image)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$sv_image);
			}
			$sv_image_1 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['sv_image']['name']);
				copy($_FILES['sv_image']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_1) or die("Image is not uploaded");
				copy($_FILES['sv_image']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_1) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_1;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_1; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['sv_image']['type'] =="image/pjpeg" OR $_FILES['sv_image']['type']=="image/jpeg" OR $_FILES['sv_image']['type']=="image/png" OR $_FILES['sv_image']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['sv_image']['type']=="image/pjpeg" OR $_FILES['sv_image']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['sv_image']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['sv_image']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
			
			db_query("update tbl_metal set country_banner='".$sv_image_1."' where country_id = $page_id ");
		}
			if($_FILES['side_image']['name']!='')
		{
		    $side_image=$side_image ?? '';
			if(strlen($side_image) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$side_image)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$sv_image);
			}
			$sv_image_6 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['side_image']['name']);
				copy($_FILES['side_image']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_6) or die("Image is not uploaded");
				copy($_FILES['side_image']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_6) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_1;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_1; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['side_image']['type'] =="image/pjpeg" OR $_FILES['side_image']['type']=="image/jpeg" OR $_FILES['side_image']['type']=="image/png" OR $_FILES['side_image']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
		if (isset($_FILES['side_image']) && $_FILES['side_image']['error'] == 0) {

    $fileType = $_FILES['side_image']['type'];
    $tmpPath  = $_FILES['side_image']['tmp_name'];
    $fileName = basename($_FILES['side_image']['name']);
    $uploadDir = "/home1/metalstampingdie/public_html/uploaded_files/banner/original/";
    $add = $uploadDir . $fileName; // Full path

    // Make sure upload directory exists
    if (!is_dir($uploadDir)) {
        mkdir($uploadDir, 0777, true);
    }

    // Move uploaded file
    if (move_uploaded_file($tmpPath, $add)) {

        // Determine image type
        if ($fileType == "image/pjpeg" || $fileType == "image/jpeg") {
            $im = @imagecreatefromjpeg($add);
        } elseif ($fileType == "image/png") {
            $im = @imagecreatefrompng($add);
        } 
         elseif ($fileType == "image/webp") {
            $im = @imagecreatefromwebp($add);
        } 
        else {
            die("Error: Unsupported image format.");
        }

        // Validate image creation
        if ($im !== false) {
            $width = imagesx($im);
            $height = imagesy($im);

            $newimage = imagecreatetruecolor($n_width, $n_height);
            imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);

            // Define resized output path
            $tsrc = $uploadDir . "resized_" . $fileName;

            if ($fileType == "image/jpeg" || $fileType == "image/pjpeg") {
                imagejpeg($newimage, $tsrc);
            } else {
                imagepng($newimage, $tsrc);
            }

            chmod($tsrc, 0777);
        } else {
            echo "Error: The uploaded file is not a valid image or is corrupted.";
        }

    } else {
        echo "Error: File could not be uploaded. Check directory permissions.";
    }

} 
	elseif (isset($_FILES['side_image']) && $_FILES['side_image']['error'] == 0) {
    $fileType = $_FILES['side_image']['type'];
    $add = $_FILES['side_image']['tmp_name'];

    // Check if file is PNG
    if ($fileType == "image/png") {
        $im = @imagecreatefrompng($add); // use @ to suppress warnings temporarily

        if ($im !== false) {
            $width = imagesx($im);
            $height = imagesy($im);
            $newimage = imagecreatetruecolor($n_width, $n_height);
            imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
            imagepng($newimage, $tsrc);
            chmod($tsrc, 0777);
        } else {
            echo "Error: The uploaded PNG file could not be processed. Please upload a valid PNG image.";
        }
    } else {
        echo "Error: Uploaded file is not a PNG image.";
    }
}
			elseif($_FILES['side_image']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
			
			db_query("update tbl_metal set side_image='".$sv_image_6."' where country_id = $page_id ");
		}
			if($_FILES['image1']['name']!='')
		{
			if(strlen($image1) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$image1)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$image1);
			}
			$sv_image_2 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['image1']['name']);
				copy($_FILES['image1']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_2) or die("Image is not uploaded");
				copy($_FILES['image1']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_2) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_2;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_2; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['image1']['type'] =="image/pjpeg" OR $_FILES['image1']['type']=="image/jpeg" OR $_FILES['image1']['type']=="image/png" OR $_FILES['image1']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['image1']['type']=="image/pjpeg" OR $_FILES['image1']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['image1']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['image1']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
             			db_query("update tbl_metal set banner1='".$sv_image_2."' where country_id = $page_id ");

		}
					if($_FILES['image2']['name']!='')
		{
			if(strlen($image2) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$image2)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$image2);
			}
			$sv_image_3 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['image2']['name']);
				copy($_FILES['image2']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_3) or die("Image is not uploaded");
				copy($_FILES['image2']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_3) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_3;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_3; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['image2']['type'] =="image/pjpeg" OR $_FILES['image2']['type']=="image/jpeg" OR $_FILES['image2']['type']=="image/png" OR $_FILES['image2']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['image2']['type']=="image/pjpeg" OR $_FILES['image2']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['image2']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['image2']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
             			db_query("update tbl_metal set banner2='".$sv_image_3."' where country_id = $page_id ");

		}
				if($_FILES['image3']['name']!='')
		{
			if(strlen($image3) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$image3)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$image2);
			}
			$sv_image_4 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['image3']['name']);
				copy($_FILES['image3']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_4) or die("Image is not uploaded");
				copy($_FILES['image3']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_4) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_4;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_4; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['image3']['type'] =="image/pjpeg" OR $_FILES['image3']['type']=="image/jpeg" OR $_FILES['image3']['type']=="image/png" OR $_FILES['image3image3']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['image3']['type']=="image/pjpeg" OR $_FILES['image3']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['image3']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['image3']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
             			db_query("update tbl_metal set banner3='".$sv_image_4."' where country_id = $page_id ");

		}
			if($_FILES['image4']['name']!='')
		{
			if(strlen($image4) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$image4)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$image4);
			}
			$sv_image_5 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['image4']['name']);
				copy($_FILES['image4']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_5) or die("Image is not uploaded");
				copy($_FILES['image4']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_5) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_5;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_5; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['image4']['type'] =="image/pjpeg" OR $_FILES['image4']['type']=="image/jpeg" OR $_FILES['image4']['type']=="image/png" OR $_FILES['image4']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['image4']['type']=="image/pjpeg" OR $_FILES['image4']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['image4']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['image4']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
             			db_query("update tbl_metal set banner4='".$sv_image_5."' where country_id = $page_id ");

		}	
		set_session_msg("Services updated successfully.");	
	
	} else{	
	
	     ########### Uploading Image ################
		if($_FILES['sv_image']['name']!='')
		{
		    $sv_image=$sv_image ?? '';
			if(strlen($sv_image) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$sv_image)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$sv_image);
			}
			$sv_image_1 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['sv_image']['name']);
				copy($_FILES['sv_image']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_1) or die("Image is not uploaded");
				copy($_FILES['sv_image']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_1) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_1;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_1; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['sv_image']['type'] =="image/pjpeg" OR $_FILES['sv_image']['type']=="image/jpeg" OR $_FILES['sv_image']['type']=="image/png")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['sv_image']['type']=="image/pjpeg" OR $_FILES['sv_image']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			else{
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			
		}
					if($_FILES['side_image']['name']!='')
		{
			if(strlen($side_image) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$side_image)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$side_image);
			}
			$sv_image_6 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['side_image']['name']);
				copy($_FILES['side_image']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_6) or die("Image is not uploaded");
				copy($_FILES['side_image']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_6) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_6;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_6; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['side_image']['type'] =="image/pjpeg" OR $_FILES['side_image']['type']=="image/jpeg" OR $_FILES['side_image']['type']=="image/png" OR $_FILES['side_image']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['side_image']['type']=="image/pjpeg" OR $_FILES['side_image']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['side_image']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['side_image']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
			
		}
			if($_FILES['image1']['name']!='')
		{
			if(strlen($image1) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$image1)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$image1);
			}
			$sv_image_2 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['image1']['name']);
				copy($_FILES['image1']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_2) or die("Image is not uploaded");
				copy($_FILES['image1']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_2) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_2;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_2; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['image1']['type'] =="image/pjpeg" OR $_FILES['image1']['type']=="image/jpeg" OR $_FILES['image1']['type']=="image/png" OR $_FILES['image1']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['image1']['type']=="image/pjpeg" OR $_FILES['image1']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['image1']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['image1']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
		}
					if($_FILES['image2']['name']!='')
		{
			if(strlen($image2) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$image2)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$image2);
			}
			$sv_image_3 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['image2']['name']);
				copy($_FILES['image2']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_3) or die("Image is not uploaded");
				copy($_FILES['image2']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_3) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_3;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_3; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['image2']['type'] =="image/pjpeg" OR $_FILES['image2']['type']=="image/jpeg" OR $_FILES['image2']['type']=="image/png" OR $_FILES['image2']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['image2']['type']=="image/pjpeg" OR $_FILES['image2']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['image2']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['image2']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }
		}
			if($_FILES['image3']['name']!='')
		{
			if(strlen($image3) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$image3)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$image2);
			}
			$sv_image_4 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['image3']['name']);
				copy($_FILES['image3']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_4) or die("Image is not uploaded");
				copy($_FILES['image3']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_4) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_4;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_4; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['image3']['type'] =="image/pjpeg" OR $_FILES['image3']['type']=="image/jpeg" OR $_FILES['image3']['type']=="image/png" OR $_FILES['image3image3']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['image3']['type']=="image/pjpeg" OR $_FILES['image3']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['image3']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['image3']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }

		}
			if($_FILES['image4']['name']!='')
		{
			if(strlen($image4) && file_exists(UP_FILES_FS_PATH."/banner/thumb/".$image4)){
				@unlink(UP_FILES_FS_PATH."/banner/thumb/".$image4);
			}
			$sv_image_5 = md5(uniqid(rand(), true)).'.'.file_ext($_FILES['image4']['name']);
				copy($_FILES['image4']['tmp_name'], UP_FILES_FS_PATH."/banner/thumb/".$sv_image_5) or die("Image is not uploaded");
				copy($_FILES['image4']['tmp_name'], UP_FILES_FS_PATH."/banner/original/".$sv_image_5) or die("Image is not uploaded");
			$n_width=120; // Fix the width of the thumb nail images
			$n_height=90; // Fix the height of the thumb nail imaage
			
			$tsrc=UP_FILES_FS_PATH."/banner/thumb/".$sv_image_5;
			$add=UP_FILES_FS_PATH."/banner/original/".$sv_image_5; // Path where thumb nail image will be stored
			
			//echo $tsrc;
			if (!($_FILES['image4']['type'] =="image/pjpeg" OR $_FILES['image4']['type']=="image/jpeg" OR $_FILES['image4']['type']=="image/png" OR $_FILES['image4']['type']=="image/webp")){echo "Your uploaded file must be of JPG or GIF or PNG. Other file types are not allowed<BR>";
			exit;}
				///////// starting of JPG thumb nail creation//////////
			if($_FILES['image4']['type']=="image/pjpeg" OR $_FILES['image4']['type']=="image/jpeg")
			{
				$im=ImageCreateFromJPEG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImageJpeg($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
		elseif($_FILES['image4']['type'] == "image/png") {
				$im=ImageCreateFromPNG($add);
				$width=ImageSx($im); // Original picture width is stored
				$height=ImageSy($im); // Original picture height is stored
				$newimage=imagecreatetruecolor($n_width,$n_height);
				imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
				ImagePng($newimage,$tsrc);
				chmod("$tsrc",0777);
			}
			elseif($_FILES['image4']['type'] == "image/webp") {
                 $im = imagecreatefromwebp($add); // Create image from WebP
                 $width = imagesx($im); // Original picture width is stored
                 $height = imagesy($im); // Original picture height is stored
                 $newimage = imagecreatetruecolor($n_width, $n_height);
                 imagecopyresized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
                 imagewebp($newimage, $tsrc); // Save thumbnail as WebP
                 chmod("$tsrc", 0777);
             }

		}	
		
		
		
			$country_name = $_POST['country_name'] ?? '';
$parent_childs = isset($_POST['parent_childs']) ? intval($_POST['parent_childs']) : 0;
$country_status = $_POST['country_status'] ?? '0'; // Default to '0' (Inactive)
$title = $_POST['title'] ?? '';
$description = $_POST['description'] ?? '';
$keyword = $_POST['keyword'] ?? '';
$country_title =$_POST['country_title'] ?? '';

$country_descriptions = isset($_POST['country_descriptions']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions']))
    ) 
    : '';
$country_descriptions1 = isset($_POST['country_descriptions1']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions1']))
    ) 
    : '';
    $country_descriptions2 = isset($_POST['country_descriptions2']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions2']))
    ) 
    : '';
    $country_descriptions3 = isset($_POST['country_descriptions3']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions3']))
    ) 
    : '';
    $country_descriptions4 = isset($_POST['country_descriptions4']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions4']))
    ) 
    : '';
    $country_descriptions5 = isset($_POST['country_descriptions5']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions5']))
    ) 
    : '';
    $country_descriptions6 = isset($_POST['country_descriptions6']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions6']))
    ) 
    : '';
       $country_descriptions7 = isset($_POST['country_descriptions7']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions7']))
    ) 
    : '';
       $country_descriptions8 = isset($_POST['country_descriptions8']) 
    ? mysqli_real_escape_string(
        $GLOBALS['dbcon'],
        str_replace(["\r", "\n"], ' ', stripslashes($_POST['country_descriptions8']))
    ) 
    : '';

$sv_image_1 = $sv_image_1 ?? ''; 
$sv_image_2 = $sv_image_2 ?? ''; 
$sv_image_3 = $sv_image_3 ?? ''; 
$sv_image_4 = $sv_image_4 ?? ''; 
$sv_image_5 = $sv_image_5 ?? ''; 

	
		 $sql = "insert into `tbl_metal` set country_name='$country_name',  parent_childs='$parent_childs',country_status='$country_status', title='$title', description='$description', keyword='$keyword', country_title='$country_title', country_descriptions='$country_descriptions', country_descriptions1='$country_descriptions1',country_descriptions2='$country_descriptions2',country_descriptions3='$country_descriptions3',country_descriptions4='$country_descriptions4',country_descriptions5='$country_descriptions5',country_descriptions6='$country_descriptions6',country_descriptions7='$country_descriptions7',country_descriptions8='$country_descriptions8',country_banner='$sv_image_1',banner1='$sv_image_2',banner2='$sv_image_3',banner3='$sv_image_4',banner4='$sv_image_5' ";
	//print_r($sql);exit();
		db_query($sql);
		set_session_msg("New Services added successfully.");
	}
	header("Location: metal_components.php?start=$start");
	exit;
}

$page_id = $_REQUEST['page_id'];
if($page_id!='') {
	$sql = "select * from `tbl_metal` where country_id = '$page_id'";
	$result = db_query($sql);
	if ($line_raw = mysqli_fetch_array($result)) {
		//$line_raw = ms_form_value($line_raw);
		@extract($line_raw);
	}
}
?>
<link href="styles.css" rel="stylesheet" type="text/css">

<? include("top.inc.php");?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td id="pageHead"><div id="txtPageHead">
       Add/Edit Services</div></td>
  </tr>
</table>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<table width="90%" align="left">
		  	<tr><td>
		  	<form method="post" action="" enctype="multipart/form-data" name="form1" id="form1" onSubmit="return validate(this);">
        <table width="80%" align="center" border=0 cellpadding="0"  cellspacing="0" class="text">
    	<tr>
    	    		  	    <?php        $start = isset($_GET['start']) ? intval($_GET['start']) : 0;?>

		<td  colspan="2"height="30"  align="right"><a href="metal_components.php?start=<?=$start?>" class="redcolor"><strong>Back To Services List</strong></a></td>
		</tr>    
        <tr><td height="15"><div align="center"><span class="msg"><?=display_sess_msg();?></span></div><br /></td></tr>  
		

        <tr><td>&nbsp;</td></tr>
        
        
        <tr>
		  <td class="lables"><b>Services Name</b></td>
          <td class="feildstxt"><input type="text" style="width:300px;" value="<?=stripslashes($country_name)?>" name="country_name" id="country_name"  /></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        
        <?php  $pcqry = db_query("select country_id,country_name from `tbl_metal` where parent_childs='0' ");	?>
        <tr>
		  <td class="lables"><b>Parent</b></td>
          <td class="feildstxt"><select name="parent_childs" id="parent_childs">
          <option value="0" <?php if($parent_childs=='0'){ echo 'selected="selected"'; } ?>>None</option>
          <?php while($parentData = mysqli_fetch_assoc($pcqry)){ ?>  
          <option value="<?php echo $parentData['country_id']; ?>" <?php if($parentData['country_id']==$parent_childs){ echo 'selected="selected"'; } ?>><?php echo $parentData['country_name']; ?></option>      
          <?php } ?>    
          </select></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
      

		<tr>
		  <td class="lables"><b>Status</b></td>
          <td class="feildstxt"><select name="country_status" id="country_status">
          <option value="1" <?php if(isset($country_status)=='1'){ echo 'selected="selected"'; } ?>>Active</option>
          <option value="0" <?php if(isset($country_status)=='0'){ echo 'selected="selected"'; } ?>>InActive</option>          
          </select></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        
        <tr>
		  <td class="lables" colspan="2"><hr/></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        
        <tr>
		  <td class="lables"><b>Title </b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="title" id="title"  ><?=stripslashes($title ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        
        <tr>
		  <td class="lables"><b>Description </b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="description" id="description"  ><?=stripslashes($description ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        
        <tr>
		  <td class="lables"><b>Keyword</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="keyword" id="keyword"  ><?=stripslashes($keyword ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables" colspan="2"><hr/></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        
        <tr>
		  <td class="lables"><b>Banner Image</b></td>
          <td class="feildstxt"><input type="file" name="sv_image" id="sv_image"  /></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Current Banner Image</b></td>
          <td class="feildstxt"> <?
          $sv_image=$country_banner ?? '';
          if(strlen($sv_image) && file_exists(UP_FILES_FS_PATH."/banner/original/".$sv_image)){
    $imgsrcBig = UP_FILES_WS_PATH."/banner/original/".$sv_image;
    $imagePath = UP_FILES_FS_PATH."/banner/original/".$sv_image;
    $size = getimagesize($imagePath);
    $mime = $size['mime'];

    switch ($mime) {
        case 'image/jpeg':
            $img = imagecreatefromjpeg($imagePath);
            break;
        case 'image/png':
            $img = imagecreatefrompng($imagePath);
            break;
        case 'image/gif':
            $img = imagecreatefromgif($imagePath);
            break;
        case 'image/webp':
            $img = imagecreatefromwebp($imagePath);
            break;
        default:
            $img = false;
            break;
    }

    if ($img !== false) {
        $width = imagesx($img);
        $height = imagesy($img);
    } else {
        echo "Invalid or unsupported image format.";
    }
}
            ?></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Services Title</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_title" id="country_title"  ><?=stripslashes($country_title ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        
        <tr>
		  <td class="lables"><b>Services Descriptions</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions" id="country_descriptions"  ><?=stripslashes($country_descriptions ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Side Image</b></td>
          <td class="feildstxt"><input type="file" name="side_image" id="side_image"  /></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Current Side Image</b></td>
          <td class="feildstxt"> <?
          $side_image=$side_image ?? '';
          if(strlen($side_image) && file_exists(UP_FILES_FS_PATH."/banner/original/".$side_image)){
    $imgsrcBig = UP_FILES_WS_PATH."/banner/original/".$side_image;
    $imagePath = UP_FILES_FS_PATH."/banner/original/".$side_image;
    $size = getimagesize($imagePath);
    $mime = $size['mime'];

    switch ($mime) {
        case 'image/jpeg':
            $img = imagecreatefromjpeg($imagePath);
            break;
        case 'image/png':
            $img = imagecreatefrompng($imagePath);
            break;
        case 'image/gif':
            $img = imagecreatefromgif($imagePath);
            break;
        case 'image/webp':
            $img = imagecreatefromwebp($imagePath);
            break;
        default:
            $img = false;
            break;
    }

    if ($img !== false) {
        $width = imagesx($img);
        $height = imagesy($img);
    } else {
        echo "Invalid or unsupported image format.";
    }
}
            ?></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Services Descriptions1</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions1" id="country_descriptions1"  ><?=stripslashes($country_descriptions1 ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Services Descriptions2</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions2" id="country_descriptions2"  ><?=stripslashes($country_descriptions2 ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Services Descriptions3</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions3" id="country_descriptions3"  ><?=stripslashes($country_descriptions3 ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Services Descriptions4</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions4" id="country_descriptions4"  ><?=stripslashes($country_descriptions4 ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Services Descriptions5</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions5" id="country_descriptions5"  ><?=stripslashes($country_descriptions5 ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Services Descriptions6</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions6" id="country_descriptions6"  ><?=stripslashes($country_descriptions6 ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Image1</b></td>
          <td class="feildstxt"><input type="file" name="image1" id="image1"  /></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Current Image1</b></td>
          <td class="feildstxt">
          <?
          $image1=$image1 ?? '';
          if(strlen($image1) && file_exists(UP_FILES_FS_PATH."/banner/original/".$image1)){
    $imgsrcBig = UP_FILES_WS_PATH."/banner/original/".$image1;
    $imagePath = UP_FILES_FS_PATH."/banner/original/".$image1;
    $size = getimagesize($imagePath);
    $mime = $size['mime'];

    switch ($mime) {
        case 'image/jpeg':
            $img = imagecreatefromjpeg($imagePath);
            break;
        case 'image/png':
            $img = imagecreatefrompng($imagePath);
            break;
        case 'image/gif':
            $img = imagecreatefromgif($imagePath);
            break;
        case 'image/webp':
            $img = imagecreatefromwebp($imagePath);
            break;
        default:
            $img = false;
            break;
    }

    if ($img !== false) {
        $width = imagesx($img);
        $height = imagesy($img);
    } else {
        echo "Invalid or unsupported image format.";
    }
}
            ?></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Image2</b></td>
          <td class="feildstxt"><input type="file" name="image2" id="image2"  /></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Current Image2</b></td>
          <td class="feildstxt"><? 
          $image2=$image2 ?? '';
        if(strlen($image2) && file_exists(UP_FILES_FS_PATH."/banner/original/".$image2)){
    $imgsrcBig = UP_FILES_WS_PATH."/banner/original/".$image2;
    $imagePath = UP_FILES_FS_PATH."/banner/original/".$image2;
    $size = getimagesize($imagePath);
    $mime = $size['mime'];

    switch ($mime) {
        case 'image/jpeg':
            $img = imagecreatefromjpeg($imagePath);
            break;
        case 'image/png':
            $img = imagecreatefrompng($imagePath);
            break;
        case 'image/gif':
            $img = imagecreatefromgif($imagePath);
            break;
        case 'image/webp':
            $img = imagecreatefromwebp($imagePath);
            break;
        default:
            $img = false;
            break;
    }

    if ($img !== false) {
        $width = imagesx($img);
        $height = imagesy($img);
    } else {
        echo "Invalid or unsupported image format.";
    }
}
            ?></td>
        </tr>
         <tr>
		  <td class="lables"><b>Services Descriptions7</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions7" id="country_descriptions7"  ><?=stripslashes($country_descriptions7?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
          <tr>
		  <td class="lables"><b>Image3</b></td>
          <td class="feildstxt"><input type="file" name="image3" id="image3"  /></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Current Image3</b></td>
          <td class="feildstxt"><? 
          $image3=$image3 ?? '';
        if(strlen($image2) && file_exists(UP_FILES_FS_PATH."/banner/original/".$image3)){
    $imgsrcBig = UP_FILES_WS_PATH."/banner/original/".$image3;
    $imagePath = UP_FILES_FS_PATH."/banner/original/".$image3;
    $size = getimagesize($imagePath);
    $mime = $size['mime'];

    switch ($mime) {
        case 'image/jpeg':
            $img = imagecreatefromjpeg($imagePath);
            break;
        case 'image/png':
            $img = imagecreatefrompng($imagePath);
            break;
        case 'image/gif':
            $img = imagecreatefromgif($imagePath);
            break;
        case 'image/webp':
            $img = imagecreatefromwebp($imagePath);
            break;
        default:
            $img = false;
            break;
    }

    if ($img !== false) {
        $width = imagesx($img);
        $height = imagesy($img);
    } else {
        echo "Invalid or unsupported image format.";
    }
}
            ?></td>
        </tr>
        
         <tr>
		  <td class="lables"><b>Services Descriptions8</b></td>
          <td class="feildstxt"><textarea style="width:300px;" name="country_descriptions8" id="country_descriptions8"  ><?=stripslashes($country_descriptions8 ?? '')?></textarea></td>
        </tr>
        <tr><td>&nbsp;</td></tr>
         <tr>
		  <td class="lables"><b>Image4</b></td>
          <td class="feildstxt"><input type="file" name="image4" id="image4"  /></td>
        </tr>
                <tr><td>&nbsp;</td></tr>
        <tr>
		  <td class="lables"><b>Current Image4</b></td>
          <td class="feildstxt"><? 
          $image4=$image4 ?? '';
        if(strlen($image4) && file_exists(UP_FILES_FS_PATH."/banner/original/".$image4)){
    $imgsrcBig = UP_FILES_WS_PATH."/banner/original/".$image4;
    $imagePath = UP_FILES_FS_PATH."/banner/original/".$image4;
    $size = getimagesize($imagePath);
    $mime = $size['mime'];

    switch ($mime) {
        case 'image/jpeg':
            $img = imagecreatefromjpeg($imagePath);
            break;
        case 'image/png':
            $img = imagecreatefrompng($imagePath);
            break;
        case 'image/gif':
            $img = imagecreatefromgif($imagePath);
            break;
        case 'image/webp':
            $img = imagecreatefromwebp($imagePath);
            break;
        default:
            $img = false;
            break;
    }

    if ($img !== false) {
        $width = imagesx($img);
        $height = imagesy($img);
    } else {
        echo "Invalid or unsupported image format.";
    }
}
            ?></td>
        </tr>
        
        <tr>
        <td align="left" class="lables">&nbsp;</td>
        <td align="left" class="feildstxt"><input class="button" type="submit" name="submit" value="Save"></td>
        </tr>
        <tr><td height="25">&nbsp;</td></tr>
        
   </table>
    </form>
    </td></tr></table> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions','650','600')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions1','650','300')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions2','650','300')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions3','650','300')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions4','650','300')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions5','650','300')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions6','650','300')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions7','650','300')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    <script type="text/javascript">
		 var oFCKeditor=new FCKeditor('country_descriptions8','650','300')	;
		 oFCKeditor.BasePath="fckeditor/";	
		 oFCKeditor.ReplaceTextarea();
    </script> 
    
  <? include("bottom.inc.php");?>