<style>.top-bar-minimize{display:none;}
thead, tfoot {display: table-header-group;}
.top-bar+.well,.accordion .accordion-heading+.accordion-body{display: inline-block !important;width: 100% !important;overflow: inherit !important;} 
</style>
<?php
if($_POST){
	//ENTER THE RELEVANT INFO BELOW
	$mysqlDatabaseName = $database;
	$mysqlUserName = $mysql_user;
	$mysqlPassword = $password;
	$mysqlHostName = $database_host;
	
	
	$mysqlImportFilename ='';
	if(isset($_FILES["photo"]["name"]) && !empty($_FILES["photo"]["name"])){
		$lfilename = basename($_FILES['photo']['name']);
		$lext = strtolower(substr($lfilename, strrpos($lfilename, '.')+1));
		if(in_array($lext,array('sql')))
		{
			$lnewfile=md5(microtime()).".".$lext;
			if(move_uploaded_file($_FILES['photo']['tmp_name'],"media/".$lnewfile))
			{
				$filename="media/".$lnewfile;
				//////////////////////////**************setting backup table***********////////////////////////////
				$db->query("CREATE TABLE temp_settings AS SELECT * FROM settings");
				////////////////////////////**********************////////////////////////////////
				// Temporary variable, used to store current query
				$templine = '';
				// Read in entire file
				$lines = file($filename);
				// Loop through each line
				foreach ($lines as $line)
				{
					// Skip it if it's a comment
					if (substr($line, 0, 2) == '--' || $line == '')
						continue;
					
					// Add this line to the current segment
					$templine .= $line;
					// If it has a semicolon at the end, it's the end of the query
					if (substr(trim($line), -1, 1) == ';')
					{
						// Perform the query
						mysql_query($templine) or die('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
						// Reset temp variable to empty
						$templine = '';
					}
				}
				$_SESSION["msg"]="Database imported successfully";
				//////////////////////////**************setting backup table***********////////////////////////////
				$db->query("Truncate table settings");
				$db->query("INSERT INTO settings SELECT * FROM temp_settings");
				$db->query("DROP TABLE temp_settings");
				//////////////////////////**************setting backup table***********////////////////////////////
				if($db->getErMsg()=="")
				redirect("?src=Promote&page_id=import");
				else
				echo $db->getErMsg();
				
			}
		}else{
			$alert_err[]="Invalid file extension";
		}
	}
	
}
if(isset($_SESSION['msg']) && $_SESSION['msg']!="")
{
	?>
	<div class="alert alert-success">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-thumbs-up-alt"></i> <b>Notice</b><?php echo $_SESSION['msg'] ?></i>
	</div>
	<?php
	unset($_SESSION["msg"]);
}
if(is_array($alert_err) && count($alert_err)>0)
{
	?>
	<div class="alert alert-error">
	  <a class="close" data-dismiss="alert">×</a>
	  <i class="icon icon-warning-sign"></i> <b>Notice</b> <?php echo $alert_err[0] ?></i>
	</div>
	<?php
}
?> 
<div class="row-fluid">
        <form method="post" action="" enctype="multipart/form-data">
			<!-- Forms: Box -->
			<div class="span12">

				<!-- Forms: Top Bar -->
				<div class="top-bar">
					<h3><i class="icon-cog"></i> Import File</h3>
				</div>
				<!-- / Forms: Top Bar -->

				<!-- Forms: Content -->
				<div class="well no-padding">

						<input type="hidden" name="ss" value="1">
                        <div class="control-group">
							<label class="control-label" for="msg">Sql File</label>
							<div class="controls">
								<input type="file" id="file" name="photo" class="input-block-level">
							</div>
						</div>
						<div class="form-actions">
							<button type="submit" class="btn btn-primary"> import</button>
							<button type="reset" class="btn"> Cancel</button>
						</div>
                        
				</div>
				<!-- / Forms: Content -->

			</div>
			<!-- / Forms: Box -->

        </form>
	</div>