[php] fabus
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- <?php
- ob_start();
- $servername = "localhost";
- $username = "u2498671_infor";
- $password = "wC5oK7eH2emD6kJ7";
- $dbname = "u2498671_infor";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql_create_table = "CREATE TABLE IF NOT EXISTS login_logs (
- id INT AUTO_INCREMENT PRIMARY KEY,
- username VARCHAR(255) NOT NULL,
- login_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- ip_address VARCHAR(45),
- device_info TEXT
- )";
- $conn->query($sql_create_table);
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $logs = $conn->real_escape_string($_POST['logs']);
- $pass = $conn->real_escape_string($_POST['pass']);
- $ip_address = $_SERVER['REMOTE_ADDR'];
- $device_info = $_SERVER['HTTP_USER_AGENT'];
- $sql = "SELECT * FROM admin WHERE logs = '$logs' AND pass = '$pass'";
- $result = $conn->query($sql);
- if ($result && $result->num_rows > 0) {
- $username = $conn->real_escape_string($_POST['logs']);
- $sql_insert_log = "INSERT INTO login_logs (username, ip_address, device_info) VALUES ('$username', '$ip_address', '$device_info')";
- $conn->query($sql_insert_log);
- sendTelegramMessage($conn, $username, $ip_address, $device_info);
- header("Location: sait.php");
- exit;
- } else {
- $sql = "SELECT * FROM adminn WHERE logs = '$logs' AND pass = '$pass'";
- $result = $conn->query($sql);
- if ($result && $result->num_rows > 0) {
- $username = $conn->real_escape_string($_POST['logs']);
- $sql_insert_log = "INSERT INTO login_logs (username, ip_address, device_info) VALUES ('$username', '$ip_address', '$device_info')";
- $conn->query($sql_insert_log);
- sendTelegramMessage($conn, $username, $ip_address, $device_info);
- header("Location: admin.php");
- exit;
- } else {
- $error_message = "Неправильный логин или пароль.";
- sendTelegramMessage($conn, "Неудачная попытка входа", $ip_address, $device_info);
- }
- }
- }
- function sendTelegramMessage($conn, $username, $ip_address, $device_info)
- {
- $telegram_bot_token = '7190751396:AAEhV_nEYKi3IeN-9-N7xtfFMBq_oQQE43Q';
- $sql = "SELECT idtg FROM tgid";
- $result = $conn->query($sql);
- if ($result && $result->num_rows > 0) {
- while ($row = $result->fetch_assoc()) {
- $chat_id = $row['idtg'];
- $message = "Успешный вход пользователя: $username\nВремя входа: " . date("Y-m-d H:i:s") . "\nIP-адрес: $ip_address\nУстройство и браузер: $device_info";
- $telegram_api_url = "https://api.telegram.org/bot{$telegram_bot_token}/sendMessage";
- $telegram_api_params = [
- 'chat_id' => $chat_id,
- 'text' => $message
- ];
- $ch = curl_init($telegram_api_url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $telegram_api_params);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_exec($ch);
- curl_close($ch);
- }
- }
- }
- $conn->close();
- ob_end_flush();
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Вход</title>
- <style>
- body, html {
- height: 100%;
- margin: 0;
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
- display: flex;
- align-items: center;
- justify-content: center;
- background: linear-gradient(-45deg, #4c0182, #8837ab, #4c0182, #8837ab);
- background-size: 400% 400%;
- animation: gradientBG 15s ease infinite;
- }
- @keyframes gradientBG {
- 0% { background-position: 0% 50%; }
- 50% { background-position: 100% 50%; }
- 100% { background-position: 0% 50%; }
- }
- form {
- padding: 40px 40px;
- background: white;
- border-radius: 10px;
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
- width: 300px;
- max-width: 90%;
- }
- h2 {
- margin-bottom: 20px;
- color: #4c0182;
- font-size: 24px;
- }
- input[type="text"], input[type="password"] {
- width: 100%;
- padding: 10px;
- margin: 10px 0 20px;
- border: 2px solid #ccc;
- border-radius: 5px;
- box-sizing: border-box; /* Убираем вытягивание */
- font-size: 16px;
- }
- input[type="submit"] {
- width: 100%;
- padding: 12px;
- background-color: #4c0182;
- color: white;
- border: none;
- border-radius: 5px;
- cursor: pointer;
- font-size: 18px;
- transition: 0.3s background-color;
- }
- input[type="submit"]:hover {
- background-color: #5c2d91;
- }
- .error {
- color: #ff3860;
- margin-top: -15px;
- margin-bottom: 20px;
- font-size: 14px;
- }
- .vhod {
- text-align: center;
- }
- .logo-container {
- display: flex;
- justify-content: center; /* Центрируем логотип по горизонтали */
- margin-bottom: 10px; /* Отступ снизу */
- }
- .logo-container img {
- max-width: 100%; /* Убедитесь, что логотип никогда не выйдет за пределы своего контейнера */
- height: auto; /* Поддерживаем пропорции изображения */
- width: 250px; /* Уменьшаем ширину логотипа. Можете подстроить под свои нужды */
- }
- </style>
- </head>
- <body>
- <form id="loginForm" action="<?php
- echo htmlspecialchars($_SERVER["PHP_SELF"]);
- ?>" method="post">
- <div class="logo-container">
- <img src="logo.png" alt="Логотип">
- </div>
- <h2 class="vhod">Вход в систему</h2>
- <input type="text" id="logs" name="logs" placeholder="Логин" required>
- <input type="password" id="pass" name="pass" placeholder="Пароль" required>
- <?php
- if (!empty($error_message)) {
- echo "<div class='error'>$error_message</div>";
- }
- ?>
- <input type="submit" value="Войти">
- </form>
- <script>
- document.getElementById('loginForm').onsubmit = function(e) {
- // Дополнительная клиентская проверка, если требуется
- const logs = document.getElementById('logs').value.trim();
- const pass = document.getElementById('pass').value.trim();
- if (!logs || !pass) {
- e.preventDefault(); // Предотвращаем отправку формы
- document.getElementById('error').textContent = 'Пожалуйста, заполните все поля.';
- }
- };
- </script>
- </body>
- </html>
Editor
You can edit this paste and save as new:
File Description
- fabus
- Paste Code
- 29 Mar-2024
- 6.99 Kb
You can Share it: