Skip to content

Commit

Permalink
Merge pull request #65
Browse files Browse the repository at this point in the history
-> Linkvertise method added
-> Added the preloader back
  • Loading branch information
NaysKutzu authored Oct 18, 2023
2 parents 1deec1c + d6e352a commit 7cdb6b9
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 16 deletions.
1 change: 1 addition & 0 deletions migrate/11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE `mythicaldash`.`mythicaldash_linkvertise` (`id` INT NOT NULL AUTO_INCREMENT , `skey` TEXT NOT NULL , `date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY (`id`)) ENGINE = InnoDB;
1 change: 1 addition & 0 deletions migrate/12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `linkvertise_enabled` ENUM('false','true') NOT NULL DEFAULT 'false' AFTER `customhead_code`, ADD `linkvertise_code` TEXT NOT NULL AFTER `linkvertise_enabled`;
1 change: 1 addition & 0 deletions migrate/13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mythicaldash_settings` ADD `linkvertise_coins` TEXT NOT NULL DEFAULT '5' AFTER `linkvertise_code`;
10 changes: 10 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@
require("../view/earn/afk.php");
});

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

$router->add("/earn/redeem", function () {
require("../include/main.php");
require("../view/earn/redeem.php");
Expand Down Expand Up @@ -270,6 +275,11 @@
require("../view/admin/settings/discord.php");
});

$router->add("/admin/settings/linkvertise", function () {
require("../include/main.php");
require("../view/admin/settings/linkvertise.php");
});

$router->add("/admin/settings/mail", function () {
require("../include/main.php");
require("../view/admin/settings/mail.php");
Expand Down
17 changes: 17 additions & 0 deletions view/admin/settings/linkvertise.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
include(__DIR__ . '/../../requirements/page.php');
include(__DIR__ . '/../../requirements/admin.php');

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']);
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `linkvertise_enabled` = '" . $enable_ads . "' WHERE `mythicaldash_settings`.`id` = 1;");
mysqli_query($conn, "UPDATE `mythicaldash_settings` SET `linkvertise_code` = '" . $ads_code . "' WHERE `mythicaldash_settings`.`id` = 1;");
header('location: /admin/settings');
$conn->close();
die();
} else {
header('location: /admin/settings');
die();
}
?>
70 changes: 60 additions & 10 deletions view/admin/settings/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</head>

<body>
<div id="preloader" class="discord-preloader">
<div class="spinner"></div>
</div>
<div id="preloader" class="discord-preloader">
<div class="spinner"></div>
</div>
<div class="layout-wrapper layout-content-navbar">
<div class="layout-container">
<?php include(__DIR__ . '/../../components/sidebar.php') ?>
Expand Down Expand Up @@ -145,7 +145,8 @@ class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
<div class="mb-3 col-md-6">
<label class="form-label">Discord Client Secret</label>
<input type="password" required="" class="form-control"
name="discord:client_secret" value="<?= $settings['discord_clientsecret'] ?>">
name="discord:client_secret"
value="<?= $settings['discord_clientsecret'] ?>">
</div>
</div>
<div class="mt-2">
Expand Down Expand Up @@ -241,12 +242,13 @@ class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
</div>
</div>
<div class="mb-3 col-md-2">
<label for="afk:coins:per:min" class="form-label">Coins per minute afk</label>
<label for="afk:coins:per:min" class="form-label">Coins per minute
afk</label>
<input class="form-control" type="text" id="afk:coins:per:min"
name="afk:coins:per:min" value="<?= $settings['afk_coins_per_min'] ?>"
placeholder="2">
</div>

</div>
<div class="mt-2">
<button type="submit" name="update_settings"
Expand Down Expand Up @@ -476,7 +478,7 @@ class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
</div>
</div>
<div class="card mb-4">
<h5 class="card-header">ADS</h5>
<h5 class="card-header">Ads</h5>
<hr class="my-0">
<div class="card-body">
<form action="/admin/settings/ads" method="GET">
Expand Down Expand Up @@ -508,11 +510,59 @@ class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
<div class="form-group">
<label class="control-label">Ads Code</label>
<div>
<textarea type="text" required="" class="form-control"
name="ads:code" rows="4"
value=""><?= $settings['ads_code'] ?></textarea>
<textarea type="text" required="" class="form-control" name="ads:code"
rows="4" value=""><?= $settings['ads_code'] ?></textarea>
</div>
</div>
</div>
<br>
<div class="mt-2">
<button type="submit" name="update_settings"
class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
changes</button>
<a href="/admin" class="btn btn-label-secondary waves-effect">Cancel</a>
</div>
</form>
</div>
</div>
<div class="card mb-4">
<h5 class="card-header">Linkvertise</h5>
<hr class="my-0">
<div class="card-body">
<form action="/admin/settings/linkvertise" method="GET">
<div class="row">
<div class="form-group col-md-2">
<label class="control-label">Status</label>
<div>
<?php
if ($settings['linkvertise_enabled'] == "true") {
?>
<select class="form-control" name="ads:enabled">
<option value="true">Enabled</option>
<option value="false">Disabled</option>
</select>
<?php
} else {
?>
<select class="form-control" name="ads:enabled">
<option value="false">Disabled</option>
<option value="true">Enabled</option>
</select>
<?php
}
?>

</div>
</div>
<div class="form-group col-md-5">
<label class="control-label">Key</label>
<div>
<input type="text" required="" class="form-control" name="ads:code"
value="<?= $settings['linkvertise_code'] ?>">
</div>
</div>
<br>

</div>
<br>
<div class="mt-2">
Expand Down
9 changes: 9 additions & 0 deletions view/components/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ function is_active_page($page_urls)
<div>Redeem</div>
</a>
</li>
<?php if ($settings['linkvertise_enabled'] == "true") {
?>
<li class="menu-item <?php echo is_active_page(['/earn/linkvertise']) ? 'active' : ''; ?>">
<a href="/earn/linkvertise" class="menu-link">
<div>Linkvertise</div>
</a>
</li>
<?php
} ?>
</ul>
</li>
<li class="menu-item <?php echo is_active_page(['/store']) ? 'active' : ''; ?>">
Expand Down
12 changes: 6 additions & 6 deletions view/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ function percentage($number, $total, $outof)
</head>

<body>
<!--<div id="preloader" class="discord-preloader">
<div class="spinner"></div>
</div>-->
<div id="preloader" class="discord-preloader">
<div class="spinner"></div>
</div>
<div class="layout-wrapper layout-content-navbar">
<div class="layout-container">
<?php include('components/sidebar.php') ?>
Expand Down Expand Up @@ -152,7 +152,7 @@ function percentage($number, $total, $outof)
</div>
</div>
</div>

<div class="row gy-3">
<div class="col-md-3 col-6">
<div class="d-flex align-items-center">
Expand Down Expand Up @@ -212,7 +212,7 @@ function percentage($number, $total, $outof)
</div>
<br>
<div id="ads">
<?php
<?php
if ($settings['enable_ads'] == "true") {
echo $settings['ads_code'];
}
Expand Down Expand Up @@ -369,7 +369,7 @@ class="btn btn-danger btn-sm">Delete</button></a>
</div>
<br>
<div id="ads">
<?php
<?php
if ($settings['enable_ads'] == "true") {
echo $settings['ads_code'];
}
Expand Down
159 changes: 159 additions & 0 deletions view/earn/linkvertise.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?php
include(__DIR__ . '/../requirements/page.php');
if ($settings['linkvertise_enabled'] == "false") {
header('location: /');
}
if (isset($_GET['key'])) {
$key = mysqli_escape_string($conn, $_GET['key']);
$result = mysqli_query($conn, "SELECT * FROM mythicaldash_linkvertise WHERE skey='$key'");
if (mysqli_num_rows($result) > 0) {
$usr_coins = $userdb['coins'];
$newcoins = $usr_coins + $settings['linkvertise_coins'];
$conn->query("UPDATE `mythicaldash_users` SET `coins` = '" . $newcoins . "' WHERE `mythicaldash_users`.`api_key` = '" . mysqli_real_escape_string($conn, $_COOKIE["token"])."'");
$conn->query("DELETE FROM mythicaldash_linkvertise WHERE skey='$key'");
header('location: /');
} else {
header('location: /dashboard?e=Error: Key not found.');
}
}
?>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<?= $settings['name'] ?> | Linkvertise
</title>
<link rel="icon" href="<?= $settings['logo'] ?>" type="image/png">
<style>
* {
font-family: Google sans, Arial;
}

html,
body {
margin: 0;
padding: 0;
}

.flex-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
color: white;
animation: colorSlide 15s cubic-bezier(0.075, 0.82, 0.165, 1) infinite;
}

.flex-container .text-center {
text-align: center;
}

.flex-container .text-center h1,
.flex-container .text-center h3 {
margin: 10px;
cursor: default;
}

.flex-container .text-center h1 .fade-in,
.flex-container .text-center h3 .fade-in {
animation: fadeIn 2s ease infinite;
}

.flex-container .text-center h1 {
font-size: 8em;
transition: font-size 200ms ease-in-out;
border-bottom: 1px dashed white;
}

.flex-container .text-center h1 span#digit1 {
animation-delay: 200ms;
}

.flex-container .text-center h1 span#digit2 {
animation-delay: 300ms;
}

.flex-container .text-center h1 span#digit3 {
animation-delay: 400ms;
}

.flex-container .text-center button {
border: 1px solid white;
background: transparent;
outline: none;
padding: 10px 20px;
font-size: 1.1rem;
font-weight: bold;
color: white;
text-transform: uppercase;
transition: background-color 200ms ease-in;
margin: 20px 0;
}

.flex-container .text-center button:hover {
background-color: white;
color: #555;
cursor: pointer;
}

@keyframes colorSlide {
0% {
background-color: #152a68;
}

25% {
background-color: royalblue;
}

50% {
background-color: seagreen;
}

75% {
background-color: tomato;
}

100% {
background-color: #152a68;
}
}

@keyframes fadeIn {
from {
opacity: 0;
}

100% {
opacity: 1;
}
}
</style>
</head>

<body>
<div class="flex-container">
<div class="text-center">
<h1>
<span class="fade-in" id="digit1">Link</span>
<span class="fade-in" id="digit2">ready</span>
</h1>
<h3 class="fadeIn">Please click the continue button to continue</h3>
<?php
$genid = mt_rand(100000000000000, 999999999999999);
$linkid = $genid;
mysqli_query($conn, "INSERT INTO `mythicaldash_linkvertise` (`skey`) VALUES ('" . $linkid . "');");
$url = "/earn/linkvertise?key=" . $linkid;
echo '
<a href="' . $url . '"><button type="button" name="button">Continue</button></a>
';
?>
</div>
</div>
</body>

</html>
<script src="https://publisher.linkvertise.com/cdn/linkvertise.js"></script>
<script>linkvertise(<?= $settings['linkvertise_code'] ?>, { whitelist: ["<?= $appURL ?>"], blacklist: [] });</script>

0 comments on commit 7cdb6b9

Please sign in to comment.