From 49623924c2e418225f79565c8ec272e2d982314b Mon Sep 17 00:00:00 2001
From: Daniel Winzen
Date: Fri, 16 Oct 2020 15:23:53 +0200
Subject: [PATCH] Add admin approval
---
common_config.php | 3 +-
lang_de.php | 5 ++
lang_en.php | 5 ++
lang_update.php | 2 +-
setup.php | 5 +-
www/admin.php | 205 +++++++++++++++++++++++++++-------------------
www/onions.php | 58 +++++++++----
7 files changed, 176 insertions(+), 107 deletions(-)
diff --git a/common_config.php b/common_config.php
index 60faba1..3fab835 100644
--- a/common_config.php
+++ b/common_config.php
@@ -33,7 +33,8 @@ define('PROMOTEPRICE', 0.025); // Price to promote a site for PROMOTETIME long
define('PROMOTETIME', 2592000); // Time (in seconds) to promote a site payed with PROMOTEPRICE - 864000 equals 10 days
define('PER_PAGE', 50); // Sites listed per page
define('VERSION', '1'); // Script version
-define('DBVERSION', 5); // Database layout version
+define('DBVERSION', 6); // Database layout version
+define('REQUIRE_APPROVAL', false); // require admin approval of new sites? true/false
//Categories - new links will always be put into the first one, leave it to Unsorted
//once configured, only add new categories at the end or you have to manually adjust the database.
$categories=['Unsorted', 'Adult/Porn', 'Communication/Social', 'Forums', 'Hacking/Programming/Software', 'Hosting', 'Libraries/Wikis', 'Link Lists', 'Market/Shop/Store', 'Other', 'Personal Sites/Blogs', 'Security/Privacy/Encryption', 'Whistleblowing', 'Empty/Error/Unknown', 'Cryptocurrencies', 'Scams', 'Fun/Games/Joke', 'Search', 'Autodetected scam (unchecked)'];
diff --git a/lang_de.php b/lang_de.php
index 029aa23..6636c05 100644
--- a/lang_de.php
+++ b/lang_de.php
@@ -67,4 +67,9 @@ $T=[
'language' => 'Sprache',
'format' => 'Format',
'hidelocked' => 'Gesperrte nicht anzeigen',
+ 'pendingapproval' => 'Genehmigung ausstehend',
+ 'rejected' => 'Abgelehnt',
+ 'reject' => 'Ablehnen',
+ 'approve' => 'Akzeptieren',
+ 'switchviewmode' => 'Ansichtsmodus wechseln',
];
diff --git a/lang_en.php b/lang_en.php
index 45795f4..995cab2 100644
--- a/lang_en.php
+++ b/lang_en.php
@@ -67,4 +67,9 @@ $I=[
'language' => 'Language',
'format' => 'Format',
'hidelocked' => 'Hide locked',
+ 'pendingapproval' => 'Pending approval',
+ 'rejected' => 'Rejected',
+ 'reject' => 'Reject',
+ 'approve' => 'Approve',
+ 'switchviewmode' => 'Switch view mode',
];
diff --git a/lang_update.php b/lang_update.php
index 6db58eb..23227d6 100644
--- a/lang_update.php
+++ b/lang_update.php
@@ -1,6 +1,6 @@
query('SELECT * FROM ' . PREFIX . 'settings LIMIT 1;')){
//create tables
$db->exec('CREATE TABLE ' . PREFIX . "captcha (id int(10) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, time int(10) UNSIGNED NOT NULL, code char(5) NOT NULL) ENGINE=MEMORY;");
- $db->exec('CREATE TABLE ' . PREFIX . "onions (id int(10) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, address varchar(56) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL, md5sum binary(16) NOT NULL UNIQUE, lasttest int(10) UNSIGNED NOT NULL DEFAULT '0', lastup int(10) UNSIGNED NOT NULL DEFAULT '0', timediff int(10) UNSIGNED NOT NULL DEFAULT '0', timeadded int(10) UNSIGNED NOT NULL DEFAULT '0', description text CHARACTER SET utf8mb4 NOT NULL, category smallint(6) NOT NULL DEFAULT '0', locked smallint(6) NOT NULL DEFAULT '0', special int(10) UNSIGNED NOT NULL DEFAULT '0', INDEX(address), INDEX(lasttest), INDEX(timediff), INDEX(category), INDEX(special));");
+ $db->exec('CREATE TABLE ' . PREFIX . "onions (id int(10) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, address varchar(56) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL, md5sum binary(16) NOT NULL UNIQUE, lasttest int(10) UNSIGNED NOT NULL DEFAULT '0', lastup int(10) UNSIGNED NOT NULL DEFAULT '0', timediff int(10) UNSIGNED NOT NULL DEFAULT '0', timeadded int(10) UNSIGNED NOT NULL DEFAULT '0', description text CHARACTER SET utf8mb4 NOT NULL, category smallint(6) NOT NULL DEFAULT '0', locked smallint(6) NOT NULL DEFAULT '0', special int(10) UNSIGNED NOT NULL DEFAULT '0', approved smallint(6) NOT NULL DEFAULT '0', INDEX(address), INDEX(lasttest), INDEX(timediff), INDEX(category), INDEX(special));");
$db->exec('CREATE TABLE ' . PREFIX . 'phishing (onion_id int(10) UNSIGNED NOT NULL PRIMARY KEY, original varchar(56) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL, FOREIGN KEY (onion_id) REFERENCES onions(id) ON DELETE CASCADE ON UPDATE CASCADE);');
$db->exec('CREATE TABLE ' . PREFIX . 'settings (setting varchar(50) NOT NULL PRIMARY KEY, value varchar(20000) NOT NULL);');
$stmt=$db->prepare('INSERT INTO ' . PREFIX . "settings (setting, value) VALUES ('version', ?);");
@@ -89,6 +89,9 @@ if(!@$db->query('SELECT * FROM ' . PREFIX . 'settings LIMIT 1;')){
if($version<5){
$db->exec('CREATE TABLE ' . PREFIX . "captcha (id int(10) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, time int(10) UNSIGNED NOT NULL, code char(5) NOT NULL) ENGINE=MEMORY;");
}
+ if($version < 6){
+ $db->exec('ALTER TABLE ' . PREFIX . "onions ADD approved smallint(6) NOT NULL DEFAULT '0';");
+ }
$stmt=$db->prepare('UPDATE ' . PREFIX . "settings SET value=? WHERE setting='version';");
$stmt->execute([DBVERSION]);
echo "$I[statusok]\n";
diff --git a/www/admin.php b/www/admin.php
index 88f2c8e..0bd85ce 100644
--- a/www/admin.php
+++ b/www/admin.php
@@ -28,14 +28,34 @@ if(!isSet($_POST['pass']) || $_POST['pass']!==ADMINPASS){
echo "$I[wrongpass]
";
}
}else{
+ $view_mode = isset($_POST['view_mode']) ? $_POST['view_mode'] : 'single';
+ if(isset($_POST['switch_view_mode'])){
+ $view_mode = $view_mode === 'single' ? 'multi' : 'single';
+ }
echo "";
+ echo "
';
echo "$I[cloneof]: $I[adddesc]: