<?php session_start();
require_once("../../config/config.php");
//require_once("../config/commonsetting.php");

$myformId=SESS_MASTER;
$myIp= ipCheck() ;
$dateceated=date("Y-m-d G:i:s");
$createdby='0';
$stat	=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'stat']);
/*file upload*/
if (!empty($_FILES[SESS_MASTER.'adimg1']['name'])){
$adimg1load_flag="true";
$adimg1_size=$_FILES[SESS_MASTER.'adimg1']['size'];
if ($_FILES[SESS_MASTER.'adimg1']['size']>2500000){
$msg=$msg."Your uploaded file size is more than 2500KB ";
$msg.=" so please reduce the file size and then upload.<BR>";
$adimg1load_flag="false";
}

// allow only jpeg or gif files, remove this if not required //
if (!($_FILES[SESS_MASTER.'adimg1']['type'] =="image/jpeg" OR $_FILES[SESS_MASTER.'adimg1']['type'] =="image/png"))
{$msg=$msg."Your uploaded file must be of JPG or GIF. ";
$msg.="Other file types are not allowed<BR>";
$adimg1load_flag="false";}

$file_name=$_FILES[SESS_MASTER.'adimg1']['name'];
// the path with the file name where the file will be stored
$temp = explode(".", $file_name);
$newfilename = round(microtime(true)) . '1.' . end($temp);
$add1="../../upload/".$newfilename; 

if($adimg1load_flag=="true"){ // checking the Flag value 

if(move_uploaded_file ($_FILES[SESS_MASTER.'adimg1']['tmp_name'], $add1)){
// do your coding here to give a thanks message or any other thing.
$msg="File successfully uploaded";
}else{
echo "Failed to upload file Contact Site admin to fix the problem";
}
}else{
$msg .= " Failed to upload file ";
}
}
echo $msg;
/*file upload*/
/*file upload*/
if (!empty($_FILES[SESS_MASTER.'adimg2']['name'])){
$adimg2load_flag="true";
$adimg2_size=$_FILES[SESS_MASTER.'adimg2']['size'];
if ($_FILES[SESS_MASTER.'adimg2']['size']>2500000){
$msg=$msg."Your uploaded file size is more than 2500KB ";
$msg.=" so please reduce the file size and then upload.<BR>";
$adimg2load_flag="false";
}

// allow only jpeg or gif files, remove this if not required //
if (!($_FILES[SESS_MASTER.'adimg2']['type'] =="image/jpeg" OR $_FILES[SESS_MASTER.'adimg2']['type'] =="image/png"))
{$msg=$msg."Your uploaded file must be of JPG or GIF. ";
$msg.="Other file types are not allowed<BR>";
$adimg2load_flag="false";}

$file_name=$_FILES[SESS_MASTER.'adimg2']['name'];
// the path with the file name where the file will be stored
$temp = explode(".", $file_name);
$newfilename = round(microtime(true)) . '2.' . end($temp);
$add2="../../upload/".$newfilename; 

if($adimg2load_flag=="true"){ // checking the Flag value 

if(move_uploaded_file ($_FILES[SESS_MASTER.'adimg2']['tmp_name'], $add2)){
// do your coding here to give a thanks message or any other thing.
$msg="File successfully uploaded";
}else{
echo "Failed to upload file Contact Site admin to fix the problem";
}
}else{
$msg .= " Failed to upload file ";
}
}
//echo $msg;
/*file upload*/
/*file upload*/
if (!empty($_FILES[SESS_MASTER.'adimg3']['name'])){
$adimg3load_flag="true";
$adimg3_size=$_FILES[SESS_MASTER.'adimg3']['size'];
if ($_FILES[SESS_MASTER.'adimg3']['size']>2500000){
$msg=$msg."Your uploaded file size is more than 2500KB ";
$msg.=" so please reduce the file size and then upload.<BR>";
$adimg3load_flag="false";
}

// allow only jpeg or gif files, remove this if not required //
if (!($_FILES[SESS_MASTER.'adimg3']['type'] =="image/jpeg" OR $_FILES[SESS_MASTER.'adimg3']['type'] =="image/png"))
{$msg=$msg."Your uploaded file must be of JPG or GIF. ";
$msg.="Other file types are not allowed<BR>";
$adimg3load_flag="false";}

$file_name=$_FILES[SESS_MASTER.'adimg3']['name'];
// the path with the file name where the file will be stored
$temp = explode(".", $file_name);
$newfilename = round(microtime(true)) . '3.' . end($temp);
$add3="../../upload/".$newfilename; 

if($adimg3load_flag=="true"){ // checking the Flag value 

if(move_uploaded_file ($_FILES[SESS_MASTER.'adimg3']['tmp_name'], $add3)){
// do your coding here to give a thanks message or any other thing.
$msg="File successfully uploaded";
}else{
echo "Failed to upload file Contact Site admin to fix the problem";
}
}else{
$msg .= " Failed to upload file ";
}
}
//echo $msg;
/*file upload*/
/*file upload*/
if (!empty($_FILES[SESS_MASTER.'adimg4']['name'])){
$adimg4load_flag="true";
$adimg4_size=$_FILES[SESS_MASTER.'adimg4']['size'];
if ($_FILES[SESS_MASTER.'adimg4']['size']>2500000){
$msg=$msg."Your uploaded file size is more than 2500KB ";
$msg.=" so please reduce the file size and then upload.<BR>";
$adimg4load_flag="false";
}

// allow only jpeg or gif files, remove this if not required //
if (!($_FILES[SESS_MASTER.'adimg4']['type'] =="image/jpeg" OR $_FILES[SESS_MASTER.'adimg4']['type'] =="image/png"))
{$msg=$msg."Your uploaded file must be of JPG or GIF. ";
$msg.="Other file types are not allowed<BR>";
$adimg4load_flag="false";}

$file_name=$_FILES[SESS_MASTER.'adimg4']['name'];
// the path with the file name where the file will be stored
$temp = explode(".", $file_name);
$newfilename = round(microtime(true)) . '4.' . end($temp);
$add4="../../upload/".$newfilename; 

if($adimg4load_flag=="true"){ // checking the Flag value 

if(move_uploaded_file ($_FILES[SESS_MASTER.'adimg4']['tmp_name'], $add4)){
// do your coding here to give a thanks message or any other thing.
$msg="File successfully uploaded";
}else{
echo "Failed to upload file Contact Site admin to fix the problem";
}
}else{
$msg .= " Failed to upload file ";
}
}
//echo $msg;
/*file upload*/
if($stat==1){
    
  	$query1="  UPDATE google_code SET activestatus='0'"; 
  	       if(!empty($add1)){
  	        $query1 =  $query1." ,google_addis =Null" ;
  	       }
  	         if(!empty($add2)){
  	             $query1 =  $query1." ,google_adfeed =Null" ;
  	         }
  	          if(!empty($add3)){
  	             $query1 =  $query1." ,google_adar =Null" ;
  	         }
  	           if(!empty($add4)){
  	             $query1 =  $query1." ,google_ad4 =Null" ;
  	         }
  	       
		$stmtdel1 = $conn->prepare($query1);
		$stmtdel1->execute();
   
    echo $stat;
    
}



 if($_POST){
  try{
	   if($stat=='0'){

			$olgaquerys="INSERT INTO google_code SET adimg1='$add1',adimg2='$add2',
			adimg3='$add3',adimg4='$add4',activestatus='0'"; 
		$stmts = $conn->prepare($olgaquerys);
		if($stmts->execute()){

			$_SESSION["google_code"] = '34' ;
			
			 header("location:../google-adsense-code.php");

			}
	   }else{
         	$olgaquerys="UPDATE google_code SETgoogle_code  SET activestatus='0'"; 
			if(!empty($_FILES[SESS_MASTER.'adimg1']['name'])){
			   $olgaquerys=$olgaquerys.",adimg1='$add1'"; 
			}if(!empty($_FILES[SESS_MASTER.'adimg2']['name'])){
			     $olgaquerys=$olgaquerys.",adimg2='$add2'"; 
			}if(!empty($_FILES[SESS_MASTER.'adimg3']['name'])){
			     $olgaquerys=$olgaquerys.",adimg3='$add3'"; 
			}if(!empty($_FILES[SESS_MASTER.'adimg4']['name'])){
			     $olgaquerys=$olgaquerys.",adimg4='$add4'"; 
			}
		$stmts = $conn->prepare($olgaquerys);
		if($stmts->execute()){

			$_SESSION["google_code"] = '34' ;
			
			 header("location:../google-adsense-code.php");
		}
	   }
 
   }
         
        // show error
        catch(PDOException $exception){
            die('ERROR: ' . $exception->getMessage());
        }
    }


?>