/**
 * reminder form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Reminder
 * @author Henry Ruhs
 */
function reminder_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* disable fields if attack blocked */
    if (ATTACK_BLOCKED > 9) {
        $code_disabled = ' disabled="disabled"';
    }
    /* captcha object */
    $captcha = new Redaxscript\Captcha(Redaxscript\Language::getInstance());
    $captcha->init();
    /* collect output */
    $output .= '<h2 class="title_content">' . l('reminder') . '</h2>';
    $output .= form_element('form', 'form_reminder', 'js_validate_form form_default form_reminder', '', '', '', 'action="' . REWRITE_ROUTE . 'reminder" method="post"');
    $output .= form_element('fieldset', '', 'set_reminder', '', '', l('reminder_request') . l('point')) . '<ul>';
    $output .= '<li>' . form_element('email', 'email', 'field_text field_note', 'email', '', l('email'), 'maxlength="50" required="required" autofocus="autofocus"' . $code_disabled) . '</li>';
    /* collect captcha task output */
    $output .= '<li>' . form_element('number', 'task', 'field_text field_note', 'task', '', $captcha->getTask(), 'min="1" max="20" required="required"' . $code_disabled) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect captcha solution output */
    $captchaHash = new Redaxscript\Hash(Redaxscript\Config::getInstance());
    $captchaHash->init($captcha->getSolution());
    $output .= form_element('hidden', '', '', 'solution', $captchaHash->getHash());
    /* collect hidden and button output */
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    $output .= form_element('button', '', 'js_submit button_default', 'reminder_post', l('submit'), '', $code_disabled);
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    $_SESSION[ROOT . '/reminder'] = 'visited';
    echo $output;
}
예제 #2
0
파일: center.php 프로젝트: ITw3/redaxscript
/**
 * center
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Center
 * @author Henry Ruhs
 */
function center()
{
    Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* center break */
    if (CENTER_BREAK == 1 || Redaxscript\Registry::get('centerBreak') == 1) {
        return;
    } else {
        routing();
    }
    Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
}
예제 #3
0
/**
 * login form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Login
 * @author Henry Ruhs
 */
function login_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* disable fields if attack blocked */
    if (ATTACK_BLOCKED > 9) {
        $code_disabled = ' disabled="disabled"';
    }
    /* captcha object */
    if (s('captcha') > 0) {
        $captcha = new Redaxscript\Captcha(Redaxscript\Language::getInstance());
        $captcha->init();
    }
    /* reminder question */
    if (s('reminder') == 1) {
        $legend = anchor_element('internal', '', 'link_legend', l('reminder_question') . l('question_mark'), 'reminder', '', 'rel="nofollow"');
    } else {
        $legend = l('fields_limited') . l('point');
    }
    /* collect output */
    $output .= '<h2 class="title_content">' . l('login') . '</h2>';
    $output .= form_element('form', 'form_login', 'js_validate_form form_default form_login', '', '', '', 'action="' . REWRITE_ROUTE . 'login" method="post"');
    $output .= form_element('fieldset', '', 'set_login', '', '', $legend) . '<ul>';
    $output .= '<li>' . form_element('text', 'user', 'field_text field_note', 'user', '', l('user'), 'maxlength="50" required="required" autofocus="autofocus"' . $code_disabled) . '</li>';
    $output .= '<li>' . form_element('password', 'password', 'js_unmask_password field_text field_note', 'password', '', l('password'), 'maxlength="50" required="required" autocomplete="off"' . $code_disabled) . '</li>';
    /* collect captcha task output */
    if (LOGGED_IN != TOKEN && s('captcha') > 0) {
        $output .= '<li>' . form_element('number', 'task', 'field_text field_note', 'task', '', $captcha->getTask(), 'min="1" max="20" required="required"' . $code_disabled) . '</li>';
    }
    $output .= '</ul></fieldset>';
    /* collect captcha solution output */
    if (s('captcha') > 0) {
        $captchaHash = new Redaxscript\Hash(Redaxscript\Config::getInstance());
        $captchaHash->init($captcha->getSolution());
        if (LOGGED_IN == TOKEN) {
            $output .= form_element('hidden', '', '', 'task', $captchaHash->getRaw());
        }
        $output .= form_element('hidden', '', '', 'solution', $captchaHash->getHash());
    }
    /* collect hidden and button output */
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    $output .= form_element('button', '', 'js_submit button_default', 'login_post', l('submit'), '', $code_disabled);
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    $_SESSION[ROOT . '/login'] = '******';
    echo $output;
}
예제 #4
0
파일: search.php 프로젝트: ITw3/redaxscript
/**
 * search form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Search
 * @author Henry Ruhs
 */
function search_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* disable fields if attack blocked */
    if (ATTACK_BLOCKED > 9) {
        $code_disabled = ' disabled="disabled"';
    }
    /* collect output */
    $output .= form_element('form', '', 'js_validate_search form_search', '', '', '', 'method="post"');
    $output .= form_element('search', '', 'js_search field_search', 'search_terms', '', '', 'maxlength="50" tabindex="1" placeholder="' . l('search_terms') . '"' . $code_disabled);
    /* collect hidden and button output */
    $output .= form_element('hidden', '', '', 'search_post');
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    $output .= form_element('button', '', 'button_search', 'search_post', l('search'), '', $code_disabled);
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
/**
 * admin users form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_users_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define fields for existing user */
    if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) {
        /* query user */
        $result = Redaxscript\Db::forTablePrefix('users')->where('id', ID_PARAMETER)->findArray();
        $r = $result[0];
        if ($r) {
            foreach ($r as $key => $value) {
                ${$key} = stripslashes($value);
            }
        }
        $wording_headline = $name;
        $wording_submit = l('save');
        $route = 'admin/process/users/' . $id;
    } else {
        if (ADMIN_PARAMETER == 'new') {
            $status = 1;
            $groups = 0;
            $wording_headline = l('user_new');
            $wording_submit = l('create');
            $route = 'admin/process/users';
            $code_required = ' required="required"';
        }
    }
    /* 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('user'), FULL_ROUTE . '#tab-1') . '</li>';
    $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li></ul>';
    /* collect tab box output */
    $output .= '<div class="js_box_tab box_tab box_tab_admin">';
    /* collect user set */
    $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l('user')) . '<ul>';
    $output .= '<li>' . form_element('text', 'name', 'field_text_admin field_note', 'name', $name, l('name'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>';
    if ($id == '') {
        $output .= '<li>' . form_element('text', 'user', 'field_text_admin field_note', 'user', $user, l('user'), 'maxlength="50" required="required"') . '</li>';
    }
    $output .= '<li>' . form_element('password', 'password', 'js_unmask_password field_text_admin field_note', 'password', '', l('password'), 'maxlength="50" autocomplete="off"' . $code_required) . '</li>';
    $output .= '<li>' . form_element('password', 'password_confirm', 'js_unmask_password field_text_admin field_note', 'password_confirm', '', l('password_confirm'), 'maxlength="50" autocomplete="off"' . $code_required) . '</li>';
    $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', $email, l('email'), 'maxlength="50" required="required"') . '</li>';
    $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small', 'description', $description, l('description'), 'rows="1" cols="15"') . '</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_directory->init('languages');
    $languages_directory_array = $languages_directory->getArray();
    /* 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 ($id == '' || $id > 1) {
        $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('enable') => 1, l('disable') => 0), $status, l('status')) . '</li>';
        /* build groups select */
        if (GROUPS_EDIT == 1 && USERS_EDIT == 1) {
            $groups_result = Redaxscript\Db::forTablePrefix('groups')->orderByAsc('name')->findArray();
            if ($groups_result) {
                foreach ($groups_result as $g) {
                    $groups_array[$g['name']] = $g['id'];
                }
            }
            $output .= '<li>' . select_element('groups', 'field_select_admin', 'groups', $groups_array, $groups, l('groups'), 'multiple="multiple"') . '</li>';
        }
    }
    $output .= '</ul></fieldset></div>';
    /* collect hidden output */
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    /* collect button output */
    if (USERS_EDIT == 1 || USERS_DELETE == 1) {
        $cancel_route = 'admin/view/users';
    } else {
        $cancel_route = 'admin';
    }
    $output .= anchor_element('internal', '', 'js_cancel button_admin button_large button_cancel_admin', l('cancel'), $cancel_route);
    /* delete button */
    if ((USERS_DELETE == 1 || USERS_EXCEPTION == 1) && $id > 1) {
        $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large button_delete_admin', l('delete'), 'admin/delete/users/' . $id . '/' . TOKEN);
    }
    /* submit button */
    if (USERS_NEW == 1 || USERS_EDIT == 1 || USERS_EXCEPTION == 1) {
        $output .= form_element('button', '', 'js_submit button_admin button_large button_submit_admin', ADMIN_PARAMETER, $wording_submit);
    }
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
/**
 * templates list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 *
 * @param array $options
 */
function templates_list($options = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* templates directory object */
    $templates_directory = new Redaxscript\Directory();
    $templates_directory->init('templates', array('admin', 'install'));
    $templates_directory_array = $templates_directory->getArray();
    /* collect templates output */
    foreach ($templates_directory_array as $value) {
        $class_string = ' class="template_' . $value;
        if ($value == Redaxscript\Registry::get('template')) {
            $class_string .= ' item_active';
        }
        $class_string .= '"';
        $output .= '<li' . $class_string . '>' . anchor_element('internal', '', '', $value, FULL_ROUTE . TEMPLATE_ROUTE . $value, '', 'rel="nofollow"') . '</li>';
    }
    /* build id string */
    if ($option_id) {
        $id_string = ' id="' . $option_id . '"';
    }
    /* build class string */
    if ($option_class) {
        $class_string = ' class="' . $option_class . '"';
    } else {
        $class_string = ' class="list_templates"';
    }
    /* collect list output */
    if ($output) {
        $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
/**
 * comment form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Comments
 * @author Henry Ruhs
 *
 * @param integer $article
 * @param string $language
 */
function comment_form($article = '', $language = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* disable fields if attack blocked */
    if (ATTACK_BLOCKED > 9) {
        $code_readonly = $code_disabled = ' disabled="disabled"';
    } else {
        if (LOGGED_IN == TOKEN) {
            $author = MY_USER;
            $email = MY_EMAIL;
            $code_readonly = ' readonly="readonly"';
        }
    }
    /* captcha object */
    if (s('captcha') > 0) {
        $captcha = new Redaxscript\Captcha(Redaxscript\Language::getInstance());
        $captcha->init();
    }
    /* collect output */
    $output .= '<h2 class="title_content">' . l('comment_new') . '</h2>';
    $output .= form_element('form', 'form_comment', 'js_validate_form form_default form_comment', '', '', '', 'method="post"');
    $output .= form_element('fieldset', '', 'set_comment', '', '', l('fields_required') . l('point')) . '<ul>';
    $output .= '<li>' . form_element('text', 'author', 'field_text field_note', 'author', $author, '* ' . l('author'), 'maxlength="50" required="required"' . $code_readonly) . '</li>';
    $output .= '<li>' . form_element('email', 'email', 'field_text field_note', 'email', $email, '* ' . l('email'), 'maxlength="50" required="required"' . $code_readonly) . '</li>';
    $output .= '<li>' . form_element('url', 'url', 'field_text', 'url', '', l('url'), 'maxlength="50"' . $code_disabled) . '</li>';
    $output .= '<li>' . form_element('textarea', 'text', 'js_auto_resize js_editor_textarea field_textarea field_note', 'text', '', '* ' . l('comment'), 'rows="5" cols="100" required="required"' . $code_disabled) . '</li>';
    /* collect captcha task output */
    if (LOGGED_IN != TOKEN && s('captcha') > 0) {
        $output .= '<li>' . form_element('number', 'task', 'field_text field_note', 'task', '', $captcha->getTask(), 'min="1" max="20" required="required"' . $code_disabled) . '</li>';
    }
    $output .= '</ul></fieldset>';
    /* collect hidden output */
    $output .= form_element('hidden', '', '', 'language', $language);
    $output .= form_element('hidden', '', '', 'date', NOW);
    $output .= form_element('hidden', '', '', 'article', $article);
    /* collect captcha solution output */
    if (s('captcha') > 0) {
        $captchaHash = new Redaxscript\Hash(Redaxscript\Config::getInstance());
        $captchaHash->init($captcha->getSolution());
        if (LOGGED_IN == TOKEN) {
            $output .= form_element('hidden', '', '', 'task', $captchaHash->getRaw());
        }
        $output .= form_element('hidden', '', '', 'solution', $captchaHash->getHash());
    }
    /* collect hidden and button output */
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    $output .= form_element('button', '', 'js_submit button_default', 'comment_post', l('create'), '', $code_disabled);
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    $_SESSION[ROOT . '/comment'] = 'visited';
    echo $output;
}
예제 #8
0
/**
 * admin modules form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_modules_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define fields for existing user */
    if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) {
        /* query modules */
        $query = 'SELECT * FROM ' . PREFIX . 'modules WHERE id = ' . ID_PARAMETER;
        $result = mysql_query($query);
        $r = mysql_fetch_assoc($result);
        if ($r) {
            foreach ($r as $key => $value) {
                ${$key} = stripslashes($value);
            }
        }
        $wording_headline = $name;
        $wording_submit = l('save');
        $route = 'admin/process/modules/' . $id;
    }
    $file_install = is_dir('modules/' . $alias);
    /* 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('module'), FULL_ROUTE . '#tab-1') . '</li>';
    $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li></ul>';
    /* collect tab box output */
    $output .= '<div class="js_box_tab box_tab box_tab_admin">';
    /* collect module set */
    $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l('user')) . '<ul>';
    $output .= '<li>' . form_element('text', 'name', 'field_text_admin field_note', 'name', $name, l('name'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>';
    $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 .= '</ul></fieldset>';
    /* collect customize set */
    $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>';
    $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('enable') => 1, l('disable') => 0), $status, l('status')) . '</li>';
    /* build access select */
    if (GROUPS_EDIT == 1) {
        $access_array[l('all')] = 0;
        $access_query = 'SELECT * 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></div>';
    /* collect hidden output */
    $output .= form_element('hidden', '', '', 'alias', $alias);
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    /* cancel button */
    if (MODULES_EDIT == 1 || MODULES_UNINSTALL == 1) {
        $cancel_route = 'admin/view/modules';
    } else {
        $cancel_route = 'admin';
    }
    $output .= anchor_element('internal', '', 'js_cancel button_admin button_large_admin button_cancel_admin', l('cancel'), $cancel_route);
    /* uninstall button */
    if (MODULES_UNINSTALL == 1 && $file_install) {
        $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large_admin button_uninstall_admin', l('uninstall'), 'admin/uninstall/modules/' . $alias . '/' . TOKEN);
    }
    /* submit button */
    if (MODULES_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;
}
예제 #9
0
파일: index.php 프로젝트: ITw3/redaxscript
        if (file_exists('modules/' . $value . '/index.php')) {
            include_once 'modules/' . $value . '/index.php';
        }
    }
}
/* call loader else render template */
if (FIRST_PARAMETER == 'loader' && (SECOND_PARAMETER == 'styles' || SECOND_PARAMETER == 'scripts')) {
    echo loader(SECOND_PARAMETER, 'outline');
} else {
    Redaxscript\Hook::trigger('render_start');
    /* transport registry to constants */
    if (Redaxscript\Registry::get('renderBreak')) {
        define(RENDER_BREAK, Redaxscript\Registry::get('renderBreak'));
    }
    if (Redaxscript\Registry::get('centerBreak')) {
        define(CENTER_BREAK, Redaxscript\Registry::get('centerBreak'));
    }
    /* undefine */
    undefine(array('RENDER_BREAK', 'CENTER_BREAK', 'REFRESH_ROUTE', 'DESCRIPTION', 'KEYWORDS', 'ROBOTS', 'TITLE'));
    /* render break */
    if (RENDER_BREAK == 1) {
        return;
    } else {
        /* handle error */
        if (CONTENT_ERROR && CENTER_BREAK == '') {
            header('http/1.0 404 not found');
        }
        include_once 'templates/' . TEMPLATE . '/index.phtml';
    }
    Redaxscript\Hook::trigger('render_end');
}
예제 #10
0
/**
 * admin router
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_router()
{
    $firstParameter = Redaxscript\Registry::get('firstParameter');
    $adminParameter = Redaxscript\Registry::get('adminParameter');
    $tableParameter = Redaxscript\Registry::get('tableParameter');
    $idParameter = Redaxscript\Registry::get('idParameter');
    $aliasParameter = Redaxscript\Registry::get('aliasParameter');
    $tokenParameter = Redaxscript\Registry::get('tokenParameter');
    $usersException = $tableParameter == 'users' && $idParameter == Redaxscript\Registry::get('myId');
    $messenger = new Redaxscript\Admin\Messenger(Redaxscript\Registry::getInstance());
    Redaxscript\Hook::trigger('adminRouterStart');
    if (Redaxscript\Registry::get('adminRouterBreak') == 1) {
        return;
    }
    /* last seen update */
    if ($firstParameter == 'admin' && !$adminParameter || $adminParameter == 'view' && $tableParameter == 'users' || Redaxscript\Registry::get('cronUpdate')) {
        admin_last_update();
    }
    /* validate routing */
    switch (true) {
        case $adminParameter && !in_array($adminParameter, ['new', 'view', 'edit', 'up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable', 'install', 'uninstall', 'delete', 'process', 'update']):
        case $adminParameter == 'process' && !$_POST['new'] && !$_POST['edit']:
        case $adminParameter == 'update' && !$_POST['update']:
        case $adminParameter && !in_array($tableParameter, ['categories', 'articles', 'extras', 'comments', 'groups', 'users', 'modules', 'settings']):
        case !$aliasParameter && ($adminParameter == 'install' || $adminParameter == 'uninstall'):
        case !$idParameter && in_array($adminParameter, ['edit', 'up', 'down', 'publish', 'unpublish', 'enable', 'disable']) && $tableParameter != 'settings':
        case is_numeric($idParameter) && !Redaxscript\Db::forTablePrefix($tableParameter)->where('id', $idParameter)->findOne()->id:
            /* show error */
            echo $messenger->setRoute(Redaxscript\Language::get('back'), 'admin')->error(Redaxscript\Language::get('something_wrong'));
            return;
    }
    /* define access variables */
    if ($adminParameter && $tableParameter) {
        if ($tableParameter == 'modules') {
            $install = Redaxscript\Registry::get('modulesInstall');
            $uninstall = Redaxscript\Registry::get('modulesUninstall');
        } else {
            if ($tableParameter != 'settings') {
                $new = Redaxscript\Registry::get('tableNew');
                if ($tableParameter == 'comments') {
                    $articles_total = Redaxscript\Db::forTablePrefix('articles')->count();
                    $articles_comments_disable = Redaxscript\Db::forTablePrefix('articles')->where('comments', 0)->count();
                    if ($articles_total == $articles_comments_disable) {
                        $new = 0;
                    }
                }
                $delete = Redaxscript\Registry::get('tableDelete');
            }
        }
        $edit = Redaxscript\Registry::get('tableEdit');
    }
    if ($edit == 1 || $delete == 1) {
        $accessValidator = new Redaxscript\Validator\Access();
        $access = Redaxscript\Db::forTablePrefix($tableParameter)->where('id', $idParameter)->findOne()->access;
        $check_access = $accessValidator->validate($access, Redaxscript\Registry::get('myGroups'));
    }
    /* validate access */
    switch (true) {
        case $adminParameter == 'new' && $new == 0:
        case $adminParameter == 'view' && in_array($tableParameter, ['categories', 'articles', 'extras', 'comments', 'groups', 'users']) && $new == 0 && $edit == 0 && $delete == 0:
        case $adminParameter == 'view' && $tableParameter == 'settings':
        case $adminParameter == 'view' && $tableParameter == 'modules' && $edit == 0 && $install == 0 && $uninstall == 0:
        case $adminParameter == 'edit' && $edit == 0 && !$usersException:
        case in_array($adminParameter, ['up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable']) && $edit == 0:
        case $adminParameter == 'install' && $install == 0:
        case $adminParameter == 'uninstall' && $uninstall == 0:
        case $adminParameter == 'delete' && $delete == 0 && !$usersException:
        case $adminParameter == 'process' && $_POST['new'] && $new == 0:
        case $adminParameter == 'process' && $_POST['edit'] && $edit == 0 && !$usersException:
        case $adminParameter == 'process' && $_POST['groups'] && !Redaxscript\Registry::get('groupsEdit'):
        case $adminParameter == 'update' && $edit == 0:
        case $idParameter == 1 && ($adminParameter == 'disable' || $adminParameter == 'delete') && ($tableParameter == 'groups' || $tableParameter == 'users'):
        case is_numeric($idParameter) && $tableParameter && $check_access == 0 && !$usersException:
            /* show error */
            echo $messenger->setRoute(Redaxscript\Language::get('back'), 'admin')->error(Redaxscript\Language::get('error_occurred'), Redaxscript\Language::get('access_no'));
            return;
    }
    /* check token */
    if (in_array($adminParameter, ['up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable', 'install', 'uninstall', 'delete']) && !$tokenParameter) {
        /* show error */
        echo $messenger->setRoute(Redaxscript\Language::get('back'), 'admin')->error(Redaxscript\Language::get('error_occurred'), Redaxscript\Language::get('token_no'));
        return;
    }
    /* admin routing */
    if ($firstParameter == 'admin' && !$adminParameter) {
        contents();
    }
    switch ($adminParameter) {
        case 'new':
            if ($tableParameter == 'categories') {
                $categoryForm = new Redaxscript\Admin\View\CategoryForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $categoryForm->render();
            }
            if ($tableParameter == 'articles') {
                $articleForm = new Redaxscript\Admin\View\ArticleForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $articleForm->render();
            }
            if ($tableParameter == 'extras') {
                $extraForm = new Redaxscript\Admin\View\ExtraForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $extraForm->render();
            }
            if ($tableParameter == 'comments') {
                $commentForm = new Redaxscript\Admin\View\CommentForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $commentForm->render();
            }
            if ($tableParameter == 'groups') {
                $groupForm = new Redaxscript\Admin\View\GroupForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $groupForm->render();
            }
            if ($tableParameter == 'users') {
                $userForm = new Redaxscript\Admin\View\UserForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $userForm->render();
            }
            return;
        case 'view':
            if (in_array($tableParameter, ['categories', 'articles', 'extras', 'comments'])) {
                admin_contents_list();
            }
            if (in_array($tableParameter, ['groups', 'users', 'modules'])) {
                call_user_func('admin_' . $tableParameter . '_list');
            }
            return;
        case 'edit':
            if ($tableParameter == 'categories') {
                $categoryForm = new Redaxscript\Admin\View\CategoryForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $categoryForm->render($idParameter);
            }
            if ($tableParameter == 'articles') {
                $articleForm = new Redaxscript\Admin\View\ArticleForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $articleForm->render($idParameter);
            }
            if ($tableParameter == 'extras') {
                $extraForm = new Redaxscript\Admin\View\ExtraForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $extraForm->render($idParameter);
            }
            if ($tableParameter == 'comments') {
                $commentForm = new Redaxscript\Admin\View\CommentForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $commentForm->render($idParameter);
            }
            if ($tableParameter == 'groups') {
                $groupForm = new Redaxscript\Admin\View\GroupForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $groupForm->render($idParameter);
            }
            if ($tableParameter == 'users') {
                $userForm = new Redaxscript\Admin\View\UserForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $userForm->render($idParameter);
            }
            if ($tableParameter == 'modules') {
                $moduleForm = new Redaxscript\Admin\View\ModuleForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $moduleForm->render($idParameter);
            }
            if ($tableParameter == 'settings') {
                $settingForm = new Redaxscript\Admin\View\SettingForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $settingForm->render();
            }
            return;
        case 'up':
        case 'down':
            admin_move();
            return;
        case 'sort':
            admin_sort();
            return;
        case 'publish':
        case 'enable':
            admin_status(1);
            return;
        case 'unpublish':
        case 'disable':
            admin_status(0);
            return;
        case 'install':
        case 'uninstall':
            admin_install();
            return;
        case 'delete':
        case 'process':
        case 'update':
            call_user_func('admin_' . $adminParameter);
            return;
    }
    Redaxscript\Hook::trigger('adminRouterEnd');
}
예제 #11
0
/**
 * pagination
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 *
 * @param integer $sub_active
 * @param integer $sub_maximum
 * @param string $route
 */
function pagination($sub_active, $sub_maximum, $route)
{
    $output = Redaxscript\Hook::trigger('paginationStart');
    $output .= '<ul class="rs-list-pagination">';
    /* collect first and previous output */
    if ($sub_active > 1) {
        $first_route = $route;
        $previous_route = $route . '/' . ($sub_active - 1);
        $output .= '<li class="rs-item-first"><a href="' . Redaxscript\Registry::get('parameterRoute') . $first_route . '">' . Redaxscript\Language::get('first') . '</a></li>';
        $output .= '<li class="rs-item-previous"><a href="' . Redaxscript\Registry::get('parameterRoute') . $previous_route . '" rel="previous">' . Redaxscript\Language::get('previous') . '</a></li>';
    }
    /* collect center output */
    $j = 2;
    if ($sub_active == 2 || $sub_active == $sub_maximum - 1) {
        $j++;
    }
    if ($sub_active == 1 || $sub_active == $sub_maximum) {
        $j = $j + 2;
    }
    for ($i = $sub_active - $j; $i < $sub_active + $j; $i++) {
        if ($i == $sub_active) {
            $j++;
            $output .= '<li class="rs-item-number rs-item-active"><span>' . $i . '</span></li>';
        } else {
            if ($i > 0 && $i < $sub_maximum + 1) {
                $output .= '<li class="rs-item-number"><a href="' . Redaxscript\Registry::get('parameterRoute') . $route . '/' . $i . '">' . $i . '</a></li>';
            }
        }
    }
    /* collect next and last output */
    if ($sub_active < $sub_maximum) {
        $next_route = $route . '/' . ($sub_active + 1);
        $last_route = $route . '/' . $sub_maximum;
        $output .= '<li class="rs-item-next"><a href="' . Redaxscript\Registry::get('parameterRoute') . $next_route . '" rel="next">' . Redaxscript\Language::get('next') . '</a></li>';
        $output .= '<li class="rs-item-last"><a href="' . Redaxscript\Registry::get('parameterRoute') . $last_route . '">' . Redaxscript\Language::get('last') . '</a></li>';
    }
    $output .= '</ul>';
    $output .= Redaxscript\Hook::trigger('paginationEnd');
    echo $output;
}
예제 #12
0
/**
 * admin groups form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_groups_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define fields for existing group */
    if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) {
        /* query user */
        $query = 'SELECT * FROM ' . PREFIX . 'groups WHERE id = ' . ID_PARAMETER;
        $result = mysql_query($query);
        $r = mysql_fetch_assoc($result);
        if ($r) {
            foreach ($r as $key => $value) {
                ${$key} = stripslashes($value);
            }
        }
        $wording_headline = $name;
        $wording_submit = l('save');
        $route = 'admin/process/groups/' . $id;
    } else {
        if (ADMIN_PARAMETER == 'new') {
            $categories = 0;
            $articles = 0;
            $extras = 0;
            $comments = 0;
            $groups = 0;
            $users = 0;
            $modules = 0;
            $settings = 0;
            $filter = 1;
            $status = 1;
            $wording_headline = l('group_new');
            $wording_submit = l('create');
            $route = 'admin/process/groups';
        }
    }
    $access_array = array(l('create') => 1, l('edit') => 2, l('delete') => 3);
    $modules_access_array = array(l('install') => 1, l('edit') => 2, l('uninstall') => 3);
    /* 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('group'), FULL_ROUTE . '#tab-1') . '</li>';
    if ($id == '' || $id > 1) {
        $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('access'), FULL_ROUTE . '#tab-2') . '</li>';
        $output .= '<li class="item_last">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-3') . '</li>';
    }
    $output .= '</ul>';
    /* collect tab box output */
    $output .= '<div class="js_box_tab box_tab box_tab_admin">';
    /* collect group set */
    $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l('group')) . '<ul>';
    $output .= '<li>' . form_element('text', 'name', 'js_generate_alias_input field_text_admin field_note', 'name', $name, l('name'), '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>';
    $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 .= '</ul></fieldset>';
    if ($id == '' || $id > 1) {
        /* collect access set */
        $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('acccess')) . '<ul>';
        $output .= '<li>' . select_element('categories', 'field_select_admin', 'categories', $access_array, $categories, l('categories'), 'multiple="multiple"') . '</li>';
        $output .= '<li>' . select_element('articles', 'field_select_admin', 'articles', $access_array, $articles, l('articles'), 'multiple="multiple"') . '</li>';
        $output .= '<li>' . select_element('extras', 'field_select_admin', 'extras', $access_array, $extras, l('extras'), 'multiple="multiple"') . '</li>';
        $output .= '<li>' . select_element('comments', 'field_select_admin', 'comments', $access_array, $comments, l('comments'), 'multiple="multiple"') . '</li>';
        $output .= '<li>' . select_element('groups', 'field_select_admin', 'groups', $access_array, $groups, l('groups'), 'multiple="multiple"') . '</li>';
        $output .= '<li>' . select_element('users', 'field_select_admin', 'users', $access_array, $users, l('users'), 'multiple="multiple"') . '</li>';
        $output .= '<li>' . select_element('modules', 'field_select_admin', 'modules', $modules_access_array, $modules, l('modules'), 'multiple="multiple"') . '</li>';
        $output .= '<li>' . select_element('settings', 'field_select_admin', 'settings', array(l('none') => 0, l('edit') => 1), $settings, l('settings')) . '</li>';
        $output .= '</ul></fieldset>';
        /* collect customize set */
        $output .= form_element('fieldset', 'tab-3', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>';
        $output .= '<li>' . select_element('filter', 'field_select_admin', 'filter', array(l('enable') => 1, l('disable') => 0), $filter, l('filter')) . '</li>';
        $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('enable') => 1, l('disable') => 0), $status, l('status')) . '</li>';
        $output .= '</ul></fieldset>';
    }
    $output .= '</div>';
    /* collect hidden output */
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    /* cancel button */
    if (GROUPS_EDIT == 1 || GROUPS_DELETE == 1) {
        $cancel_route = 'admin/view/groups';
    } 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 (GROUPS_DELETE == 1 && $id > 1) {
        $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large_admin button_delete_admin', l('delete'), 'admin/delete/groups/' . $id . '/' . TOKEN);
    }
    /* submit button */
    if (GROUPS_NEW == 1 || GROUPS_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;
}
예제 #13
0
/**
 * login list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 */
function login_list()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
        $output .= '<li class="item_logout">' . anchor_element('internal', '', '', l('logout'), 'logout', '', 'rel="nofollow"') . '</li>';
        $output .= '<li class="item_administration">' . anchor_element('internal', '', '', l('administration'), 'admin', '', 'rel="nofollow"') . '</li>';
    } else {
        $output .= '<li class="item_login">' . anchor_element('internal', '', '', l('login'), 'login', '', 'rel="nofollow"') . '</li>';
        if (s('reminder') == 1) {
            $output .= '<li class="item_reminder">' . anchor_element('internal', '', '', l('reminder'), 'reminder', '', 'rel="nofollow"') . '</li>';
        }
        if (s('registration') == 1) {
            $output .= '<li class="item_registration">' . anchor_element('internal', '', '', l('registration'), 'registration', '', 'rel="nofollow"') . '</li>';
        }
    }
    $output = '<ul class="list_login">' . $output . '</ul>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
예제 #14
0
/**
 * comments
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Comments
 * @author Henry Ruhs
 *
 * @param integer $article
 * @param string $route
 */
function comments($article, $route)
{
    $output = Redaxscript\Hook::trigger('commentStart');
    /* query comments */
    $comments = Redaxscript\Db::forTablePrefix('comments')->where(['status' => 1, 'article' => $article])->whereLanguageIs(Redaxscript\Registry::get('language'))->orderGlobal('rank');
    /* query result */
    $result = $comments->findArray();
    if ($result) {
        $num_rows = count($result);
        $sub_maximum = ceil($num_rows / Redaxscript\Db::getSetting('limit'));
        $sub_active = Redaxscript\Registry::get('lastSubParameter');
        /* sub parameter */
        if (Redaxscript\Registry::get('lastSubParameter') > $sub_maximum || !Redaxscript\Registry::get('lastSubParameter')) {
            $sub_active = 1;
        } else {
            $offset_string = ($sub_active - 1) * Redaxscript\Db::getSetting('limit') . ', ';
        }
    }
    $comments->limit($offset_string . Redaxscript\Db::getSetting('limit'));
    /* query result */
    $result = $comments->findArray();
    $num_rows_active = count($result);
    /* handle error */
    if (!$result || !$num_rows) {
        $error = Redaxscript\Language::get('comment_no');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            foreach ($result as $r) {
                $access = $r['access'];
                /* access granted */
                if ($accessValidator->validate($access, Redaxscript\Registry::get('myGroups')) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('commentFragmentStart', $r) . '<h3 id="comment-' . $id . '" class="rs-title-comment">';
                    if ($url) {
                        $output .= '<a href="' . $url . '" rel="nofollow">' . $author . '</a>';
                    } else {
                        $output .= $author;
                    }
                    $output .= '</h3>';
                    /* collect box output */
                    $output .= '<div class="rs-box-comment">' . $text . '</div>';
                    $output .= byline('comments', $id, $author, $date);
                    $output .= Redaxscript\Hook::trigger('commentFragmentEnd', $r);
                    /* admin dock */
                    if (Redaxscript\Registry::get('loggedIn') == Redaxscript\Registry::get('token') && Redaxscript\Registry::get('firstParameter') != 'logout') {
                        $output .= admin_dock('comments', $id);
                    }
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows_active == $counter) {
                $error = Redaxscript\Language::get('access_no');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output = '<div class="rs-box-comment">' . $error . Redaxscript\Language::get('point') . '</div>';
    }
    $output .= Redaxscript\Hook::trigger('commentEnd');
    echo $output;
    /* call pagination as needed */
    if ($sub_maximum > 1 && Redaxscript\Db::getSetting('pagination') == 1) {
        pagination($sub_active, $sub_maximum, $route);
    }
}
예제 #15
0
파일: head.php 프로젝트: ITw3/redaxscript
/**
 * head
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Head
 * @author Henry Ruhs
 */
function head()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    if (LAST_TABLE) {
        /* query contents */
        $query = 'SELECT title, description, keywords, access FROM ' . PREFIX . LAST_TABLE . ' WHERE alias = \'' . LAST_PARAMETER . '\' && status = 1';
        $result = mysql_query($query);
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            while ($r = mysql_fetch_assoc($result)) {
                $access = $r['access'];
                $check_access = $accessValidator->validate($access, MY_GROUPS);
                /* if access granted */
                if ($check_access == 1) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                }
            }
        }
    }
    /* prepare title */
    if (TITLE) {
        $title = TITLE;
    } else {
        if ($title == '') {
            $title = s('title');
        }
    }
    /* prepare description */
    if (DESCRIPTION) {
        $description = DESCRIPTION;
    } else {
        if ($description == '') {
            $description = s('description');
        }
    }
    /* prepare keywords */
    if (KEYWORDS) {
        $keywords = KEYWORDS;
    } else {
        if ($keywords == '') {
            $keywords = s('keywords');
        }
    }
    /* prepare robots */
    if (ROBOTS) {
        $robots = ROBOTS;
    } else {
        if (CONTENT_ERROR || LAST_PARAMETER && $check_access == 0) {
            $robots = 'none';
        } else {
            $robots = s('robots');
        }
    }
    /* collect meta output */
    $output .= '<base href="' . ROOT . '/" />' . PHP_EOL;
    $output .= '<meta charset="' . s('charset') . '" />' . PHP_EOL;
    /* collect title output */
    if ($title || $description) {
        if ($title && $description) {
            $divider = s('divider');
        }
        $output .= '<title>' . truncate($title . $divider . $description, 80) . '</title>' . PHP_EOL;
    }
    /* collect refresh route */
    if (REFRESH_ROUTE) {
        $output .= '<meta http-equiv="refresh" content="2; url=' . REFRESH_ROUTE . '" />' . PHP_EOL;
    }
    /* collect author */
    if (s('author')) {
        $output .= '<meta name="author" content="' . s('author') . '" />' . PHP_EOL;
    }
    /* collect metadata */
    $output .= '<meta name="generator" content="' . l('redaxscript') . ' ' . l('redaxscript_version') . '" />' . PHP_EOL;
    if ($description) {
        $output .= '<meta name="description" content="' . $description . '" />' . PHP_EOL;
    }
    if ($keywords) {
        $output .= '<meta name="keywords" content="' . $keywords . '" />' . PHP_EOL;
    }
    $output .= '<meta name="robots" content="' . $robots . '" />' . PHP_EOL;
    /* build canonical url */
    $canonical_url = ROOT . '/' . REWRITE_ROUTE;
    /* if article in category */
    if (FIRST_TABLE == 'categories' && LAST_TABLE == 'articles') {
        if (SECOND_TABLE == 'categories') {
            $category = retrieve('id', SECOND_TABLE, 'alias', SECOND_PARAMETER);
        } else {
            $category = retrieve('id', FIRST_TABLE, 'alias', FIRST_PARAMETER);
        }
        /* total articles of category */
        $articles_total = query_total('articles', 'category', $category);
        if ($articles_total == 1) {
            $canonical_route = FIRST_PARAMETER;
            if (SECOND_TABLE == 'categories') {
                $canonical_route .= '/' . SECOND_PARAMETER;
            }
        }
    }
    /* extend canonical url */
    if ($canonical_route) {
        $canonical_url .= $canonical_route;
    } else {
        $canonical_url .= FULL_ROUTE;
    }
    $output .= '<link href="' . $canonical_url . '" rel="canonical" />' . PHP_EOL;
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
예제 #16
0
/**
 * navigation list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 *
 * @param string $table
 * @param array $options
 */
function navigation_list($table, $options)
{
    $output = Redaxscript\Hook::trigger('navigationStart');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* fallback */
    if (!$option_order) {
        $option_order = Redaxscript\Db::getSetting('order');
    }
    if (!$option_limit) {
        $option_limit = Redaxscript\Db::getSetting('limit');
    }
    /* switch table */
    switch ($table) {
        case 'categories':
            $wording_single = 'category';
            $query_parent = 'parent';
            break;
        case 'articles':
            $wording_single = 'article';
            $query_parent = 'category';
            break;
        case 'comments':
            $wording_single = 'comment';
            $query_parent = 'article';
            break;
    }
    /* query contents */
    $contents = Redaxscript\Db::forTablePrefix($table)->where('status', 1)->whereLanguageIs(Redaxscript\Registry::get('language'));
    /* setup parent */
    if ($query_parent) {
        if ($option_parent) {
            $contents->where($query_parent, $option_parent);
        } else {
            if ($table == 'categories') {
                $contents->whereNull($query_parent);
            }
        }
    }
    /* setup query filter */
    if ($table == 'categories' || $table == 'articles') {
        /* setup filter alias option */
        if ($option_filter_alias) {
            $contents->whereIn('alias', $option_filter_alias);
        }
        /* setup filter rank option */
        if ($option_filter_rank) {
            $contents->whereIn('rank', $option_filter_rank);
        }
    }
    /* setup rank and limit */
    if ($option_order === 'asc') {
        $contents->orderByAsc('rank');
    } else {
        $contents->orderByDesc('rank');
    }
    $contents->limit($option_limit);
    /* query result */
    $result = $contents->findArray();
    $num_rows = count($result);
    if (!$result || !$num_rows) {
        $error = Redaxscript\Language::get($wording_single . '_no') . Redaxscript\Language::get('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            foreach ($result as $r) {
                $access = $r['access'];
                /* access granted */
                if ($accessValidator->validate($access, Redaxscript\Registry::get('myGroups')) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    /* build class string */
                    if (Redaxscript\Registry::get('lastParameter') == $alias && $table != 'comments') {
                        $class_string = ' class="rs-item-active"';
                    } else {
                        $class_string = null;
                    }
                    /* prepare metadata */
                    if ($table == 'comments') {
                        $description = $title = $author . Redaxscript\Language::get('colon') . ' ' . strip_tags($text);
                    }
                    if (!$description) {
                        $description = $title;
                    }
                    /* build route */
                    if ($table == 'categories' && $parent == 0 || $table == 'articles' && $category == 0) {
                        $route = $alias;
                    } else {
                        $route = build_route($table, $id);
                    }
                    /* collect item output */
                    $output .= '<li' . $class_string . '><a href="' . Redaxscript\Registry::get('parameterRoute') . $route . '">' . $title . '</a>';
                    /* collect children list output */
                    if ($table == 'categories' && $option_children == 1) {
                        ob_start();
                        navigation_list($table, ['parent' => $id, 'class' => 'rs-list-children']);
                        $output .= ob_get_clean();
                    }
                    $output .= '</li>';
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = Redaxscript\Language::get('access_no') . Redaxscript\Language::get('point');
            }
        }
    }
    /* build id string */
    if ($option_id) {
        $id_string = ' id="' . $option_id . '"';
    }
    /* build class string */
    if ($option_class) {
        $class_string = ' class="' . $option_class . '"';
    } else {
        $class_string = ' class="rs-list-' . $table . '"';
    }
    /* handle error */
    if ($error && !$option_parent) {
        $output = '<ul' . $id_string . $class_string . '><li><span>' . $error . '</span></li></ul>';
    } else {
        if ($output) {
            $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
        }
    }
    $output .= Redaxscript\Hook::trigger('navigationEnd');
    echo $output;
}
예제 #17
0
/**
 * admin control
 *
 * @since 2.0.0
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 *
 * @param string $type
 * @param string $table
 * @param integer $id
 * @param string $alias
 * @param integer $status
 * @param string $new
 * @param string $edit
 * @param string $delete
 * @return string
 */
function admin_control($type, $table, $id, $alias, $status, $new, $edit, $delete)
{
    $output = Redaxscript\Hook::trigger('adminControlStart');
    /* define access variables */
    if ($type == 'access' && $id == 1) {
        $delete = 0;
    }
    if ($type == 'modules_not_installed') {
        $edit = $delete = 0;
    }
    /* collect modules output */
    if ($new == 1 && $type == 'modules_not_installed') {
        $output .= '<li class="rs-admin-item-control rs-admin-item-install"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/install/' . $table . '/' . $alias . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('install') . '</a></li>';
    }
    /* collect contents output */
    if ($type == 'contents') {
        if ($status == 2) {
            $output .= '<li class="rs-admin-item-control rs-admin-item-future-posting"><span>' . Redaxscript\Language::get('future_posting') . '</span></li>';
        }
        if ($edit == 1) {
            if ($status == 1) {
                $output .= '<li class="rs-admin-item-control rs-admin-item-unpublish"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/unpublish/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('unpublish') . '</a></li>';
            } else {
                if ($status == 0) {
                    $output .= '<li class="rs-admin-item-control rs-admin-item-publish"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/publish/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('publish') . '</a></li>';
                }
            }
        }
    }
    /* collect access and system output */
    if ($edit == 1 && ($type == 'access' && $id > 1 || $type == 'modules_installed')) {
        if ($status == 1) {
            $output .= '<li class="rs-admin-item-control rs-admin-item-disable"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/disable/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('disable') . '</a></li>';
        } else {
            if ($status == 0) {
                $output .= '<li class="rs-admin-item-control rs-admin-item-enable"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/enable/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('enable') . '</a></li>';
            }
        }
    }
    /* collect general edit and delete output */
    if ($edit == 1) {
        $output .= '<li class="rs-admin-item-control rs-admin-item-edit"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/edit/' . $table . '/' . $id . '">' . Redaxscript\Language::get('edit') . '</a></li>';
    }
    if ($delete == 1) {
        if ($type == 'modules_installed') {
            $output .= '<li class="rs-admin-item-control rs-admin-item-uninstall"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/uninstall/' . $table . '/' . $alias . '/' . Redaxscript\Registry::get('token') . '" class="rs-admin-js-confirm">' . Redaxscript\Language::get('uninstall') . '</a></li>';
        } else {
            $output .= '<li class="rs-admin-item-control rs-admin-item-delete"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/delete/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '" class="rs-admin-js-confirm">' . Redaxscript\Language::get('delete') . '</a></li>';
        }
    }
    /* collect list output */
    if ($output) {
        $output = '<ul class="rs-admin-list-control">' . $output . '</ul>';
    }
    $output .= Redaxscript\Hook::trigger('adminControlEnd');
    return $output;
}
예제 #18
0
/**
 * admin modules list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_modules_list()
{
    $output = Redaxscript\Hook::trigger('adminModuleListStart');
    /* query modules */
    $result = Redaxscript\Db::forTablePrefix('modules')->orderByAsc('name')->findArray();
    $num_rows = count($result);
    /* collect listing output */
    $output .= '<h2 class="rs-admin-title-content">' . Redaxscript\Language::get('modules') . '</h2>';
    $output .= '<div class="rs-admin-wrapper-table"><table class="rs-admin-table-default rs-admin-table-module">';
    /* collect thead and tfoot */
    $output .= '<thead><tr><th class="rs-admin-col-name">' . Redaxscript\Language::get('name') . '</th><th class="rs-admin-col-alias">' . Redaxscript\Language::get('alias') . '</th><th class="rs-admin-col-version">' . Redaxscript\Language::get('version') . '</th></tr></thead>';
    $output .= '<tfoot><tr><td>' . Redaxscript\Language::get('name') . '</td><td>' . Redaxscript\Language::get('alias') . '</td><td>' . Redaxscript\Language::get('version') . '</td></tr></tfoot>';
    if (!$result || !$num_rows) {
        $error = Redaxscript\Language::get('module_no') . Redaxscript\Language::get('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            $output .= '<tbody>';
            foreach ($result as $r) {
                $access = $r['access'];
                /* access granted */
                if ($accessValidator->validate($access, Redaxscript\Registry::get('myGroups')) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    $modules_installed_array[] = $alias;
                    /* build class string */
                    if ($status == 1) {
                        $class_status = null;
                    } else {
                        $class_status = 'rs-admin-is-disabled';
                    }
                    /* collect table row */
                    $output .= '<tr';
                    if ($alias) {
                        $output .= ' id="' . $alias . '"';
                    }
                    if ($class_status) {
                        $output .= ' class="' . $class_status . '"';
                    }
                    $output .= '><td>' . $name;
                    /* collect control output */
                    $output .= admin_control('modules_installed', 'modules', $id, $alias, $status, Redaxscript\Registry::get('tableInstall'), Redaxscript\Registry::get('tableEdit'), Redaxscript\Registry::get('tableUninstall'));
                    /* collect alias and version output */
                    $output .= '</td><td>' . $alias . '</td><td>' . $version . '</td></tr>';
                } else {
                    $counter++;
                }
            }
            $output .= '</tbody>';
            /* handle access */
            if ($num_rows == $counter) {
                $error = Redaxscript\Language::get('access_no') . Redaxscript\Language::get('point');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output .= '<tbody><tr><td colspan="3">' . $error . '</td></tr></tbody>';
    }
    /* modules not installed */
    if (Redaxscript\Registry::get('modulesInstall') == 1) {
        /* modules directory */
        $modules_directory = new Redaxscript\Directory();
        $modules_directory->init('modules');
        $modules_directory_array = $modules_directory->getArray();
        if ($modules_directory_array && $modules_installed_array) {
            $modules_not_installed_array = array_diff($modules_directory_array, $modules_installed_array);
        } else {
            if ($modules_directory_array) {
                $modules_not_installed_array = $modules_directory_array;
            }
        }
        if ($modules_not_installed_array) {
            $output .= '<tbody><tr class="rs-admin-row-group"><td colspan="3">' . Redaxscript\Language::get('install') . '</td></tr>';
            foreach ($modules_not_installed_array as $alias) {
                /* collect table row */
                $output .= '<tr';
                if ($alias) {
                    $output .= ' id="' . $alias . '"';
                }
                $output .= '><td colspan="3">' . $alias;
                /* collect control output */
                $output .= admin_control('modules_not_installed', 'modules', $id, $alias, $status, Redaxscript\Registry::get('tableInstall'), Redaxscript\Registry::get('tableEdit'), Redaxscript\Registry::get('tableUninstall'));
                $output .= '</td></tr>';
            }
            $output .= '</tbody>';
        }
    }
    $output .= '</table></div>';
    $output .= Redaxscript\Hook::trigger('adminModuleListEnd');
    echo $output;
}
/**
 * notification
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 *
 * @param string $title
 * @param string $text
 * @param string $action
 * @param string $route
 */
function notification($title = '', $text = '', $action = '', $route = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* detect needed mode */
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin') {
        $suffix = '_admin';
    } else {
        $suffix = '_default';
    }
    /* collect output */
    if ($title) {
        $output .= '<h2 class="title_content title_notification">' . $title . '</h2>';
    }
    $output .= '<div class="box_content box_notification">';
    /* collect text output */
    if (is_string($text)) {
        $text = array($text);
    }
    foreach ($text as $value) {
        if ($value) {
            $output .= '<p class="text_notification">' . $value . l('point') . '</p>';
        }
    }
    /* collect button output */
    if ($action && $route) {
        $output .= anchor_element('internal', '', 'js_forward_notification button' . $suffix, $action, $route);
    }
    $output .= '</div>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
예제 #20
0
    /* install cli */
    install_cli($argv);
    /* bootstrap */
    include_once 'includes/bootstrap.php';
    /* install */
    install();
} else {
    /* install post */
    install_post();
    /* bootstrap */
    include_once 'includes/bootstrap.php';
    /* define meta */
    define('TITLE', l('installation'));
    define('ROBOTS', 'none');
    /* module init */
    Redaxscript\Hook::trigger('init');
    /* call loader else render template */
    if (FIRST_PARAMETER == 'loader' && (SECOND_PARAMETER == 'styles' || SECOND_PARAMETER == 'scripts')) {
        echo loader(SECOND_PARAMETER, 'outline');
    } else {
        include_once 'templates/install/install.phtml';
    }
}
/**
 * install
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Install
예제 #21
0
/**
 * admin control
 *
 * @since 2.0.0
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 *
 * @param string $type
 * @param string $table
 * @param integer $id
 * @param string $alias
 * @param integer $status
 * @param string $new
 * @param string $edit
 * @param string $delete
 * @return string
 */
function admin_control($type = '', $table = '', $id = '', $alias = '', $status = '', $new = '', $edit = '', $delete = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define access variables */
    if ($type == 'access' && $id == 1) {
        $delete = 0;
    }
    if ($type == 'modules_not_installed') {
        $edit = $delete = 0;
    }
    /* collect modules output */
    if ($new == 1 && $type == 'modules_not_installed') {
        $output .= '<li class="item_control_admin link_install">' . anchor_element('internal', '', 'install', l('install'), 'admin/install/' . $table . '/' . $alias . '/' . TOKEN) . '</li>';
    }
    /* collect contents output */
    if ($type == 'contents') {
        if ($status == 2) {
            $output .= '<li class="item_control_admin item_future_posting"><span>' . l('future_posting') . '</span></li>';
        }
        if ($edit == 1) {
            if ($status == 1) {
                $output .= '<li class="item_control_admin item_unpublish">' . anchor_element('internal', '', '', l('unpublish'), 'admin/unpublish/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
            } else {
                if ($status == 0) {
                    $output .= '<li class="item_control_admin item_publish">' . anchor_element('internal', '', '', l('publish'), 'admin/publish/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
                }
            }
        }
    }
    /* collect access and system output */
    if ($edit == 1 && ($type == 'access' && $id > 1 || $type == 'modules_installed')) {
        if ($status == 1) {
            $output .= '<li class="item_control_admin item_disable">' . anchor_element('internal', '', '', l('disable'), 'admin/disable/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
        } else {
            if ($status == 0) {
                $output .= '<li class="item_control_admin item_enable">' . anchor_element('internal', '', '', l('enable'), 'admin/enable/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
            }
        }
    }
    /* collect general edit and delete output */
    if ($edit == 1) {
        $output .= '<li class="item_control_admin item_edit">' . anchor_element('internal', '', '', l('edit'), 'admin/edit/' . $table . '/' . $id) . '</li>';
    }
    if ($delete == 1) {
        if ($type == 'modules_installed') {
            $output .= '<li class="item_control_admin item_uninstall">' . anchor_element('internal', '', 'js_confirm', l('uninstall'), 'admin/uninstall/' . $table . '/' . $alias . '/' . TOKEN) . '</li>';
        } else {
            $output .= '<li class="item_control_admin item_delete">' . anchor_element('internal', '', 'js_confirm', l('delete'), 'admin/delete/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
        }
    }
    /* collect list output */
    if ($output) {
        $output = '<ul class="list_control_admin">' . $output . '</ul>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    return $output;
}
예제 #22
0
/**
 * scripts
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Loader
 * @author Henry Ruhs
 *
 * @param string $mode
 */
function scripts($mode = '')
{
    if ($mode == '') {
        $output = Redaxscript\Hook::trigger('script_start');
    }
    /* parse loader ini */
    $loader_ini = parse_ini_file('templates/' . Redaxscript\Registry::get('template') . '/scripts/.loader', 1);
    /* inherit from other templates */
    $loader_inherit = $loader_ini['inherit'];
    if ($loader_inherit) {
        foreach ($loader_inherit as $key => $template) {
            $loader_inherit_ini = parse_ini_file('templates/' . $template . '/scripts/.loader', 1);
            $loader_ini = array_merge_recursive($loader_inherit_ini, $loader_ini);
        }
    }
    $loader_minify = $loader_ini['settings']['minify'];
    /* init mode */
    if ($mode == 'init') {
        $output .= '<script> /* <![cdata[ */ ' . loader('scripts', 'init') . ' /* ]]> */ </script>' . PHP_EOL;
    } else {
        $loader_single = $loader_ini['single'];
        /* logged in */
        if (LOGGED_IN == TOKEN) {
            $loader_admin_single = $loader_ini['admin_single'];
        }
        $loader_deploy = $loader_ini['settings']['deploy'];
        /* merge loader include as needed */
        $loader_include = array();
        if ($loader_single) {
            $loader_include = array_merge($loader_include, $loader_single);
        }
        if ($loader_admin_single) {
            $loader_include = array_merge($loader_include, $loader_admin_single);
        }
        /* collect output */
        if ($loader_include) {
            foreach ($loader_include as $value) {
                $output .= '<script src="' . $value . '"></script>' . PHP_EOL;
            }
        }
        /* type of deployment */
        $output .= '<script> /* <![cdata[ */ ' . scripts_transport($loader_minify);
        if ($loader_deploy == 'inline') {
            $output .= loader('scripts', 'inline') . ' /* ]]> */ </script>' . PHP_EOL;
        } else {
            $output .= ' /* ]]> */ </script>' . PHP_EOL;
            $output .= '<script src="' . REWRITE_ROUTE . 'loader/scripts"></script>' . PHP_EOL;
        }
    }
    if ($mode == '') {
        $output .= Redaxscript\Hook::trigger('script_end');
    }
    echo $output;
}
예제 #23
0
/**
 * router
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Center
 * @author Henry Ruhs
 */
function router()
{
    $firstParameter = Redaxscript\Registry::get('firstParameter');
    $secondParameter = Redaxscript\Registry::get('secondParameter');
    $thirdParameter = Redaxscript\Registry::get('thirdParameter');
    $thirdSubParameter = Redaxscript\Registry::get('thirdSubParameter');
    $config = Redaxscript\Config::getInstance();
    Redaxscript\Hook::trigger('routerStart');
    if (Redaxscript\Registry::get('routerBreak')) {
        return;
    }
    /* check token */
    $messenger = new Redaxscript\Messenger(Redaxscript\Registry::getInstance());
    if ($_POST && $_POST['token'] != Redaxscript\Registry::get('token')) {
        echo $messenger->setRoute(Redaxscript\Language::get('home'), Redaxscript\Registry::get('root'))->error(Redaxscript\Language::get('token_incorrect'), Redaxscript\Language::get('error_occurred'));
        return;
    }
    /* install routing */
    if (Redaxscript\Registry::get('file') === 'install.php' && $config->get('env') !== 'production') {
        if (Redaxscript\Request::getPost('Redaxscript\\View\\InstallForm')) {
            $installController = new Redaxscript\Controller\Install(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance(), Redaxscript\Config::getInstance());
            echo $installController->process();
            return;
        } else {
            $systemStatus = new Redaxscript\View\SystemStatus(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
            $installForm = new Redaxscript\View\InstallForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
            echo $systemStatus->render() . $installForm->render();
            return;
        }
    }
    /* general routing */
    $post_list = ['Redaxscript\\View\\LoginForm' => 'Redaxscript\\Controller\\Login', 'Redaxscript\\View\\RegisterForm' => 'Redaxscript\\Controller\\Register', 'Redaxscript\\View\\ResetForm' => 'Redaxscript\\Controller\\Reset', 'Redaxscript\\View\\RecoverForm' => 'Redaxscript\\Controller\\Recover', 'Redaxscript\\View\\CommentForm' => 'Redaxscript\\Controller\\Comment'];
    foreach ($post_list as $key => $value) {
        if (Redaxscript\Request::getPost($key)) {
            if (class_exists($value)) {
                $controller = new $value(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance());
                echo $controller->process();
            }
            return;
        }
    }
    /* search routing */
    if (Redaxscript\Request::getPost('Redaxscript\\View\\SearchForm')) {
        $messenger = new Redaxscript\Messenger(Redaxscript\Registry::getInstance());
        $table = Redaxscript\Request::getPost('table');
        if ($table) {
            $table = '/' . $table;
        }
        echo $messenger->setRoute(Redaxscript\Language::get('continue'), 'search' . $table . '/' . Redaxscript\Request::getPost('search'))->doRedirect(0)->success(Redaxscript\Language::get('search'));
    }
    /* parameter routing */
    switch ($firstParameter) {
        case 'admin':
            if (Redaxscript\Registry::get('loggedIn') == Redaxscript\Registry::get('token')) {
                admin_router();
            } else {
                echo $messenger->setRoute(Language::get('login'), 'login')->error(Language::get('access_no'), Language::get('error_occurred'));
            }
            return;
        case 'login':
            switch ($secondParameter) {
                case 'recover':
                    if (Redaxscript\Db::getSetting('recovery') == 1) {
                        $recoverForm = new Redaxscript\View\RecoverForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                        echo $recoverForm->render();
                        return;
                    }
                case 'reset':
                    if (Redaxscript\Db::getSetting('recovery') == 1 && $thirdParameter && $thirdSubParameter) {
                        $resetForm = new Redaxscript\View\ResetForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                        echo $resetForm->render();
                        return;
                    }
                    /* show error */
                    echo $messenger->setRoute(Language::get('login'), 'login')->error(Language::get('access_no'), Language::get('error_occurred'));
                    return;
                default:
                    $loginForm = new Redaxscript\View\LoginForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                    echo $loginForm->render();
                    return;
            }
        case 'logout':
            if (Redaxscript\Registry::get('loggedIn') == Redaxscript\Registry::get('token')) {
                $logoutController = new Redaxscript\Controller\Logout(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance());
                echo $logoutController->process();
                return;
            }
            /* show error */
            echo $messenger->setRoute(Language::get('login'), 'login')->error(Language::get('access_no'), Language::get('error_occurred'));
            return;
        case 'register':
            if (Redaxscript\Db::getSetting('registration')) {
                $registerForm = new Redaxscript\View\RegisterForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                echo $registerForm->render();
                return;
            }
            /* show error */
            echo $messenger->setRoute(Language::get('home'), Redaxscript\Registry::get('root'))->error(Language::get('access_no'), Language::get('error_occurred'));
            return;
        case 'search':
            $searchController = new Redaxscript\Controller\Search(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance());
            echo $searchController->process();
            return;
        default:
            contents();
            return;
    }
    Redaxscript\Hook::trigger('routerEnd');
}
/**
 * admin modules form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_modules_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define fields for existing user */
    if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) {
        /* query modules */
        $result = Redaxscript\Db::forTablePrefix('modules')->where('id', ID_PARAMETER)->findArray();
        $r = $result[0];
        if ($r) {
            foreach ($r as $key => $value) {
                ${$key} = stripslashes($value);
            }
        }
        $wording_headline = $name;
        $wording_submit = l('save');
        $route = 'admin/process/modules/' . $id;
    }
    /* directory object */
    $docs_directory = new Redaxscript\Directory();
    $docs_directory->init('modules/' . $alias . '/docs');
    $docs_directory_array = $docs_directory->getArray();
    /* 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('module'), FULL_ROUTE . '#tab-1') . '</li>';
    $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li>';
    foreach ($docs_directory_array as $key => $value) {
        $output .= '<li class="item_third">' . anchor_element('internal', '', '', str_replace('.phtml', '', $value), FULL_ROUTE . '#tab-' . ($key + 3)) . '</li>';
    }
    $output .= '</ul>';
    /* collect tab box output */
    $output .= '<div class="js_box_tab box_tab box_tab_admin">';
    /* collect module set */
    $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l('user')) . '<ul>';
    $output .= '<li>' . form_element('text', 'name', 'field_text_admin field_note', 'name', $name, l('name'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>';
    $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small', 'description', $description, l('description'), 'rows="1" cols="15"') . '</li>';
    $output .= '</ul></fieldset>';
    /* collect customize set */
    $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>';
    $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('enable') => 1, l('disable') => 0), $status, l('status')) . '</li>';
    /* build access select */
    if (GROUPS_EDIT == 1) {
        $access_array[l('all')] = null;
        $access_result = Redaxscript\Db::forTablePrefix('groups')->orderByAsc('name')->findArray();
        if ($access_result) {
            foreach ($access_result as $g) {
                $access_array[$g['name']] = $g['id'];
            }
        }
        $output .= '<li>' . select_element('access', 'field_select_admin', 'access', $access_array, $access, l('access'), 'multiple="multiple"') . '</li></ul></fieldset>';
    }
    /* template object */
    $template = new Redaxscript\Template();
    /* collect docs set */
    foreach ($docs_directory_array as $key => $value) {
        $output .= form_element('fieldset', 'tab-' . ($key + 3), 'js_set_tab set_tab set_tab_admin', '', '', 'docs') . '<ul>';
        $output .= '<li>' . $template->partial('modules/' . $alias . '/docs/' . $value) . '</li></ul></fieldset>';
    }
    $output .= '</div>';
    /* collect hidden output */
    $output .= form_element('hidden', '', '', 'alias', $alias);
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    /* cancel button */
    if (MODULES_EDIT == 1 || MODULES_UNINSTALL == 1) {
        $cancel_route = 'admin/view/modules';
    } else {
        $cancel_route = 'admin';
    }
    $output .= anchor_element('internal', '', 'js_cancel button_admin button_large button_cancel_admin', l('cancel'), $cancel_route);
    /* uninstall button */
    if (MODULES_UNINSTALL == 1) {
        $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large button_uninstall_admin', l('uninstall'), 'admin/uninstall/modules/' . $alias . '/' . TOKEN);
    }
    /* submit button */
    if (MODULES_EDIT == 1) {
        $output .= form_element('button', '', 'js_submit button_admin button_large button_submit_admin', ADMIN_PARAMETER, $wording_submit);
    }
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
/**
 * admin settings form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_settings_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    $output .= '<h2 class="title_content">' . l('settings') . '</h2>';
    $output .= form_element('form', 'form_admin', 'js_validate_form js_accordion form_admin', '', '', '', 'action="' . REWRITE_ROUTE . 'admin/update/settings" method="post"');
    /* collect general set */
    $output .= '<fieldset class="js_set_accordion js_set_active set_accordion set_accordion_admin set_active">';
    $output .= '<legend class="js_title_accordion js_title_active title_accordion title_accordion_admin title_active">' . l('general') . '</legend>';
    $output .= '<ul class="js_box_accordion js_box_active box_accordion box_accordion_admin box_active">';
    /* languages directory object */
    $languages_directory = new Redaxscript\Directory();
    $languages_directory->init('languages');
    $languages_directory_array = $languages_directory->getArray();
    /* build languages select */
    if (count($languages_directory_array) > 1) {
        $language_array[l('detect')] = 'detect';
    }
    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, s('language'), l('language')) . '</li>';
    /* templates directory object */
    $templates_directory = new Redaxscript\Directory();
    $templates_directory->init('templates', array('admin', 'install'));
    $templates_directory_array = $templates_directory->getArray();
    /* build templates select */
    $output .= '<li>' . select_element('template', 'field_select_admin', 'template', $templates_directory_array, s('template'), l('template')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect metadata set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('metadata') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . form_element('text', 'title', 'field_text_admin', 'title', s('title'), l('title'), 'maxlength="50"') . '</li>';
    $output .= '<li>' . form_element('text', 'author', 'field_text_admin', 'author', s('author'), l('author'), 'maxlength="50"') . '</li>';
    $output .= '<li>' . form_element('text', 'copyright', 'field_text_admin', 'copyright', s('copyright'), l('copyright'), 'maxlength="50"') . '</li>';
    $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small', 'description', s('description'), l('description'), 'rows="1" cols="15"') . '</li>';
    $output .= '<li>' . form_element('textarea', 'keywords', 'js_auto_resize field_textarea_admin field_small', 'keywords', s('keywords'), l('keywords'), 'rows="1" cols="15"') . '</li>';
    $output .= '<li>' . select_element('robots', 'field_select_admin', 'robots', array(l('index') => 'all', l('index_no') => 'none'), s('robots'), l('robots')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect contact set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('contact') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', s('email'), l('email'), 'maxlength="50" required="required"') . '</li>';
    $output .= '<li>' . form_element('text', 'subject', 'field_text_admin', 'subject', s('subject'), l('subject'), 'maxlength="50"') . '</li>';
    $output .= '<li>' . select_element('notification', 'field_select_admin', 'notification', array(l('enable') => 1, l('disable') => 0), s('notification'), l('notification')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect formatting set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('formatting') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . form_element('text', 'charset', 'field_text_admin field_note', 'charset', s('charset'), l('charset'), 'maxlength="10" required="required"') . '</li>';
    $output .= '<li>' . form_element('text', 'divider', 'field_text_admin', 'divider', s('divider'), l('divider'), 'maxlength="10"') . '</li>';
    $output .= '<li>' . select_element('time', 'field_select_admin', 'time', array('H:i', 'h:i'), s('time'), l('time')) . '</li>';
    $output .= '<li>' . select_element('date', 'field_select_admin', 'date', array('d.m.Y', 'm.d.Y', 'Y.m.d'), s('date'), l('date')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect contents set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('contents') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $homepage_array[l('none')] = 0;
    $homepage_result = Redaxscript\Db::forTablePrefix('articles')->orderByAsc('title')->findArray();
    if ($homepage_result) {
        foreach ($homepage_result as $r) {
            $homepage_array[$r['title'] . ' (' . $r['id'] . ')'] = $r['id'];
        }
    }
    $output .= '<li>' . select_element('homepage', 'field_select_admin', 'homepage', $homepage_array, s('homepage'), l('homepage')) . '</li>';
    $output .= '<li>' . form_element('text', 'limit', 'field_text_admin field_note', 'limit', s('limit'), l('limit'), 'min="1" max="1000" required="required"') . '</li>';
    $output .= '<li>' . select_element('order', 'field_select_admin', 'order', array(l('ascending') => 'asc', l('descending') => 'desc'), s('order'), l('order')) . '</li>';
    $output .= '<li>' . select_element('pagination', 'field_select_admin', 'pagination', array(l('enable') => 1, l('disable') => 0), s('pagination'), l('pagination')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect comments set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('comments') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . select_element('moderation', 'field_select_admin', 'moderation', array(l('enable') => 1, l('disable') => 0), s('moderation'), l('moderation')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect users set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('users') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . select_element('registration', 'field_select_admin', 'registration', array(l('enable') => 1, l('disable') => 0), s('registration'), l('registration')) . '</li>';
    $output .= '<li>' . select_element('verification', 'field_select_admin', 'verification', array(l('enable') => 1, l('disable') => 0), s('verification'), l('verification')) . '</li>';
    $output .= '<li>' . select_element('reminder', 'field_select_admin', 'reminder', array(l('enable') => 1, l('disable') => 0), s('reminder'), l('reminder')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect security set */
    $output .= '<fieldset class="js_set_accordion js_set_accordion_last set_accordion set_accordion_admin set_accordion_last">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('security') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . select_element('captcha', 'field_select_admin', 'captcha', array(l('random') => 1, l('addition') => 2, l('subtraction') => 3, l('disable') => 0), s('captcha'), l('captcha')) . '</li>';
    $output .= '<li>' . select_element('blocker', 'field_select_admin', 'blocker', array(l('enable') => 1, l('disable') => 0), s('blocker'), l('blocker')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect hidden and button output */
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    $output .= anchor_element('internal', '', 'js_cancel button_admin button_large button_cancel_admin', l('cancel'), 'admin');
    $output .= form_element('button', '', 'js_submit button_admin button_large button_submit_admin', 'update', l('save'));
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
예제 #26
0
/**
 * head
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Head
 * @author Henry Ruhs
 *
 * @param string $type
 */
function head($type = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    if (LAST_TABLE) {
        /* fetch result */
        $result = Redaxscript\Db::forTablePrefix(LAST_TABLE)->where(array('alias' => LAST_PARAMETER, 'status' => 1))->findArray();
        /* process result */
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            foreach ($result as $r) {
                $access = $r['access'];
                /* if access granted */
                if ($accessValidator->validate($access, MY_GROUPS) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                }
            }
        }
    }
    /* prepare title */
    if (TITLE) {
        $title = TITLE;
    } else {
        if ($title == '') {
            $title = s('title');
        }
    }
    /* prepare description */
    if (DESCRIPTION) {
        $description = DESCRIPTION;
    } else {
        if ($description == '') {
            $description = s('description');
        }
    }
    /* prepare keywords */
    if (KEYWORDS) {
        $keywords = KEYWORDS;
    } else {
        if ($keywords == '') {
            $keywords = s('keywords');
        }
    }
    /* prepare robots */
    if (ROBOTS) {
        $robots = ROBOTS;
    } else {
        if (CONTENT_ERROR || LAST_PARAMETER && $check_access == 0) {
            $robots = 'none';
        } else {
            $robots = s('robots');
        }
    }
    /* collect meta output */
    if ($type == '' || $type == 'base') {
        $output .= '<base href="' . ROOT . '/" />' . PHP_EOL;
    }
    if ($type == '' || $type == 'meta') {
        $output .= '<meta charset="' . s('charset') . '" />' . PHP_EOL;
    }
    /* collect title */
    if (($type == '' || $type == 'title') && ($title || $description)) {
        if ($title && $description) {
            $divider = s('divider');
        }
        $output .= '<title>' . truncate($title . $divider . $description, 80) . '</title>' . PHP_EOL;
    }
    /* collect meta */
    if ($type == '' || $type == 'meta') {
        /* collect refresh route */
        if (REFRESH_ROUTE) {
            $output .= '<meta http-equiv="refresh" content="2; url=' . REFRESH_ROUTE . '" />' . PHP_EOL;
        }
        /* collect author */
        if (s('author')) {
            $output .= '<meta name="author" content="' . s('author') . '" />' . PHP_EOL;
        }
        /* collect metadata */
        $output .= '<meta name="generator" content="' . l('name', '_package') . ' ' . l('version', '_package') . '" />' . PHP_EOL;
        if ($description) {
            $output .= '<meta name="description" content="' . $description . '" />' . PHP_EOL;
        }
        if ($keywords) {
            $output .= '<meta name="keywords" content="' . $keywords . '" />' . PHP_EOL;
        }
        $output .= '<meta name="robots" content="' . $robots . '" />' . PHP_EOL;
    }
    /* collect link */
    if ($type == '' || $type == 'link') {
        /* build canonical url */
        $canonical_url = ROOT . '/' . REWRITE_ROUTE;
        /* if article in category */
        if (FIRST_TABLE == 'categories' && LAST_TABLE == 'articles') {
            if (SECOND_TABLE == 'categories') {
                $category = Redaxscript\Db::forTablePrefix(SECOND_TABLE)->where('alias', SECOND_PARAMETER)->findOne()->id;
            } else {
                $category = Redaxscript\Db::forTablePrefix(FIRST_TABLE)->where('alias', FIRST_PARAMETER)->findOne()->id;
            }
            /* total articles of category */
            $articles_total = Redaxscript\Db::forTablePrefix('articles')->where('category', $category)->count();
            if ($articles_total == 1) {
                $canonical_route = FIRST_PARAMETER;
                if (SECOND_TABLE == 'categories') {
                    $canonical_route .= '/' . SECOND_PARAMETER;
                }
            }
        }
        /* extend canonical url */
        if ($canonical_route) {
            $canonical_url .= $canonical_route;
        } else {
            $canonical_url .= FULL_ROUTE;
        }
        $output .= '<link href="' . $canonical_url . '" rel="canonical" />' . PHP_EOL;
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
/**
 * 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';
            $wording_sibling = 'category_sibling';
            break;
        case 'articles':
            $wording_single = 'article';
            $wording_sibling = 'article_sibling';
            break;
        case 'extras':
            $wording_single = 'extra';
            $wording_sibling = 'extra_sibling';
            break;
        case 'comments':
            $wording_single = 'comment';
            break;
    }
    /* define fields for existing user */
    if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) {
        /* query content */
        $result = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('id', ID_PARAMETER)->findArray();
        $r = $result[0];
        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') {
                $sibling = 0;
                $parent = 0;
            }
            if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') {
                $category = 0;
                $headline = 1;
            }
            if (TABLE_PARAMETER == 'articles') {
                $sibling = 0;
                $infoline = 0;
                $comments = 0;
            }
            if (TABLE_PARAMETER == 'extras') {
                $sibling = 0;
            }
            $status = 1;
            $rank = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->max('rank') + 1;
            $access = null;
            $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') {
        $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', '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', '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_directory->init('languages');
    $languages_directory_array = $languages_directory->getArray();
    /* 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_directory->init('templates', array('admin', 'install'));
        $templates_directory_array = $templates_directory->getArray();
        /* 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 sibling select */
    if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') {
        $sibling_array[l('none')] = 0;
        $sibling_result = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->orderByAsc('rank')->findArray();
        if ($sibling_result) {
            foreach ($sibling_result as $s) {
                if (ID_PARAMETER != $s['id']) {
                    $sibling_array[$s['title'] . ' (' . $s['id'] . ')'] = $s['id'];
                }
            }
        }
        $output .= '<li>' . select_element('sibling', 'field_select_admin', 'sibling', $sibling_array, $sibling, l($wording_sibling)) . '</li>';
    }
    /* build category and parent select */
    if (TABLE_PARAMETER != 'comments') {
        if (TABLE_PARAMETER == 'extras') {
            $category_array[l('all')] = 0;
        } else {
            $category_array[l('none')] = 0;
        }
        $categories_result = Redaxscript\Db::forTablePrefix('categories')->orderByAsc('rank')->findArray();
        if ($categories_result) {
            foreach ($categories_result as $c) {
                if (TABLE_PARAMETER != 'categories') {
                    $category_array[$c['title'] . ' (' . $c['id'] . ')'] = $c['id'];
                } else {
                    if (ID_PARAMETER != $c['id'] && $c['parent'] == 0) {
                        $category_array[$c['title'] . ' (' . $c['id'] . ')'] = $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 = Redaxscript\Db::forTablePrefix('articles');
        if (TABLE_PARAMETER == 'comments') {
            $articles->where('comments', 0);
        }
        $articles_result = $articles->orderByAsc('rank')->findArray();
        if ($articles_result) {
            foreach ($articles_result as $a) {
                $article_array[$a['title'] . ' (' . $a['id'] . ')'] = $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')] = null;
        $access_result = Redaxscript\Db::forTablePrefix('groups')->orderByAsc('name')->findArray();
        if ($access_result) {
            foreach ($access_result as $g) {
                $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 != 'categories') {
        $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, 2021, 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 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 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 button_submit_admin', ADMIN_PARAMETER, $wording_submit);
    }
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
예제 #28
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);
        ini_set('mbstring.substitute_character', 0);
    }
    /* define general */
    $request = Redaxscript\Request::getInstance();
    $registry = Redaxscript\Registry::getInstance();
    $file = new Redaxscript\Server\File($request);
    $root = new Redaxscript\Server\Root($request);
    $host = new Redaxscript\Server\Host($request);
    $registry->set('file', $file->getOutput());
    $registry->set('root', $root->getOutput());
    $registry->set('host', $host->getOutput());
    /* session */
    session_start();
    /* prevent session hijacking */
    $request->refreshSession();
    if (!$request->getSession('regenerateId')) {
        session_regenerate_id();
        $request->setSession('regenerateId', true);
    }
    /* database status */
    $registry->set('dbStatus', Redaxscript\Db::getStatus());
    /* define token */
    $token = new Redaxscript\Server\Token($request);
    $auth = new Redaxscript\Auth($request);
    $registry->set('token', $token->getOutput());
    if ($auth->getStatus()) {
        $registry->set('loggedIn', $token->getOutput());
    }
    /* setup charset */
    if (function_exists('ini_set') && $registry->get('dbStatus') === 2) {
        ini_set('default_charset', Redaxscript\Db::getSetting('charset'));
    }
    /* define status */
    $pdoDriverArray = PDO::getAvailableDrivers();
    $fallbackModuleArray = ['mod_deflate', 'mod_headers', 'mod_rewrite'];
    $apacheModuleArray = function_exists('apache_get_modules') ? apache_get_modules() : $fallbackModuleArray;
    $registry->set('phpOs', strtolower(php_uname('s')));
    $registry->set('phpVersion', phpversion());
    $registry->set('pdoDriverArray', $pdoDriverArray);
    $registry->set('apacheModuleArray', $apacheModuleArray);
    $registry->set('sessionStatus', session_status());
    /* define parameter */
    $parameter = new Redaxscript\Router\Parameter($request);
    $parameter->init();
    $registry->set('firstParameter', $parameter->getFirst());
    $registry->set('firstSubParameter', $parameter->getSub());
    $registry->set('secondParameter', $parameter->getSecond());
    $registry->set('secondSubParameter', $parameter->getSub());
    $registry->set('thirdParameter', $parameter->getThird());
    $registry->set('thirdSubParameter', $parameter->getSub());
    if ($registry->get('loggedIn') == $registry->get('token') && $registry->get('firstParameter') == 'admin') {
        $registry->set('adminParameter', $parameter->getAdmin());
        $registry->set('tableParameter', $parameter->getTable());
        $registry->set('idParameter', $parameter->getId());
        $registry->set('aliasParameter', $parameter->getAlias());
    }
    $registry->set('lastParameter', $parameter->getLast());
    $registry->set('lastSubParameter', $parameter->getSub());
    $registry->set('tokenParameter', $parameter->getToken());
    /* define routes */
    $resolver = new Redaxscript\Router\Resolver($request);
    $resolver->init();
    $registry->set('liteRoute', $resolver->getLite());
    $registry->set('fullRoute', $resolver->getFull());
    if (!in_array('mod_rewrite', $registry->get('apacheModuleArray')) || !file_exists('.htaccess') || $registry->get('file') == 'install.php') {
        $registry->set('parameterRoute', '?p=');
        $registry->set('languageRoute', '&amp;l=');
        $registry->set('templateRoute', '&amp;t=');
    } else {
        $registry->set('parameterRoute', null);
        $registry->set('languageRoute', '.');
        $registry->set('templateRoute', '.');
    }
    /* define tables */
    if ($registry->get('dbStatus') === 2) {
        if (!$registry->get('fullRoute') || $registry->get('firstParameter') == 'admin' && !$registry->get('secondParameter')) {
            /* check for homepage */
            if (Redaxscript\Db::getSetting('homepage') > 0) {
                $table = 'articles';
                $id = Redaxscript\Db::getSetting('homepage');
            } else {
                $table = 'categories';
                $id = 0;
                /* check order */
                if (Redaxscript\Db::getSetting('order') == 'asc') {
                    $rank = Redaxscript\Db::forTablePrefix($table)->min('rank');
                } else {
                    if (Redaxscript\Db::getSetting('order') == 'desc') {
                        $rank = Redaxscript\Db::forTablePrefix($table)->max('rank');
                    }
                }
                /* category is published */
                if ($rank) {
                    $status = Redaxscript\Db::forTablePrefix($table)->where('rank', $rank)->findOne()->status;
                    if ($status == 1) {
                        $id = Redaxscript\Db::forTablePrefix($table)->where('rank', $rank)->findOne()->id;
                    }
                }
            }
            $registry->set('firstTable', $table);
            $registry->set('lastTable', $table);
        } else {
            if ($registry->get('firstParameter')) {
                $registry->set('firstTable', query_table($registry->get('firstParameter')));
            }
            if ($registry->get('firstTable')) {
                $registry->set('secondTable', query_table($registry->get('secondParameter')));
            }
            if ($registry->get('secondTable')) {
                $registry->set('thirdTable', query_table($registry->get('thirdParameter')));
            }
            if ($registry->get('lastParameter')) {
                $registry->set('lastTable', query_table($registry->get('lastParameter')));
            }
            if ($registry->get('lastTable')) {
                $id = Redaxscript\Db::forTablePrefix($registry->get('lastTable'))->where('alias', $registry->get('lastParameter'))->findOne()->id;
            }
        }
    }
    /* define ids */
    $aliasValidator = new Redaxscript\Validator\Alias();
    if ($registry->get('firstParameter') === 'admin' || $aliasValidator->validate($registry->get('firstParameter'), Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::FAILED) {
        if ($registry->get('lastTable') == 'categories') {
            $registry->set('categoryId', $id);
            $registry->set('lastId', $id);
        } else {
            if ($registry->get('lastTable') == 'articles') {
                $registry->set('articleId', $id);
                $registry->set('lastId', $id);
            }
        }
    }
    /* define content error */
    if (!$registry->get('lastId') && $aliasValidator->validate($registry->get('firstParameter'), Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::FAILED) {
        $registry->set('contentError', true);
    } else {
        $registry->set('contentError', false);
    }
    /* define user */
    $browser = new Redaxscript\Client\Browser($request);
    $version = new Redaxscript\Client\Version($request);
    $engine = new Redaxscript\Client\Engine($request);
    $mobile = new Redaxscript\Client\Mobile($request);
    $tablet = new Redaxscript\Client\Tablet($request);
    $desktop = new Redaxscript\Client\Desktop($request);
    $registry->set('myBrowser', $browser->getOutput());
    $registry->set('myBrowserVersion', $version->getOutput());
    $registry->set('myEngine', $engine->getOutput());
    $registry->set('myMobile', $mobile->getOutput());
    $registry->set('myTablet', $tablet->getOutput());
    if (!$registry->get('myMobile') || !$registry->get('myTablet')) {
        $registry->set('myDesktop', $desktop->getOutput());
    }
    /* auth */
    Redaxscript\Request::refreshSession();
    $auth->init();
    if ($auth->getStatus()) {
        $registry->set('myId', $auth->getUser('id'));
        $registry->set('myName', $auth->getUser('name'));
        $registry->set('myUser', $auth->getUser('user'));
        $registry->set('myEmail', $auth->getUser('email'));
        $registry->set('myLanguage', $auth->getUser('language'));
        $registry->set('myGroups', $auth->getUser('groups'));
        $registry->set('categoriesNew', $auth->getPermissionNew('categories'));
        $registry->set('categoriesEdit', $auth->getPermissionEdit('categories'));
        $registry->set('categoriesDelete', $auth->getPermissionDelete('categories'));
        $registry->set('articlesNew', $auth->getPermissionNew('articles'));
        $registry->set('articlesEdit', $auth->getPermissionEdit('articles'));
        $registry->set('articlesDelete', $auth->getPermissionDelete('articles'));
        $registry->set('extrasNew', $auth->getPermissionNew('extras'));
        $registry->set('extrasEdit', $auth->getPermissionEdit('extras'));
        $registry->set('extrasDelete', $auth->getPermissionDelete('extras'));
        $registry->set('commentsNew', $auth->getPermissionNew('comments'));
        $registry->set('commentsEdit', $auth->getPermissionEdit('comments'));
        $registry->set('commentsDelete', $auth->getPermissionDelete('comments'));
        $registry->set('groupsNew', $auth->getPermissionNew('groups'));
        $registry->set('groupsEdit', $auth->getPermissionEdit('groups'));
        $registry->set('groupsDelete', $auth->getPermissionDelete('groups'));
        $registry->set('usersNew', $auth->getPermissionNew('users'));
        $registry->set('usersEdit', $auth->getPermissionEdit('users'));
        $registry->set('usersDelete', $auth->getPermissionDelete('users'));
        $registry->set('modulesInstall', $auth->getPermissionInstall('modules'));
        $registry->set('modulesEdit', $auth->getPermissionEdit('modules'));
        $registry->set('modulesUninstall', $auth->getPermissionUninstall('modules'));
        $registry->set('settingsEdit', $auth->getPermissionEdit('settings'));
    }
    $registry->set('filter', $auth->getFilter());
    /* define table access */
    $tableParameter = $registry->get('tableParameter');
    $registry->set('tableNew', $registry->get($tableParameter . 'New'));
    $registry->set('tableInstall', $registry->get($tableParameter . 'Install'));
    $registry->set('tableEdit', $registry->get($tableParameter . 'Edit'));
    $registry->set('tableDelete', $registry->get($tableParameter . 'Delete'));
    $registry->set('tableUninstall', $registry->get($tableParameter . 'Uninstall'));
    /* define time */
    $registry->set('now', date('Y-m-d H:i:s'));
    /* cron update */
    $registry->set('cronUpdate', false);
    if (!Redaxscript\Request::getSession('timerUpdate') && $registry->get('dbStatus') === 2 && function_exists('future_update')) {
        Redaxscript\Request::setSession('timerUpdate', date('Y-m-d H:i:s', strtotime('+1 minute')));
        $registry->set('cronUpdate', true);
    } else {
        if (Redaxscript\Request::getSession('timerUpdate') < $registry->get('now')) {
            Redaxscript\Request::setSession('timerUpdate', false);
        }
    }
    /* future update */
    if ($registry->get('cronUpdate')) {
        Redaxscript\Hook::trigger('cronUpdate');
        future_update('categories');
        future_update('articles');
        future_update('comments');
        future_update('extras');
    }
    /* cache */
    $registry->set('noCache', false);
    $filterBoolean = new Redaxscript\Filter\Boolean();
    $noCache = $filterBoolean->sanitize($request->getQuery('no-cache'));
    if ($registry->get('loggedIn') == $registry->get('token') || $noCache) {
        $registry->set('noCache', true);
    }
}