Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
-> Done #79
  • Loading branch information
NaysKutzu committed Oct 26, 2023
1 parent 511ea68 commit 5550e58
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 103 deletions.
1 change: 1 addition & 0 deletions migrate/23.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `enable_adblocker_detection` ENUM('true','false') NOT NULL AFTER `enable_ads`;
5 changes: 5 additions & 0 deletions routes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
require("../view/errors/404.php");
});

$router->add("/e/adblock", function () {
require("../include/main.php");
require("../view/errors/adblock.php");
});

$router->add("/e/401", function () {
require("../include/main.php");
require("../view/errors/401.php");
Expand Down
4 changes: 3 additions & 1 deletion view/admin/settings/ads.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
if (isset($_GET['update_settings'])) {
$enable_ads = mysqli_real_escape_string($conn, $_GET['ads:enabled']);
$ads_code = mysqli_real_escape_string($conn, $_GET['ads:code']);
$enable_adblocker_detection = mysqli_real_escape_string($conn, $_GET['ads:adblocker']);
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `enable_ads` = '" . $enable_ads . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `ads_code` = '" . $ads_code . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `enable_ads` = '" . $enable_ads . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `enable_adblocker_detection` = '" . $enable_adblocker_detection . "' WHERE `mythicaldash_settings`.`id` = 1;");
header('location: /admin/settings?s=We updated the settings inside the database');
$conn->close();
die ();
Expand Down
242 changes: 145 additions & 97 deletions view/admin/settings/main.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion view/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ function percentage($number, $total, $outof)
<!DOCTYPE html>
<html lang="en" class="dark-style layout-navbar-fixed layout-menu-fixed" dir="ltr" data-theme="theme-semi-dark"
data-assets-path="<?= $appURL ?>/assets/" data-template="vertical-menu-template">

<head>
<?php include('requirements/head.php'); ?>
<title>
<?= SettingsManager::getSetting("name") ?> - Dashboard
</title>

</head>

<body>
Expand Down
46 changes: 46 additions & 0 deletions view/errors/adblock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
use MythicalDash\SettingsManager;
http_response_code(401);
?>
<!DOCTYPE html>

<html lang="en" class="dark-style customizer-hide" dir="ltr" data-theme="theme-semi-dark"
data-assets-path="<?= $appURL ?>/assets/" data-template="vertical-menu-template">

<head>
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>
<?= SettingsManager::getSetting("name") ?> - Not Allowed
</title>
<?php include(__DIR__ . '/../requirements/head.php'); ?>
<link rel="stylesheet" href="<?= $appURL ?>/assets/vendor/css/pages/page-misc.css" />
</head>

<body>
<div id="preloader" class="discord-preloader">
<div class="spinner"></div>
</div>
<div class="container-xxl container-p-y">
<div class="misc-wrapper">
<h2 class="mb-1 mx-2">Please disable your adblocker!</h2>
<p class="mb-4 mx-2">
You do not have permission to view this page. It is really sad when you try to use an adblocker on a free host! <br />
</p>
<a href="/" class="btn btn-primary mb-4">Back to home</a>
<div class="mt-4">
<img src="<?= $appURL ?>/assets/img/illustrations/page-misc-you-are-not-authorized.png"
alt="page-misc-not-authorized" width="170" class="img-fluid" />
</div>
</div>
</div>
<div class="container-fluid misc-bg-wrapper">
<img src="<?= $appURL ?>/assets/img/illustrations/bg-shape-image-light.png" alt="page-misc-not-authorized"
data-app-light-img="illustrations/bg-shape-image-light.png"
data-app-dark-img="illustrations/bg-shape-image-dark.png" />
</div>
<?php include(__DIR__ . '/../requirements/footer.php'); ?>
</body>

</html>
52 changes: 51 additions & 1 deletion view/requirements/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,54 @@
<script src="<?= $appURL ?>/assets/js/main.js"></script>
<script src="<?= $appURL ?>/assets/vendor/libs/bs-stepper/bs-stepper.js"></script>
<script src="<?= $appURL ?>/assets/js/MythicalGuard.js"></script>
<script src="<?= $appURL ?>/assets/js/preloader.js"></script>
<script src="<?= $appURL ?>/assets/js/preloader.js"></script>
<?php
function fis_active_page($page_urls)
{
foreach ($page_urls as $page_url) {
if (strpos($_SERVER['REQUEST_URI'], $page_url) !== false) {
return true;
}
}
return false;
}
use MythicalDash\SettingsManager;

if (!fis_active_page(['/e/adblock'])) {
if (SettingsManager::getSetting("enable_adblocker_detection") == "true") {
if (isset($_COOKIE['token']) && !$_COOKIE['token'] == "") {
if (!$session->getUserInfo('role') == "Administrator") {
?>
<script>
let fakeAd = document.createElement("div");
fakeAd.className =
"textads banner-ads banner_ads ad-unit ad-zone ad-space adsbox"

fakeAd.style.height = "1px"

document.body.appendChild(fakeAd)

let x_width = fakeAd.offsetHeight;
let msg = document.getElementById("msg")


if (x_width) {

} else {
window.location.replace("/e/adblock");
}

</script>
<?php
} else {
?>
<script>
console.warn("You bypassed the Anti-AdBlock protection");
</script>
<?php
}
}
}
}

?>
9 changes: 6 additions & 3 deletions view/requirements/head.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
<?php
use MythicalDash\SettingsManager;

?>
<meta charset="utf-8">
<meta name="viewport"
Expand All @@ -14,7 +15,7 @@
<meta name="twitter:description" content="<?= SettingsManager::getSetting("seo_description") ?>">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="<?= SettingsManager::getSetting("logo") ?>">
<meta property="og:image" content="<?=SettingsManager::getSetting("logo") ?>">
<meta property="og:image" content="<?= SettingsManager::getSetting("logo") ?>">
<meta name="description" content="<?= SettingsManager::getSetting("seo_description") ?>">
<meta property="og:type" content="website">
<meta name="twitter:title" content="<?= SettingsManager::getSetting("name") ?>">
Expand Down Expand Up @@ -65,9 +66,10 @@ class="template-customizer-theme-css" />
if (SettingsManager::getSetting("customcss_enabled") == 'true') {
?>
<style type="text/css">
#template-customizer .template-customizer-open-btn {
#template-customizer .template-customizer-open-btn {
visibility: hidden;
}

<?= SettingsManager::getSetting("customcss_code") ?>
</style>
<?php
Expand All @@ -78,4 +80,5 @@ class="template-customizer-theme-css" />
<?= SettingsManager::getSetting("customhead_code") ?>
<?php
}

?>

0 comments on commit 5550e58

Please sign in to comment.