Skip to content

Commit

Permalink
Addons-compatibility
Browse files Browse the repository at this point in the history
This update enables compatibility for upcoming addons
  • Loading branch information
Salmen2 committed Jun 26, 2020
1 parent 18aacdd commit d11ffd9
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 16 deletions.
73 changes: 73 additions & 0 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,25 @@
$DatabaseAdminKey = "Admin_".$UserDB."_Password_".$PwDB;
if($AdminSessionKey != $DatabaseAdminKey){ unset($_SESSION['admin']); header("Location: admin.php"); die; }

// Addon list - Start

$directories = array_diff(scandir('addons'), array('..', '.'));

$addonList = array();

foreach($directories AS $directoryName){
if(file_exists("addons/".$directoryName."/__acp.php") == true AND file_exists("addons/".$directoryName."/__page.php") == true){
$addonList[] = $directoryName;
$btnContent = "<a class='btn btn-default' href='?p=".$directoryName."'>".ucfirst($directoryName)." settings</a><br />";
}
}

define('ADDON_ACTIVE', 1);

// Addon list - End

switch($_GET['p']){
case(""):
default:
// Total Stats

Expand All @@ -32,6 +50,7 @@

$Last24HoursReferralPayout = $mysqli->query("SELECT SUM(amount) FROM faucet_transactions WHERE type = 'Referral Payout' AND timestamp > '$Last24Hours'")->fetch_row()[0];
$Last24HoursReferralPayout = $Last24HoursReferralPayout ? $Last24HoursReferralPayout : 0;

$content .= "<h2>Stats</h2>
<div class='row'>
<div class='col-md-12'>
Expand Down Expand Up @@ -69,6 +88,8 @@
<a class='btn btn-default' href='?p=wds'>Withdrawal settings</a><br />
<a class='btn btn-default' href='?p=ps'>Page settings</a><br />
<a class='btn btn-default' href='?p=ads'>Advertising settings</a><br />
<a class='btn btn-default' href='?p=adds'>Addon settings</a><br />
".$btnContent."
<hr />
Expand Down Expand Up @@ -902,8 +923,60 @@
}

break;

case("adds"):

$content .= "<a href='admin.php'>Back</a><br>
<h3>Addon Settings</h3>
<p>Enable or disable installed Addons below. Disabled addons will disappear for the users.</p>";

if(isset($_GET['sw'])){
$pSWID = $mysqli->real_escape_string($_GET['sw']);
$checkAddon = $mysqli->query("SELECT * FROM faucet_addon_list WHERE id = '$pSWID'");
if($checkAddon->num_rows == 1){
$addonData = $checkAddon->fetch_assoc();
if($addonData['enabled'] == 1){
$mysqli->query("UPDATE faucet_addon_list Set enabled = '0' WHERE id = '$pSWID'");
$content .= alert("info", "Addon '".$addonData['name']."' has been disabled.");
} else {
$mysqli->query("UPDATE faucet_addon_list Set enabled = '1' WHERE id = '$pSWID'");
$content .= alert("info", "Addon '".$addonData['name']."' has been enabled.");
}
}
}


$addonList = $mysqli->query("SELECT * FROM faucet_addon_list");

$content .= "<table class='table table-bordered' style='text-align: center; width: 100%;' border='0'>
<thead>
<tr>
<td>Name</td>
<td>Actions</td>
</tr>
</thead><tbody>";

while($addonRow = $addonList->fetch_assoc()){
if($addonRow['enabled'] == 1)
$status = "<span style='color:green;'>Enabled</span> <a href='?p=adds&sw=".$addonRow['id']."' class='btn btn-primary' role='button'>Disable</a>";
else
$status = "<span style='color:red;'>Disabled</span> <a href='?p=adds&sw=".$addonRow['id']."' class='btn btn-primary' role='button'>Enable</a>";

$content .= "<tr><td>".$addonRow['name']."</td><td>".$status."</td></tr>";
}

$content .= "</tbody></table>";

break;


case(in_array($_GET['p'], $addonList)):
include("addons/".$_GET['p']."/__acp.php");
break;

}


} else {
$content .= "<h3>Log In</h3>";

Expand Down
6 changes: 6 additions & 0 deletions includes/template.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

$navLinks = [["Faucet", "index.php"]];

$addonListSQL = $mysqli->query("SELECT * FROM faucet_addon_list WHERE enabled = '1'");

while($addonRow = $addonListSQL->fetch_assoc())
$navLinks[] = [$addonRow['name'], "page.php?p=".$addonRow['directory_name']];


$PageQuery = $mysqli->query("SELECT * FROM faucet_pages");

while($NavLinks = $PageQuery->fetch_assoc()){
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,4 @@ function showform(){

$tpl->assign("content", $content);
$tpl->display();
?>
?>
42 changes: 33 additions & 9 deletions page.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
<?php
include("includes/core.php");

$pageID = $mysqli->real_escape_string($_GET['pid']);
if(!is_numeric($pageID)){
header("Location: index.php");
exit;
}
$pageContent = $mysqli->query("SELECT * FROM faucet_pages WHERE id = '$pageID'");
if($pageContent->num_rows == 1){
$pageContent = $mysqli->query("SELECT * FROM faucet_pages WHERE id = '$pageID'")->fetch_assoc();
$content = $pageContent['content'];
if($_GET['p']){

define('ADDON_ACTIVE', 1);

$addonList = array();
$addonListSQL = $mysqli->query("SELECT * FROM faucet_addon_list WHERE enabled = '1'");

while($addonRow = $addonListSQL->fetch_assoc())
$addonList[] = $addonRow['directory_name'];

switch($_GET['p']){
case(""):
default:
header("Location: index.php");
exit;
break;

case in_array($_GET['p'], $addonList):
include("addons/".$_GET['p']."/__page.php");
break;
}

} else {
$pageID = $mysqli->real_escape_string($_GET['pid']);
if(!is_numeric($pageID)){
header("Location: index.php");
exit;
}
$pageContent = $mysqli->query("SELECT * FROM faucet_pages WHERE id = '$pageID'");
if($pageContent->num_rows == 1){
$pageContent = $mysqli->query("SELECT * FROM faucet_pages WHERE id = '$pageID'")->fetch_assoc();
$content = $pageContent['content'];
}
}

$tpl->assign("content", $content);
Expand Down
21 changes: 15 additions & 6 deletions sql.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
CREATE TABLE IF NOT EXISTS `faucet_addon_list` (
`id` int(32) unsigned NOT NULL,
`name` varchar(50) NOT NULL,
`directory_name` varchar(50) NOT NULL,
`enabled` int(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `faucet_banned_address` (
`id` int(32) unsigned NOT NULL,
`address` varchar(100) NOT NULL
Expand Down Expand Up @@ -69,6 +76,10 @@ CREATE TABLE IF NOT EXISTS `faucet_user_list` (
`claim_cryptokey` varchar(75) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


ALTER TABLE `faucet_addon_list`
ADD PRIMARY KEY (`id`);

ALTER TABLE `faucet_banned_address`
ADD PRIMARY KEY (`id`);

Expand All @@ -87,20 +98,18 @@ ALTER TABLE `faucet_transactions`
ALTER TABLE `faucet_user_list`
ADD PRIMARY KEY (`id`);


ALTER TABLE `faucet_addon_list`
MODIFY `id` int(32) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `faucet_banned_address`
MODIFY `id` int(32) unsigned NOT NULL AUTO_INCREMENT;

ALTER TABLE `faucet_banned_ip`
MODIFY `id` int(32) unsigned NOT NULL AUTO_INCREMENT;

ALTER TABLE `faucet_pages`
MODIFY `id` int(32) unsigned NOT NULL AUTO_INCREMENT;

ALTER TABLE `faucet_settings`
MODIFY `id` int(32) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=26;

ALTER TABLE `faucet_transactions`
MODIFY `id` int(32) unsigned NOT NULL AUTO_INCREMENT;

ALTER TABLE `faucet_user_list`
MODIFY `id` int(32) unsigned NOT NULL AUTO_INCREMENT;
MODIFY `id` int(32) unsigned NOT NULL AUTO_INCREMENT;

0 comments on commit d11ffd9

Please sign in to comment.