Beispiel #1
0
/**
 * admin routing
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_routing()
{
    /* call last update */
    if (FIRST_PARAMETER == 'admin' && ADMIN_PARAMETER == '' || ADMIN_PARAMETER == 'view' && TABLE_PARAMETER == 'users' || UPDATE == '') {
        admin_last_update();
    }
    /* validate routing */
    switch (true) {
        case ADMIN_PARAMETER && in_array(ADMIN_PARAMETER, array('new', 'view', 'edit', 'up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable', 'install', 'uninstall', 'delete', 'process', 'update')) == '':
        case ADMIN_PARAMETER == 'process' && $_POST['new'] == '' && $_POST['edit'] == '':
        case ADMIN_PARAMETER == 'update' && $_POST['update'] == '':
        case ADMIN_PARAMETER && in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments', 'groups', 'users', 'modules', 'settings')) == '':
        case ALIAS_PARAMETER == '' && (ADMIN_PARAMETER == 'install' || ADMIN_PARAMETER == 'uninstall'):
        case ID_PARAMETER == '' && in_array(ADMIN_PARAMETER, array('edit', 'up', 'down', 'publish', 'unpublish', 'enable', 'disable')) && TABLE_PARAMETER != 'settings':
        case is_numeric(ID_PARAMETER) && retrieve('id', TABLE_PARAMETER, 'id', ID_PARAMETER) == '':
            notification(l('something_wrong'), '', l('back'), 'admin');
            return;
    }
    /* define access variables */
    if (ADMIN_PARAMETER && TABLE_PARAMETER) {
        if (TABLE_PARAMETER == 'modules') {
            $install = MODULES_INSTALL;
            $uninstall = MODULES_UNINSTALL;
        } else {
            if (TABLE_PARAMETER != 'settings') {
                $new = TABLE_NEW;
                if (TABLE_PARAMETER == 'comments') {
                    $articles_total = query_total('articles');
                    $articles_comments_disable = query_total('articles', 'comments', 0);
                    if ($articles_total == $articles_comments_disable) {
                        $new = 0;
                    }
                }
                $delete = TABLE_DELETE;
            }
        }
        $edit = TABLE_EDIT;
    }
    if ($edit == 1 || $delete == 1) {
        $accessValidator = new Redaxscript\Validator\Access();
        $access = retrieve('access', TABLE_PARAMETER, 'id', ID_PARAMETER);
        $check_access = $accessValidator->validate($access, MY_GROUPS);
    }
    /* validate access */
    switch (true) {
        case ADMIN_PARAMETER == 'new' && $new == 0:
        case ADMIN_PARAMETER == 'view' && in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments', 'groups', 'users')) && $new == 0 && $edit == 0 && $delete == 0:
        case ADMIN_PARAMETER == 'view' && TABLE_PARAMETER == 'settings':
        case ADMIN_PARAMETER == 'view' && TABLE_PARAMETER == 'modules' && $edit == 0 && $install == 0 && $uninstall == 0:
        case ADMIN_PARAMETER == 'edit' && $edit == 0 && USERS_EXCEPTION == 0:
        case in_array(ADMIN_PARAMETER, array('up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable')) && $edit == 0:
        case ADMIN_PARAMETER == 'install' && $install == 0:
        case ADMIN_PARAMETER == 'uninstall' && $uninstall == 0:
        case ADMIN_PARAMETER == 'delete' && $delete == 0 && USERS_EXCEPTION == 0:
        case ADMIN_PARAMETER == 'process' && $_POST['new'] && $new == 0:
        case ADMIN_PARAMETER == 'process' && $_POST['edit'] && $edit == 0 && USERS_EXCEPTION == 0:
        case ADMIN_PARAMETER == 'update' && $edit == 0:
        case ID_PARAMETER == 1 && (ADMIN_PARAMETER == 'disable' || ADMIN_PARAMETER == 'delete') && (TABLE_PARAMETER == 'groups' || TABLE_PARAMETER == 'users'):
        case is_numeric(ID_PARAMETER) && TABLE_PARAMETER && $check_access == 0 && USERS_EXCEPTION == 0:
            notification(l('error_occurred'), l('access_no'), l('back'), 'admin');
            return;
    }
    /* check token */
    if (in_array(ADMIN_PARAMETER, array('up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable', 'install', 'uninstall', 'delete')) && TOKEN_PARAMETER == '') {
        notification(l('error_occurred'), l('access_no'), l('back'), 'admin');
        return;
    }
    /* admin routing */
    if (FIRST_PARAMETER == 'admin' && ADMIN_PARAMETER == '') {
        admin_notification();
        contents();
    }
    switch (ADMIN_PARAMETER) {
        case 'new':
            if (in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments'))) {
                admin_contents_form();
            }
            if (in_array(TABLE_PARAMETER, array('groups', 'users'))) {
                call_user_func('admin_' . TABLE_PARAMETER . '_form');
            }
            return;
        case 'view':
            if (in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments'))) {
                admin_contents_list();
            }
            if (in_array(TABLE_PARAMETER, array('groups', 'users', 'modules'))) {
                call_user_func('admin_' . TABLE_PARAMETER . '_list');
            }
            return;
        case 'edit':
            if (in_array(TABLE_PARAMETER, array('categories', 'articles', 'extras', 'comments'))) {
                admin_contents_form();
            }
            if (in_array(TABLE_PARAMETER, array('groups', 'users', 'modules', 'settings'))) {
                call_user_func('admin_' . TABLE_PARAMETER . '_form');
            }
            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_' . ADMIN_PARAMETER);
            return;
    }
}
/**
 * search post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Search
 * @author Henry Ruhs
 */
function search_post()
{
    /* clean post */
    if (ATTACK_BLOCKED < 10) {
        $search_terms = clean($_POST['search_terms'], 5);
        $table = clean($_POST['table']);
    }
    /* validate post */
    if (strlen($search_terms) < 3 || $search_terms == l('search_terms')) {
        $error = l('input_incorrect');
    } else {
        /* fetch result */
        $result = Redaxscript\Db::forTablePrefix($table)->where('status', 1)->whereIn('language', array(Redaxscript\Registry::get('language'), ''))->whereLikeMany(array('title', 'description', 'keywords', 'text'), array('%' . $search_terms . '%', '%' . $search_terms . '%', '%' . $search_terms . '%', '%' . $search_terms . '%'))->orderByDesc('date')->findArray();
        /* process result */
        $num_rows = count($result);
        if (!$result) {
            $error = l('search_no');
        } else {
            if ($result) {
                $accessValidator = new Redaxscript\Validator\Access();
                $output = '<h2 class="title_content title_search_result">' . l('search') . '</h2>';
                $output .= form_element('fieldset', '', 'set_search_result', '', '', '') . '<ol class="list_search_result">';
                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);
                            }
                        }
                        /* prepare metadata */
                        if ($description == '') {
                            $description = $title;
                        }
                        $date = date(s('date'), strtotime($date));
                        /* 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="item_search_result">' . anchor_element('internal', '', 'link_search_result', $title, $route, $description) . '<span class="date_search_result">' . $date . '</span></li>';
                    } else {
                        $counter++;
                    }
                }
                $output .= '</ol></fieldset>';
                /* handle access */
                if ($num_rows == $counter) {
                    $error = l('access_no');
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        notification(l('something_wrong'), $error);
    } else {
        echo $output;
    }
}
/**
 * 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(__FUNCTION__ . '_start');
    /* query modules */
    $result = Redaxscript\Db::forTablePrefix('modules')->orderByAsc('name')->findArray();
    $num_rows = count($result);
    /* collect listing output */
    $output .= '<h2 class="title_content">' . l('modules') . '</h2>';
    $output .= '<div class="wrapper_table_admin"><table class="table table_admin">';
    /* collect thead and tfoot */
    $output .= '<thead><tr><th class="s4o6 column_first">' . l('name') . '</th><th class="s1o6 column_second">' . l('alias') . '</th><th class="s1o6 column_last">' . l('version') . '</th></tr></thead>';
    $output .= '<tfoot><tr><td class="column_first">' . l('name') . '</td><td class="column_second">' . l('alias') . '</td><td class="column_last">' . l('version') . '</td></tr></tfoot>';
    if ($result == '' || $num_rows == '') {
        $error = l('module_no') . l('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            $output .= '<tbody>';
            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);
                        }
                    }
                    $modules_installed_array[] = $alias;
                    /* build class string */
                    if ($status == 1) {
                        $class_status = '';
                    } else {
                        $class_status = 'row_disabled';
                    }
                    /* collect table row */
                    $output .= '<tr';
                    if ($alias) {
                        $output .= ' id="' . $alias . '"';
                    }
                    if ($class_status) {
                        $output .= ' class="' . $class_status . '"';
                    }
                    $output .= '><td class="column_first">' . $name;
                    /* collect control output */
                    $output .= admin_control('modules_installed', 'modules', $id, $alias, $status, MODULES_INSTALL, MODULES_EDIT, MODULES_UNINSTALL);
                    /* collect alias and version output */
                    $output .= '</td><td class="column_second">' . $alias . '</td><td class="column_last">' . $version . '</td></tr>';
                } else {
                    $counter++;
                }
            }
            $output .= '</tbody>';
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output .= '<tbody><tr><td colspan="3">' . $error . '</td></tr></tbody>';
    }
    /* modules not installed */
    if (MODULES_INSTALL == 1) {
        /* modules directory object */
        $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="row_group"><td colspan="3">' . l('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, MODULES_INSTALL, MODULES_EDIT, MODULES_UNINSTALL);
                $output .= '</td></tr>';
            }
            $output .= '</tbody>';
        }
    }
    $output .= '</table></div>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
Beispiel #4
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;
}
/**
 * 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(__FUNCTION__ . '_start');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* fallback */
    if ($option_order == '') {
        $option_order = s('order');
    }
    if ($option_limit == '') {
        $option_limit = s('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)->whereIn('language', array(Redaxscript\Registry::get('language'), ''));
    /* setup parent */
    if ($query_parent) {
        if ($option_parent) {
            $contents->where($query_parent, $option_parent);
        } else {
            if ($table == 'categories') {
                $contents->where($query_parent, 0);
            }
        }
    }
    /* 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 = l($wording_single . '_no') . l('point');
    } else {
        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);
                        }
                    }
                    /* build class string */
                    if (LAST_PARAMETER == $alias && $table != 'comments') {
                        $class_string = ' class="item_active"';
                    } else {
                        $class_string = '';
                    }
                    /* prepare metadata */
                    if ($table == 'comments') {
                        $description = $title = truncate($author . l('colon') . ' ' . strip_tags($text), 80, '...');
                    }
                    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 . '>' . anchor_element('internal', '', '', $title, $route, $description);
                    /* collect children list output */
                    if ($table == 'categories' && $option_children == 1) {
                        ob_start();
                        navigation_list($table, array('parent' => $id, 'class' => 'list_children'));
                        $output .= ob_get_clean();
                    }
                    $output .= '</li>';
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('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="list_' . $table . '"';
    }
    /* handle error */
    if ($error && $option_parent == '') {
        $output = '<ul' . $id_string . $class_string . '><li>' . $error . '</li></ul>';
    } else {
        if ($output) {
            $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
        }
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
Beispiel #6
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;
}
Beispiel #7
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;
}
/**
 * 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;
}
Beispiel #9
0
/**
 * archive
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @return string
 */
function archive()
{
    $query = 'SELECT id, title, alias, description, date, category, access FROM ' . PREFIX . 'articles WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1 ORDER BY date DESC';
    $result = mysql_query($query);
    $num_rows = mysql_num_rows($result);
    if ($result == '' || $num_rows == '') {
        $error = l('article_no') . l('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            $month_names = explode(', ', l('month_names'));
            $last = 0;
            while ($r = mysql_fetch_assoc($result)) {
                /* check for access */
                $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);
                        }
                    }
                    if ($description == '') {
                        $description = $title;
                    }
                    $year = substr($date, 0, 4);
                    $month = substr($date, 5, 2) - 1;
                    /* build route */
                    if ($category == 0) {
                        $route = $alias;
                    } else {
                        $route = build_route('articles', $id);
                    }
                    /* collect output */
                    if ($last != $month + $year) {
                        if ($last > 0) {
                            $output .= '</ul></fieldset>';
                        }
                        $output .= form_element('fieldset', '', 'set_archive', '', '', '<span class="title_content_sub title_archive_sub">' . $month_names[$month] . ' ' . $year . '</span>') . '<ul class="list_default list_archive">';
                    }
                    $output .= '<li>' . anchor_element('internal', '', '', $title, $route, $description) . '</li>';
                    $last = $month + $year;
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output = form_element('fieldset', '', 'set_archive', '', '', '<span class="title_content_sub title_archive_sub">' . l('error') . '</span>') . '<ul class="list_default list_archive">';
        $output .= '<li>' . $error . '</li>';
    }
    $output .= '</ul></fieldset>';
    return $output;
}
Beispiel #10
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;
}
Beispiel #11
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');
}
Beispiel #12
0
/**
 * 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;
}
Beispiel #13
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(__FUNCTION__ . '_start');
    /* query comments */
    $query = 'SELECT id, author, url, text, date, article, access FROM ' . PREFIX . 'comments WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && article = ' . $article . ' && status = 1 ORDER BY rank ' . s('order');
    $result = mysql_query($query);
    if ($result) {
        $num_rows = mysql_num_rows($result);
        $sub_maximum = ceil($num_rows / s('limit'));
        $sub_active = LAST_SUB_PARAMETER;
        /* if sub parameter */
        if (LAST_SUB_PARAMETER > $sub_maximum || LAST_SUB_PARAMETER == '') {
            $sub_active = 1;
        } else {
            $offset_string = ($sub_active - 1) * s('limit') . ', ';
        }
    }
    $query .= ' LIMIT ' . $offset_string . s('limit');
    $result = mysql_query($query);
    $num_rows_active = mysql_num_rows($result);
    /* handle error */
    if ($result == '' || $num_rows == '') {
        $error = l('comment_no');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            $output .= '<div class="box_line"></div>';
            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);
                        }
                    }
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('comment_start', $id) . '<h3 id="comment-' . $id . '" class="title_comment">';
                    if ($url) {
                        $output .= anchor_element('external', '', '', $author, $url, '', 'rel="nofollow"');
                    } else {
                        $output .= $author;
                    }
                    $output .= '</h3>';
                    /* collect box output */
                    $output .= infoline('comments', $id, $author, $date);
                    $output .= '<div class="box_comment">' . $text . '</div>' . Redaxscript\Hook::trigger('comment_end', $id);
                    /* admin dock */
                    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                        $output .= admin_dock('comments', $id);
                    }
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows_active == $counter) {
                $error = l('access_no');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output = '<div class="box_comment_error">' . $error . l('point') . '</div>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
    /* call pagination as needed */
    if ($sub_maximum > 1 && s('pagination') == 1) {
        pagination($sub_active, $sub_maximum, $route);
    }
}
Beispiel #14
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;
}
Beispiel #15
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;
}
/**
 * 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(__FUNCTION__ . '_start');
    /* query comments */
    $comments = Redaxscript\Db::forTablePrefix('comments')->where(array('status' => 1, 'article' => $article))->whereIn('language', array(Redaxscript\Registry::get('language'), ''))->orderGlobal('rank');
    /* query result */
    $result = $comments->findArray();
    if ($result) {
        $num_rows = count($result);
        $sub_maximum = ceil($num_rows / s('limit'));
        $sub_active = LAST_SUB_PARAMETER;
        /* sub parameter */
        if (LAST_SUB_PARAMETER > $sub_maximum || LAST_SUB_PARAMETER == '') {
            $sub_active = 1;
        } else {
            $offset_string = ($sub_active - 1) * s('limit') . ', ';
        }
    }
    $comments->limit($offset_string . s('limit'));
    /* query result */
    $result = $comments->findArray();
    $num_rows_active = count($result);
    /* handle error */
    if ($result == '' || $num_rows == '') {
        $error = l('comment_no');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            $output .= '<div class="box_line"></div>';
            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);
                        }
                    }
                    /* collect headline output */
                    $output .= Redaxscript\Hook::trigger('comment_start', $r) . '<h3 id="comment-' . $id . '" class="title_comment">';
                    if ($url) {
                        $output .= anchor_element('external', '', '', $author, $url, '', 'rel="nofollow"');
                    } else {
                        $output .= $author;
                    }
                    $output .= '</h3>';
                    /* collect box output */
                    $output .= infoline('comments', $id, $author, $date);
                    $output .= '<div class="box_comment">' . $text . '</div>' . Redaxscript\Hook::trigger('comment_end', $r);
                    /* admin dock */
                    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
                        $output .= admin_dock('comments', $id);
                    }
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows_active == $counter) {
                $error = l('access_no');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output = '<div class="box_comment_error">' . $error . l('point') . '</div>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
    /* call pagination as needed */
    if ($sub_maximum > 1 && s('pagination') == 1) {
        pagination($sub_active, $sub_maximum, $route);
    }
}
Beispiel #17
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);
    }
}
Beispiel #18
0
/**
 * search post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Search
 * @author Henry Ruhs
 */
function search_post()
{
    /* clean post */
    if (ATTACK_BLOCKED < 10) {
        $search_terms = clean($_POST['search_terms'], 1);
    }
    /* validate post */
    if (strlen($search_terms) < 3 || $search_terms == l('search_terms')) {
        $error = l('input_incorrect');
    } else {
        $search = array_filter(explode(' ', $search_terms));
        $search_keys = array_keys($search);
        $last = end($search_keys);
        /* query search */
        $query = 'SELECT id, title, alias, description, date, category, access FROM ' . PREFIX . 'articles WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1';
        if ($search) {
            $query .= ' && (';
            foreach ($search as $key => $value) {
                $query .= 'title LIKE \'%' . $value . '%\' || description LIKE \'%' . $value . '%\' || keywords LIKE \'%' . $value . '%\' || text LIKE \'%' . $value . '%\'';
                if ($last != $key) {
                    $query .= ' || ';
                }
            }
            $query .= ')';
        }
        $query .= ' ORDER BY date DESC LIMIT 50';
        $result = mysql_query($query);
        $num_rows = mysql_num_rows($result);
        if ($result == '' || $num_rows == '') {
            $error = l('search_no');
        } else {
            if ($result) {
                $accessValidator = new Redaxscript\Validator\Access();
                $output = '<h2 class="title_content title_search_result">' . l('search') . '</h2>';
                $output .= form_element('fieldset', '', 'set_search_result', '', '', '<span class="title_content_sub title_search_result_sub">' . l('articles') . '</span>') . '<ol class="list_search_result">';
                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 metadata */
                        if ($description == '') {
                            $description = $title;
                        }
                        $date = date(s('date'), strtotime($date));
                        /* build route */
                        if ($category == 0) {
                            $route = $alias;
                        } else {
                            $route = build_route('articles', $id);
                        }
                        /* collect item output */
                        $output .= '<li class="item_search_result">' . anchor_element('internal', '', 'link_search_result', $title, $route, $description) . '<span class="date_search_result">' . $date . '</span></li>';
                    } else {
                        $counter++;
                    }
                }
                $output .= '</ol></fieldset>';
                /* handle access */
                if ($num_rows == $counter) {
                    $error = l('access_no');
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        notification(l('something_wrong'), $error);
    } else {
        echo $output;
    }
}
Beispiel #19
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(__FUNCTION__ . '_start');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* fallback */
    if ($option_order == '') {
        $option_order = s('order');
    }
    if ($option_limit == '') {
        $option_limit = s('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 */
    $query = 'SELECT * FROM ' . PREFIX . $table . ' WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1';
    /* setup parent */
    if ($query_parent) {
        if ($option_parent) {
            $query .= ' && ' . $query_parent . ' = ' . $option_parent;
        } else {
            if ($table == 'categories') {
                $query .= ' && ' . $query_parent . ' = 0';
            }
        }
    }
    /* setup query filter */
    if ($table == 'categories' || $table == 'articles') {
        /* setup filter alias option */
        if ($option_filter_alias) {
            $query .= ' && alias IN (' . $option_filter_alias . ')';
        }
        /* setup filter rank option */
        if ($option_filter_rank) {
            $query .= ' && rank IN (' . $option_filter_rank . ')';
        }
    }
    /* setup rank and limit */
    $query .= ' ORDER BY rank ' . $option_order . ' LIMIT ' . $option_limit;
    /* query result */
    $result = mysql_query($query);
    $num_rows = mysql_num_rows($result);
    if ($result == '' || $num_rows == '') {
        $error = l($wording_single . '_no') . l('point');
    } else {
        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);
                        }
                    }
                    /* build class string */
                    if (LAST_PARAMETER == $alias && $table != 'comments') {
                        $class_string = ' class="item_active"';
                    } else {
                        $class_string = '';
                    }
                    /* prepare metadata */
                    if ($table == 'comments') {
                        $description = $title = truncate($author . l('colon') . ' ' . strip_tags($text), 80, '...');
                    }
                    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 . '>' . anchor_element('internal', '', '', $title, $route, $description);
                    /* collect children list output */
                    if ($table == 'categories' && $option_children == 1) {
                        ob_start();
                        navigation_list($table, array('parent' => $id, 'class' => 'list_children'));
                        $output .= ob_get_clean();
                    }
                    $output .= '</li>';
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('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="list_' . $table . '"';
    }
    /* handle error */
    if ($error && $option_parent == '') {
        $output = '<ul' . $id_string . $class_string . '><li>' . $error . '</li></ul>';
    } else {
        if ($output) {
            $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
        }
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
/**
 * admin contents list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_contents_list()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define access variables */
    $table_new = TABLE_NEW;
    if (TABLE_PARAMETER == '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) {
            $table_new = 0;
        }
    }
    /* switch table */
    switch (TABLE_PARAMETER) {
        case 'categories':
            $wording_single = 'category';
            $wording_parent = 'category_parent';
            break;
        case 'articles':
            $wording_single = 'article';
            $wording_parent = 'category';
            break;
        case 'extras':
            $wording_single = 'extra';
            break;
        case 'comments':
            $wording_single = 'comment';
            $wording_parent = 'article';
            break;
    }
    /* query contents */
    $result = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->orderByAsc('rank')->findArray();
    $num_rows = count($result);
    /* collect listing output */
    $output .= '<h2 class="title_content">' . l(TABLE_PARAMETER) . '</h2>';
    $output .= '<div class="wrapper_button_admin">';
    if ($table_new == 1) {
        $output .= anchor_element('internal', '', 'button_admin button_plus_admin', l($wording_single . '_new'), 'admin/new/' . TABLE_PARAMETER);
    }
    if (TABLE_EDIT == 1 && $num_rows) {
        $output .= anchor_element('internal', '', 'button_admin button_sort_admin', l('sort'), 'admin/sort/' . TABLE_PARAMETER . '/' . TOKEN);
    }
    $output .= '</div><div class="wrapper_table_admin"><table class="table table_admin">';
    /* collect thead */
    $output .= '<thead><tr><th class="s3o6 column_first">' . l('title') . '</th><th class="';
    if (TABLE_PARAMETER != 'extras') {
        $output .= 's1o6';
    } else {
        $output .= 's3o6';
    }
    $output .= ' column_second">';
    if (TABLE_PARAMETER == 'comments') {
        $output .= l('identifier');
    } else {
        $output .= l('alias');
    }
    $output .= '</th>';
    if (TABLE_PARAMETER != 'extras') {
        $output .= '<th class="column_third">' . l($wording_parent) . '</th>';
    }
    $output .= '<th class="column_move column_last">' . l('rank') . '</th></tr></thead>';
    /* collect tfoot */
    $output .= '<tfoot><tr><td class="column_first">' . l('title') . '</td><td class="column_second">';
    if (TABLE_PARAMETER == 'comments') {
        $output .= l('identifier');
    } else {
        $output .= l('alias');
    }
    $output .= '</td>';
    if (TABLE_PARAMETER != 'extras') {
        $output .= '<td class="column_third">' . l($wording_parent) . '</td>';
    }
    $output .= '<td class="column_move column_last">' . l('rank') . '</td></tr></tfoot>';
    if ($result == '' || $num_rows == '') {
        $error = l($wording_single . '_no') . l('point');
    } else {
        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);
                        }
                    }
                    /* prepare name */
                    if (TABLE_PARAMETER == 'comments') {
                        $name = truncate($author . l('colon') . ' ' . strip_tags($text), 80, '...');
                    } else {
                        $name = $title;
                    }
                    /* build class string */
                    if ($status == 1) {
                        $class_status = '';
                    } else {
                        $class_status = 'row_disabled';
                    }
                    /* build route */
                    if (TABLE_PARAMETER != 'extras' && $status == 1) {
                        if (TABLE_PARAMETER == 'categories' && $parent == 0 || TABLE_PARAMETER == 'articles' && $category == 0) {
                            $route = $alias;
                        } else {
                            $route = build_route(TABLE_PARAMETER, $id);
                        }
                    } else {
                        $route = '';
                    }
                    /* collect tbody output */
                    if (TABLE_PARAMETER == 'categories') {
                        if ($before != $parent) {
                            $output .= '<tbody><tr class="row_group"><td colspan="4">';
                            if ($parent) {
                                $output .= Redaxscript\Db::forTablePrefix('categories')->where('id', $parent)->findOne()->title;
                            } else {
                                $output .= l('none');
                            }
                            $output .= '</td></tr>';
                        }
                        $before = $parent;
                    }
                    if (TABLE_PARAMETER == 'articles') {
                        if ($before != $category) {
                            $output .= '<tbody><tr class="row_group"><td colspan="4">';
                            if ($category) {
                                $output .= Redaxscript\Db::forTablePrefix('categories')->where('id', $category)->findOne()->title;
                            } else {
                                $output .= l('uncategorized');
                            }
                            $output .= '</td></tr>';
                        }
                        $before = $category;
                    }
                    if (TABLE_PARAMETER == 'comments') {
                        if ($before != $article) {
                            $output .= '<tbody><tr class="row_group"><td colspan="4">';
                            if ($article) {
                                $output .= Redaxscript\Db::forTablePrefix('articles')->where('id', $article)->findOne()->title;
                            } else {
                                $output .= l('none');
                            }
                            $output .= '</td></tr>';
                        }
                        $before = $article;
                    }
                    /* collect table row */
                    $output .= '<tr';
                    if ($alias) {
                        $output .= ' id="' . $alias . '"';
                    }
                    if ($class_status) {
                        $output .= ' class="' . $class_status . '"';
                    }
                    $output .= '><td class="column_first">';
                    if ($language) {
                        $output .= '<span class="icon_flag language_' . $language . '" title="' . l($language) . '">' . $language . '</span>';
                    }
                    if ($status == 1) {
                        $output .= anchor_element('internal', '', 'link_view', $name, $route);
                    } else {
                        $output .= $name;
                    }
                    /* collect control output */
                    $output .= admin_control('contents', TABLE_PARAMETER, $id, $alias, $status, TABLE_NEW, TABLE_EDIT, TABLE_DELETE);
                    /* collect alias and id output */
                    $output .= '</td><td class="column_second">';
                    if (TABLE_PARAMETER == 'comments') {
                        $output .= $id;
                    } else {
                        $output .= $alias;
                    }
                    $output .= '</td>';
                    /* collect parent output */
                    if (TABLE_PARAMETER != 'extras') {
                        $output .= '<td class="column_third">';
                        if (TABLE_PARAMETER == 'categories') {
                            if ($parent) {
                                $parent_title = Redaxscript\Db::forTablePrefix('categories')->where('id', $parent)->findOne()->title;
                                $output .= anchor_element('internal', '', 'link_parent', $parent_title, 'admin/edit/categories/' . $parent);
                            } else {
                                $output .= l('none');
                            }
                        }
                        if (TABLE_PARAMETER == 'articles') {
                            if ($category) {
                                $category_title = Redaxscript\Db::forTablePrefix('categories')->where('id', $category)->findOne()->title;
                                $output .= anchor_element('internal', '', 'link_parent', $category_title, 'admin/edit/categories/' . $category);
                            } else {
                                $output .= l('uncategorized');
                            }
                        }
                        if (TABLE_PARAMETER == 'comments') {
                            if ($article) {
                                $article_title = Redaxscript\Db::forTablePrefix('articles')->where('id', $article)->findOne()->title;
                                $output .= anchor_element('internal', '', 'link_parent', $article_title, 'admin/edit/articles/' . $article);
                            } else {
                                $output .= l('none');
                            }
                        }
                        $output .= '</td>';
                    }
                    $output .= '<td class="column_move column_last">';
                    /* collect control output */
                    if (TABLE_EDIT == 1) {
                        $rank_desc = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->max('rank');
                        if ($rank > 1) {
                            $output .= anchor_element('internal', '', 'move_up', l('up'), 'admin/up/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN);
                        } else {
                            $output .= '<span class="move_up">' . l('up') . '</span>';
                        }
                        if ($rank < $rank_desc) {
                            $output .= anchor_element('internal', '', 'move_down', l('down'), 'admin/down/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN);
                        } else {
                            $output .= '<span class="move_down">' . l('down') . '</span>';
                        }
                        $output .= '</td>';
                    }
                    $output .= '</tr>';
                    /* collect tbody output */
                    if (TABLE_PARAMETER == 'categories') {
                        if ($before != $parent) {
                            $output .= '</tbody>';
                        }
                    }
                    if (TABLE_PARAMETER == 'articles') {
                        if ($before != $category) {
                            $output .= '</tbody>';
                        }
                    }
                    if (TABLE_PARAMETER == 'comments') {
                        if ($before != $article) {
                            $output .= '</tbody>';
                        }
                    }
                } else {
                    $counter++;
                }
            }
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output .= '<tbody><tr><td colspan="4">' . $error . '</td></tr></tbody>';
    }
    $output .= '</table></div>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
Beispiel #21
0
/**
 * sitemap
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @return string
 */
function sitemap()
{
    /* query categories */
    $categories_query = 'SELECT id, title, alias, description, access FROM ' . PREFIX . 'categories WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1 && parent = 0 ORDER BY rank ASC';
    $categories_result = mysql_query($categories_query);
    $categories_num_rows = mysql_num_rows($categories_result);
    /* collect output */
    $output = form_element('fieldset', '', 'set_sitemap', '', '', '<span class="title_content_sub title_sitemap_sub">' . l('categories') . '</span>') . '<ul class="list_default list_sitemap">';
    if ($categories_result == '' || $categories_num_rows == '') {
        $categories_error = l('category_no') . l('point');
    } else {
        if ($categories_result) {
            $accessValidator = new Redaxscript\Validator\Access();
            while ($r = mysql_fetch_assoc($categories_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);
                        }
                    }
                    if ($description == '') {
                        $description = $title;
                    }
                    /* collect item output */
                    $output .= '<li>' . anchor_element('internal', '', '', $title, $alias, $description);
                    /* collect children list output */
                    ob_start();
                    navigation_list('categories', array('parent' => $id, 'class' => 'list_children'));
                    navigation_list('articles', array('parent' => $id, 'class' => 'list_children'));
                    $output .= ob_get_clean();
                    $output .= '</li>';
                } else {
                    $categories_counter++;
                }
            }
            /* handle access */
            if ($categories_num_rows == $categories_counter) {
                $categories_error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($categories_error) {
        $output .= '<li>' . $categories_error . '</li>';
    }
    $output .= '</ul></fieldset>';
    /* query articles */
    $articles_query = 'SELECT id, title, alias, description, access FROM ' . PREFIX . 'articles WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1 && category = 0 ORDER BY rank ASC';
    $articles_result = mysql_query($articles_query);
    $articles_num_rows = mysql_num_rows($articles_result);
    /* collect output */
    $output .= form_element('fieldset', '', 'set_sitemap', '', '', '<span class="title_content_sub title_sitemap_sub">' . l('uncategorized') . '</span>') . '<ul class="list_default list_sitemap">';
    if ($articles_result == '' || $articles_num_rows == '') {
        $articles_error = l('article_no') . l('point');
    } else {
        if ($articles_result) {
            while ($r = mysql_fetch_assoc($articles_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);
                        }
                    }
                    if ($description == '') {
                        $description = $title;
                    }
                    /* collect item output */
                    $output .= '<li>' . anchor_element('internal', '', '', $title, $alias, $description) . '</li>';
                } else {
                    $articles_counter++;
                }
            }
            /* handle access */
            if ($articles_num_rows == $articles_counter) {
                $articles_error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($articles_error) {
        $output .= '<li>' . $articles_error . '</li>';
    }
    $output .= '</ul></fieldset>';
    return $output;
}