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

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


#
#
### Liste (form)
if (!$_GET['action']) {
    ### Typen
    $result = $_db->query('SELECT *
                           FROM `'.$_cfg['DB_PREFIX'].'filetype`
                           ORDER BY `group_id`, `extension`');
    $filetype_lines = array();
    while ($Daten = $_db->fetch_array($result)) {
        $Daten['image'] = str_replace('%images%', $_style->cfg['images'].'/filetypes', $Daten['image']);
        $Daten['maxsize'] = format_size($Daten['maxsize']);
        $filetype_lines[$Daten['group_id']] .= eval ('return ("'.$_style->get('acp_filetype_line').'");');
    }
    ### Gruppen
    if (count($filetype_lines) > 0) {
        $result = $_db->query('SELECT id, name
                               FROM `'.$_cfg['DB_PREFIX'].'group`
                               WHERE id IN ('.implode(',', array_keys($filetype_lines)).')
                               ORDER BY `name`');
        while ($Daten = $_db->fetch_array($result)) {
            $filetype_lines[$Daten['id']] = eval ('return ("'.$_style->get('acp_filetype_group_line').'");').$filetype_lines[$Daten['id']];
        }
        
        $filetype_lines = implode("\n", $filetype_lines);
    }
    
    eval ('echo "'.$_style->get('acp_filetype').'";');



#
#
### hinzufügen / bearbeiten
} elseif (($_GET['action'] == 'edit' && is_numeric($_GET['id'])) || $_GET['action'] == 'add') {
    ### bearbeiten
    if ($_GET['action'] == 'edit') {
        $Daten = $_db->fetch_first('SELECT * FROM `'.$_cfg['DB_PREFIX'].'filetype` WHERE id = '.$_GET['id']);
        $attachment[$Daten['attachment']] = $_style->cfg['template_choice'];
        $avatar[$Daten['avatar']] = $_style->cfg['template_choice'];
        $Daten['maxsize'] = ($Daten['maxsize'] > 0) ? $Daten['maxsize']/1024 : $Daten['maxsize'];;
    }
    
    ### Gruppen
    $result = $_db->query('SELECT id, name
                           FROM `'.$_cfg['DB_PREFIX'].'group`
                           ORDER BY `name`');
    $groups = array();
    while ($group = $_db->fetch_array($result)) {
        $groups[] = '<option value="'.$group['id'].'"'.(($group['id'] == $Daten['group_id']) ? ' selected="selected"' : '').'>'.$group['name'].'</option>';
    }
    $group_lines = implode("\n", $groups);
    
    eval ('echo "'.$_style->get('acp_filetype_'.$_GET['action']).'";');



#
#
### speichern
} elseif ($_GET['action'] == 'save') {
    # Dateigr��e
    $_POST['maxsize'] = intval($_POST['maxsize']) * 1024;
    
    # hinzuf�gen
    if (!$_POST['id']) {
        $_db->u_query('INSERT INTO `'.$_cfg['DB_PREFIX'].'filetype` (`group_id`,`extension`,`maxsize`,`image`,`attachment`,`avatar`)
                       VALUES ('.intval($_POST['group_id']).',\''.gpc_addslashes($_POST['extension']).'\','.$_POST['maxsize'].',
                               \''.gpc_addslashes($_POST['image']).'\','.intval($_POST['attachment']).','.intval($_POST['avatar']).')');
    # bearbeiten
    } else {
        $_db->u_query('UPDATE `'.$_cfg['DB_PREFIX'].'filetype`
                       SET `group_id` = '.intval($_POST['group_id']).',
                           `extension` = \''.gpc_addslashes($_POST['extension']).'\',
                           `maxsize` = '.$_POST['maxsize'].',
                           `image` = \''.gpc_addslashes($_POST['image']).'\',
                           `attachment` = '.intval($_POST['attachment']).',
                           `avatar` = '.intval($_POST['avatar']).'
                       WHERE `id` = '.intval($_POST['id']));
    }
    // Cache erstellen
    cache_attachment_type();
    
    msg('error_acp_save', 'filetype.php?'.$_sess['url']);



#
#
### löschen
} elseif ($_GET['action'] == 'del' && is_numeric($_GET['id'])) {
    # Formular anzeigen
    if (!$_GET['ok']) {
        $Daten = $_db->fetch_first('SELECT * FROM `'.$_cfg['DB_PREFIX'].'filetype` WHERE id = '.$_GET['id']);
        eval ('echo "'.$_style->get('acp_filetype_del').'";');
    # wirklich l�schen
    } else {
        $_db->u_query('DELETE FROM `'.$_cfg['DB_PREFIX'].'filetype` WHERE id = '.$_GET['id']);
        // Cache erstellen
        cache_attachment_type();
    
        msg('error_acp_del', 'filetype.php?'.$_sess['url']);
    }
}
?>
Return current item: PhpMyForum