<?php

    if(file_exists('../config.php')){
        header('Location: '. siteURL() .'/app/login.php');
        die;
    }

$check_session = session_status();
if($check_session != PHP_SESSION_ACTIVE && $check_session != PHP_SESSION_NONE)
    $check_session = false;
else
    $check_session = true;

$default_timezone = date_default_timezone_get();

function siteURL()
{
    $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
    $domainName = $_SERVER['HTTP_HOST'];
    $siteName = trim($_SERVER['PHP_SELF'],"/");
    $siteName = explode("/",$siteName);
    if(empty($siteName))
        return $protocol.$domainName.'/';
    else{
	$protocol = $protocol.$domainName;
	for($i = 0; $i < count($siteName) - 2; $i++){
        	$protocol = $protocol.'/'.$siteName[$i];
		}
	return $protocol;
	}
}
?>
<!DOCTYPE html>
    <head>
	
		<!-- Title --> 
		<title> Fan Page Auto Commenter </title>
	
		<!-- Meta Data -->
        <meta charset="UTF-8">
		<meta name="description" content="HTML templeate by Sufain Khan" >
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="author" content="Sufian Khan bdcodex.net">
		
		
		<!-- Mobile Specific Meta -->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
		
		
		<!-- Favicon -->
		<link rel="shortcut icon" type="image/x-icon" href="img/favicon/favicon.ico"> 
		<link rel="apple-touch-icon" sizes="72x72" href="img/favicon/apple-touch-icon-72x72.png">
		<link rel="apple-touch-icon" sizes="114x114" href="img/favicon/apple-touch-icon-114x114.png">
		<link rel="apple-touch-icon" sizes="144x144" href="img/favicon/apple-touch-icon.png">
		
		
		<!-- Fonts -->
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'>
		<link rel="stylesheet" href="css/font-awesome.min.css">

		<!-- CSS -->
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/main.css">
		
    </head>
    <body  style="background: rgb(77, 89, 105) url('./img/bg.jpg') no-repeat fixed center center;">
        <!--[if lt IE 8]>
            <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
		
		<!-- Content Start here  -->
		
			<div id="form-pages">
				<div class="contianer">
					<div class="row">
						<div class="col-sm-offset-4 col-sm-4 col-xs-10 col-xs-offset-1">
							<div class="form-area">
				
								<h2>Checking Server Requirements</h2>
								
								<form action="install.php" method="post">
									<?php $check = true; ?>
									<div class="form-group clearfix row">
										<label for="UserName" class="control-label col-sm-5 col-sm-offset-3"> 777 Permissions:</label>
                                        <?php if(!is_writable('../')){ $check = false; ?>
                                            <div class="col-sm-2 red"><i class="fa fa-times"></i></div>
                                        <?php } else { ?>
                                            <div class="col-sm-2 green"><i class="fa fa-check"></i></div>
                                        <?php } ?>
									</div>
									
									<div class="form-group clearfix row">
										<label for="UserPass" class="control-label col-sm-5 col-sm-offset-3"> LAMP Server:</label>
                                        <?php if(version_compare(PHP_VERSION, '5.4.0', '<')){ $check = false; ?>
                                            <div class="col-sm-2 red"><i class="fa fa-times"></i></div>
                                        <?php } else { ?>
                                            <div class="col-sm-2 green"><i class="fa fa-check"></i></div>
                                        <?php } ?>
									</div> 

									<div class="form-group clearfix row">
										<label for="UserPass" class="control-label col-sm-5 col-sm-offset-3"> PHP 5.4 or later :</label>
                                        <?php if(version_compare(PHP_VERSION, '5.4.0', '<')){ $check = false; ?>
                                            <div class="col-sm-2 red"><i class="fa fa-times"></i></div>
                                        <?php } else { ?>
                                            <div class="col-sm-2 green"><i class="fa fa-check"></i></div>
                                        <?php } ?>
									</div>

									<div class="form-group clearfix row">
										<label for="UserPass" class="control-label col-sm-5 col-sm-offset-3"> Curl Installed :</label>
                                        <?php if(!function_exists('curl_version')){ $check = false; ?>
                                            <div class="col-sm-2 red"><i class="fa fa-times"></i></div>
                                        <?php } else { ?>
                                            <div class="col-sm-2 green"><i class="fa fa-check"></i></div>
                                        <?php } ?>
									</div>

									<div class="form-group clearfix row">
										<label for="UserPass" class="control-label col-sm-5 col-sm-offset-3"> Session enabled :</label>
                                        <?php if(!$check_session){ $check = false; ?>
                                            <div class="col-sm-2 red"><i class="fa fa-times"></i></div>
                                        <?php } else { ?>
                                            <div class="col-sm-2 green"><i class="fa fa-check"></i></div>
                                        <?php } ?>
									</div>

									<div class="form-group clearfix row">
										<label for="UserPass" class="control-label col-sm-5 col-sm-offset-3"> Server Time Zone :</label>
                                        <div class="col-sm-2 control-label"><?php echo $default_timezone;?></div>
									</div>

                                    <?php if($check) { ?>
                                    <input type="hidden" name="pre-install" value="true">
                                    <?php } ?>

									<div class="clearfix form-group">
										<div class="row">	
											<div class="col-sm-12 text-right">
												  <button type="submit" class="btn btn-fb" <?php if(!$check) echo 'disabled'; ?>> Next </button>
											</div>

										</div>
									</div>

								</form>
							
							</div>
						</div>
					</div>
				</div>
			</div>
			
			<footer id="footer">
				<div class="container">
					<div class="row">
						<div class="col-sm-12 text-center">
							<div class="footer">
								<p>Copyright © 2015 HENOZ Developers Pvt Ltd. All Rights Reserved.</p>
							</div>
						</div>
					</div>
				</div>
			</footer>

		<!-- Contents End here  //.-->
    </body>
</html>
