<?php
/**
 * Created by PhpStorm.
 * User: IOAN
 * Date: 11/13/2015
 * Time: 10:36 AM
 */
$optres['css'][] = $module_css_path . "amodules/account/css/login.css";

if (!isset($_SESSION['member_id'])){

    $webpage_title_en = 'Login | ' . $webpage_title_en;
    $meta['description'] = "";
    $meta['keywords'] = "";

    // Hide sides
    $cf_show_left_side = false;
    $cf_show_right_side = false;


    // Set breadcrumbs
    $breadcrumbs [] = array(
        'link' => '',
        'title' => "Account Login"
    );

    $data_remote = 'local';
    $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_process';
                $form_target = '_self';
                $optres['js'][] = $path . "amodules/account/js/login.js";
            }
            else {
                $form_url = $protocol . 'www.cyprusnet.com/account/login_process';
                $form_pref = $protocol . 'www.cyprusnet.com/';
                $data_remote = 'remote';
            }
        }
    }

    $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 class="article">

        <div class="article-body" id="login-module">
            <div class="row">
                <div class="col-sm-4 col-sm-offset-3">
                    <div class="alert alert-error hidden"></div>
                    <div class="login-box box box-primary">

                        <div class="box-header with-border">
                            <h1 class="no-margin"><i class="fa fa-user fa-lg"></i> Account Login</h1>
                        </div>
                        <div class="box-body">
                            <form id="login-form" data-remote="<?=$data_remote;?>" action="<?=$form_url;?>" <?php echo 'target="'.$form_target.'"';?> rel="noopener" method="post" class="form-horizontal" role="form">
                                <input name="action" type="hidden" id="action" value="login"/>

                                <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" required>
                                    <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" required>
                                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                                </div>
                                <div class="text-center">
                                    <button id="login-submit" type="submit" class="login-btn btn btn-primary btn-sm btn-block">Login</button>
                                </div>
                                <hr class="hr-login">
                                <div class="text-left">
                                    <i class="fa fa-chevron-right"></i> <a href="<?php echo $form_pref . 'account/forgot.html';?>" <?php echo 'target="'.$form_target.'"';?> rel="noreferrer noopener" class=""> Forgot password?</a>
                                </div>
                                <div class="text-left">
                                    <i class="fa fa-chevron-right"></i> No account? <a href="<?php echo $form_pref . 'account/add_member.html';?>" <?php echo 'target="'.$form_target.'"';?> rel="noreferrer noopener" class="">Click here to register!</a>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </section>

    <?php
}
else {
    ob_end_clean();
    header("Location: " . $protocol . $server_host . "/account/my_account");
}
?>