<?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';

$google_addis=   $_REQUEST[SESS_MASTER.'google_addis'];
$google_adfeed	=$_REQUEST[SESS_MASTER.'google_adfeed'];
$google_adar=   $_REQUEST[SESS_MASTER.'google_adar'];
$google_ad4	=  $_REQUEST[SESS_MASTER.'google_ad4'];
$stat	=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'stat']);
if($stat==1){
    
  	$query1="  UPDATE google_code SET activestatus='0'"; 
  	       if(!empty($google_addis)){
  	        $query1 =  $query1." ,adimg1 =Null" ;
  	       }
  	         if(!empty($google_adfeed)){
  	             $query1 =  $query1." ,adimg2 =Null" ;
  	         }
  	          if(!empty($google_adar)){
  	             $query1 =  $query1." ,adimg3 =Null" ;
  	         }
  	           if(!empty($google_ad4)){
  	             $query1 =  $query1." ,adimg4 =Null" ;
  	         }
  	       
		$stmtdel1 = $conn->prepare($query1);
		$stmtdel1->execute();
   
    echo $stat;
    
}

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

			$olgaquerys="INSERT INTO google_code SET createdIp='$myIp',datecreated='$dateceated',createdby='$createdby',google_addis='$google_addis',google_adfeed='$google_adfeed',
			google_adar='$google_adar',google_ad4='$google_ad4',activestatus='0'"; 
		$stmts = $conn->prepare($olgaquerys);
		if($stmts->execute()){

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

			}
	   }else{
         	$olgaquerys="UPDATE google_code SET createdIp='$myIp',datecreated='$dateceated',createdby='$createdby',google_addis='$google_addis',google_adfeed='$google_adfeed',
			google_adar='$google_adar',google_ad4='$google_ad4',activestatus='0'"; 
		$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());
        }
    }


?>