<?php
session_start();
$dbtype = "root";
require("includes/dbconnect.php");
require("includes/config.php");
require("includes/function.php");

$zdir = $dbname;
$zcomp = 1;
$zdbroot = $zdir;
$focusfield = "user";
if (isset($_POST["submit"])) {
    $udbf = $zdbroot . "passmain";

    $login = mysqli_query($conn, "SELECT * FROM `passmain` WHERE `user` = '" . mysqli_real_escape_string($conn, $_POST['user']) . "'
                         AND `password` = '" . mysqli_real_escape_string($conn, $_POST['pass']) . "'") or die(mysqli_error($conn));

    //    $_SESSION["username_" . $dbname] = $login["user"];

    $_SESSION["zdbroot"] = $zdbroot;
    $_SESSION["zdir"] = $zdir;

    $_SESSION["zcompany"] = '';

    if (mysqli_num_rows($login) == 1) {

        $_SESSION['username_' . $dbname] = $_POST["user"];


        $_SESSION['logged-in'] = true;
        $getuser_dtl = mysqli_fetch_object($login);
        $admin = $getuser_dtl->admin;
        $usertype = $getuser_dtl->usertype;
        $_SESSION["password_" . $dbname] = $getuser_dtl->password;

        $_SESSION["mastadd_" . $dbname]   = $getuser_dtl->mastadd;
        $_SESSION["mastedit_" . $dbname]  = $getuser_dtl->mastedit;
        $_SESSION["mastdel_" . $dbname]   = $getuser_dtl->mastdel;

        $_SESSION["transadd_" . $dbname]  = $getuser_dtl->transadd;
        $_SESSION["transedit_" . $dbname] = $getuser_dtl->transedit;
        $_SESSION["transdel_" . $dbname]  = $getuser_dtl->transdel;

        $_SESSION["admin_" . $dbname] = $admin;
        $_SESSION["usertype_" . $dbname] = $usertype;
        $_SESSION["spltype_" . $dbname] = $getuser_dtl->spltype;
        $_SESSION["zdbyear_$dbname"] = $dbyear;

        header("Location: comp.php");
    } else {

        print '<script type="text/javascript">';
        print 'alert("Invalid Login Credentials")';
        print '</script>';
    }
}
include("includes/linkshead.php");
?>
<style>
    @import url("https://fonts.googleapis.com/css2?family=Russo+One&display=swap");

    svg {
        font-family: "Russo One", sans-serif;
        width: 100%;
        height: 100%;
    }

    svg text {
        animation: stroke 5s infinite alternate;
        stroke-width: 2;
        stroke: #FFFFFF;
        font-size: 50px;
    }

    @keyframes stroke {
        0% {
            fill: rgba(255, 255, 255, 0);
            stroke: rgba(255, 255, 255, 1);
            stroke-dashoffset: 25%;
            stroke-dasharray: 0 50%;
            stroke-width: 2;
        }

        70% {
            fill: rgba(255, 255, 255, 0);
            stroke: rgba(255, 255, 255, 1);
        }

        80% {
            fill: rgba(255, 255, 255, 0);
            stroke: rgba(255, 255, 255, 1);
            stroke-width: 3;
        }

        100% {
            fill: rgba(255, 255, 255, 1);
            stroke: rgba(255, 255, 255, 0);
            stroke-dashoffset: -25%;
            stroke-dasharray: 50% 0;
            stroke-width: 0;
        }
    }

    .wrapper {
        background-color: #347ab7;
        height: 50px;
    }
</style>
</head>

<body class="animated fadeIn">
    <section id="login-container">
        <div class="row text-center">

        </div>
        <div class="row">
            <div class="col-md-3" id="login-wrapper">
                <div class="panel panel-primary animated flipInY">
                    <div class="panel-heading">
                        <div class="wrapper">
                            <svg>
                                <text x="50%" y="50%" dy=".35em" text-anchor="middle">
                                    <?php echo $project_title; ?>
                                </text>
                            </svg>
                        </div>
                        <!-- <h3 class="panel-title">     
                            
                        </h3>       -->
                    </div>
                    <div class="panel-body">
                        <p> Login to access your account.</p>
                        <form class="form-horizontal" action='' method="POST">
                            <div class="form-group">
                                <div class="col-md-12">
                                    <input type="text" class="form-control" id="email" placeholder="Username" name='user' autofocus>
                                    <i class="fa fa-user"></i>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-12">
                                    <input type="password" class="form-control" id="password" placeholder="Password" name='pass'>
                                    <i class="fa fa-lock"></i>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-12">
                                    <input type='submit' name='submit' value="SUBMIT" class="btn btn-primary btn-block">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </section>
    <?php include("includes/linksfoot.php") ?>
</body>

</html>