diff --git a/admin/admin.php b/admin/admin.php index 25d2a4e..8704688 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -13,7 +13,7 @@ * GNU General Public License in GPL.txt for more details. */ -define('IN_ADMIN', 1); +define('IN_PONEPASTE', 1); require_once('common.php'); $query = $conn->query('SELECT user FROM admin LIMIT 1'); diff --git a/admin/ads.php b/admin/ads.php index 1a15ec2..359bbb9 100644 --- a/admin/ads.php +++ b/admin/ads.php @@ -13,7 +13,7 @@ * GNU General Public License in GPL.txt for more details. */ -define('IN_ADMIN', 1); +define('IN_PONEPASTE', 1); require_once('common.php'); updateAdminHistory($conn); diff --git a/admin/common.php b/admin/common.php index b88ed43..7076f49 100644 --- a/admin/common.php +++ b/admin/common.php @@ -1,15 +1,8 @@ PDO::ERRMODE_EXCEPTION, /* throw a fatal exception on database errors */ - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, /* Fetch rows as an associative array (hash table) by default */ - PDO::ATTR_EMULATE_PREPARES => false -]; - - -require_once('../includes/config.php'); +require_once('../includes/common.php'); function updateAdminHistory($conn) { $last_date = null; @@ -29,8 +22,6 @@ function updateAdminHistory($conn) { } } -session_start(); - if (!isset($_SESSION['login'])) { header('Location: .'); exit(); @@ -45,11 +36,3 @@ if (isset($_GET['logout'])) { exit(); } -$conn = new PDO( - "mysql:host=$db_host;dbname=$db_schema;charset=utf8", - $db_user, - $db_pass, - $db_opts -); - - diff --git a/admin/configuration.php b/admin/configuration.php index e70a3af..b823f17 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -12,7 +12,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License in GPL.txt for more details. */ -define('IN_ADMIN', 1); +define('IN_PONEPASTE', 1); require_once('common.php'); const CONFIG_FILE_PATH = '../config/site.php'; @@ -31,39 +31,26 @@ function updateConfiguration(string $path, array $new_config) { fclose($fp); } -/** @noinspection PhpIncludeInspection */ $current_config = require(CONFIG_FILE_PATH); $current_site_info = $current_config['site_info']; $current_permissions = $current_config['permissions']; $current_mail = $current_config['mail']; - -$result = $conn->query('SELECT * FROM captcha WHERE id = 1'); - -if ($row = $result->fetch()) { - $cap_e = $row['cap_e']; - $mode = $row['mode']; - $mul = $row['mul']; - $allowed = $row['allowed']; - $color = $row['color']; - $recaptcha_sitekey = $row['recaptcha_sitekey']; - $recaptcha_secretkey = $row['recaptcha_secretkey']; -} +$current_captcha = $current_config['captcha']; /* Update the configuration if necessary */ - if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = $_POST['action']; - if ($action === 'manage') { + if ($action === 'site_info') { + $data = $_POST['site_info']; $new_site_info = [ - 'title' => trim($_POST['title']), - 'description' => trim($_POST['description']), - 'baseurl' => trim($_POST['baseurl']), - 'keywords' => trim($_POST['keywords']), - 'site_name' => trim($_POST['site_name']), - 'email' => trim($_POST['email']), - 'google_analytics' => trim($_POST['ga']), - 'additional_scripts' => trim($_POST['additional_scripts']) + 'title' => trim($data['title']), + 'description' => trim($data['description']), + 'baseurl' => trim($data['baseurl']), + 'keywords' => trim($data['keywords']), + 'site_name' => trim($data['site_name']), + 'email' => trim($data['email']), + 'additional_scripts' => trim($data['additional_scripts']) ]; $current_config['site_info'] = $new_site_info; @@ -86,23 +73,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $msg = '
Site permissions saved.
'; - } elseif (isset($_POST['cap'])) { - $query = $conn->prepare( - 'UPDATE captcha SET cap_e = ?, mode = ?, mul = ?, allowed = ?, color = ?, recaptcha_sitekey = ?, recaptcha_secretkey = ? WHERE id = 1' - ); - $query->execute([ - trim($_POST['cap_e']), - trim($_POST['mode']), - trim($_POST['mul']), - trim($_POST['allowed']), - trim($_POST['color']), - trim($_POST['recaptcha_sitekey']), - trim($_POST['recaptcha_secretkey']) - ]); + } elseif ($action === 'captcha') { + $new_captcha = [ + 'enabled' => ($_POST['captcha']['enabled'] === '1'), + 'multiple' => ($_POST['captcha']['multiple'] === '1') + ]; + + $current_config['captcha'] = $new_captcha; + $current_captcha = $new_captcha; + + updateConfiguration(CONFIG_FILE_PATH, $current_config); + $msg = '
Captcha settings saved
'; - } } ?> @@ -170,89 +154,76 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ action="">
- +
- + value="">
- +
- + value="">
- +
- + ;
- +
- +
- + value="">
- +
- + value="">
-
- +
- +
- -
- -
-
- -
-
- +
@@ -300,36 +271,33 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ action="">
- type="checkbox" - name="cap_e" - id="cap_e"> - + type="checkbox" + name="captcha[enabked]" + id="captcha_enabled"> +

- - reCAPTCHA'; - } else { - echo ''; - } - if ($mode == "Easy") { + if ($current_captcha['mode'] == "Easy") { echo ''; } else { echo ''; } - if ($mode == "Normal") { + + if ($current_captcha['mode'] == "Normal") { echo ''; } else { echo ''; } - if ($mode == "Tough") { + + if ($current_captcha['mode'] == "Tough") { echo ''; } else { echo ''; @@ -343,52 +311,31 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { Internal Captcha Settings:
- type="checkbox" - name="mul" - id="mul"> - + type="checkbox" + name="captcha[multiple]" + id="captcha_multiple"> +

-
-

-
- reCAPTCHA Settings: -
-
- -
- -
-
- -
- -
- -
-
@@ -429,16 +376,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { "; - } ?> diff --git a/theme/bulma/main.php b/theme/bulma/main.php index 4f7f4b8..dd4d9c7 100644 --- a/theme/bulma/main.php +++ b/theme/bulma/main.php @@ -389,17 +389,8 @@ ?>
- - -
-
- - + +
'; ?> @@ -409,7 +400,7 @@ "Enter"

- } ?>