$ git clone https://thingshare.ion.nu/thingshare.git
commit 6b7f3f004c5f948925a58b83201c09aee79a89b2
Author: Alicia <...>
Date: Mon Nov 2 21:02:15 2020 +0100
Added missing file from the tag support commit.
diff --git a/Dependencies b/Dependencies
index 589e08e..53a3d52 100644
--- a/Dependencies
+++ b/Dependencies
@@ -6,6 +6,7 @@ x3dom (wget https://x3dom.org/download/1.8.1/x3dom.{debug.js,css})
Web dependencies:
PHP
PHP curl module
+PHP gd module
PHP MariaDB/MySQL module
System dependencies (just need to be installed and findable in path)
diff --git a/admin_tags.php b/admin_tags.php
new file mode 100644
index 0000000..23d40b0
--- /dev/null
+++ b/admin_tags.php
@@ -0,0 +1,79 @@
+<...>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+include_once('db.php');
+include_once('nonce.php');
+include_once('rpc.php');
+if(!isset($_SESSION['id'])){die(_('Insufficient privileges'));}
+if(!($privileges&PRIV_TAGS)){die(_('Insufficient privileges'));}
+
+$error='';
+if(checknonce()) // Save changes
+{
+ if(isset($_POST['options']))
+ {
+ setoption('usertags', isset($_POST['usertags']));
+ }
+ if(isset($_POST['addtag']) || isset($_POST['blacklisttag']))
+ {
+ $tag=mysqli_real_escape_string($db, $_POST['newtag']);
+ $blacklist='0';
+ if(isset($_POST['blacklisttag']))
+ {
+ $blacklist='1';
+ $res=mysqli_query($db, 'select id from tags where name="'.$tag.'"');
+ if($res=mysqli_fetch_row($res))
+ {
+ mysqli_query($db, 'delete from tagmaps where tag="'.(int)$res[0].'"');
+ }
+ }
+ mysqli_query($db, 'delete from tags where name="'.$tag.'"');
+ mysqli_query($db, 'insert into tags(name, blacklist) values("'.$tag.'", '.$blacklist.')');
+ }
+ if(isset($_POST['deletetag']))
+ {
+ $tag=(int)$_POST['deletetag'];
+ mysqli_query($db, 'delete from tagmaps where tag="'.$tag.'"');
+ mysqli_query($db, 'delete from tags where id="'.$tag.'"');
+ }
+}
+if($error!=''){$error='<span class="error">'.$error.'</span>';}
+
+// Load current
+$tags='';
+$res=mysqli_query($db, 'select name, blacklist, id from tags order by name asc');
+while($row=mysqli_fetch_assoc($res))
+{
+ $name=htmlentities($row['name']);
+ if($row['blacklist']){$name='<span class="blacklist">'.$name.'</span>';}
+ $tags.=$name.'<button name="deletetag" value="'.$row['id'].'">X</button><br />';
+}
+$usertagscheck=(getoption('usertags', true)?' checked':'');
+?>
+<?=$error?>
+<form method="post"><?=nonce()?>
+ <h2><?=_('Options')?></h2>
+ <label><input type="checkbox" name="usertags"<?=$usertagscheck?> /><?=_('Allow users to create tags')?></label><br />
+ <input type="submit" name="options" value="<?=_('Save')?>" />
+</form>
+<form method="post"><?=nonce()?>
+<h2><?=_('Tags')?></h2>
+<?=$tags?>
+ <input type="text" name="newtag" /><button name="addtag"><?=_('Add tag')?></button><button name="blacklisttag" title="<?=_('Don\'t allow this tag to be added')?>"><?=_('Add tag to blacklist')?></button><br />
+</form>