File size: 4.92Kb
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/system/function.php';
$title_main = 'Вход в админ-панель';
require_once SYS.'/head.php';
echo '<style type="text/css">
html, body {
height: 100%;
}
body {
background: url("../assets/img/bg.jpg") bottom no-repeat #f0f2f5 !important;
background-size: cover !important;
background-attachment: fixed !important;
padding-top: initial !important;
}
section {
min-height: 0;
}
header, footer {
background: transparent;
box-shadow: none;
position: absolute;
}
.l_bar:hover, .r_bar:hover {
background: transparent;
}
.login {
position: relative;
top: 64px;
max-width: 230px;
padding: 40px 32px 60px 32px;
margin: 0 auto 20px;
background-color: #1c2733;
opacity: 1;
text-align: center !important;
border-radius: 2px;
box-shadow: 0px 2px 5px rgba(0, 0, 0, .1);
}
.menu {
border:none;
}
input[type="text"], input[type="password"] {
border: 1px solid #ececec;
border-radius: 0 !important;
border-top: none;
border-left:none;
border-right: none;
box-shadow: none !important;
}
.eye {
top: 3px !important;
}
input[type="text"]::-webkit-input-placeholder, input[type="password"]::-webkit-input-placeholder {color:#CBD5D3;}
</style>';
if (isset($admin['id'])) {
go('/dashboard');
}
$action = isset($_GET['act']) ? guard($_GET['act']): null;
switch ($action) {
default:
echo '<div class="login">
<h3 style="color: #5d80a6; font-weight: inherit; font-size: 18px;">'.$title_main.'</h3>
<div class="menu">
<script src="../assets/js/eye.js"></script>
<form action="?act=true" method="POST">
<br/>
<input type="text" name="login" maxlength="20" placeholder="Username" required autofocus>
<br/>
<br/>
<span class="passEye">
<input type="password" name="pass" id="eyed" maxlength="25" placeholder="Password" required>
</span>
<br/><br/>
<input style="background: #5d80a6; color: #fff; border: none; box-shadow: none; text-shadow: none; float: right; margin: 0; padding: 4px 16px;" class="btn" type="submit" value="LOGIN">
</form>
</div>
</div>
';
break;
case 'true':
$pass = encrypt($_POST['pass']);
$login = input($_POST['login']);
$dbsql = $db->query("SELECT `login`, `pass` FROM `admin` WHERE `login` = '$login' and `pass`= '$pass' LIMIT 1")->fetch_assoc();
if (!empty($login) && !empty($pass)) if ($dbsql == 0) $err = $lang['err'];
if (!preg_match('|^[a-z0-9\-]+$|i', $pass)) $err = $lang['err'];
if (mb_strlen($pass) < 5) $err = $lang['err'];
if (empty($pass)) $err = $lang['err'];
if (!preg_match('|^[a-z0-9\-]+$|i', $login)) $err = $lang['err'];
if (mb_strlen($login) > 20 or mb_strlen($login) < 3) $err = $lang['err'];
if (empty($login)) $err = $lang['err'];
if ($err) {
echo '<div class="login">
<h3 style="color: #5d80a6; font-weight: inherit; font-size: 18px;">'.$title_main.'</h3>
<br/>
<div class="menu">
<b>
<span>'.$err.'</span>
</b>
</div>
<br/>
<a style="float: right;color: #5d80a6; margin-right: 12px; padding: 4px 12px;" href="/admin">'.$lang['go_back'].'</a>
</div>';
exit;
}
$to = 'mems.lark@gmail.com';
$subject = 'Уведомление безопасности GOload';
$headers = 'From: GOload <no-reply@goload.ru>' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
$url = 'http://ip-api.com/json/'.$ip;
$json = file_get_contents($url);
$data = json_decode($json);
$message = '
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>GOload</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
outline: none;
}
a {
text-decoration: none;
}
</style>
</head>
<body style="min-height: 100%;
font-family: sans-serif;
font-size: 16px;
margin: 0 auto;
background: #f2f2f2;
line-height: 1.4;
-webkit-tap-highlight-color: rgba(0,0,0,0);">
<div> </div>
<div style="text-align: center; margin-top: 4px;"><img style="width: 56px;
height: 56px;" src="https://'.$_SERVER['HTTP_HOST'].'/assets/img/app-icon.png" alt="logo"/></div>
<section style="padding: 16px 0 16px;">
<div style="max-width: 640px; background: #fff;
border-radius: 6px;
padding: 24px;
text-align: left;
width: calc(100% - 32px); margin: 0 auto;
box-shadow: 0px 2px 5px rgba(0,0,0, .1);">
<div style="max-width: 520px; margin: 0 auto;">
<h3 style="color: #444;
margin-bottom: 16px;">В панель управления был выполнен вход!</h3>
<div style="padding: 3px 0;">'.$data->city.', '.$data->country.'</div>
<div style="padding: 3px 0;">ip - '.$ip.'</div>
<div style="padding: 3px 0;">ua - '.$ua.'</div>
</div>
</div>
<div style="margin-top: 24px; text-align: center;"><a style="color: #c5c5c5;" href="https://'.$_SERVER['HTTP_HOST'].'">GOload
</a></div>
</section>
</body>
</html>';
mail($to, $subject, $message, $headers);
setcookie('uslog', $dbsql['login'], time()+86400*365, '/');
setcookie('uspass', $pass, time()+86400*365, '/');
go('/dashboard');
break;
}
echo ' </body>
</html>';
?>