


<?php

$error = "";

require 'config.php';


$db_handle = mysqli_connect(DB_SERVER, DB_USER, DB_PASS);

//$database = $_SESSION['database'];
$database = "lawpedc3_lbs_users";


$db_found = mysqli_select_db($db_handle, $database);


//this script is to check if database parameters has alredy been taken
$db_found_db = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );
			
		//$SQL = "DELETE FROM product_table WHERE product_id=$txnid";
   //$query_del = mysqli_query($db_handle, $SQL);



  
if($db_found){
if(isset($_POST['A']))
{
//	    $biz_name = $_POST['biz_name'];
//		$biz_nature = $_POST['biz_nature'] ;
		$admin_name = $_POST['admin_name'] ;
	
		$nation = $_POST['nation'] ;
		$city = $_POST['city'] ;
		//$address = $_POST['address'] ;
		$fone = $_POST['fone'] ;
		$email = $_POST['email'] ;
	
		$user_name=$_POST['pass'];
    	$pass=$_POST['pass'];
		$re_pass=$_POST['re_pass'];
		
	
	
	//$d_b=  'lawpedc3_'.str_shuffle($pass); 

	
	$d_b= 'lawpedc3_2i2ad20vd';
	
	
	
	
	$db_size=$_POST['db_size'];
	
		$app_code = "BM".rand(1000,10000);
		//$app_code ="LBS7777";
	 	$app_name =$_POST['app_name'];
	
	 	$privilage =$_POST['privilage'];
	 	$status =$_POST['status'];
	
	$product_key =$_POST['product_key'];
	
	 	$date = date("Y-m-d");
		
	
		
	
	 if($admin_name=="" or $nation=="" or $city==""or $fone =="" or $pass =="" or $re_pass=="" )
		
			{
					$error = "OPERATION FAILED|| one of the fields is blank";
			}
	
	
		
	
	
		else if($pass!=$re_pass )
	
		{
			$error = "OPERATION FAILED||passwords mis-matched";
		}
			
			
		
			 
			
				
		
		
	
			
			else if ($db_found_db) {
				
				//$database = "lawpedc3_lbs_users";


	$SQL = $db_found_db->prepare('SELECT L1 FROM login WHERE L1 = ?');
	$SQL->bind_param('s', $pass);
	$SQL->execute();
	$result = $SQL->get_result();
				
	$SQL_lbs = $db_found_db->prepare('SELECT app_code FROM login WHERE app_code = ?');
	$SQL_lbs->bind_param('s', $app_code);
	$SQL_lbs->execute();
	$result_lbs = $SQL_lbs->get_result();
				
		
				
			//phone number check
		
				
				$SQL_f = $db_found_db->prepare('SELECT fone FROM login WHERE fone = ?');
	$SQL_f->bind_param('s', $fone);
	$SQL_f->execute();
	$result_f = $SQL_f->get_result();
				
				

		if ($result->num_rows == 1) {
 			
			//$errorMessage = "incorrect password";
			
			$db_field = $result->fetch_assoc();
			
			$error = "OPERATION FAILED||Password Not Suitable";

			
		}
				
			
				
				else if ($result_lbs->num_rows == 1) {
 			
			//$errorMessage = "incorrect password";
			
			$db_field_lbs = $result_lbs->fetch_assoc();
			
			$error = " OPERATION FAILED||please restart all over again <br> Dont change anything";

			
		}
				
				
				
				else if ($result_f->num_rows == 1) {
 			
			//$errorMessage = "incorrect password";
			
			$db_field_f = $result_f->fetch_assoc();
			
			$error = " OPERATION FAILED||please this phone number has been used. change it. thanks";

			
		}
				
				
				
				
				
	
		
				
				
				
					
			
		else{
			
			
			$background_color = "#440dab";
			$text_color = "#fbfaff";
			$bottom_background = "pink";
			$bottom_textcolor = "black";

			
			
			
			$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );
	
			/*$SQL = $db_found->prepare("INSERT INTO login (biz_name,biz_nature,name,nation,city,fone,email,L1,L2,d_b,db_size,app_code,app_name,privilage,status,date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			$SQL->bind_param('ssssssssssssssss',$biz_name,$biz_nature, $admin_name,$nation,$city,$fone,$email,$user_name,$pass,$d_b,$db_size,$app_code,$app_name,$privilage,$status,$date);
			$SQL->execute();*/
			
			
			
			
			$SQL = $db_found->prepare("INSERT INTO login (name,nation,city,fone,email,L1,L2,d_b,db_size,app_code,app_name,privilage,status,date,key_update,background_color,text_color,bottom_background,bottom_textcolor) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
			$SQL->bind_param('sssssssssssssssssss',$admin_name,$nation,$city,$fone,$email,$user_name,$pass,$d_b,$db_size,$app_code,$app_name,$privilage,$status,$date,$product_key,$background_color,$text_color,$bottom_background,$bottom_textcolor);
			$SQL->execute();
			
			//email function
			
  		
			
   ini_set("sendmail_from", "lbs@lawped.com.ng");  
   $to = $email.",lbs@lawped.com.ng";//change receiver address  
   $subject = "LBS";  
   $message = 'FTP:'.$pass.', App Code:'.$app_code;  
   $header = "From:lbs@lawped.com.ng\r\n";  
  
   $result = mail ($to,$subject,$message,$header);  
  
   if( $result == true ){  
     	$error = "App build Successfully<br>Check ur Email"; 
	   
	   header ("Location: inactive.php?txnfailed=$error");
   }
			else{  
     	$error = "App Buid Successfully<br> Unable to send you an email"; 
	   
	   header ("Location: inactive.php?txnfailed=$error");
   }  


			
			
			
			//header ("Location: inactive.php");
			
			//$error = "no blank";
		
		
		
		
		
		
		
	}
	
				
				
				
				
				
				
				
				
				
				
				
				
				
	}

			
			
			
		
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
		
	
	
	
	

	
	
	
	
	
	
	
}
	  
	  
	// header ("Location: inventory_ac.php");

	 
	  
  
  }
	  
  
else{
	
	$error =  "database not found";

	}

 


?>






	<html>
		
			<title>Business Manager</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->	
		 <link href="css/bootstrap-4.4.1.css" rel="stylesheet">
		 <link href="css/popup.css" rel="stylesheet">
		
		
		
	<head>



	</head>
		
	
		<style>
			.loader {
  border: 16px solid #f3f3f3;
  border-radius: 30%;
  border-top: 5px solid blue;
  border-right: 5px solid green;
  border-bottom: 5px solid red;
  border-left: 5px solid yellow;
  width: 40px;
  height: 40px;
  -webkit-animation: spin 2s linear infinite;
  animation: spin 1s linear infinite;
}

		
		
@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

			
			
			
		
		body, html {
background-color: #E1E1DF;
		//	background: image();
			}
		</style>
	
		<body onLoad="<?php echo "customAlert.alert('$error','BM App Builder')"; ?>, spinner()">


			

	
			<div class="jumbotron" style="text-align: center">
		
		
		
		
		<div class="row">
			
			
			
		
					<div class="col-md-4">
			</div>
			
			
			
			<div class="col-md-4">
				
				
					
				
		
				
			
				
		 			<span style="background-color: black; color: white;">  <?php echo $error; ?></span>
			<h3><b><span style="color: #8996C9">BUSINESS <span style="color: red">MANAGER</span> </b></h3>
				
					<form METHOD ="POST" ACTION = "user_reg.php" >
				
						
						<input type="hidden" value="LBS" name="app_name">
						<input type="hidden" value="admin" name="privilage">
						<input type="hidden" value="active125" name="status">
						<input type="hidden" value="1000" name="db_size">
						
							<input type="hidden" value="Product Key" name="product_key">
						
						
										
										
										
										
										
										<div class="input-group mb-3" style="margin-top: 40px">
  					

											<input type="text" class="form-control" placeholder="Full Name  " aria-label="Username" aria-describedby="basic-addon1" name="admin_name" value="">

											<input type="text" class="form-control" placeholder="Nationality" aria-label="Username" aria-describedby="basic-addon1" value="" name="nation">
										</div>
										
										
										
										
										
										
										
										
										
										
										
										
										
									
										
										<div class="input-group mb-3">
											
									
										
										
											<input type="email" class="form-control" placeholder="Email" aria-label="Username" aria-describedby="basic-addon1" value= "" name = "email">
											
											<input type = "number" class = "form-control" placeholder= "Phone No" aria-label="Username" aria-describedby="basic-addon1" value="" name="fone">
				
										</div>
										
										
										
										
										
										
	
										<div class="input-group mb-3">
											
											
												
										
										
										
												
													<textarea cols="50" rows = "3" style="width:100%" placeholder="Owners Address" class="form-control" aria-label="Amount (to the nearest dollar)" name="city"></textarea>
				
										</div>
										
										
										
								
										
										
										<label><i> Password</i></label>
										
										<div class="input-group mb-3">
											
											<div class="input-group-prepend">
				
											
					
											</div>
											
											<input type="password" placeholder= "password" class="form-control"  aria-label="Username" aria-describedby="basic-addon1"  name="pass">
										
											<input type="password" class="form-control" placeholder="Retype-Password" aria-label="Username" aria-describedby="basic-addon1" value="" name="re_pass">
												
												
												
												
										
												
				
										</div>
										
										
									
										
							
				<div>
					
					
					
					
					
							<div class="input-group mb-3">
											
									
											
												<input type="submit" value="                    Build APP with Ai                 "  name = "A" style= "width:100%; height: 40px" class="btn btn-info" onClick="spinner()" > 
										
										<a href = "../login.php"><input type="button" value=" BACK "  name = "" style= "width:100% height: " class="" onClick="spinner()"> </a>
												
												
												
												
										
												
				
										</div>
					
					
					
					
					
					
					
							
							<div class="loader" id="load" style="margin: auto"></div>
							
							
					
											
							
					</form>
		
		        
					
					
				
				
				
				
			</div>
			
			
			
				
				
				<div class="col-md-4">
			</div>
			
			
	
		</div>
			
			
			
			
			
			
			</div>
			
	
		
			

	
		</body>
	
		</html>
<script>


		function spinner() {
  
			var x = document.getElementById("load");
	
	
	
  if (x.style.display === "none") {
    x.style.display = "block ";
	  
	  
  }
	else {
    x.style.display = "none";
  }
	
	
}
	
		
		
		


</script>



<script>
	
	//pop scripts
	
	
function CustomAlert(){
  this.alert = function(message,title){
    document.body.innerHTML = document.body.innerHTML + '<div id="dialogoverlay"></div><div id="dialogbox" class="slit-in-vertical"><div><div id="dialogboxhead"></div><div id="dialogboxbody"></div><div id="dialogboxfoot"></div></div></div>';

    let dialogoverlay = document.getElementById('dialogoverlay');
    let dialogbox = document.getElementById('dialogbox');
    
    let winH = window.innerHeight;
    dialogoverlay.style.height = winH+"px";
    
    dialogbox.style.top = "100px";

    dialogoverlay.style.display = "block";
    dialogbox.style.display = "block";
    
    document.getElementById('dialogboxhead').style.display = 'block';

    if(typeof title === 'undefined') {
      document.getElementById('dialogboxhead').style.display = 'none';
    } else {
      document.getElementById('dialogboxhead').innerHTML = '<i class="fa fa-exclamation-circle" aria-hidden="true"></i> '+ title;
    }
    document.getElementById('dialogboxbody').innerHTML = message;
    document.getElementById('dialogboxfoot').innerHTML = '<button class="pure-material-button-contained active" onclick="customAlert.ok()">OK</button>';
  }
  
  this.ok = function(){
    document.getElementById('dialogbox').style.display = "none";
    document.getElementById('dialogoverlay').style.display = "none";
  }
}

let customAlert = new CustomAlert();
	</script>