Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Отримання IP-адреси
- if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
- $ip = $_SERVER['HTTP_CLIENT_IP'];
- } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } else {
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- // Файл для зберігання IP-адрес і часу
- $file = 'ip_attempts.json';
- // Встановлюємо поточний час у читаємому форматі
- $current_time_readable = date("Y-m-d H:i:s");
- // Перевірка наявності файлу та читання даних
- if (file_exists($file)) {
- $ip_attempts = json_decode(file_get_contents($file), true);
- } else {
- $ip_attempts = [];
- }
- // Перевірка на наявність IP та часу останньої спроби
- if (isset($ip_attempts[$ip])) {
- $last_attempt_time = strtotime($ip_attempts[$ip]);
- $time_diff = time() - $last_attempt_time;
- // Якщо з останньої спроби минуло менше години (3600 секунд), не записуємо
- if ($time_diff < 3600) {
- $recent_attempt = true;
- } else {
- $recent_attempt = false;
- }
- } else {
- $recent_attempt = false;
- }
- // Якщо не було недавньої спроби, записуємо нову спробу з датою
- if (!$recent_attempt) {
- $ip_attempts[$ip] = $current_time_readable;
- file_put_contents($file, json_encode($ip_attempts));
- }
- // Визначення мови за параметром у URL або за налаштуваннями браузера
- $available_languages = ['uk', 'en'];
- $lang = 'en'; // Мова за замовчуванням
- if (isset($_GET['lang']) && in_array($_GET['lang'], $available_languages)) {
- $lang = $_GET['lang'];
- } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
- $browser_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
- if (in_array($browser_lang, $available_languages)) {
- $lang = $browser_lang;
- }
- }
- // Тексти на двох мовах
- $texts = [
- 'uk' => [
- 'title' => 'Увага! Спроба злому',
- 'warning' => 'Виявлена спроба злому',
- 'ip_logged' => 'Ваша IP-адреса: <strong>%s</strong> зафіксована та передана до служби безпеки.',
- 'legal_action' => 'Будь-які подальші спроби будуть переслідуватися законом!',
- 'go_home' => 'Повернутись на головну'
- ],
- 'en' => [
- 'title' => 'Warning! Hacking attempt',
- 'warning' => 'Hacking attempt detected',
- 'ip_logged' => 'Your IP address: <strong>%s</strong> has been recorded and reported to security.',
- 'legal_action' => 'Any further attempts will be prosecuted by law!',
- 'go_home' => 'Return to homepage'
- ]
- ];
- ?>
- <!DOCTYPE html>
- <html lang="<?php echo $lang; ?>">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="robots" content="noindex, nofollow">
- <title><?php echo $texts[$lang]['title']; ?></title>
- <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
- <style>
- .image-container {
- text-align: center;
- margin-top: 20px;
- }
- .image-container img {
- max-width: 100%;
- height: auto;
- width: 300px; /* Встановлюємо фіксовану ширину зображення */
- }
- </style>
- </head>
- <body class="bg-light">
- <div class="container">
- <div class="row justify-content-center">
- <div class="col-md-8">
- <div class="alert alert-danger mt-5 p-4 text-center">
- <h1 class="display-4"><?php echo $texts[$lang]['title']; ?></h1>
- <p class="lead"><?php echo $texts[$lang]['warning']; ?></p>
- <hr class="my-4">
- <p><?php printf($texts[$lang]['ip_logged'], $ip); ?></p>
- <p><?php echo $texts[$lang]['legal_action']; ?></p>
- <a href="/" class="btn btn-primary mt-4"><?php echo $texts[$lang]['go_home']; ?></a>
- </div>
- <div class="image-container">
- <img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/Stamp_of_Ukraine_s1985.jpg">
- </div>
- <div class="text-center mt-3">
- <a href="?lang=uk" class="btn btn-link">Ukrainian</a> |
- <a href="?lang=en" class="btn btn-link">English</a>
- </div>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Comments
-
- 1. We transfer the main admin to another safe directory
- 2. Create the /admin directory at the root of the site with the index.php file with the above content
- Profit
- ---
- All visitors who visited yoursite.com/admin/ will receive a message about a hacking attempt with a log of the IP address
Add Comment
Please, Sign In to add comment