>
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');
if(!isset($_SESSION['id'])){die(_('Insufficient privileges'));}
if(!($privileges&PRIV_LICENSES)){die(_('Insufficient privileges'));}
if(checknonce()) // Save changes
{
if(isset($_POST['action']) && $_POST['action']=='newlicense')
{
$name=mysqli_real_escape_string($db, $_POST['newname']);
$simple=mysqli_real_escape_string($db, $_POST['newsimple']);
$full=mysqli_real_escape_string($db, $_POST['newfull']);
if(!mysqli_query($db, 'insert into licenses(name, simple, full, removed, defaultlicense) values("'.$name.'", "'.$simple.'", "'.$full.'", false, false)'))
{
mysqli_query($db, 'update licenses set simple="'.$simple.'", full="'.$full.'", removed=false, defaultlicense=false where name="'.$name.'" and removed');
}
}
if(isset($_POST['removelicense']))
{
$name=mysqli_real_escape_string($db, $_POST['removelicense']);
mysqli_query($db, 'update licenses set removed=true where name="'.$name.'"');
}
if(isset($_POST['defaultlicense']))
{
$name=mysqli_real_escape_string($db, $_POST['defaultlicense']);
mysqli_query($db, 'update licenses set defaultlicense=false where name!="'.$name.'"');
mysqli_query($db, 'update licenses set defaultlicense=true where name="'.$name.'"');
}
}
// Load current
$licenses='';
$res=mysqli_query($db, 'select name, simple, full, defaultlicense from licenses where !removed order by name asc');
while($row=mysqli_fetch_assoc($res))
{
$name=htmlentities($row['name']);
$simple=htmlentities($row['simple']);
$full=htmlentities($row['full']);
$licenses.='