settings.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:8k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: settings.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.19 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Settings maintenance (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "list";
- }
- // globalise variables
- $global = array (
- array('id', 'number'),
- array('onecat', 'number') // only show a particular category
- );
- rg($global);
- include('./settings_include.php');
- ############################### UPDATE THE SETTINGS ###############################
- if ($_REQUEST['do'] == "update") {
- update_settings();
- alert('Settings Updated');
- $_REQUEST['do'] = "list";
- }
- ############################### DISPLAY SETTINGS ###############################
- if ($_REQUEST['do'] == "list") {
- admin_header('Settings', 'Edit Settings');
- show_settings();
- }
- ############################### EDIT CATEGORIES (DEVELOPER ONLY) ###############################
- if ($_REQUEST['do'] == "cat2") {
- developer_check();
- while (list ($key, $value) = each ($_REQUEST[name])) {
- $db->query("UPDATE settings_cat SET name = '".mysql_escape_string($value)."' WHERE id='$key'");
- $array[] = array(
- $key,
- $value,
- $_REQUEST[description][$key],
- $_REQUEST[defaultdisplay][$key],
- $_REQUEST[displayorder][$key]
- );
- }
- $db->query("REPLACE INTO settings_cat (id, name, description, defaultdisplay, displayorder) VALUES " . multi_array2sql($array) . "");
- alert('Categories Updated');
- $_REQUEST['do'] = "cats";
- }
- ############################### ADD / DELETE CATEGORY (DEVELOPER ONLY) ###############################
- if ($_REQUEST['do'] == "addcat") {
- developer_check();
- $db->query("INSERT INTO settings_cat SET name = 'new'");
-
- alert('Category Created');
- $_REQUEST['do'] = "cats";
- }
- if ($_REQUEST['do'] == "delcat") {
- developer_check();
- $db->query("DELETE FROM settings_cat WHERE id = '$id'");
- $db->query("DELETE FROM settings WHERE category = '$id'");
-
- alert('Category Deleted');
- $_REQUEST['do'] = "cats";
- }
- ############################### EDIT CATEGORY SETTINGS (DEVELOPER ONLY) ###############################
- if ($_REQUEST['do'] == "cats") {
- developer_check();
- admin_header('Settings', 'Edit Categories');
- $db->query("SELECT * FROM settings_cat ORDER BY defaultdisplay DESC, displayorder ASC");
-
- while ($set = $db->row_array()) {
-
- if ($set[defaultdisplay] != 1 AND !$y) {
- $table[] = table_midheader('Not Displayed by Default');
- $y=1;
- }
- $table[] = array(
- form_input($set[id], $set[displayorder], '3', 'displayorder'),
- form_radio_yn($set[id], 'defaultdisplay', $set[defaultdisplay]),
- form_input($set[id], $set[name], '25', 'name'),
- form_input($set[id], $set[description], '50', 'description'),
- jprompt('Confirm deletion of category and any settings it contains', "settings.php?do=delcat&id=$set[id]", "Delete")
- );
- }
- $cols = array('Order', 'Default Display', 'Title', 'Description', 'Delete');
- table_header("Edit the Setting Categories", 'settings.php', array('do' => 'cat2'));
- table_content($cols, $table);
- table_footer('Update');
- echo "<br /><center><a href="settings.php?do=addcat">Add Category</a></center>";
-
- }
- ############################### ADD / DELETE / SETTING (DEVELOPER ONLY) ###############################
- if ($_REQUEST['do'] == "add") {
- developer_check();
-
- $db->query("INSERT INTO settings SET category=1, field_type = '$_REQUEST[type]'");
- alert('Setting Created');
- $_REQUEST['do'] = "edit_settings";
- }
- if ($_REQUEST['do'] == "del") {
- developer_check();
- $db->query("DELETE FROM settings WHERE id = '$id'");
- alert('Setting Deleted');
- $_REQUEST['do'] = "edit_settings";
- }
- ############################### EDIT SETTINGS (2) (DEVELOPER ONLY) ###############################
- if ($_REQUEST['do'] == "edit_settings2") {
- // update the settings
- while (list ($key, $value) = each ($_REQUEST[name])) {
- $db->query("
- UPDATE settings SET
- name = '" . mysql_escape_string($value) . "',
- settings = '" . mysql_escape_string($_REQUEST[variablename][$key]) . "',
- description = '" . mysql_escape_string($_REQUEST[description][$key]) . "',
- category = '" . mysql_escape_string($_REQUEST[category][$key]) . "',
- value = '" . mysql_escape_string($_REQUEST[settings][$key]) . "'
- WHERE id = '$key'
- ");
- }
- alert('Setting Updated');
- $_REQUEST['do'] = 'edit_settings';
- }
- ############################### EDIT SETTINGS (DEVELOPER ONLY) ###############################
- if ($_REQUEST['do'] == "edit_settings") {
- developer_check();
- admin_header('Settings', 'Edit The Settings');
- // get settings_cat details
- $db->query(
- "SELECT * from settings_cat"
- );
- while ($setcat = $db->row_array()) {
-
- $settingid[] = $setcat[id];
- $settingname[$setcat[id]] = $setcat[name];
- $settingdescription[$setcat[id]] = $setcat[description];
-
- }
- // get settings data
- $db->query(
- "SELECT settings.*
- FROM settings
- LEFT JOIN settings_cat ON (settings.category = settings_cat.id)
- ORDER BY settings.category, settings.show_order"
- );
- $no=1;
- $width = array('60%', '40%');
- echo "<form action="settings.php" method="post">";
- while ($set = $db->row_array()) {
- if ($set[category] != $previous) {
- if ($no != "1") {
- if ($onecat != $previous) {
- $show = 1;
- } else {
- $show = '';
- }
- $show=0;
- table_header($settingname[$previous] . "</b>: " . $settingdescription[$previous] . "<b>", '', '', $show);
- table_content('', $table, '', '', '', '', $width);
- table_footer();
- unset($table);
- }
- unset($no);
-
- }
- if ($set[field_type] == "text") {
- $bit = form_input($set[id], $set[value], '30', 'settings');
- } elseif ($set[field_type] == "area") {
- $bit = form_textarea($set[id], '30', '5', $set[value], 'settings');
- } elseif ($set[field_type] == "radio") {
- $bit = form_radio_yn($set[id], 'settings', $set[value]);
- }
- $table[] =
- '<table cellpadding="3">
- <tr><td><b>Name</b></td><td>' . form_input($set[id], $set[name], '45', 'name') .
- ' <b>Variable Name</b> ' . form_input($set[id], $set[settings], '25', 'variablename') . '</td></tr>' .
- '<tr><td><b>Description</b></td><td>' . form_input($set[id], $set[description], '100', 'description') . '</td></tr>' .
- '<tr><td><b>Category</b></td><td>' . form_select($set[id], $settingname, 'category', $set[category]) . jprompt('Confirm deletion of setings', "settings.php?do=del&id=$set[id]", "Delete") . $bit .
- '</td></tr></table>';
- $previous = $set[category];
-
- }
- table_header($settingname[$previous] . "</b>: " . $settingdescription[$previous] . "<b>", '', '', $show);
- table_content('', $table, '', '', '', '', $width);
- table_footer();
- echo form_hidden('do', 'edit_settings2');
- echo "<input type="submit" name="update" value="update"></form>";
- echo "
- <br /><br />
- <a href="settings.php?do=add&type=text">Create new text based setting</a><br /><br />
- <a href="settings.php?do=add&type=radio">Create new radio based setting</a><br /><br />";
- }
- admin_footer();