<?php
/*
Title: Droppy installation

Thanks to riliwanrabo for design
*/

error_reporting(0);

session_start();

$install_version = '1.4.5';
$time = time();

if($_POST['action'] == 'dbsettings') {
	$mysqli_test = new mysqli($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']);

	if ($mysqli_test->connect_errno ) {
		header('Location: install.php?page=1&db=error');
	}
	else
	{
		$db_file = file_get_contents(dirname(__FILE__) . '/config/db.php');
		$get_values = array(
			'#db_host#',
			'#db_user#',
			'#db_pass#',
			'#db_name#'
		);
		$change = array(
			$_POST['dbhost'],
			$_POST['dbuser'],
			$_POST['dbpass'],
			$_POST['dbname']
		);
		
		$db_config = str_replace($get_values, $change, $db_file);

		file_put_contents('config/db.php', $db_config);
		header('Location: install.php?action=inserttabledata');
	}
	$mysqli_test->close();
}
if($_GET['action'] == 'inserttabledata') {	
	require_once dirname(__FILE__) . '/config/config.php';
	if(dirname($_SERVER['PHP_SELF']) == '/') {
		$site = 'http://' . $_SERVER['SERVER_NAME'] . '/';
	}
	else
	{
		$site = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/';
	}

	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_accounts` (
					  `id` int(11) NOT NULL AUTO_INCREMENT,
					  `email` varchar(100) NOT NULL,
					  `password` varchar(100) NOT NULL,
					  `ip` varchar(100) NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_downloads` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `download_id` varchar(100) NOT NULL,
					  `time` int(100) NOT NULL,
					  `ip` varchar(100) NULL,
					  `email` varchar(100) NOT NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_files` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `upload_id` varchar(500) NOT NULL,
					  `secret_code` varchar(500) NOT NULL,
					  `file` varchar(500) NOT NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_settings` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `site_name` varchar(100) NULL,
					  `site_title` varchar(100) NULL,
					  `site_desc` varchar(200) NULL,
					  `site_url` varchar(100) NULL,
					  `lock_page` varchar(100) NULL,
					  `name_on_file` varchar(100) NULL,
					  `max_size` int(100) NULL,
					  `max_files` int(100) NULL,
					  `max_file_reports` int(100) NULL,
					  `blocked_types` varchar(1000) NULL,
					  `expire` int(100) NULL,
					  `upload_dir` varchar(100) NULL,
					  `favicon_path` varchar(100) NULL,
					  `logo_path` varchar(100) NULL,
					  `language` varchar(100) NULL,
					  `bg_timer` int(100) NULL,
					  `default_destruct` varchar(100) NULL,
					  `default_sharetype` varchar(100) NULL,
					  `default_email_to` varchar(100) NULL,
					  `password_enabled` varchar(100) NULL,
					  `analytics` text NULL,
					  `accept_terms` varchar(100) NULL,
					  `email_from_name` varchar(100) NULL,
					  `email_from_email` varchar(100) NULL,
					  `email_to_name` varchar(100) NULL,
					  `email_server` varchar(100) NULL,
					  `smtp_host` varchar(100) NULL,
					  `smtp_auth` varchar(100) NULL,
					  `smtp_secure` varchar(100) NULL,
					  `smtp_port` int(100) NULL,
					  `smtp_username` varchar(100) NULL,
					  `smtp_password` varchar(100) NULL,
					  `terms_text` text NULL,
					  `about_text` text NULL,
					  `ad_1_enabled` varchar(100) NULL,
					  `ad_1_code` text NULL,
					  `ad_2_enabled` varchar(100) NULL,
					  `ad_2_code` text NULL,
					  `purchase_code` varchar(100) NULL,
					  `version` varchar(100) NULL,
					  `last_update_check` int(100) NULL,
					  `encrypt_files` int(1) NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("INSERT INTO `$table_settings` (`id`, `site_name`, `site_title`, `site_desc`, `site_url`, `lock_page`, `name_on_file`, `max_size`, `max_files`, `max_file_reports`, `blocked_types`, `expire`, `upload_dir`, `favicon_path`, `logo_path`, `language`, `bg_timer`, `default_destruct`, `default_sharetype`, `default_email_to`, `password_enabled`, `accept_terms`, `email_from_name`, `email_from_email`, `email_to_name`, `email_server`, `smtp_host`, `smtp_auth`, `smtp_secure`, `smtp_port`, `smtp_username`, `smtp_password`, `terms_text`, `about_text`, `ad_1_enabled`, `ad_1_code`, `ad_2_enabled`, `ad_2_code`, `purchase_code`, `version`, `last_update_check`, `encrypt_files`) VALUES
	(1, 'Droppy', 'Droppy - Online file sharing', 'Online file sharing, share large or small files with friends and family.', '$site', 'false', 'droppy', 2048, '200', 0, 'image/bmp,application/exe', 0, 'uploads/', 'src/images/icon.png', 'src/images/logo.png', 'English.php', 60, 'no', 'mail', '', 'yes', 'no', 'No-Reply Droppy', 'noreply@example.com', 'Droppy User', 'LOCAL', '', '', '', '0', '', '', 'This is a example of an terms of service page', 'This is a example of an about page. Fill in your own information here.', 'false', 'Fill in your code here', 'false', 'Fill in your code here', '', '$install_version', '$time', '0');");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_social` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `facebook` varchar(100) NULL,
					  `twitter` varchar(100) NULL,
					  `google` varchar(100) NULL,
					  `instagram` varchar(100) NULL,
					  `github` varchar(100) NULL,
					  `tumblr` varchar(100) NULL,
					  `pinterest` varchar(100) NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("INSERT INTO `$table_social` (`id`, `facebook`, `twitter`, `google`, `instagram`, `github`, `tumblr`, `pinterest`) VALUES
					(1, 'http://facebook.com', 'http://twitter.com', 'http://google.com', '', '', '', '');");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_templates` (
					  `id` int(11) NOT NULL AUTO_INCREMENT,
					  `type` varchar(100) NOT NULL,
					  `msg` text NOT NULL,
					  `lang` varchar(100) NOT NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("INSERT INTO `$table_templates` (`type`, `msg`, `lang`) VALUES
						('receiver', 'Dear,\n\nYou have received some file(s) from {email_from} with a total size of {size} MB.\nThe file(s) will be destroyed after {expire_time}.\n\n<b>Files:</b>\n{file_list}\n\n<b>Message:</b>\n{message}\n\n{download_btn}\n\nBest regards,\n{site_name}', 'English.php'),
						('sender', 'Dear,\n\nThank you for using {site_name} the file(s) with a total of {size} MB have been sent to the recipients.\nIt will be destroyed after {expire_time}.\n\n<b>Files sent to:</b>\n{email_list}\n<b>Files sent:</b>\n{file_list}\n\n{download_btn}\n\nBest regards,\n{site_name}\n', 'English.php'),
						('destroyed', 'Dear,\n\nYour files on {site_name} have been destroyed.\n\n<b>Files destroyed:</b>\n{file_list}\n\n{download_btn}\n\nBest regards,\n{site_name}', 'English.php'),
						('downloaded', 'Dear,\n\nThis is just an email to let you know that {download_email} has downloaded your file.\n\n<b>Files:</b>\n{file_list}\n\n<b>Receivers:</b>\n{email_list}\n\n{download_btn}\n\nBest regards,\n{site_name}', 'English.php'),
						('receiver_subject', 'You have received some files !', 'English.php'),
						('sender_subject', 'Your items have been sent !', 'English.php'),
						('destroyed_subject', 'Your items have been destroyed !', 'English.php'),
						('downloaded_subject', 'Someone has downloaded your items !', 'English.php'),
						('receiver', 'Beste,\r\n\r\n{email_from} heeft u bestanden gestuurd met een totale grootte van {size} MB\r\nDe bestanden worden vernietigd over {expire_time}\r\n\r\n<b>Bestanden:</b>\r\n{file_list}\r\n\r\n<b>Bericht:</b>\r\n{message}\r\n\r\n{download_btn}\r\n\r\nMet vriendelijke groet,\r\n{site_name}', 'Dutch.php'),
						('sender', 'Beste,\r\n\r\nBedankt voor het gebruiken van {site_name}, de bestanden zijn succesvol naar de ontvangers gestuurd.\r\nDe bestanden worden vernietigd in {expire_time}\r\n\r\n<b>Verstuurd naar:</b>\r\n{email_list}\r\n<b>Bestanden verstuurd:</b>\r\n{file_list}\r\n\r\n{download_btn}\r\n\r\nMet vriendelijke groet,\r\n{site_name}\r\n', 'Dutch.php'),
						('destroyed', 'Beste,\r\n\r\nUw bestanden op {site_name} zijn vernietigd.\r\n\r\n<b>Bestanden vernietigd:</b>\r\n{file_list}\r\n<b>Bestanden waren verstuurd  naar:</b>\r\n{email_list}\r\n\r\nMet vriendelijke groet,\r\n{site_name}', 'Dutch.php'),
						('downloaded', 'Beste,\r\n\r\nDit is een email om u ervan op hoogte te stellen dat {download_email} uw bestanden heeft gedownload.\r\n\r\n<b>Bestanden:</b>\r\n{file_list}\r\n\r\n<b>Ontvangers:</b>\r\n{email_list}\r\n\r\n{download_btn}\r\n\r\nMet vriendelijke groet,\r\n{site_name}', 'Dutch.php'),
						('receiver_subject', 'U heeft bestanden ontvangen', 'Dutch.php'),
						('sender_subject', 'Uw bestanden zijn verzonden', 'Dutch.php'),
						('destroyed_subject', 'Uw bestanden zijn vernietigd', 'Dutch.php'),
						('downloaded_subject', 'Iemand heeft uw bestanden gedownload.', 'Dutch.php');");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_uploads` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `upload_id` varchar(200) NOT NULL,
					  `email_from` varchar(500) NULL,
					  `message` varchar(5000) NULL,
					  `secret_code` varchar(500) NOT NULL,
					  `password` varchar(100) NULL,
					  `status` varchar(100) NOT NULL,
					  `size` varchar(100) NOT NULL,
					  `time` int(100) NOT NULL,
					  `time_expire` int(100) NULL,
					  `ip` varchar(100) NULL,
					  `count` int(100) NOT NULL,
					  `share` varchar(100) NOT NULL,
					  `destruct` varchar(100) NULL,
					  `flag` varchar(100) NULL,
					  `lang` varchar(100) NULL,
					  `encrypt` varchar(500) NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_backgrounds` (
					  `id` int(11) NOT NULL AUTO_INCREMENT,
					  `src` varchar(100) NOT NULL,
					  `url` varchar(100) NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB  DEFAULT CHARSET=utf8;");
	$mysqli->query("INSERT INTO `$table_backgrounds` (`id`, `src`, `url`) VALUES
					(1, 'src/images/bg3.jpg', 'http://proxibolt.com'),
					(2, 'src/images/bg2.jpg', 'http://proxibolt.com');");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_receivers` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `upload_id` varchar(100) NOT NULL,
					  `email` varchar(100) NOT NULL,
					  `private_id` varchar(200) NOT NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=MyISAM  DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_language` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `name` varchar(100) NOT NULL,
					  `path` varchar(100) NOT NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("INSERT INTO `$table_language` (`name`, `path`) VALUES
					('English', 'English.php'),
					('Dutch', 'Dutch.php');");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_plugins` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `name` varchar(100) NOT NULL,
					  `path` varchar(200) NOT NULL,
					  `status` varchar(100) NULL,
					  `version` varchar(100) NOT NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_users` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `email` varchar(100) NOT NULL,
					  `password` varchar(100) NOT NULL,
					  `ip` varchar(100) NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE IF NOT EXISTS `$table_themes` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `name` varchar(100) NOT NULL,
					  `path` varchar(200) NOT NULL,
					  `status` varchar(50) NOT NULL,
					  PRIMARY KEY (id)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("INSERT INTO `$table_themes` (`id`, `name`, `path`, `status`) VALUES
					(1, 'Default', 'default/', 'ready'),
					(2, 'OldTimer', 'oldtimer/', 'stopped'),
					(3, 'Grey-Dark', 'grey/', 'stopped');");
	$mysqli->query("CREATE TABLE `$table_log` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `time` int(100) NOT NULL,
					  `msg` text NULL,
					  primary key (id)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE `$table_pages` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `type` varchar(100) NOT NULL,
					  `title` varchar(200) NOT NULL,
					  `parent` varchar(100) NOT NULL,
					  `path` varchar(200) NOT NULL,
					  `custom_html` varchar(500) NOT NULL,
					  primary key (id)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE `$table_popups` (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `title` varchar(100) NOT NULL,
					  `path` varchar(100) NOT NULL,
					  primary key (id)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
	$mysqli->query("CREATE TABLE IF NOT EXISTS $table_updates (
					  `id` int(100) NOT NULL AUTO_INCREMENT,
					  `version` varchar(100) NOT NULL,
					  `type` varchar(100) NOT NULL,
					  `date` varchar(100) NOT NULL,
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB DEFAULT CHARSET=utf8;");

	header('Location: install.php?page=2&db=ok');
}
if($_POST['action'] == 'p_code') {
	function post_to_url($url, $data) {
	    $fields = '';
	    foreach ($data as $key => $value) {
	        $fields .= $key . '=' . $value . '&';
	    }
	    rtrim($fields, '&');

	    $post = curl_init();

	    curl_setopt($post, CURLOPT_URL, $url);
	    curl_setopt($post, CURLOPT_POST, count($data));
	    curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
	    curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);

	    $result = curl_exec($post);

	    curl_close($post);
	    return $result;
	}

	$data = array(
	    "purchase_code" => $_POST['code'],
	    "ip" => $_SERVER['SERVER_ADDR']
	);

	$surl = 'http://api.proxibolt.com/verify/droppy/install_verify.php';
	$res = post_to_url($surl, $data);

	if($res == '2') {
		$_SESSION['p'] = '2';
		header('Location: install.php?page=1');
	}
	elseif($res == 'valid') {
		header('Location: install.php?page=validate&p=2');
	}
	elseif($res == '3') {
		header('Location: install.php?page=validate&p=3');
	}
}
if($_POST['action'] == 'createuser') {
	include dirname(__FILE__) . '/config/config.php';
	$email = mysqli_real_escape_string($mysqli, $_POST['email']);
	$password = md5(mysqli_real_escape_string($mysqli, $_POST['password']));
	$ip = $_SERVER['REMOTE_ADDR'];

	$mysqli->query("INSERT INTO $table_accounts (`email`, `password`, `ip`) VALUES ('$email','$password','$ip')");
	header('Location: install.php?page=3&user=ok');
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
	<link href="src/css/bootstrap/bootstrap.css" rel="stylesheet">
	<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
	<!--<link href="../css/install.css" rel="stylesheet">-->
	<style>
		@import url(http://fonts.googleapis.com/css?family=Roboto+Condensed:400,700);

		body { 
		  background: url('https://www.toptal.com/designers/subtlepatterns/patterns/sayagata-400px.png');
		}

		.board{
		    width: 75%;
			margin: 60px auto;
			height: 550px;
			background: #fff;
			/*box-shadow: 10px 10px #ccc,-10px 20px #ddd;*/
		}
		.board .nav-tabs {
		    position: relative;
		    /* border-bottom: 0; */
		    /* width: 80%; */
		    margin: 40px auto;
		    margin-bottom: 0;
		    box-sizing: border-box;

		}

		.board > div.board-inner{
		    background: #fafafa url(http://subtlepatterns.com/patterns/geometry2.png);
		    background-size: 30%;
		}

		p.narrow{
		    width: 60%;
		    margin: 10px auto;
		}

		.liner{
		    height: 2px;
		    background: #ddd;
		    position: absolute;
		    width: 50%;
		    margin: 0 auto;
		    left: 0;
		    right: 0;
		    top: 50%;
		    z-index: 1;
		}

		.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
		    color: #555555;
		    cursor: default;
		    /* background-color: #ffffff; */
		    border: 0;
		    border-bottom-color: transparent;
		}

		span.round-tabs{
		    width: 70px;
		    height: 70px;
		    line-height: 70px;
		    display: inline-block;
		    border-radius: 100px;
		    background: white;
		    z-index: 2;
		    position: absolute;
		    left: 0;
		    text-align: center;
		    font-size: 25px;
		}

		span.round-tabs.one{
		    color: rgb(34, 194, 34);border: 2px solid rgb(34, 194, 34);
		}

		li.active span.round-tabs.one{
		    background: #fff !important;
		    border: 2px solid #ddd;
		    color: rgb(34, 194, 34);
		}

		span.round-tabs.two{
		    color: #febe29;border: 2px solid #febe29;
		}

		li.active span.round-tabs.two{
		    background: #fff !important;
		    border: 2px solid #ddd;
		    color: #febe29;
		}

		span.round-tabs.three{
		    color: #3e5e9a;border: 2px solid #3e5e9a;
		}

		li.active span.round-tabs.three{
		    background: #fff !important;
		    border: 2px solid #ddd;
		    color: #3e5e9a;
		}

		span.round-tabs.four{
		    color: #f1685e;border: 2px solid #f1685e;
		}

		li.active span.round-tabs.four{
		    background: #fff !important;
		    border: 2px solid #ddd;
		    color: #f1685e;
		}

		span.round-tabs.five{
		    color: #999;border: 2px solid #999;
		}

		li.active span.round-tabs.five{
		    background: #fff !important;
		    border: 2px solid #ddd;
		    color: #999;
		}

		.nav-tabs > li.active > a span.round-tabs{
		    background: #fafafa;
		}
		.nav-tabs > li {
		    width: 20%;
		}
		/*li.active:before {
		    content: " ";
		    position: absolute;
		    left: 45%;
		    opacity:0;
		    margin: 0 auto;
		    bottom: -2px;
		    border: 10px solid transparent;
		    border-bottom-color: #fff;
		    z-index: 1;
		    transition:0.2s ease-in-out;
		}*/
		li:after {
		    content: " ";
		    position: absolute;
		    left: 45%;
		   opacity:0;
		    margin: 0 auto;
		    bottom: 0px;
		    border: 5px solid transparent;
		    border-bottom-color: #ddd;
		    transition:0.1s ease-in-out;
		    
		}
		li.active:after {
		    content: " ";
		    position: absolute;
		    left: 45%;
		   opacity:1;
		    margin: 0 auto;
		    bottom: 0px;
		    border: 10px solid transparent;
		    border-bottom-color: #ddd;
		    
		}
		.nav-tabs > li a{
		   width: 70px;
		   height: 70px;
		   margin: 20px auto;
		   border-radius: 100%;
		   padding: 0;
		}

		.nav-tabs > li a:hover{
		    background: transparent;
		}

		.tab-content{
		}
		.tab-pane{
		   position: relative;
			padding-top: 10px;
		}
		.tab-content .head{
		    font-family: 'Roboto Condensed', sans-serif;
		    font-size: 25px;
		    text-transform: uppercase;
		    padding-bottom: 10px;
		}
		.btn-outline-rounded{
		    padding: 10px 40px;
		    margin: 20px 0;
		    border: 2px solid transparent;
		    border-radius: 25px;
		}

		.btn.green{
		    background-color:#5cb85c;
		    /*border: 2px solid #5cb85c;*/
		    color: #ffffff;
		}



		@media( max-width : 585px ){
		    
		    .board {
		width: 90%;
		height:auto !important;
		}
		    span.round-tabs {
		        font-size:16px;
		width: 50px;
		height: 50px;
		line-height: 50px;
		    }
		    .tab-content .head{
		        font-size:20px;
		        }
		    .nav-tabs > li a {
		width: 50px;
		height: 50px;
		line-height:50px;
		}

		li.active:after {
		content: " ";
		position: absolute;
		left: 35%;
		}

		.btn-outline-rounded {
		    padding:12px 20px;
		    }
		}
	</style>
</head>
<body>
<section style="background-color: transparent;">
        <div class="container">
            <div class="row">
                <div class="board">
                    <div class="board-inner">
                    <ul class="nav nav-tabs" id="myTab" style="padding-left: 140px">
                    <div class="liner"></div>
                    <?php
                    if(!isset($_GET['page'])) {
                    	echo '<li class="active">';
                    }
                    else
                    {
                    	echo '<li>';
                    }
                    ?>
	                     <a title="Welcome">
	                      <span class="round-tabs one">
                                <i class="glyphicon glyphicon-home"></i>
	                      </span> 
	                 	 </a>
	             	 </li>

	             	<?php
	                if($_GET['page'] == '1') {
                    	echo '<li class="active">';
                    }
                    else
                    {
                    	echo '<li>';
                    }
                    ?>
	                  	<a title="Database settings">
	                     <span class="round-tabs two">
	                        <i class="fa fa-database"></i>
	                     </span> 
	           			</a>
	                 </li>
	                 <?php
	                if($_GET['page'] == '2') {
                    	echo '<li class="active">';
                    }
                    else
                    {
                    	echo '<li>';
                    }
                    ?>
	                 	<a title="Create admin user">
	                     <span class="round-tabs three">
	                          <i class="glyphicon glyphicon-user"></i>
	                     </span> 
	                    </a>
	                 </li>

	                 <?php
	                if($_GET['page'] == '43') {
                    	echo '<li class="active">';
                    }
                    else
                    {
                    	echo '<li>';
                    }
                    ?>
	                 	<a title="Success">
	                     <span class="round-tabs five">
	                          <i class="glyphicon glyphicon-ok"></i>
	                     </span> 
	                    </a>
	                 </li>
                     
                     </ul></div>

                     <div id="tab-content">
                      <div class="tab-pane" id="home">
                      <?php
                      	if(!isset($_GET['page'])) :
                      		$total_checks = 0;
                      ?>
                  		<div style="padding-top: 60px;">
                          <h3 class="head text-center">Droppy installation</h3>
                          <p class="narrow text-center">
                              Thank you for purchasing our product, before you can use Droppy you need to follow these small steps.
                          </p>
                          <hr>
                          <p class="narrow text-center"><strong style="font-size: 20px;">Requirements:</strong><br>
                          	<?php if(function_exists('mysqli_connect')) { echo '<i class="fa fa-check"></i>'; $total_checks++; } else { echo '<i class="fa fa-times"></i>'; } ?> MySqli installed <br>
                          	<?php if(function_exists('curl_version')) { echo '<i class="fa fa-check"></i>'; $total_checks++; } else { echo '<i class="fa fa-times"></i>'; } ?> PHP Curl installed <br>
                          	<?php if(file_exists(dirname(__FILE__) . '/.htaccess')) { echo '<i class="fa fa-check"></i>'; $total_checks++; } else { echo '<i class="fa fa-times"></i>'; } ?> .htaccess file found <br>
                          </p>

                          <p class="text-center">
                          	<?php
                          	if($total_checks == 3) :
                          	?>
                    		<a href="?page=validate" class="btn btn-success btn-outline-rounded green"> Start the installation</a>
                    		<?php
                    		else:
                    		?>
                    		<a href="?page=validate" onclick="return confirm('Are you sure you want to proceed even though the requirements are not correct ?');" class="btn btn-danger btn-outline-rounded red"> Start install without all the correct requirements</a>
                    		<?php
                    		endif;
                    		?>
            			  </p>
                      	</div>
                      <?php
                      	endif;
                      	if($_GET['page'] == 'validate') :
                      		if($_GET['p'] == '2') {
                  	  			echo '<div class="alert alert-danger" role="alert" style="margin-right: auto; margin-left: auto; width: 70%; text-align: center;">Purchase code incorrect</div>';
                  	  		}
                  	  		if($_GET['p'] == '3') {
                  	  			echo '<div class="alert alert-danger" role="alert" style="width: 80%; margin-right: auto; margin-left: auto;">Droppy and this purchase code are already in use on another IP address, if you would like to use Droppy on two systems you will need to purchase another license <a href="http://codecanyon.net/item/droppy-online-file-sharing/10575317">here</a></div>';
                  				echo '<div class="alert alert-warning" role="alert" style="width: 80%; margin-right: auto; margin-left: auto;">If you would like to transfer Droppy over to another IP address you will need to contact us <a href="http://support.proxibolt.com">here</a>.</div>';
                  	  		}
                      ?>
                  		<h3 style="text-align: center;">Droppy validate purchase</h3>
                  		<form method="POST" action='install.php'>
                          <div class="narrow text-center" style="margin-left: auto; margin-right: auto; width: 70%; padding-top: 20px;">
							<input type="hidden" name="action" value="p_code">
                            <div class="input-group" style="padding-top: 10px;">
                            	<div class="input-group-addon"><i class="fa fa-lock"></i></div>
								<input type="text" class="form-control" name="code" placeholder="Purchase code" required="required">
							</div>
							<p><i>Don't know where to find your purchase code ? Please give a look to this article: <a href="https://help.market.envato.com/hc/en-us/articles/202822600-Where-Can-I-Find-my-Purchase-Code-">here</a></i></p>
                          </div>
                          <p class="text-center">
                    		<input type="submit" class="btn btn-success btn-outline-rounded green" value="Submit">
            			  </p>
            			  </form>
                  	  <?php
                  	  	endif;
                      	if($_GET['page'] == 1 && $_SESSION['p'] == '2') :
                      		if($_GET['db'] == 'error') {
                  	  			echo '<div class="alert alert-danger" role="alert" style="margin-right: auto; margin-left: auto; width: 70%; text-align: center;">Droppy could not connect to the database please try again !</div>';
                  	  		}
                      ?>
                  		<h3 style="text-align: center;">Droppy database settings</h3>
                  		<form method="POST" action='install.php'>
                          <div class="narrow text-center" style="margin-left: auto; margin-right: auto; width: 70%; padding-top: 20px;">
 								<input type="hidden" name="action" value="dbsettings">
	                            <div class="input-group" style="padding-top: 10px;">
	                            	<div class="input-group-addon"><i class="fa fa-database"></i></div>
									<input type="text" class="form-control" name="dbhost" placeholder="Database host" required="required">
								</div>
								<div class="input-group" style="padding-top: 10px;">
									<div class="input-group-addon"><i class="fa fa-database"></i></div>
									<input type="text" class="form-control" name="dbuser" placeholder="Database username" required="required">
								</div>
								<div class="input-group" style="padding-top: 10px;">
									<div class="input-group-addon"><i class="fa fa-database"></i></div>
									<input type="password" class="form-control" name="dbpass" placeholder="Database password" required="required">
								</div>
								<div class="input-group" style="padding-top: 10px;">
									<div class="input-group-addon"><i class="fa fa-database"></i></div>
									<input type="text" class="form-control" name="dbname" placeholder="Database name" required="required">
								</div>
							
                          </div>
                          <p class="text-center">
                    		<input type="submit" class="btn btn-success btn-outline-rounded green" value="Submit">
            			  </p>
            			  </form>
                  	  <?php
                  	  	endif;
                  	  	if($_GET['page'] == 2 && $_SESSION['p'] == '2') :
                  	  ?>
                  		<h3 style="text-align: center;">Create admin user</h3>
                  		<form method="POST" action='install.php'>
                          <div class="narrow text-center" style="margin-left: auto; margin-right: auto; width: 70%; padding-top: 20px;">
 								<input type="hidden" name="action" value="createuser">
	                            <div class="input-group" style="padding-top: 10px;">
	                            	<div class="input-group-addon"><i class="fa fa-user"></i></div>
									<input type="email" class="form-control" name="email" placeholder="Admin e-mail" required="required">
								</div>
								<div class="input-group" style="padding-top: 10px;">
									<div class="input-group-addon"><i class="fa fa-lock"></i></div>
									<input type="password" class="form-control" name="password" placeholder="Admin password" required="required">
								</div>
	                      </div>
	                      <p class="text-center">
	                		<input type="submit" class="btn btn-success btn-outline-rounded green" value="Create user">
	        			  </p>
	        			  </form>
                  	  <?php
                  	  	endif;
                  	  	if($_GET['page'] == 3 && $_SESSION['p'] == '2') :
                  	  ?>
                  		<h3 style="text-align: center;">Completed !</h3>
                  		<div style="padding-top: 40px; text-align: center;">
                  			<p>The installation of droppy has been finished successfully !</p>
                  			<p>You can login to your admin panel <a href="admin/index.php">here</a>.</p>
                  			<p>Do not forget to delete this file (install.php) !</p>
                  		</div>
                  		<p class="text-center">
	                		<a href="index.php" class="btn btn-success btn-outline-rounded green"><i class="glyphicon glyphicon-home"></i> Go to home page</a>
	        			</p>
                  	  <?php
                  	  	endif;
                  	  ?>
					  </div>
<div class="clearfix"></div>
</div>

</div>
</div>
</div>
</section>
</body>

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="src/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(function(){
$('a[title]').tooltip();
});

</script>