settings_include.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:5k
- <?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_include.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.17 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Utility functions for settings handling (administration
- // | interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- ############################### UPDATE SETTINGS ###############################
- function update_settings() {
- global $_REQUEST, $db;
- // update the settings
- if (!is_array($_REQUEST['settings'])) {
- return;
- }
- while (list ($key, $value) = each ($_REQUEST[settings])) {
- $db->query("UPDATE settings SET value = '" . mysql_escape_string($value) . "' WHERE settings='$key'");
- }
- }
- ############################### SHOW SETTINGS ###############################
- /*
- target : form we are submitting to
- cat : restrict by cats
- default : show default categories
- array : specify settings by name
- no_form : no_form
- extra_rows : used by basic_config.php
- */
- function show_settings($target='settings.php', $cat=NULL, $default=true, $array='', $form=true, $extra_rows='') {
- global $db;
- if ($cat) {
- if (!is_array($cat)) {
- $cat = array($cat);
- }
- }
- if ($default) {
- $terms[] = " defaultdisplay";
- }
- if ($cat) {
- $terms[] = " name IN " . array2sql($cat) . "";
- }
- if ($terms) {
- $terms = "WHERE " . join(' AND ', $terms);
- }
- // get settings_cat details
- $db->query(
- "SELECT * from settings_cat $terms");
- unset($cat);
- while ($setcat = $db->row_array()) {
- $settingid[] = $setcat[id];
- $settingname[$setcat[id]] = $setcat[name];
- $settingdescription[$setcat[id]] = $setcat[description];
- $cat[] = $setcat[id];
- }
- if ($cat) {
- if (is_array($cat)) {
- $where = " WHERE category IN " . array2sql($cat);
- } else {
- $where = " WHERE category = '$cat'";
- }
- } elseif ($default) {
- $where = " WHERE category IN " . array2sql($settingid);
- }
-
- if ($array) {
- $where .= iff($where, ' AND', ' WHERE') . " settings IN " . array2sql($array);
- }
- // get settings data
- $db->query(
- "SELECT settings.*
- FROM settings
- LEFT JOIN settings_cat ON (settings.category = settings_cat.id)" .
- $where . " ORDER BY settings.category, settings.show_order"
- );
- $no=1;
- if ($form) {
- echo "<form action="$target" 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);
- table_footer();
- unset($table);
- }
- unset($no);
-
- }
- if ($set[field_type] == "text") {
- $bit = form_input($set[settings], $set[value], '30', 'settings');
- } elseif ($set[field_type] == "area") {
- $bit = form_textarea($set[settings], '30', '5', $set[value], 'settings');
- } elseif ($set[field_type] == "radio") {
- $bit = form_radio_yn($set[settings], 'settings', $set[value]);
- }
- $table[] = "<table width="100%"><tr><td><b>$set[name]</b>" . iff(defined('DEVELOPERMODE'), " <i>Variable: $settings[" . $set[settings] . "]</I>") . "</td><td width="200" align="right"><p align="right">" . $bit . "</td></tr><tr><td>$set[description]</td></tr></table>";
- $previous = $set[category];
- }
- if (is_array($extra_rows)) {
- foreach($extra_rows AS $key => $var) {
- $table[] = settings_extra_row($var[0], $var[1], $var[2]);
- }
- }
- if ($form) {
- table_header($settingname[$previous] . "</b>: " . $settingdescription[$previous] . "<b>", '', '', $show);
- } else {
- echo "<br /><br /><table border="0" cellpadding="5" width="100%" align="center" cellspacing="0"><tr><td height="1" class="borderCell"><img src="../images/spacer.gif" width="1" height="1"></td></tr>";
- }
-
- table_content('', $table);
- table_footer();
- if ($form) {
- echo "<center><input type="submit" name="update" value="Update Settings">" . form_hidden('do', 'update') . "</center></form>";
- }
- }
- function settings_extra_row($name, $description, $form) {
- return "<table width="100%"><tr><td><b>$name</b></td><td width="200" align="right"><p align="right">" . $form . "</td></tr><tr><td>$description</td></tr></table>";
- }