>
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 .
*/
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=''.$error.'';}
// 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=''.$name.'';}
$tags.=$name.' ';
}
$usertagscheck=(getoption('usertags', true)?' checked':'');
?>
=$error?>