Skip to content

Commit

Permalink
Added maintenance_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
farisc0de committed Jan 17, 2024
1 parent 9b6f52e commit 1b5d006
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 44 deletions.
83 changes: 53 additions & 30 deletions uploady/admin/settings/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,49 +225,72 @@
<hr>

<div class="form-group">
<input hidden name="adsense_status" value="0" />
<input hidden name="maintenance_mode" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="adsense_status" name="adsense_status" value="1" type="checkbox" <?= ($settings->getSettingValue('adsense_status') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="adsense_status">Enable Adsense</label>
<input class="custom-control-input" id="maintenance_mode" name="maintenance_mode" value="1" type="checkbox" <?= ($settings->getSettingValue('maintenance_mode') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="maintenance_mode">Enable Maintenance Mode</label>
</div>
</div>

<div class="form-group">
<div class="form-label-group">
<input class="form-control" type="text" id="adsense_client_code" name="adsense_client_code" placeholder="Adsense Client Code" value="<?= $settings->getSettingValue('adsense_client_code'); ?>">
<label for="adsense_client_code">Adsense Client Code</label>
<hr>

<?php if ($utils->module_exist("adsense")) : ?>

<div class="form-group">
<input hidden name="adsense_status" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="adsense_status" name="adsense_status" value="1" type="checkbox" <?= ($settings->getSettingValue('adsense_status') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="adsense_status">Enable Adsense</label>
</div>
</div>
</div>

<div class="form-group">
<input hidden name="analytics_status" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="analytics_status" name="analytics_status" value="1" type="checkbox" <?= ($settings->getSettingValue('analytics_status') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="analytics_status">Enable Google Analytics</label>
<div class="form-group">
<div class="form-label-group">
<input class="form-control" type="text" id="adsense_client_code" name="adsense_client_code" placeholder="Adsense Client Code" value="<?= $settings->getSettingValue('adsense_client_code'); ?>">
<label for="adsense_client_code">Adsense Client Code</label>
</div>
</div>
</div>

<div class="form-group">
<div class="form-label-group">
<input class="form-control" type="text" id="analytics_code" name="analytics_code" placeholder="Analytics UA Code" value="<?= $settings->getSettingValue('analytics_code'); ?>">
<label for="analytics_code">Google Analytics Code</label>
<?php endif; ?>


<?php if ($utils->module_exist("analytics")) : ?>

<div class="form-group">
<input hidden name="analytics_status" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="analytics_status" name="analytics_status" value="1" type="checkbox" <?= ($settings->getSettingValue('analytics_status') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="analytics_status">Enable Google Analytics</label>
</div>
</div>
</div>

<div class="form-group">
<input hidden name="sharethis_status" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="sharethis_status" name="sharethis_status" value="1" type="checkbox" <?= ($settings->getSettingValue('sharethis_status') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="sharethis_status">Enable ShareThis</label>
<div class="form-group">
<div class="form-label-group">
<input class="form-control" type="text" id="analytics_code" name="analytics_code" placeholder="Analytics UA Code" value="<?= $settings->getSettingValue('analytics_code'); ?>">
<label for="analytics_code">Google Analytics Code</label>
</div>
</div>
</div>

<div class="form-group">
<div class="form-label-group">
<input class="form-control" type="text" id="sharethis_code" name="sharethis_code" placeholder="Sharethis Code" value="<?= $settings->getSettingValue('sharethis_code'); ?>">
<label for="sharethis_code">Sharethis Code</label>
<?php endif; ?>

<?php if ($utils->module_exist("sharethis")) : ?>

<div class="form-group">
<input hidden name="sharethis_status" value="0" />
<div class="custom-control custom-switch custom-control-right">
<input class="custom-control-input" id="sharethis_status" name="sharethis_status" value="1" type="checkbox" <?= ($settings->getSettingValue('sharethis_status') == true) ? 'checked' : null; ?>>
<label class="custom-control-label" for="sharethis_status">Enable ShareThis</label>
</div>
</div>
</div>

<div class="form-group">
<div class="form-label-group">
<input class="form-control" type="text" id="sharethis_code" name="sharethis_code" placeholder="Sharethis Code" value="<?= $settings->getSettingValue('sharethis_code'); ?>">
<label for="sharethis_code">Sharethis Code</label>
</div>
</div>

<?php endif; ?>

<button class="btn btn-primary btn-block">
Update Settings
Expand Down
6 changes: 1 addition & 5 deletions uploady/components/js.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
$utils->script("https://code.jquery.com/jquery-3.6.0.min.js");
$utils->script("https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js");
$utils->script("https://cdn.datatables.net/v/bs5/dt-1.11.3/datatables.min.js");

if (strpos($_SERVER['REQUEST_URI'], 'download.php') !== false) {
$utils->script("https://platform-api.sharethis.com/js/sharethis.js#property={$st['sharethis_code']}&product=inline-share-buttons");
}

$utils->script("https://unpkg.com/[email protected]/dist/dropzone-min.js");
$utils->script("https://cdn.datatables.net/fixedcolumns/4.2.2/js/dataTables.fixedColumns.min.js");

Expand All @@ -27,3 +22,4 @@

include_once APP_PATH . "modules/adsense/main.php";
include_once APP_PATH . "modules/analytics/main.php";
include_once APP_PATH . "modules/analytics/main.php";
6 changes: 5 additions & 1 deletion uploady/languages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@
"delete_after_downloads_placeholder": "أدخل عدد التنزيلات بعد الذي سيتم حذف الملف. اترك 0 إذا كنت لا تريد حذف الملف.",
"delete_after_downloads_help": "أدخل عدد التنزيلات بعد الذي سيتم حذف الملف. اترك 0 إذا كنت لا تريد حذف الملف.",
"account_not_activated": "لم يتم تفعيل حسابك. يرجى التحقق من بريدك الإلكتروني.",
"set_btn": "تعيين"
"set_btn": "تعيين",
"maintenance_mode": "وضع الصيانة",
"maintenance_mode_help": "يمكنك تعطيل الموقع للصيانة. سيتم إرسال رسالة إلى المستخدمين أن الموقع متوقف مؤقتًا. يمكنك تعطيل هذه الميزة بإلغاء التحديد.",
"maintenance_mode_title": "وضع الصيانة",
"maintenance_mode_body": "الموقع متوقف مؤقتًا للصيانة. يرجى المحاولة مرة أخرى في وقت لاحق."
},
"navbar": {
"home": "الصفحة الرئيسية",
Expand Down
6 changes: 5 additions & 1 deletion uploady/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@
"delete_after_downloads": "Delete After Downloads",
"delete_after_downloads_placeholder": "Enter number of downloads after which the file will be deleted",
"delete_after_downloads_help": "Enter number of downloads after which the file will be deleted. Leave 0 if you don't want to delete the file.",
"set_btn": "Set"
"set_btn": "Set",
"maintenance_mode": "Maintenance Mode",
"maintenance_mode_help": "Enable maintenance mode to disable all the uploads and downloads.",
"maintenance_mode_title": "Maintenance Mode",
"maintenance_mode_body": "Maintenance Mode is enabled. Please try again later."
},
"navbar": {
"home": "Home",
Expand Down
6 changes: 5 additions & 1 deletion uploady/languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@
"delete_after_downloads": "Delete After Downloads",
"delete_after_downloads_placeholder": "Enter number of downloads after which the file will be deleted",
"delete_after_downloads_help": "Enter number of downloads after which the file will be deleted. Leave 0 if you don't want to delete the file.",
"set_btn": "Imposta"
"set_btn": "Imposta",
"maintenance_mode": "Maintenance Mode",
"maintenance_mode_help": "Enable maintenance mode to disable all the uploads and downloads.",
"maintenance_mode_title": "Maintenance Mode",
"maintenance_mode_body": "Maintenance Mode is enabled. Please try again later."
},
"navbar": {
"home": "Home",
Expand Down
6 changes: 5 additions & 1 deletion uploady/languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@
"delete_after_downloads": "Удалить через... (кол-во загрузок)",
"delete_after_downloads_placeholder": "Введите количество скачиваний, после которого файл будет удален",
"delete_after_downloads_help": "Введите количество скачиваний, после которого файл будет удален. Оставьте 0, если не хотите удалять файл",
"set_btn": "Установить"
"set_btn": "Установить",
"maintenance_mode": "Maintenance Mode",
"maintenance_mode_help": "Enable maintenance mode to disable all the uploads and downloads.",
"maintenance_mode_title": "Maintenance Mode",
"maintenance_mode_body": "Maintenance Mode is enabled. Please try again later."
},
"navbar": {
"home": "Главная",
Expand Down
7 changes: 7 additions & 0 deletions uploady/logic/installLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@
'setting_value' => ''
]
);
$install->insertValue(
"settings",
[
'setting_key' => 'maintenance_mode',
'setting_value' => false
]
);
$install->insertValue(
"settings",
[
Expand Down
22 changes: 22 additions & 0 deletions uploady/maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php include_once 'session.php'; ?>

<?php $title = $lang['general']['maintenance_mode_title'] ?>

<?php include_once 'components/header.php'; ?>

<div class="container pb-5 pt-5">
<div class="row justify-content-center text-center">
<div class="col-sm-12 col-md-8 col-lg-8">
<div class="card">
<div class="card-header">
<b><?= $lang['general']['maintenance_mode_title'] ?></b>
</div>
<div class="card-body">
<p><?= $lang['general']['maintenance_mode_body'] ?></p>
</div>
</div>
</div>
</div>
</div>

<?php include_once 'components/footer.php'; ?>
5 changes: 5 additions & 0 deletions uploady/modules/sharethis/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

if (strpos($_SERVER['REQUEST_URI'], 'download.php') !== false) {
$utils->script("https://platform-api.sharethis.com/js/sharethis.js#property={$st['sharethis_code']}&product=inline-share-buttons");
}
10 changes: 5 additions & 5 deletions uploady/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

$st = $settings->getSettings();

// if ($st['maintenance_mode'] == 1) {
// if (!strpos($_SERVER['REQUEST_URI'], "maintenance.php")) {
// $utils->redirect($utils->siteUrl('/maintenance.php'));
// }
// }
if ($st['maintenance_mode'] == 1) {
if (!strpos($_SERVER['REQUEST_URI'], "maintenance.php")) {
$utils->redirect($utils->siteUrl('/maintenance.php'));
}
}

$allowed_pages = array(
'login.php',
Expand Down
5 changes: 5 additions & 0 deletions uploady/src/Uploady/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,9 @@ public function loadAlerts($msg, $module = "user")

echo $this->alert($msg, $status, $icon);
}

public function module_exist($module)
{
return file_exists(APP_PATH . "modules/$module/main.php");
}
}

0 comments on commit 1b5d006

Please sign in to comment.