Exemple #1
0
/**
 * db backup render start
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 */
function db_backup_render_start()
{
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == 'db-backup') {
        define('TITLE', l('database_backup', 'db_backup'));
        /* registry object */
        $registry = Redaxscript\Registry::getInstance();
        $registry->set('title', l('database_backup', 'db_backup'));
        /* config object */
        $config = Redaxscript\Config::getInstance();
        /* download database backup */
        if (THIRD_PARAMETER == 'download') {
            define('RENDER_BREAK', 1);
            db_backup($config::get('name'), 0);
        }
        /* send database backup */
        if (THIRD_PARAMETER == 'send') {
            define('CENTER_BREAK', 1);
            /* prepare body parts */
            $urlLink = anchor_element('external', '', '', ROOT, ROOT);
            $fileName = $config::get('name') . '-' . db_backup_clean_date(NOW) . '.sql';
            /* prepare mail inputs */
            $toArray = $fromArray = array(s('author') => s('email'));
            $subject = l('database_backup', 'db_backup');
            $bodyArray = array('<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink, '<strong>' . l('database') . l('colon') . '</strong> ' . $config::get('name'), '<br />', '<strong>' . l('message') . l('colon') . '</strong> ' . l('save_attachment', 'db_backup') . l('point'));
            $attachmentArray = array($fileName => db_backup($config::get('name'), 1));
            /* mail object */
            $mail = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray, $attachmentArray);
            $mail->send();
        }
    }
}
Exemple #2
0
/**
 * file manager render start
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 */
function file_manager_render_start()
{
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == 'file-manager') {
        define('CENTER_BREAK', 1);
        define('TITLE', l('file_manager', 'file_manager'));
        /* registry object */
        $registry = Redaxscript\Registry::getInstance();
        $registry->set('title', l('file_manager', 'file_manager'));
    }
}
Exemple #3
0
/**
 * qunit render start
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 */
function qunit_render_start()
{
    if (FIRST_PARAMETER == 'qunit') {
        define('CENTER_BREAK', 1);
        define('TITLE', l('qunit', 'qunit'));
        define('DESCRIPTION', l('description', 'qunit'));
        /* registry object */
        $registry = Redaxscript\Registry::getInstance();
        $registry->set('title', l('qunit', 'qunit'));
    }
}
/**
 * check install
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Install
 * @author Henry Ruhs
 *
 * @return integer
 */
function check_install()
{
    global $name, $user, $password, $email;
    $registry = Redaxscript\Registry::getInstance();
    $loginValidator = new Redaxscript\Validator\Login();
    $emailValidator = new Redaxscript\Validator\Email();
    if ($_POST['install_post'] && $registry->get('dbStatus') && $name && $loginValidator->validate($user) == Redaxscript\Validator\ValidatorInterface::PASSED && $loginValidator->validate($password) == Redaxscript\Validator\ValidatorInterface::PASSED && $emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::PASSED) {
        $output = 1;
    } else {
        $output = 0;
    }
    return $output;
}
Exemple #5
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');
}
/**
 * extras
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 *
 * @param mixed $filter
 */
function extras($filter = '')
{
    if ($filter == '') {
        $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    }
    /* query extras */
    $extras = Redaxscript\Db::forTablePrefix('extras')->whereIn('language', array(Redaxscript\Registry::get('language'), ''));
    /* has filter */
    if ($filter) {
        $id = Redaxscript\Db::forTablePrefix('extras')->where('alias', $filter)->findOne()->id;
        /* handle sibling */
        $sibling = Redaxscript\Db::forTablePrefix('extras')->where('id', $id)->findOne()->sibling;
        /* query sibling collection */
        $sibling_array = Redaxscript\Db::forTablePrefix('extras')->whereIn('sibling', array($id, $sibling > 0 ? $sibling : null))->where('language', Redaxscript\Registry::get('language'))->select('id')->findArrayFlat();
        /* process sibling array */
        foreach ($sibling_array as $value) {
            $id_array[] = $value;
        }
        $id_array[] = $sibling;
        $id_array[] = $id;
    } else {
        $id_array = $extras->where('status', 1)->orderByAsc('rank')->select('id')->findArrayFlat();
    }
    /* query result */
    $result = $extras->whereIn('id', $id_array)->findArray();
    /* collect output */
    if ($result) {
        $accessValidator = new Redaxscript\Validator\Access();
        foreach ($result as $r) {
            $access = $r['access'];
            /* access granted */
            if ($accessValidator->validate($access, MY_GROUPS) === Redaxscript\Validator\ValidatorInterface::PASSED) {
                if ($r) {
                    foreach ($r as $key => $value) {
                        ${$key} = stripslashes($value);
                    }
                }
                /* show if cagegory or article matched */
                if ($category == CATEGORY || $article == ARTICLE || $category == 0 && $article == 0) {
                    /* parser object */
                    $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                    $parser->init($text, array('className' => array('readmore' => 'link_read_more', 'codequote' => 'js_code_quote box_code'), 'route' => $route));
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('extra_start', $r);
                    if ($headline == 1) {
                        $output .= '<h3 class="title_extra" id="extra-' . $alias . '">' . $title . '</h3>';
                    }
                    /* collect box output */
                    $output .= '<div class="box_extra">' . $parser->getOutput() . '</div>' . Redaxscript\Hook::trigger('extra_end', $r);
                    /* prepend admin dock */
                    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                        $output .= admin_dock('extras', $id);
                    }
                }
            }
        }
    }
    if ($filter == '') {
        $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    }
    echo $output;
}
Exemple #7
0
include_once 'includes/contents.php';
include_once 'includes/generate.php';
include_once 'includes/get.php';
include_once 'includes/head.php';
include_once 'includes/loader.php';
include_once 'includes/migrate.php';
include_once 'includes/navigation.php';
include_once 'includes/query.php';
include_once 'includes/replace.php';
include_once 'includes/search.php';
include_once 'includes/startup.php';
/* bootstrap */
include_once 'includes/Bootstrap.php';
startup();
/* migrate deprecated constants */
$registry = Redaxscript\Registry::getInstance();
$registry->init(migrate_constants());
/* include files as needed */
if (LAST_TABLE == 'articles') {
    include_once 'includes/comments.php';
}
if (FIRST_PARAMETER == 'admin' || FIRST_PARAMETER == 'login' || FIRST_PARAMETER == 'logout') {
    include_once 'includes/login.php';
}
if ((FIRST_PARAMETER == 'password_reset' || FIRST_PARAMETER == 'reminder') && s('reminder') == 1) {
    include_once 'includes/password.php';
    include_once 'includes/reminder.php';
}
if (FIRST_PARAMETER == 'registration' && s('registration') == 1) {
    include_once 'includes/password.php';
    include_once 'includes/registration.php';
/**
 * helper subset
 *
 * @since 2.1.0
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Migrate
 * @author Kim Kha Nguyen
 */
function helper_subset()
{
    $helper = new Redaxscript\Helper(Redaxscript\Registry::getInstance());
    echo $helper->getSubset();
}
Exemple #9
0
/**
 * extras
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 *
 * @param mixed $filter
 */
function extras($filter = '')
{
    if ($filter == '') {
        $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    }
    /* query extras */
    $extras = Redaxscript\Db::forTablePrefix('extras')->whereIn('language', array(Redaxscript\Registry::get('language'), ''));
    /* setup filter */
    if (is_numeric($filter)) {
        $extras->where('rank', $filter);
    } else {
        if ($filter) {
            $extras->where('alias', $filter);
        } else {
            $extras->where('status', 1);
        }
    }
    $extras->orderByAsc('rank');
    /* query result */
    $result = $extras->findArray();
    /* collect output */
    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);
                    }
                }
                /* show if cagegory or article matched */
                if ($category == CATEGORY || $article == ARTICLE || $category == 0 && $article == 0) {
                    /* parser object */
                    $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                    $parser->init($text, $route, array('className' => array('break' => 'link_read_more', 'code' => 'box_code')));
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('extra_start', $r);
                    if ($headline == 1) {
                        $output .= '<h3 class="title_extra">' . $title . '</h3>';
                    }
                    /* collect box output */
                    $output .= '<div class="box_extra">' . $parser->getOutput() . '</div>' . Redaxscript\Hook::trigger('extra_end', $r);
                    /* prepend admin dock */
                    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                        $output .= admin_dock('extras', $id);
                    }
                }
            }
        }
    }
    if ($filter == '') {
        $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    }
    echo $output;
}
/**
 * admin update
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_update()
{
    $tableParameter = Redaxscript\Registry::get('tableParameter');
    if ($tableParameter == 'settings') {
        $specialFilter = new Redaxscript\Filter\Special();
        $emailFilter = new Redaxscript\Filter\Email();
        /* clean post */
        $r['language'] = $specialFilter->sanitize($_POST['language']);
        $r['template'] = $specialFilter->sanitize($_POST['template']);
        $r['title'] = $_POST['title'];
        $r['author'] = $_POST['author'];
        $r['copyright'] = $_POST['copyright'];
        $r['description'] = $_POST['description'];
        $r['keywords'] = $_POST['keywords'];
        $r['robots'] = $specialFilter->sanitize($_POST['robots']);
        $r['email'] = $emailFilter->sanitize($_POST['email']);
        $r['subject'] = $_POST['subject'];
        $r['notification'] = $specialFilter->sanitize($_POST['notification']);
        $r['charset'] = !$r['charset'] ? 'utf-8' : $r['charset'];
        $r['divider'] = $_POST['divider'];
        $r['time'] = $_POST['time'];
        $r['date'] = $_POST['date'];
        $r['homepage'] = $specialFilter->sanitize($_POST['homepage']);
        $r['limit'] = !$specialFilter->sanitize($_POST['limit']) ? 10 : $specialFilter->sanitize($_POST['limit']);
        $r['order'] = $specialFilter->sanitize($_POST['order']);
        $r['pagination'] = $specialFilter->sanitize($_POST['pagination']);
        $r['moderation'] = $specialFilter->sanitize($_POST['moderation']);
        $r['registration'] = $specialFilter->sanitize($_POST['registration']);
        $r['verification'] = $specialFilter->sanitize($_POST['verification']);
        $r['recovery'] = $specialFilter->sanitize($_POST['recovery']);
        $r['captcha'] = $specialFilter->sanitize($_POST['captcha']);
        /* update settings */
        foreach ($r as $key => $value) {
            if ($value == 'select') {
                $value = null;
            }
            Redaxscript\Db::forTablePrefix($tableParameter)->where('name', $key)->findOne()->set('value', $value)->save();
        }
        /* show success */
        $messenger = new Redaxscript\Admin\Messenger(Redaxscript\Registry::getInstance());
        echo $messenger->setRoute(Redaxscript\Language::get('continue'), 'admin/edit/settings')->doRedirect()->success(Redaxscript\Language::get('operation_completed'));
    }
}
Exemple #11
0
/**
 * extras
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 *
 * @param mixed $filter
 */
function extras($filter = '')
{
    if ($filter == '') {
        $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    }
    /* query extras */
    $query = 'SELECT id, title, text, category, article, headline, access FROM ' . PREFIX . 'extras WHERE (language = \'' . LANGUAGE . '\' || language = \'\')';
    if (is_numeric($filter)) {
        $query .= ' && rank = ' . $filter;
    } else {
        if ($filter) {
            $query .= ' && alias = \'' . $filter . '\'';
        } else {
            $query .= ' && status = 1';
        }
    }
    $query .= ' ORDER BY rank';
    $result = mysql_query($query);
    /* collect output */
    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);
                    }
                }
                /* show if cagegory or article matched */
                if ($category == CATEGORY || $article == ARTICLE || $category == 0 && $article == 0) {
                    /* parser object */
                    $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), $text, $route, array('className' => array('break' => 'link_read_more', 'code' => 'box_code')));
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('extra_start', $id);
                    if ($headline == 1) {
                        $output .= '<h3 class="title_extra">' . $title . '</h3>';
                    }
                    /* collect box output */
                    $output .= '<div class="box_extra">' . $parser->getOutput() . '</div>' . Redaxscript\Hook::trigger('extra_end', $id);
                    /* prepend admin dock */
                    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                        $output .= admin_dock('extras', $id);
                    }
                }
            }
        }
    }
    if ($filter == '') {
        $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    }
    echo $output;
}
/**
 * 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');
}
Exemple #13
0
/**
 * extras
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 *
 * @param mixed $filter
 */
function extras($filter)
{
    if (!$filter) {
        $output .= Redaxscript\Hook::trigger('extraStart');
    }
    $categoryId = Redaxscript\Registry::get('categoryId');
    $articleId = Redaxscript\Registry::get('articleId');
    $firstParameter = Redaxscript\Registry::get('firstParameter');
    /* query extras */
    $extras = Redaxscript\Db::forTablePrefix('extras')->whereLanguageIs(Redaxscript\Registry::get('language'));
    /* has filter */
    if ($filter) {
        $id = Redaxscript\Db::forTablePrefix('extras')->where('alias', $filter)->findOne()->id;
        /* handle sibling */
        $sibling = Redaxscript\Db::forTablePrefix('extras')->where('id', $id)->findOne()->sibling;
        /* query sibling collection */
        $sibling_array = Redaxscript\Db::forTablePrefix('extras')->whereIn('sibling', [$id, $sibling > 0 ? $sibling : null])->where('language', Redaxscript\Registry::get('language'))->select('id')->findFlatArray();
        /* process sibling array */
        foreach ($sibling_array as $value) {
            $id_array[] = $value;
        }
        $id_array[] = $sibling;
        $id_array[] = $id;
    } else {
        $id_array = $extras->where('status', 1)->orderByAsc('rank')->select('id')->findFlatArray();
    }
    /* query result */
    if ($id_array) {
        $result = $extras->whereIn('id', $id_array)->findArray();
    }
    /* collect output */
    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);
                    }
                }
                /* show if category or article matched */
                if ($category === $categoryId || $article === $articleId || !$category && !$article) {
                    /* parser */
                    $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance());
                    $parser->init($text, ['route' => $route]);
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('extraFragmentStart', $r);
                    if ($headline == 1) {
                        $output .= '<h3 class="rs-title-extra" id="extra-' . $alias . '">' . $title . '</h3>';
                    }
                    /* collect box output */
                    $output .= '<div class="rs-box-extra">' . $parser->getOutput() . '</div>' . Redaxscript\Hook::trigger('extraFragmentEnd', $r);
                    /* prepend admin dock */
                    if (Redaxscript\Registry::get('loggedIn') == Redaxscript\Registry::get('token') && $firstParameter != 'logout') {
                        $output .= admin_dock('extras', $id);
                    }
                }
            }
        }
    }
    if (!$filter) {
        $output .= Redaxscript\Hook::trigger('extraEnd');
    }
    echo $output;
}
Exemple #14
0
/**
 * debug extras end
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 */
function debug_extras_end()
{
    global $hooks;
    /* debug general */
    if (function_exists('memory_get_usage')) {
        $memory_usage = memory_get_usage();
        $debug['general']['memory_usage'] = round($memory_usage / 1024) . ' Kb';
    }
    $debug['general']['operating_system'] = php_uname('s');
    $debug['general']['server_software'] = $_SERVER['SERVER_SOFTWARE'];
    if (function_exists('phpversion')) {
        $php_version = phpversion();
        $debug['general']['php_version'] = substr($php_version, 0, strpos($php_version, '-'));
    }
    if (function_exists('mysql_get_server_info')) {
        $mysql_version = mysql_get_server_info();
        $debug['general']['mysql_version'] = substr($mysql_version, 0, strpos($mysql_version, '-'));
    }
    /* debug last error */
    if (function_exists('error_get_last')) {
        $debug['last_error'] = error_get_last();
    }
    /* debug disabled functions */
    if (function_exists('ini_get')) {
        $debug['disabled_functions'] = explode(',', ini_get('disable_functions'));
    }
    /* debug session */
    foreach ($_SESSION as $key => $value) {
        $key = str_replace(ROOT . '/', '', $key);
        $debug['session'][$key] = $value;
    }
    /* debug registry */
    $registry = Redaxscript\Registry::getInstance();
    $registry_array = $registry->get();
    foreach ($registry_array as $key => $value) {
        $debug['registry'][$key] = $value;
    }
    /* debug constants */
    $defined_constants = get_defined_constants(1);
    foreach ($defined_constants['user'] as $key => $value) {
        $debug['constants'][$key] = $value;
    }
    /* debug hooks */
    $debug['hooks'] = $hooks;
    /* debug file */
    $included_files = get_included_files();
    $document_root = $_SERVER['DOCUMENT_ROOT'];
    foreach ($included_files as $key => $value) {
        $debug['file'][$key] = str_replace($document_root, '', $value);
    }
    /* collect output */
    foreach ($debug as $key => $value) {
        if (count($value)) {
            $output .= '<h3 class="title_extra title_debug">Debug: ' . $key . '</h3><div class="box_extra box_debug"><ul class="js_list_debug list_sidebar list_debug">';
            foreach ($value as $key_sub => $value_sub) {
                if ($value_sub) {
                    $output .= '<li>' . $key_sub . ': <span>' . $value_sub . '</span>';
                } else {
                    $output .= '<li class="js_item_debug item_debug_strike"><del>' . $key_sub . '</del>';
                }
                $output .= '</li>';
            }
            $output .= '</ul></div>';
        }
    }
    echo $output;
}
Exemple #15
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);
    }
}