Location: PHPKode > projects > PhpMyForum > phpmyforum_4_1_1/admin/settings.php
<?php
define('PMF_INCLUDE', 1);
require('head.php');
access('acp_setting');

require_once($_cfg['MAIN'].'/lib/sys.inc.php');
$_sys = new pmf_sys();
require_once($_cfg['MAIN'].'/lib/admin.inc.php');


#
#
### Liste
if (!$_GET['action'] && !$_GET['cid'] && !$_POST) {
    eval ('echo "'.$_style->get('acp_settings').'";');



#
#
### Kategorie
} elseif (is_numeric($_GET['cid'])) {
    $result = $_db->query('SELECT *
                           FROM `'.$_cfg['DB_PREFIX'].'setting`
                           WHERE cid = '.$_GET['cid'].'
                           ORDER BY rang');
    $setting_lines = '';
    while ($settings = $_db->fetch_array($result)) {
        unset($value);
        # Typ: text / textarea
        if (substr($settings['typ'], 0, 4) == 'text') {
            $value = htmlentities($settings['value'], ENT_QUOTES);
            $template = $settings['typ'];
            
        # Typ: radio
        } elseif ($settings['typ'] == 'radio') {
            $value[$settings['value']] = $_style->cfg['template_choice'];
            $template = 'radio';
            
        # Typ: access
        } elseif ($settings['typ'] == 'access') {
            $rs_access = $_db->query('SELECT * FROM `'.$_cfg['DB_PREFIX'].'group` ORDER BY name');
            $value = '';
            while ($access = $_db->fetch_array($rs_access)) {
                $value .= '<option value="'.$access['id'].'"';
                $value .= ($access['id'] == $settings['value']) ? ' selected="selected"' : '';
                $value .= '>'.$access['name'].'</option>'."\n";
            }
            $template = 'select';
            
        # Typ: lang
        } elseif ($settings['typ'] == 'lang') {
            $rs_lang = $_db->query('SELECT * FROM `'.$_cfg['DB_PREFIX'].'lang` ORDER BY name');
            $value = '';
            while ($lang = $_db->fetch_array($rs_lang)) {
                $value .= '<option value="'.$lang['id'].'"';
                $value .= ($lang['id'] == $settings['value']) ? ' selected="selected"' : '';
                $value .= '>'.$lang['name'].'</option>'."\n";
            }
            $template = 'select';

        # Typ: timezone
        } elseif ($settings['typ'] == 'timezone') {
            $zones = explode("\n", $_style->get('time_zones'));
            $value = '';
            foreach ($zones AS $key => $zone_array) {
                list($nr, $name) = explode('=', $zone_array);
                $value .= '<option value="'.trim($nr).'"';
                $value .= ($nr == $settings['value']) ? ' selected="selected"' : '';
                $value .= '>'.trim($name).'</option>'."\n";
            }
            $template = 'select';
            
        # Typ: weekdays
        } elseif ($settings['typ'] == 'weekdays') {
            $weeks = explode("\n", eval('return("'.$_style->get_lang('weekdays').'");'));
            $value = '';
            foreach ($weeks AS $key => $week) {
                $value .= '<option value="'.trim($nr).'"';
                $value .= ($key == $settings['value']) ? ' selected="selected"' : '';
                $value .= '>'.trim($week).'</option>'."\n";
            }
            $template = 'select';
            
        # Typ: between
        } elseif ($settings['typ'] == 'between') {
            list($from, $to) = explode('-', $settings['special']);
            $value = '';
            for ($n = $from; $n <= $to; $n++) {
                $value .= '<option value="'.$n.'"';
                $value .= ($n == $settings['value']) ? ' selected="selected"' : '';
                $value .= '>'.$n.'</option>'."\n";
            }
            $template = 'select';
            
        # Typ: select
        } elseif ($settings['typ'] == 'select') {
            $settings['special'] = explode("\n", eval('return ("'.$settings['special'].'");'));
            $value = '';
            foreach ($settings['special'] AS $special) {
                $special = explode('=', $special, 2);
                $value .= '<option value="'.trim($special[0]).'"';
                $value .= (trim($special[0]) == $settings['value']) ? ' selected="selected"' : '';
                $value .= '>'.trim($special[1]).'</option>'."\n";
            }
            $template = 'select';
        }
        
        $Daten['title'] = eval('return("'.$_style->get_lang('acp_settings_'.strtolower($settings['name'])).'");');
        $Daten['comment'] = eval('return("'.$_style->get_lang('acp_settings_'.strtolower($settings['name']).'_text').'");');
        eval ('$setting_lines .= "'.$_style->get('acp_settings_cat_line_'.$template).'";');
    }
    
    $Daten = array();
    $cat['name'] = eval('return("'.$_style->get_lang('acp_settings_cat_'.$_GET['cid']).'");');
    
    eval ('echo "'.$_style->get('acp_settings_cat').'";');
    
    
    
#
#
### Speichern
} elseif ($_POST['cid']) {
    # was zu speichern ?
    $result = $_db->query('SELECT name FROM `'.$_cfg['DB_PREFIX'].'setting` WHERE cid = '.intval($_POST['cid']));
    while ($what = $_db->fetch_array($result)) {
        $_db->u_query('UPDATE `'.$_cfg['DB_PREFIX'].'setting` SET value = \''.gpc_addslashes($_POST[$what['name']]).'\' WHERE name = \''.$what['name'].'\'');
    }
    # settings.inc.php neu schreiben
    cache_settings();
    
    msg('error_acp_save', 'settings.php?'.$_sess['url']);
}
?>
Return current item: PhpMyForum