<?php
// +----------------------------------------------------------------------+
// | Fantastic File Database |
// +----------------------------------------------------------------------+
// | By Tony Baird |
// | Copyright (c) 2003 Fantastic Scripts |
// | http://fscripts.com |
// +----------------------------------------------------------------------+
// | Fantastic File Database Can be modified freely as long as copyright |
// | is intact and this is left at the top of every source file |
// +----------------------------------------------------------------------+
// | license.php |
// | Date Started: March 13, 2003 |
// | Last Modified: March 13, 2003 |
// +----------------------------------------------------------------------+
Class License {
//*************************************************/
// Just seing what we are doing
//*************************************************/
function License() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin;
if ($_REQUEST['action']=="add_license") {
$this->AddLicenseForm();
}elseif (isset($_REQUEST['add_license'])) {
$this->AddLicense();
}elseif ($_REQUEST['action']=="edit_license") {
$this->LicenseList();
}elseif ($_REQUEST['action']=="delete_license_confirm") {
$this->ConfirmDeleteLicense();
}elseif ($_REQUEST['action']=="delete_license") {
$this->DeleteLicense();
}elseif ($_REQUEST['action']=="edit_license_form") {
$this->EditLicenseForm();
}elseif (isset($_REQUEST['edit_license'])) {
$this->EditLicense();
}
}
//*************************************************/
// Add License Form
//*************************************************/
function AddLicenseForm() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin;
$tpl->LoadTemplate("add_license_form","Admin/templates/$admin_skin/add_license_form.tpl");
$tpl->ParseTemplate("add_license_form",$add_license_form_array,"No");
$tpl->PrintTemplate("add_license_form");
}
//*************************************************/
// Actually Adds License
//*************************************************/
function AddLicense() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin,$admin;
if (empty($_POST['license_name'])) {
$error .="Missing License Name<br>";
}
if (empty($_POST['license_text'])) {
$error .="Missing License Text<br>";
}
if ($error) {
$admin->Error($error);
}
$ffdb->slash_array($_POST);
$add_license_array = array(
'license_name' => $_POST['license_name'],
'license_text'=>$_POST['license_text']
);
nl2br($_POST['license_text']);
$mysql->MakeInsertString($add_license_array);
$mysql->Query("INSERT INTO ffdb_licenses ($mysql->insert_fields) VALUES ($mysql->insert_values)");
$admin->Success("License Added Successfully");
}
//*************************************************/
// License List for editing
//*************************************************/
function LicenseList() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin,$admin;
$mysql->Query("SELECT * FROM ffdb_licenses ORDER BY license_name");
$tpl->LoadTemplate("license_list","Admin/templates/$admin_skin/license_list.tpl");
while ($show_license=mysql_fetch_array($mysql->result_id)) {
$has_license=1;
$license_list_array = array(
'license_name'=> $show_license[license_name],
'license_text'=> $show_license[license_text],
'license_id'=> $show_license[license_id],
);
$tpl->ParseTemplate("license_list",$license_list_array,"Yes");
}
if ($has_license==1) {
$tpl->PrintTemplate("license_list");
} else {
$admin->Error("There are currently no licenses to edit");
}
}
//*************************************************/
// Confirms that the user wants to delete the
// license
//*************************************************/
function ConfirmDeleteLicense() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin,$admin;
$mysql->Query("SELECT * FROM ffdb_licenses WHERE license_id=".$_REQUEST['id']."");
$show_license=mysql_fetch_array($mysql->result_id);
$admin->Confirm("Are you sure you want to delete $show_license[license_name]?<br>","admin.php?action=delete_license&id=$show_license[license_id]");
}
//*************************************************/
// Deletes the license
//*************************************************/
function DeleteLicense() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin,$admin;
$mysql->Query("DELETE FROM ffdb_licenses WHERE license_id=".$_REQUEST['id']."");
$admin->Success("License Deleted successfully");
}
//*************************************************/
// Edit License form
//*************************************************/
function EditLicenseForm() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin,$admin;
$mysql->Query("SELECT * FROM ffdb_licenses WHERE license_id=".$_REQUEST['id']."");
$show_license=mysql_fetch_array($mysql->result_id);
$tpl->LoadTemplate("edit_license_form","Admin/templates/$admin_skin/edit_license_form.tpl");
$edit_license_form_array = array(
'license_name'=> $show_license[license_name],
'license_text'=> $show_license[license_text],
'license_id'=> $show_license[license_id],
);
$tpl->ParseTemplate("edit_license_form",$edit_license_form_array,"No");
$tpl->PrintTemplate("edit_license_form");
}
//*************************************************/
// Actually edits the licenses
//*************************************************/
function EditLicense() {
global $tpl,$mysql,$ffdb,$CONFIG,$admin_skin,$admin;
if (empty($_POST['license_name'])) {
$error .="Missing License Name<br>";
}
if (empty($_POST['license_text'])) {
$error .="Missing License Text<br>";
}
if ($error) {
$admin->Error($error);
}
$ffdb->slash_array($_POST);
nl2br($_POST['license_text']);
$update_license_array = array(
'license_name' => $_POST['license_name'],
'license_text' => $_POST['license_text']
);
$mysql->MakeUpdateString($update_license_array);
$mysql->Query("UPDATE ffdb_licenses SET $mysql->update_string WHERE license_id=".$_POST['id']."");
$admin->Success("License Updated successfully");
}
}
?>