<?php

 //return ; // أزل هذا الامر اذا اردت اعادة التثبيت


header('Content-Type: text/html; charset=utf-8');

 include '../config.php';
 $conn = mysqli_connect($HostName, $HostUser, $HostPass, $DatabaseName);	// الاتصال بقاعدة البيانات
 
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
	exit ;
} 

 $site = $_SERVER['HTTP_HOST'] ;
 $dateCreate = date("Y-m-d") ;
		
		
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////QUESTION

        //Create Table admin
         $sql = "CREATE TABLE QUESTION(
		 id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
		 question TEXT NULL,
		 a_1 VARCHAR(64) NULL,
		 a_2 VARCHAR(64) NULL,
		 a_3 VARCHAR(64) NULL,
		 a_4 VARCHAR(64) NULL,
         answer VARCHAR(64) NULL,
		 state VARCHAR(64) NULL,
         log TEXT NULL
		 )";
        if ($conn->query($sql) === TRUE) {
            echo "<br>Table QUESTION created successfully";		
        } else {echo "<br>Error creating table: " . $conn->error;}


		
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////USERS

         $sql = "CREATE TABLE USERS(
		 id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
		 fullname VARCHAR(64) NULL,
		 email VARCHAR(64) NULL,
		 pass VARCHAR(64) NULL,
		 stage VARCHAR(64) NULL,
		 log TEXT NULL,
         state VARCHAR(64) NULL,
		 ip VARCHAR(64) NULL,
         date_r VARCHAR(64) NULL
		 )";
        if ($conn->query($sql) === TRUE) {
            echo "<br>Table USERS created successfully";
        } else {echo "<br>Error creating table: " . $conn->error;}
		

///////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////// ADMIN
		
         $sql = "CREATE TABLE ADMIN(
		 id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
		 admin VARCHAR(64) NULL,
		 pass VARCHAR(64) NULL,
		 email VARCHAR(64) NULL,
		 stages VARCHAR(64) NULL,
		 ip VARCHAR(64) NULL,
         date_changes VARCHAR(64) NULL
		 )";
        if ($conn->query($sql) === TRUE) {
            echo "<br>Table ADMIN created successfully";
			
				$connn = mysqli_connect($HostName, $HostUser, $HostPass, $DatabaseName);	// الاتصال بقاعدة البيانات
		     	$sqlCreate = "INSERT INTO ADMIN (admin, pass, email , stages ,ip, date_changes)
				                         VALUES ('admin', 'e10adc3949ba59abbe56e057f20f883e', 'medsikb@gmail.com' , '5' , '127.0.0.1' ,'2020-03-03')";
                $connn->query($sqlCreate);
				
        } else {echo "<br>Error creating table: " . $conn->error;}

	
$conn->close();

?>

<!DOCTYPE html>
<html lang="en">
	<head>
		<title>Install And Cpanel</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
		<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	</head>
	<body>
<br>
<br>
		<div class="container">
			<div class="row">
				<div class="col-lg-6">
					<h2>Cpanel admin</h2>
					<hr />
					<form action="" method="post">

						<div class="form-group">
							<label for="firebase_api">Url: </label> <a href="../admin/" target="_blank" ><?php echo $site; ?>/admin/</a> <br>
							<label for="firebase_api">username: </label>admin<br>
							<label for="firebase_api">password: </label>123456<br>
						</div>

					</form>
				
				</div>

			</div>
		</div>

	</body>
	<footer>
		<p><center>© irba7ni.store</center></p>
	</footer>
</html>

