<?php
if (!isset($_SESSION['member_id'])){
	$form_pref = '';
	$form_url = "$pathcyprusnet/";
	$form_target = "_blank";
	if(isset($domain_id)) {
		$q = "select * from domaincategories where catdom_id='$domain_id' and parent_id='0';";
		$r = @mysql_query($q);
		if($r && mysql_num_rows($r) == 1) {
			$row = mysql_fetch_assoc($r);
			$hosting_server = intval($row['hosting_server']);

			if($hosting_server == 0 || (isset($_SESSION['user_id'] ) && intval($_SESSION['user_id']) > 0 ) ) {
				$form_url = 'account/login_logout.html';
				$form_target = '_self';
			}
			else {
				$form_url = 'https://www.cyprusnet.com/account/login_logout.html';
				$form_pref = 'https://www.cyprusnet.com/';
			}
		}
	}

    $log_username = '';
    $log_password = '';

    if( (isset($login_failed) && $login_failed) || (isset($login_incomplete) && $login_incomplete)) {
        $log_username = trim(mysql_real_escape_string($_POST['log_username']));
        $log_password = '';
    }
	
	?>
    <section id="login-module">
        <div class="box box-primary">
            <div class="box-header with-border text-left">
                <i class="fa fa-user text-primary"></i> <b>Account</b>
            </div>
            <div class="box-body">
                <form action="<?php echo $form_url;?>" <?php echo 'target="'.$form_target.'"';?> method="post" class="form-horizontal" role="form">
                    <input name="action" type="hidden" id="action" value="login"/>
                    <input name="module_page" type="hidden" id="module_page" value="account"/>
                    <input name="account_url" type="hidden" value="my_account"/>
                    <div class="form-group has-feedback">
                        <label class="control-label sr-only">Email</label>
                        <input type="email" class="form-control input-sm" placeholder="Email" value="<?=$log_username;?>" name="log_username" id="log_username">
                        <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
                    </div>
                    <div class="form-group has-feedback">
                        <label class="control-label sr-only">Password</label>
                        <input type="password" class="form-control input-sm" placeholder="Password" value="<?=$log_password?>" name="log_password" id="log_password">
                        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                    </div>
                    <div class="row">
                        <div class="col-md-10 col-sm-5 col-xs-5">
                            <button type="submit" class="login-btn btn btn-primary btn-sm btn-block">Login</button>
                        </div>
                        <div class="col-md-10 col-sm-5 col-xs-5">
                            <a href="<?php echo $form_pref . 'account/add_member.html';?>" <?php echo 'target="'.$form_target.'"';?> class="register-btn btn btn-info btn-sm btn-block">Register</a>
                        </div>

                    </div>
                    <div class="text-left">
                        <a href="<?php echo $form_pref . 'account/forgot.html';?>" <?php echo 'target="'.$form_target.'"';?> class="forgot-pass"><i class="fa fa-info-circle"></i> Forgot password?</a>
                    </div>
                </form>
            </div>
        </div>

    </section>

	<?php 
}
else {
	?>
    <section id="login-module">
        <?php
        $querymembers = "SELECT * FROM members WHERE member_id='".$_SESSION['member_id']."'";
        //echo $querymembers;
        $resultmembers = mysql_query($querymembers);
        $linemembers = mysql_fetch_assoc($resultmembers);
        ?>
        <div class="box box-primary">
            <div class="box-header with-border text-left">
                <i class="fa fa-user text-primary"></i> <b><?php echo $linemembers["shipname"] . ' ' . $linemembers["shipsurname"];?></b>
            </div>
            <div class="box-body text-left">
                <a href="account/my_account.html" class="loginLink"><i class="fa fa-cogs fa-fw"></i> My Account</a>
                <br><a href="account/login_logout.html?logout=yes" class=""><i class="fa fa-sign-out fa-fw text-danger"></i> Logout</a>
            </div>
        </div>
    </section>

	<?php 
}
?>