<?php require_once __DIR__ . "/logic.php"; if (isset($_POST["login"]) && isset($_POST["password"])) { $username = post("login"); $password = post("password"); $r = CAdmin::login($username, $password); if ($r) { header("Location: /admin/index.php"); } } if (CAdmin::checkLogin()) { header("Location: /admin/index.php"); } ?> <!DOCTYPE html> <html lang="en"> <meta charset="UTF-8"> <head> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap-theme.min.css"> </head> <body> <div class="container"> <div class="jumbotron"> <h3 class="center-block">Login</h3> <form method="post" accept-charset="UTF-8" enctype="application/x-www-form-urlencoded" autocomplete="off"> <div class="form-group form-group-sm"> <input type="text" class="form-control input-sm" id="inputLogin" placeholder="Login" name="login">
} } $_SESSION['user_ip'] = $_SERVER['REMOTE_ADDR']; $_SESSION['referer'] = BASE_URL; // validation if ($username == '') { $errors['username'] = '******'; } if ($password == '') { $errors['password'] = '******'; } // no errors, go to review page if (empty($errors)) { require_once APP_PATH . '_lib/class.Admin.php'; $admin = new CAdmin(); if ($admin->login($username, $password)) { $_SESSION['AdminId'] = $admin->getId(); redirect_to(BASE_URL . 'home/'); exit; } else { $errors['incorrect'] = 'Incorrect username or password'; $smarty->assign('errors', $errors); } } else { $smarty->assign('errors', $errors); } } $template = 'login.tpl'; $smarty->assign('ENABLE_RECAPTCHA', $captcha_enabled); if ($captcha_enabled) { $smarty->assign('the_captcha', recaptcha_get_html(CAPTCHA_PUBLIC_KEY));