Ejemplo n.º 1
0
/**
 * startup
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Startup
 * @author Henry Ruhs
 */
function startup()
{
    /* ini set */
    if (function_exists('ini_set')) {
        if (error_reporting() == 0) {
            ini_set('display_startup_errors', 0);
            ini_set('display_errors', 0);
        }
        ini_set('session.use_trans_sid', 0);
        ini_set('url_rewriter.tags', 0);
    }
    /* session start */
    session_start();
    /* define general */
    define('FILE', get_file());
    define('ROOT', get_root());
    define('TOKEN', get_token());
    /* prefix and salt */
    define('PREFIX', Redaxscript\Config::get('prefix'));
    define('SALT', Redaxscript\Config::get('salt'));
    /* database connect */
    database_connect(Redaxscript\Config::get('host'), Redaxscript\Config::get('name'), Redaxscript\Config::get('user'), Redaxscript\Config::get('password'));
    /* define session */
    define('DB_CONNECTED', $_SESSION[ROOT . '/db_connected']);
    define('DB_ERROR', $_SESSION[ROOT . '/db_error']);
    define('LOGGED_IN', $_SESSION[ROOT . '/logged_in']);
    define('ATTACK_BLOCKED', $_SESSION[ROOT . '/attack_blocked']);
    /* setup charset */
    if (function_exists('ini_set')) {
        ini_set('default_charset', s('charset'));
    }
    /* define parameter */
    define('FIRST_PARAMETER', get_parameter('first'));
    define('FIRST_SUB_PARAMETER', get_parameter('first_sub'));
    define('SECOND_PARAMETER', get_parameter('second'));
    define('SECOND_SUB_PARAMETER', get_parameter('second_sub'));
    define('THIRD_PARAMETER', get_parameter('third'));
    define('THIRD_SUB_PARAMETER', get_parameter('third_sub'));
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin') {
        define('ADMIN_PARAMETER', get_parameter('admin'));
        define('TABLE_PARAMETER', get_parameter('table'));
        define('ID_PARAMETER', get_parameter('id'));
        define('ALIAS_PARAMETER', get_parameter('alias'));
    } else {
        undefine(array('ADMIN_PARAMETER', 'TABLE_PARAMETER', 'ID_PARAMETER', 'ALIAS_PARAMETER'));
    }
    define('LAST_PARAMETER', get_parameter('last'));
    define('LAST_SUB_PARAMETER', get_parameter('last_sub'));
    define('TOKEN_PARAMETER', get_parameter('token'));
    /* define routes */
    define('FULL_ROUTE', get_route(0));
    define('FULL_TOP_ROUTE', get_route(1));
    if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) == '' || file_exists('.htaccess') == '' || FILE == 'install.php') {
        define('REWRITE_ROUTE', '?p=');
        define('LANGUAGE_ROUTE', '&l=');
        define('TEMPLATE_ROUTE', '&t=');
    } else {
        define('REWRITE_ROUTE', '');
        define('LANGUAGE_ROUTE', '.');
        define('TEMPLATE_ROUTE', '.');
    }
    /* redirect to install */
    if (DB_CONNECTED == 0 && file_exists('install.php')) {
        define('REFRESH_ROUTE', ROOT . '/install.php');
    }
    /* define tables */
    if (FULL_ROUTE == '' || FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == '') {
        /* check for homepage */
        if (s('homepage') > 0) {
            $table = 'articles';
            $id = s('homepage');
        } else {
            $table = 'categories';
            $id = 0;
            /* check order */
            if (s('order') == 'asc') {
                $function = 'min';
            } else {
                if (s('order') == 'desc') {
                    $function = 'max';
                }
            }
            $rank = query_plumb('rank', $table, $function);
            /* if category is published */
            if ($rank) {
                $status = retrieve('status', $table, 'rank', $rank);
                if ($status == 1) {
                    $id = retrieve('id', $table, 'rank', $rank);
                }
            }
        }
        define('FIRST_TABLE', $table);
        define('SECOND_TABLE', '');
        define('THIRD_TABLE', '');
        define('LAST_TABLE', $table);
    } else {
        if (FIRST_PARAMETER) {
            define('FIRST_TABLE', query_table(FIRST_PARAMETER));
        } else {
            define('FIRST_TABLE', '');
        }
        if (FIRST_TABLE) {
            define('SECOND_TABLE', query_table(SECOND_PARAMETER));
        } else {
            define('SECOND_TABLE', '');
        }
        if (SECOND_TABLE) {
            define('THIRD_TABLE', query_table(THIRD_PARAMETER));
        } else {
            define('THIRD_TABLE', '');
        }
        if (LAST_PARAMETER) {
            define('LAST_TABLE', query_table(LAST_PARAMETER));
        } else {
            define('LAST_TABLE', '');
        }
        if (LAST_TABLE) {
            $id = retrieve('id', LAST_TABLE, 'alias', LAST_PARAMETER);
        }
    }
    /* define ids */
    if (LAST_TABLE == 'categories') {
        define('CATEGORY', $id);
        define('ARTICLE', '');
        define('LAST_ID', $id);
    } else {
        if (LAST_TABLE == 'articles') {
            define('CATEGORY', '');
            define('ARTICLE', $id);
            define('LAST_ID', $id);
        } else {
            undefine(array('CATEGORY', 'ARTICLE', 'LAST_ID'));
        }
    }
    /* define content error */
    $aliasValidator = new Redaxscript\Validator\Alias();
    if (LAST_ID == '' && $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::FAILED) {
        define('CONTENT_ERROR', 1);
    } else {
        define('CONTENT_ERROR', 0);
    }
    /* define user */
    define('MY_IP', get_user_ip());
    define('MY_BROWSER', get_user_agent(0));
    define('MY_BROWSER_VERSION', get_user_agent(1));
    define('MY_ENGINE', get_user_agent(2));
    define('MY_MOBILE', get_user_agent(4));
    define('MY_TABLET', get_user_agent(5));
    /* if mobile or tablet */
    if (MY_MOBILE || MY_TABLET) {
        define('MY_DESKTOP', '');
    } else {
        define('MY_DESKTOP', get_user_agent(3));
    }
    /* if logged in */
    if (LOGGED_IN == TOKEN) {
        define('MY_ID', $_SESSION[ROOT . '/my_id']);
        define('MY_NAME', $_SESSION[ROOT . '/my_name']);
        define('MY_USER', $_SESSION[ROOT . '/my_user']);
        define('MY_EMAIL', $_SESSION[ROOT . '/my_email']);
        define('MY_GROUPS', $_SESSION[ROOT . '/my_groups']);
        /* define access */
        $access_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users');
        foreach ($access_array as $value) {
            define(strtoupper($value) . '_NEW', $_SESSION[ROOT . '/' . $value . '_new']);
            define(strtoupper($value) . '_EDIT', $_SESSION[ROOT . '/' . $value . '_edit']);
            define(strtoupper($value) . '_DELETE', $_SESSION[ROOT . '/' . $value . '_delete']);
            if (TABLE_PARAMETER == 'users' && ID_PARAMETER == MY_ID && $value == 'users') {
                define('USERS_EXCEPTION', 1);
            } else {
                if ($value == 'users') {
                    define('USERS_EXCEPTION', 0);
                }
            }
        }
        define('MODULES_INSTALL', $_SESSION[ROOT . '/modules_install']);
        define('MODULES_EDIT', $_SESSION[ROOT . '/modules_edit']);
        define('MODULES_UNINSTALL', $_SESSION[ROOT . '/modules_uninstall']);
        define('SETTINGS_EDIT', $_SESSION[ROOT . '/settings_edit']);
        define('FILTER', $_SESSION[ROOT . '/filter']);
    } else {
        define('FILTER', 1);
    }
    /* define table access */
    define('TABLE_NEW', constant(strtoupper(TABLE_PARAMETER) . '_NEW'));
    define('TABLE_INSTALL', constant(strtoupper(TABLE_PARAMETER) . '_INSTALL'));
    define('TABLE_EDIT', constant(strtoupper(TABLE_PARAMETER) . '_EDIT'));
    define('TABLE_DELETE', constant(strtoupper(TABLE_PARAMETER) . '_DELETE'));
    define('TABLE_UNINSTALL', constant(strtoupper(TABLE_PARAMETER) . '_UNINSTALL'));
    /* define time */
    define('GMDATE', gmdate('D, d M Y H:i:s') . ' GMT');
    define('GMDATE_PLUS_WEEK', gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT');
    define('GMDATE_PLUS_YEAR', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT');
    define('NOW', date('Y-m-d H:i:s'));
    define('DELAY', date('Y-m-d H:i:s', strtotime('+1 minute')));
    define('TODAY', date('Y-m-d'));
    /* future update */
    define('UPDATE', $_SESSION[ROOT . '/update']);
    if (UPDATE == '') {
        future_update('articles');
        future_update('extras');
        $_SESSION[ROOT . '/update'] = DELAY;
    } else {
        if (UPDATE < NOW) {
            $_SESSION[ROOT . '/update'] = '';
        }
    }
}
Ejemplo n.º 2
0
/**
 * comment post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Comments
 * @author Henry Ruhs
 */
function comment_post()
{
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    $urlValidator = new Redaxscript\Validator\Url();
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/comment'] == 'visited') {
        $author = $r['author'] = clean($_POST['author'], 0);
        $email = $r['email'] = clean($_POST['email'], 3);
        $url = $r['url'] = clean($_POST['url'], 4);
        $text = break_up($_POST['text']);
        $text = $r['text'] = clean($text, 1);
        $r['language'] = clean($_POST['language'], 0);
        $r['date'] = clean($_POST['date'], 1);
        $article = $r['article'] = clean($_POST['article'], 0);
        $r['rank'] = query_plumb('rank', 'comments', 'max') + 1;
        $r['access'] = clean($_POST['access'], 0);
        if ($r['access'] == '') {
            $r['access'] = 0;
        }
        $task = $_POST['task'];
        $solution = $_POST['solution'];
        $route = build_route('articles', $article);
    }
    /* validate post */
    if ($author == '') {
        $error = l('author_empty');
    } else {
        if ($email == '') {
            $error = l('email_empty');
        } else {
            if ($text == '') {
                $error = l('comment_empty');
            } else {
                if ($emailValidator->validate($email) == Redaxscript\Validator\Validator::FAILED) {
                    $error = l('email_incorrect');
                } else {
                    if ($url && $urlValidator->validate($url) == Redaxscript\Validator\Validator::FAILED) {
                        $error = l('url_incorrect');
                    } else {
                        if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\Validator::FAILED) {
                            $error = l('captcha_incorrect');
                        } else {
                            if (COMMENTS_NEW == 0 && s('moderation') == 1) {
                                $r['status'] = 0;
                                $success = l('comment_moderation');
                            } else {
                                $r['status'] = 1;
                                $success = l('comment_sent');
                            }
                            /* send comment notification */
                            if (s('notification') == 1) {
                                /* prepare body parts */
                                $emailLink = anchor_element('email', '', '', $email);
                                if ($url) {
                                    $urlLink = anchor_element('external', '', '', $url);
                                }
                                $articleRoute = ROOT . '/' . REWRITE_ROUTE . $route;
                                $articleLink = anchor_element('external', '', '', $articleRoute, $articleRoute);
                                /* prepare mail inputs */
                                $toArray = array(s('author') => s('email'));
                                $fromArray = array($author => $email);
                                $subject = l('comment_new');
                                $bodyArray = array('<strong>' . l('author') . l('colon') . '</strong> ' . $author . ' (' . MY_IP . ')', '<strong>' . l('email') . l('colon') . '</strong> ' . $emailLink, '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink, '<br />', '<strong>' . l('comment') . l('colon') . '</strong> ' . $text, '<br />', '<strong>' . l('article') . l('colon') . '</strong> ' . $articleLink);
                                /* mailer object */
                                $mailer = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray);
                                $mailer->send();
                            }
                            /* build key and value strings */
                            $r_keys = array_keys($r);
                            $last = end($r_keys);
                            foreach ($r as $key => $value) {
                                $key_string .= $key;
                                $value_string .= '\'' . $value . '\'';
                                if ($last != $key) {
                                    $key_string .= ', ';
                                    $value_string .= ', ';
                                }
                            }
                            /* insert comment */
                            $query = 'INSERT INTO ' . PREFIX . 'comments (' . $key_string . ') VALUES (' . $value_string . ')';
                            mysql_query($query);
                        }
                    }
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        if (s('blocker') == 1) {
            $_SESSION[ROOT . '/attack_blocked']++;
        }
        notification(l('error_occurred'), $error, l('back'), $route);
    } else {
        notification(l('operation_completed'), $success, l('continue'), $route);
    }
    $_SESSION[ROOT . '/comment'] = '';
}
Ejemplo n.º 3
0
/**
 * admin delete
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_delete()
{
    /* query general */
    $general_delete_query = 'DELETE FROM ' . PREFIX . TABLE_PARAMETER . ' WHERE id = ' . ID_PARAMETER . ' LIMIT 1';
    if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras' || TABLE_PARAMETER == 'comments') {
        $rank_desc = query_plumb('rank', TABLE_PARAMETER, 'max');
        $rank_old = retrieve('rank', TABLE_PARAMETER, 'id', ID_PARAMETER);
        if ($rank_old > 1 && $rank_old < $rank_desc) {
            for ($rank_old; $rank_old - 1 < $rank_desc; $rank_old++) {
                $general_update_query = 'UPDATE ' . PREFIX . TABLE_PARAMETER . ' SET rank = ' . ($rank_old - 1) . ' WHERE rank = ' . $rank_old;
                mysql_query($general_update_query);
            }
        }
    }
    /* query categories */
    if (TABLE_PARAMETER == 'categories') {
        $categories_string = admin_children('categories', ID_PARAMETER, 0);
        $categories_children_string = admin_children('categories', ID_PARAMETER, 2);
        $categories_delete_query = 'DELETE FROM ' . PREFIX . 'categories WHERE id IN (' . $categories_string . ')';
        $articles_delete_query = 'DELETE FROM ' . PREFIX . 'articles WHERE category IN (' . $categories_string . ')';
        $extras_update_query = 'UPDATE ' . PREFIX . '.extras SET category = 0 WHERE category IN (' . $categories_string . ')';
        $comments_delete_query = 'DELETE FROM ' . PREFIX . 'comments WHERE article IN (' . $categories_children_string . ')';
        mysql_query($categories_delete_query);
        mysql_query($articles_delete_query);
    }
    /* query articles */
    if (TABLE_PARAMETER == 'articles') {
        $extras_update_query = 'UPDATE ' . PREFIX . 'extras SET article = 0 WHERE article = ' . ID_PARAMETER;
        $comments_delete_query = 'DELETE FROM ' . PREFIX . 'comments WHERE article = ' . ID_PARAMETER;
        if (ID_PARAMETER == s('homepage')) {
            $homepage_update_query = 'UPDATE ' . PREFIX . 'settings SET value = 0 WHERE name = \'homepage\' LIMIT 1';
            mysql_query($homepage_update_query);
        }
    }
    /* query general */
    mysql_query($general_delete_query);
    if ($extras_update_query) {
        mysql_query($extras_update_query);
    }
    if ($comments_delete_query) {
        mysql_query($comments_delete_query);
    }
    /* handle exception */
    if (USERS_EXCEPTION == 1) {
        logout();
    } else {
        $route = 'admin';
        if (TABLE_EDIT == 1 || TABLE_DELETE == 1) {
            $route .= '/view/' . TABLE_PARAMETER;
        }
        notification(l('operation_completed'), '', l('continue'), $route);
    }
}
Ejemplo n.º 4
0
/**
 * admin contents form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_contents_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* switch table */
    switch (TABLE_PARAMETER) {
        case 'categories':
            $wording_single = 'category';
            break;
        case 'articles':
            $wording_single = 'article';
            break;
        case 'extras':
            $wording_single = 'extra';
            break;
        case 'comments':
            $wording_single = 'comment';
            break;
    }
    /* define fields for existing user */
    if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) {
        /* query content */
        $query = 'SELECT * FROM ' . PREFIX . TABLE_PARAMETER . ' WHERE id = ' . ID_PARAMETER;
        $result = mysql_query($query);
        $r = mysql_fetch_assoc($result);
        if ($r) {
            foreach ($r as $key => $value) {
                ${$key} = stripslashes($value);
            }
        }
        if (TABLE_PARAMETER == 'comments') {
            $wording_headline = $author;
        } else {
            $wording_headline = $title;
        }
        if (TABLE_PARAMETER != 'categories') {
            $text = htmlspecialchars($text);
        }
        $wording_submit = l('save');
        $route = 'admin/process/' . TABLE_PARAMETER . '/' . $id;
    } else {
        if (ADMIN_PARAMETER == 'new') {
            if (TABLE_PARAMETER == 'comments') {
                $author = MY_USER;
                $email = MY_EMAIL;
                $code_readonly = ' readonly="readonly"';
            }
            if (TABLE_PARAMETER == 'categories') {
                $parent = 0;
            }
            if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') {
                $category = 0;
                $headline = 1;
            }
            if (TABLE_PARAMETER == 'articles') {
                $infoline = 0;
                $comments = 0;
            }
            $status = 1;
            $rank = query_plumb('rank', TABLE_PARAMETER, 'max') + 1;
            $access = 0;
            $wording_headline = l($wording_single . '_new');
            $wording_submit = l('create');
            $route = 'admin/process/' . TABLE_PARAMETER;
        }
    }
    /* collect output */
    $output .= '<h2 class="title_content">' . $wording_headline . '</h2>';
    $output .= form_element('form', 'form_admin', 'js_validate_form js_tab form_admin hidden_legend', '', '', '', 'action="' . REWRITE_ROUTE . $route . '" method="post"');
    /* collect tab list output */
    $output .= '<ul class="js_list_tab list_tab list_tab_admin">';
    $output .= '<li class="js_item_active item_first item_active">' . anchor_element('internal', '', '', l($wording_single), FULL_ROUTE . '#tab-1') . '</li>';
    $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li>';
    if (TABLE_PARAMETER != 'categories' && TABLE_PARAMETER != 'comments') {
        $output .= '<li class="item_last">' . anchor_element('internal', '', '', l('date'), FULL_ROUTE . '#tab-3') . '</li>';
    }
    $output .= '</ul>';
    /* collect tab box output */
    $output .= '<div class="js_box_tab box_tab box_tab_admin">';
    /* collect content set */
    $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l($wording_single)) . '<ul>';
    if (TABLE_PARAMETER == 'comments') {
        $output .= '<li>' . form_element('text', 'author', 'field_text_admin field_note', 'author', $author, '* ' . l('author'), 'maxlength="50" required="required" autofocus="autofocus"' . $code_readonly) . '</li>';
        $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', $email, '* ' . l('email'), 'maxlength="50" required="required"' . $code_readonly) . '</li>';
        $output .= '<li>' . form_element('url', 'url', 'field_text_admin', 'url', $url, l('url'), 'maxlength="50"') . '</li>';
    } else {
        $output .= '<li>' . form_element('text', 'title', 'js_generate_alias_input field_text_admin field_note', 'title', $title, l('title'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>';
        $output .= '<li>' . form_element('text', 'alias', 'js_generate_alias_output field_text_admin field_note', 'alias', $alias, l('alias'), 'maxlength="50" required="required"') . '</li>';
    }
    if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles') {
        $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small_admin', 'description', $description, l('description'), 'rows="1" cols="15"') . '</li>';
        $output .= '<li>' . form_element('textarea', 'keywords', 'js_auto_resize js_generate_keyword_output field_textarea_admin field_small_admin', 'keywords', $keywords, l('keywords'), 'rows="1" cols="15"') . '</li>';
    }
    if (TABLE_PARAMETER != 'categories') {
        $output .= '<li>' . form_element('textarea', 'text', 'js_auto_resize js_generate_keyword_input js_editor_textarea field_textarea_admin field_note', 'text', $text, l('text'), 'rows="5" cols="100" required="required"') . '</li>';
    }
    $output .= '</ul></fieldset>';
    /* collect customize set */
    $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>';
    /* languages directory object */
    $languages_directory = new Redaxscript\Directory('languages');
    $languages_directory_array = $languages_directory->get();
    /* build languages select */
    $language_array[l('select')] = '';
    foreach ($languages_directory_array as $value) {
        $value = substr($value, 0, 2);
        $language_array[l($value, '_index')] = $value;
    }
    $output .= '<li>' . select_element('language', 'field_select_admin', 'language', $language_array, $language, l('language')) . '</li>';
    if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles') {
        /* templates directory object */
        $templates_directory = new Redaxscript\Directory('templates', array('admin', 'install'));
        $templates_directory_array = $templates_directory->get();
        /* build templates select */
        $template_array[l('select')] = '';
        foreach ($templates_directory_array as $value) {
            $template_array[$value] = $value;
        }
        $output .= '<li>' . select_element('template', 'field_select_admin', 'template', $template_array, $template, l('template')) . '</li>';
    }
    /* build category select */
    if (TABLE_PARAMETER != 'comments') {
        if (TABLE_PARAMETER == 'extras') {
            $category_array[l('all')] = 0;
        } else {
            $category_array[l('none')] = 0;
        }
        $categories_query = 'SELECT id, title, parent FROM ' . PREFIX . 'categories ORDER BY rank ASC';
        $categories_result = mysql_query($categories_query);
        if ($categories_result) {
            while ($c = mysql_fetch_assoc($categories_result)) {
                if (TABLE_PARAMETER != 'categories') {
                    $category_array[$c['title']] = $c['id'];
                } else {
                    if (ID_PARAMETER != $c['id'] && $c['parent'] == 0) {
                        $category_array[$c['title']] = $c['id'];
                    }
                }
            }
        }
        if (TABLE_PARAMETER == 'categories') {
            $output .= '<li>' . select_element('parent', 'field_select_admin', 'parent', $category_array, $parent, l('category_parent')) . '</li>';
        } else {
            $output .= '<li>' . select_element('category', 'field_select_admin', 'category', $category_array, $category, l('category')) . '</li>';
        }
    }
    /* build article select */
    if (TABLE_PARAMETER == 'extras' || TABLE_PARAMETER == 'comments') {
        if (TABLE_PARAMETER == 'extras') {
            $article_array[l('all')] = 0;
        }
        $articles_query = 'SELECT id, title FROM ' . PREFIX . 'articles';
        if (TABLE_PARAMETER == 'comments') {
            $articles_query .= ' WHERE comments > 0';
        }
        $articles_query .= ' ORDER BY rank ASC';
        $articles_result = mysql_query($articles_query);
        if ($articles_result) {
            while ($a = mysql_fetch_assoc($articles_result)) {
                $article_array[$a['title']] = $a['id'];
            }
        }
        $output .= '<li>' . select_element('article', 'field_select_admin', 'article', $article_array, $article, l('article')) . '</li>';
    }
    if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') {
        $output .= '<li>' . select_element('headline', 'field_select_admin', 'headline', array(l('enable') => 1, l('disable') => 0), $headline, l('headline')) . '</li>';
    }
    if (TABLE_PARAMETER == 'articles') {
        $output .= '<li>' . select_element('infoline', 'field_select_admin', 'infoline', array(l('enable') => 1, l('disable') => 0), $infoline, l('infoline')) . '</li>';
        $output .= '<li>' . select_element('comments', 'field_select_admin', 'comments', array(l('enable') => 1, l('freeze') => 2, l('restrict') => 3, l('disable') => 0), $comments, l('comments')) . '</li>';
    }
    if ($status != 2) {
        $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('publish') => 1, l('unpublish') => 0), $status, l('status')) . '</li>';
    }
    /* build access select */
    if (GROUPS_EDIT == 1) {
        $access_array[l('all')] = 0;
        $access_query = 'SELECT id, name FROM ' . PREFIX . 'groups ORDER BY name ASC';
        $access_result = mysql_query($access_query);
        if ($access_result) {
            while ($g = mysql_fetch_assoc($access_result)) {
                $access_array[$g['name']] = $g['id'];
            }
        }
        $output .= '<li>' . select_element('access', 'field_select_admin', 'access', $access_array, $access, l('access'), 'multiple="multiple"') . '</li>';
    }
    $output .= '</ul></fieldset>';
    /* collect date set */
    if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') {
        $output .= form_element('fieldset', 'tab-3', 'js_set_tab set_tab set_tab_admin', '', '', l('date')) . '<ul>';
        $output .= '<li>' . select_date('day', 'field_select_admin', 'day', $date, 'd', 1, 32, l('day')) . '</li>';
        $output .= '<li>' . select_date('month', 'field_select_admin', 'month', $date, 'm', 1, 13, l('month')) . '</li>';
        $output .= '<li>' . select_date('year', 'field_select_admin', 'year', $date, 'Y', 2000, 2020, l('year')) . '</li>';
        $output .= '<li>' . select_date('hour', 'field_select_admin', 'hour', $date, 'H', 0, 24, l('hour')) . '</li>';
        $output .= '<li>' . select_date('minute', 'field_select_admin', 'minute', $date, 'i', 0, 60, l('minute')) . '</li>';
        $output .= '</ul></fieldset>';
    }
    $output .= '</div>';
    /* collect hidden output */
    if (TABLE_PARAMETER != 'comments') {
        $output .= form_element('hidden', '', '', 'author', MY_USER);
    }
    if ($status == 2) {
        $output .= form_element('hidden', '', '', 'publish', 2);
    }
    $output .= form_element('hidden', '', '', 'rank', $rank);
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    /* cancel button */
    if (TABLE_EDIT == 1 || TABLE_DELETE == 1) {
        $cancel_route = 'admin/view/' . TABLE_PARAMETER;
    } else {
        $cancel_route = 'admin';
    }
    $output .= anchor_element('internal', '', 'js_cancel button_admin button_large_admin button_cancel_admin', l('cancel'), $cancel_route);
    /* delete button */
    if (TABLE_DELETE == 1 && $id) {
        $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large_admin button_delete_admin', l('delete'), 'admin/delete/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN);
    }
    /* submit button */
    if (TABLE_NEW == 1 || TABLE_EDIT == 1) {
        $output .= form_element('button', '', 'js_submit button_admin button_large_admin button_submit_admin', ADMIN_PARAMETER, $wording_submit);
    }
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}