Exemplo n.º 1
0
/**
 * admin delete
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_delete()
{
    $tableParameter = Redaxscript\Registry::get('tableParameter');
    $idParameter = Redaxscript\Registry::get('idParameter');
    if ($tableParameter == 'categories' || $tableParameter == 'articles' || $tableParameter == 'extras' || $tableParameter == 'comments' || $tableParameter == 'groups' || $tableParameter == 'users') {
        Redaxscript\Db::forTablePrefix($tableParameter)->where('id', $idParameter)->findMany()->delete();
    }
    /* query categories */
    if ($tableParameter == 'categories') {
        $categoryChildren = Redaxscript\Db::forTablePrefix($tableParameter)->where('parent', $idParameter);
        $categoryArray = array_merge($categoryChildren->findFlatArray(), [$idParameter]);
        $articleChildren = Redaxscript\Db::forTablePrefix('articles')->whereIn('category', $categoryArray);
        $articleArray = $articleChildren->findFlatArray();
        if (count($articleArray) > 0) {
            Redaxscript\Db::forTablePrefix('comments')->whereIn('article', $articleArray)->findMany()->delete();
        }
        $categoryChildren->findMany()->delete();
        $articleChildren->findMany()->delete();
        /* reset extras */
        Redaxscript\Db::forTablePrefix('extras')->whereIn('category', $categoryArray)->findMany()->set('category', 0)->save();
    }
    /* query articles */
    if ($tableParameter == 'articles') {
        Redaxscript\Db::forTablePrefix('comments')->where('article', $idParameter)->findMany()->delete();
        /* reset extras */
        Redaxscript\Db::forTablePrefix('extras')->where('article', $idParameter)->findMany()->set('article', 0)->save();
        /* reset homepage */
        if ($idParameter == Redaxscript\Db::getSetting('homepage')) {
            Redaxscript\Db::forTablePrefix('settings')->where('name', 'homepage')->findOne()->set('value', 0)->save();
        }
    }
    /* handle exception */
    if ($tableParameter == 'users' && $idParameter == Redaxscript\Registry::get('myId')) {
        $logoutController = new Redaxscript\Controller\Logout(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance());
        echo $logoutController->process();
    } else {
        $route = 'admin';
        if (Redaxscript\Registry::get('tableEdit') == 1 || Redaxscript\Registry::get('tableEdit') == 1) {
            $route .= '/view/' . $tableParameter;
        }
        /* show success */
        $messenger = new Redaxscript\Admin\Messenger(Redaxscript\Registry::getInstance());
        echo $messenger->setRoute(Redaxscript\Language::get('continue'), $route)->doRedirect()->success(Redaxscript\Language::get('operation_completed'));
    }
}
Exemplo n.º 2
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');
}
Exemplo n.º 3
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);
    }
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
/**
 * admin users list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_users_list()
{
    $output = Redaxscript\Hook::trigger('adminUserListStart');
    /* query users */
    $result = Redaxscript\Db::forTablePrefix('users')->orderByDesc('last')->findArray();
    $num_rows = count($result);
    /* collect listing output */
    $output .= '<h2 class="rs-admin-title-content">' . Redaxscript\Language::get('users') . '</h2>';
    $output .= '<div class="rs-admin-wrapper-button">';
    if (Redaxscript\Registry::get('usersNew')) {
        $output .= '<a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/new/users" class="rs-admin-button-default rs-admin-button-create">' . Redaxscript\Language::get('user_new') . '</a>';
    }
    $output .= '</div><div class="rs-admin-wrapper-table"><table class="rs-admin-table-default rs-admin-table-user">';
    /* collect thead and tfoot */
    $output .= '<thead><tr><th class="rs-admin-col-name">' . Redaxscript\Language::get('name') . '</th><th class="rs-admin-col-user">' . Redaxscript\Language::get('user') . '</th><th class="rs-admin-col-group">' . Redaxscript\Language::get('groups') . '</th><th class="rs-admin-col-session">' . Redaxscript\Language::get('session') . '</th></tr></thead>';
    $output .= '<tfoot><tr><td>' . Redaxscript\Language::get('name') . '</td><td>' . Redaxscript\Language::get('user') . '</td><td>' . Redaxscript\Language::get('groups') . '</td><td>' . Redaxscript\Language::get('session') . '</td></tr></tfoot>';
    if (!$result || !$num_rows) {
        $error = Redaxscript\Language::get('user_no') . Redaxscript\Language::get('point');
    } else {
        if ($result) {
            $output .= '<tbody>';
            foreach ($result as $r) {
                if ($r) {
                    foreach ($r as $key => $value) {
                        ${$key} = stripslashes($value);
                    }
                }
                /* build class string */
                if ($status == 1) {
                    $class_status = null;
                } else {
                    $class_status = 'rs-admin-is-disabled';
                }
                /* collect table row */
                $output .= '<tr';
                if ($user) {
                    $output .= ' id="' . $user . '"';
                }
                if ($class_status) {
                    $output .= ' class="' . $class_status . '"';
                }
                $output .= '><td>';
                if ($language) {
                    $output .= '<span class="rs-admin-has-language" data-language="' . $language . '">';
                }
                $output .= $name;
                if ($language) {
                    $output .= '</span>';
                }
                /* collect control output */
                $output .= admin_control('access', 'users', $id, $alias, $status, Redaxscript\Registry::get('tableNew'), Redaxscript\Registry::get('tableEdit'), Redaxscript\Registry::get('tableDelete'));
                /* collect user and parent output */
                $output .= '</td><td>' . $user . '</td><td>';
                if ($groups) {
                    $groups_array = array_filter(explode(', ', $groups));
                    $groups_array_keys = array_keys($groups_array);
                    $groups_array_last = end($groups_array_keys);
                    foreach ($groups_array as $key => $value) {
                        $group_alias = Redaxscript\Db::forTablePrefix('groups')->where('id', $value)->findOne()->alias;
                        if ($group_alias) {
                            $group_name = Redaxscript\Db::forTablePrefix('groups')->where('id', $value)->findOne()->name;
                            $output .= '<a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/edit/groups/' . $value . '" class="rs-admin-link-parent">' . $group_name . '</a>';
                            if ($groups_array_last != $key) {
                                $output .= ', ';
                            }
                        }
                    }
                } else {
                    $output .= Redaxscript\Language::get('none');
                }
                $output .= '</td><td>';
                if ($first == $last) {
                    $output .= Redaxscript\Language::get('none');
                } else {
                    $minute_ago = date('Y-m-d H:i:s', strtotime('-1 minute'));
                    $day_ago = date('Y-m-d H:i:s', strtotime('-1 day'));
                    if ($last > $minute_ago) {
                        $output .= Redaxscript\Language::get('online');
                    } else {
                        if ($last > $day_ago) {
                            $time = date(Redaxscript\Db::getSetting('time'), strtotime($last));
                            $output .= Redaxscript\Language::get('today') . ' ' . Redaxscript\Language::get('at') . ' ' . $time;
                        } else {
                            $date = date(Redaxscript\Db::getSetting('date'), strtotime($last));
                            $output .= $date;
                        }
                    }
                }
                $output .= '</td></tr>';
            }
            $output .= '</tbody>';
        }
    }
    /* handle error */
    if ($error) {
        $output .= '<tbody><tr><td colspan="3">' . $error . '</td></tr></tbody>';
    }
    $output .= '</table></div>';
    $output .= Redaxscript\Hook::trigger('adminUserListEnd');
    echo $output;
}
Exemplo n.º 6
0
/**
 * byline
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 *
 * @param string $table
 * @param integer $id
 * @param string $author
 * @param string $date
 *
 * @return string
 */
function byline($table, $id, $author, $date)
{
    $output = Redaxscript\Hook::trigger('bylineStart');
    $time = date(Redaxscript\Db::getSetting('time'), strtotime($date));
    $date = date(Redaxscript\Db::getSetting('date'), strtotime($date));
    if ($table == 'articles') {
        $comments_total = Redaxscript\Db::forTablePrefix('comments')->where('article', $id)->count();
    }
    /* collect output */
    $output .= '<div class="rs-box-byline">';
    /* collect author output */
    if ($table == 'articles') {
        $output .= '<span class="rs-text-by">' . Redaxscript\Language::get('posted_by') . ' ' . $author . '</span>';
        $output .= '<span class="rs-text-on"> ' . Redaxscript\Language::get('on') . ' </span>';
    }
    /* collect date and time output */
    $output .= '<span class="rs-text-date">' . $date . '</span>';
    $output .= '<span class="rs-text-at"> ' . Redaxscript\Language::get('at') . ' </span>';
    $output .= '<span class="rs-text-time">' . $time . '</span>';
    /* collect comment output */
    if ($comments_total) {
        $output .= '<span class="rs-text-divider">' . Redaxscript\Db::getSetting('divider') . '</span><span class="rs-text-total">' . $comments_total . ' ';
        if ($comments_total == 1) {
            $output .= Redaxscript\Language::get('comment');
        } else {
            $output .= Redaxscript\Language::get('comments');
        }
        $output .= '</span>';
    }
    $output .= '</div>';
    $output .= Redaxscript\Hook::trigger('bylineEnd');
    return $output;
}
Exemplo n.º 7
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);
    }
}