/** * contents * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs */ function contents() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); $aliasValidator = new Redaxscript\Validator\Alias(); /* query articles */ $articles = Redaxscript\Db::forTablePrefix('articles')->where('status', 1); $articles->whereIn('language', array(Redaxscript\Registry::get('language'), '')); /* handle sibling */ if (LAST_ID) { $sibling = Redaxscript\Db::forTablePrefix(LAST_TABLE)->where('id', LAST_ID)->findOne()->sibling; /* query sibling collection */ $sibling_array = Redaxscript\Db::forTablePrefix(LAST_TABLE)->whereIn('sibling', array(LAST_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; } } /* handle article */ if (ARTICLE) { $id_array[] = $sibling; $id_array[] = ARTICLE; $articles->whereIn('id', $id_array); } else { if (CATEGORY) { if (!$id_array) { if ($sibling > 0) { $id_array[] = $sibling; } else { $id_array[] = CATEGORY; } } $articles->whereIn('category', $id_array)->orderGlobal('rank'); /* handle sub parameter */ $result = $articles->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') . ', '; } } $articles->limit($offset_string . s('limit')); } else { $articles->limit(0); } } /* query result */ $result = $articles->findArray(); $num_rows_active = count($result); /* handle error */ if (CATEGORY && $num_rows == '') { $error = l('article_no'); } else { if ($result == '' || $num_rows_active == '' || CONTENT_ERROR) { $error = l('content_not_found'); } 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); } } if (LAST_TABLE == 'categories' || FULL_ROUTE == '' || $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::PASSED) { $route = build_route('articles', $id); } /* 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('article_start', $r); if ($headline == 1) { $output .= '<h2 class="title_content" id="article-' . $alias . '">'; if (LAST_TABLE == 'categories' || FULL_ROUTE == '' || $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::PASSED) { $output .= anchor_element('internal', '', '', $title, $route); } else { $output .= $title; } $output .= '</h2>'; } /* collect box output */ $output .= '<div class="box_content">' . $parser->getOutput(); $output .= '</div>' . Redaxscript\Hook::trigger('article_end', $r); /* prepend admin dock */ if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') { $output .= admin_dock('articles', $id); } /* infoline */ if ($infoline == 1) { $output .= infoline('articles', $id, $author, $date); } } else { $counter++; } } /* handle access */ if (LAST_TABLE == 'categories') { if ($num_rows_active == $counter) { $error = l('access_no'); } } else { if (LAST_TABLE == 'articles' && $counter == 1) { $error = l('access_no'); } } } } } /* handle error */ if ($error) { notification(l('something_wrong'), $error); } else { $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; /* call comments as needed */ if (ARTICLE) { /* comments replace */ if ($comments == 1 && (COMMENTS_REPLACE == 1 || Redaxscript\Registry::get('commentsReplace'))) { Redaxscript\Hook::trigger('comments_replace'); } else { if ($comments > 0) { $route = build_route('articles', ARTICLE); comments(ARTICLE, $route); /* comment form */ if ($comments == 1 || COMMENTS_NEW == 1 && $comments == 3) { comment_form(ARTICLE, $language); } } } } } /* call pagination as needed */ if ($sub_maximum > 1 && s('pagination') == 1) { $route = build_route('categories', CATEGORY); pagination($sub_active, $sub_maximum, $route); } }
/** * startup * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Startup * @author Henry Ruhs */ function startup() { /* ini set */ if (function_exists('ini_set')) { if (error_reporting() == 0) { ini_set('display_startup_errors', 0); ini_set('display_errors', 0); } ini_set('session.use_trans_sid', 0); ini_set('url_rewriter.tags', 0); ini_set('mbstring.substitute_character', 0); } /* define general */ $request = Redaxscript\Request::getInstance(); $file = new Redaxscript\Server\File($request); $root = new Redaxscript\Server\Root($request); define('FILE', $file->getOutput()); define('ROOT', $root->getOutput()); /* session start */ session_start(); /* prevent session hijacking */ if (!$_SESSION[ROOT . '/regenerate_id']) { session_regenerate_id(); $_SESSION[ROOT . '/regenerate_id'] = 1; } /* database status */ Redaxscript\Registry::set('dbStatus', Redaxscript\Db::getStatus()); /* define token */ $token = new Redaxscript\Server\Token($request); define('TOKEN', $token->getOutput()); /* prefix and salt */ define('PREFIX', Redaxscript\Config::get('dbPrefix')); define('SALT', Redaxscript\Config::get('dbSalt')); /* define session */ define('LOGGED_IN', $_SESSION[ROOT . '/logged_in']); define('ATTACK_BLOCKED', $_SESSION[ROOT . '/attack_blocked']); /* setup charset */ if (function_exists('ini_set') && Redaxscript\Registry::get('dbStatus') === 2) { ini_set('default_charset', s('charset')); } /* define parameter */ $parameter = new Redaxscript\Parameter($request); $parameter->init(); define('FIRST_PARAMETER', $parameter->getFirst()); define('FIRST_SUB_PARAMETER', $parameter->getSub()); define('SECOND_PARAMETER', $parameter->getSecond()); define('SECOND_SUB_PARAMETER', $parameter->getSub()); define('THIRD_PARAMETER', $parameter->getThird()); define('THIRD_SUB_PARAMETER', $parameter->getSub()); if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin') { define('ADMIN_PARAMETER', $parameter->getAdmin()); define('TABLE_PARAMETER', $parameter->getTable()); define('ID_PARAMETER', $parameter->getId()); define('ALIAS_PARAMETER', $parameter->getAlias()); } else { undefine(array('ADMIN_PARAMETER', 'TABLE_PARAMETER', 'ID_PARAMETER', 'ALIAS_PARAMETER')); } define('LAST_PARAMETER', $parameter->getLast()); define('LAST_SUB_PARAMETER', $parameter->getSub()); define('TOKEN_PARAMETER', $parameter->getToken()); /* define routes */ $router = new Redaxscript\Router($request); $router->init(); define('LITE_ROUTE', $router->getLite()); define('FULL_ROUTE', $router->getFull()); if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) == '' || file_exists('.htaccess') == '' || FILE == 'install.php') { define('REWRITE_ROUTE', '?p='); define('LANGUAGE_ROUTE', '&l='); define('TEMPLATE_ROUTE', '&t='); } else { define('REWRITE_ROUTE', ''); define('LANGUAGE_ROUTE', '.'); define('TEMPLATE_ROUTE', '.'); } /* define tables */ if (Redaxscript\Registry::get('dbStatus') === 2) { if (FULL_ROUTE == '' || FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == '') { /* check for homepage */ if (s('homepage') > 0) { $table = 'articles'; $id = s('homepage'); } else { $table = 'categories'; $id = 0; /* check order */ if (s('order') == 'asc') { $rank = Redaxscript\Db::forTablePrefix($table)->min('rank'); } else { if (s('order') == 'desc') { $rank = Redaxscript\Db::forTablePrefix($table)->max('rank'); } } /* if category is published */ if ($rank) { $status = Redaxscript\Db::forTablePrefix($table)->where('rank', $rank)->findOne()->status; if ($status == 1) { $id = Redaxscript\Db::forTablePrefix($table)->where('rank', $rank)->findOne()->id; } } } define('FIRST_TABLE', $table); define('SECOND_TABLE', ''); define('THIRD_TABLE', ''); define('LAST_TABLE', $table); } else { if (FIRST_PARAMETER) { define('FIRST_TABLE', query_table(FIRST_PARAMETER)); } else { define('FIRST_TABLE', ''); } if (FIRST_TABLE) { define('SECOND_TABLE', query_table(SECOND_PARAMETER)); } else { define('SECOND_TABLE', ''); } if (SECOND_TABLE) { define('THIRD_TABLE', query_table(THIRD_PARAMETER)); } else { define('THIRD_TABLE', ''); } if (LAST_PARAMETER) { define('LAST_TABLE', query_table(LAST_PARAMETER)); } else { define('LAST_TABLE', ''); } if (LAST_TABLE) { $id = Redaxscript\Db::forTablePrefix(LAST_TABLE)->where('alias', LAST_PARAMETER)->findOne()->id; } } } else { undefine(array('FIRST_TABLE', 'SECOND_TABLE', 'THIRD_TABLE', 'LAST_TABLE')); } /* define ids */ if (LAST_TABLE == 'categories') { define('CATEGORY', $id); define('ARTICLE', ''); define('LAST_ID', $id); } else { if (LAST_TABLE == 'articles') { define('CATEGORY', ''); define('ARTICLE', $id); define('LAST_ID', $id); } else { undefine(array('CATEGORY', 'ARTICLE', 'LAST_ID')); } } /* define content error */ $aliasValidator = new Redaxscript\Validator\Alias(); if (LAST_ID == '' && $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::FAILED) { define('CONTENT_ERROR', 1); } else { define('CONTENT_ERROR', 0); } /* define user */ $browser = new Redaxscript\Client\Browser($request); $version = new Redaxscript\Client\Version($request); $engine = new Redaxscript\Client\Engine($request); $mobile = new Redaxscript\Client\Mobile($request); $tablet = new Redaxscript\Client\Tablet($request); define('MY_BROWSER', $browser->getOutput()); define('MY_BROWSER_VERSION', $version->getOutput()); define('MY_ENGINE', $engine->getOutput()); define('MY_MOBILE', $mobile->getOutput()); define('MY_TABLET', $tablet->getOutput()); /* if mobile or tablet */ if (MY_MOBILE || MY_TABLET) { define('MY_DESKTOP', ''); } else { $desktop = new Redaxscript\Client\Desktop($request); define('MY_DESKTOP', $desktop->getOutput()); } /* if logged in */ if (LOGGED_IN == TOKEN) { define('MY_ID', $_SESSION[ROOT . '/my_id']); define('MY_NAME', $_SESSION[ROOT . '/my_name']); define('MY_USER', $_SESSION[ROOT . '/my_user']); define('MY_EMAIL', $_SESSION[ROOT . '/my_email']); define('MY_GROUPS', $_SESSION[ROOT . '/my_groups']); /* define access */ $access_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users'); foreach ($access_array as $value) { define(strtoupper($value) . '_NEW', $_SESSION[ROOT . '/' . $value . '_new']); define(strtoupper($value) . '_EDIT', $_SESSION[ROOT . '/' . $value . '_edit']); define(strtoupper($value) . '_DELETE', $_SESSION[ROOT . '/' . $value . '_delete']); if (TABLE_PARAMETER == 'users' && ID_PARAMETER == MY_ID && $value == 'users') { define('USERS_EXCEPTION', 1); } else { if ($value == 'users') { define('USERS_EXCEPTION', 0); } } } define('MODULES_INSTALL', $_SESSION[ROOT . '/modules_install']); define('MODULES_EDIT', $_SESSION[ROOT . '/modules_edit']); define('MODULES_UNINSTALL', $_SESSION[ROOT . '/modules_uninstall']); define('SETTINGS_EDIT', $_SESSION[ROOT . '/settings_edit']); define('FILTER', $_SESSION[ROOT . '/filter']); } else { define('FILTER', 1); } /* define table access */ define('TABLE_NEW', constant(strtoupper(TABLE_PARAMETER) . '_NEW')); define('TABLE_INSTALL', constant(strtoupper(TABLE_PARAMETER) . '_INSTALL')); define('TABLE_EDIT', constant(strtoupper(TABLE_PARAMETER) . '_EDIT')); define('TABLE_DELETE', constant(strtoupper(TABLE_PARAMETER) . '_DELETE')); define('TABLE_UNINSTALL', constant(strtoupper(TABLE_PARAMETER) . '_UNINSTALL')); /* define time */ define('GMDATE', gmdate('D, d M Y H:i:s') . ' GMT'); define('GMDATE_PLUS_WEEK', gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT'); define('GMDATE_PLUS_YEAR', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT'); define('NOW', date('Y-m-d H:i:s')); Redaxscript\Registry::set('now', NOW); define('DELAY', date('Y-m-d H:i:s', strtotime('+1 minute'))); define('TODAY', date('Y-m-d')); /* future update */ define('UPDATE', $_SESSION[ROOT . '/update']); if (UPDATE == '' && Redaxscript\Registry::get('dbStatus') === 2) { future_update('articles'); future_update('comments'); future_update('extras'); $_SESSION[ROOT . '/update'] = DELAY; } else { if (UPDATE < NOW) { $_SESSION[ROOT . '/update'] = ''; } } }
/** * startup * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Startup * @author Henry Ruhs */ function startup() { /* ini set */ if (function_exists('ini_set')) { if (error_reporting() == 0) { ini_set('display_startup_errors', 0); ini_set('display_errors', 0); } ini_set('session.use_trans_sid', 0); ini_set('url_rewriter.tags', 0); } /* session start */ session_start(); /* define general */ define('FILE', get_file()); define('ROOT', get_root()); define('TOKEN', get_token()); /* prefix and salt */ define('PREFIX', Redaxscript\Config::get('prefix')); define('SALT', Redaxscript\Config::get('salt')); /* database connect */ database_connect(Redaxscript\Config::get('host'), Redaxscript\Config::get('name'), Redaxscript\Config::get('user'), Redaxscript\Config::get('password')); /* define session */ define('DB_CONNECTED', $_SESSION[ROOT . '/db_connected']); define('DB_ERROR', $_SESSION[ROOT . '/db_error']); define('LOGGED_IN', $_SESSION[ROOT . '/logged_in']); define('ATTACK_BLOCKED', $_SESSION[ROOT . '/attack_blocked']); /* setup charset */ if (function_exists('ini_set')) { ini_set('default_charset', s('charset')); } /* define parameter */ define('FIRST_PARAMETER', get_parameter('first')); define('FIRST_SUB_PARAMETER', get_parameter('first_sub')); define('SECOND_PARAMETER', get_parameter('second')); define('SECOND_SUB_PARAMETER', get_parameter('second_sub')); define('THIRD_PARAMETER', get_parameter('third')); define('THIRD_SUB_PARAMETER', get_parameter('third_sub')); if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin') { define('ADMIN_PARAMETER', get_parameter('admin')); define('TABLE_PARAMETER', get_parameter('table')); define('ID_PARAMETER', get_parameter('id')); define('ALIAS_PARAMETER', get_parameter('alias')); } else { undefine(array('ADMIN_PARAMETER', 'TABLE_PARAMETER', 'ID_PARAMETER', 'ALIAS_PARAMETER')); } define('LAST_PARAMETER', get_parameter('last')); define('LAST_SUB_PARAMETER', get_parameter('last_sub')); define('TOKEN_PARAMETER', get_parameter('token')); /* define routes */ define('FULL_ROUTE', get_route(0)); define('FULL_TOP_ROUTE', get_route(1)); if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) == '' || file_exists('.htaccess') == '' || FILE == 'install.php') { define('REWRITE_ROUTE', '?p='); define('LANGUAGE_ROUTE', '&l='); define('TEMPLATE_ROUTE', '&t='); } else { define('REWRITE_ROUTE', ''); define('LANGUAGE_ROUTE', '.'); define('TEMPLATE_ROUTE', '.'); } /* redirect to install */ if (DB_CONNECTED == 0 && file_exists('install.php')) { define('REFRESH_ROUTE', ROOT . '/install.php'); } /* define tables */ if (FULL_ROUTE == '' || FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == '') { /* check for homepage */ if (s('homepage') > 0) { $table = 'articles'; $id = s('homepage'); } else { $table = 'categories'; $id = 0; /* check order */ if (s('order') == 'asc') { $function = 'min'; } else { if (s('order') == 'desc') { $function = 'max'; } } $rank = query_plumb('rank', $table, $function); /* if category is published */ if ($rank) { $status = retrieve('status', $table, 'rank', $rank); if ($status == 1) { $id = retrieve('id', $table, 'rank', $rank); } } } define('FIRST_TABLE', $table); define('SECOND_TABLE', ''); define('THIRD_TABLE', ''); define('LAST_TABLE', $table); } else { if (FIRST_PARAMETER) { define('FIRST_TABLE', query_table(FIRST_PARAMETER)); } else { define('FIRST_TABLE', ''); } if (FIRST_TABLE) { define('SECOND_TABLE', query_table(SECOND_PARAMETER)); } else { define('SECOND_TABLE', ''); } if (SECOND_TABLE) { define('THIRD_TABLE', query_table(THIRD_PARAMETER)); } else { define('THIRD_TABLE', ''); } if (LAST_PARAMETER) { define('LAST_TABLE', query_table(LAST_PARAMETER)); } else { define('LAST_TABLE', ''); } if (LAST_TABLE) { $id = retrieve('id', LAST_TABLE, 'alias', LAST_PARAMETER); } } /* define ids */ if (LAST_TABLE == 'categories') { define('CATEGORY', $id); define('ARTICLE', ''); define('LAST_ID', $id); } else { if (LAST_TABLE == 'articles') { define('CATEGORY', ''); define('ARTICLE', $id); define('LAST_ID', $id); } else { undefine(array('CATEGORY', 'ARTICLE', 'LAST_ID')); } } /* define content error */ $aliasValidator = new Redaxscript\Validator\Alias(); if (LAST_ID == '' && $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::FAILED) { define('CONTENT_ERROR', 1); } else { define('CONTENT_ERROR', 0); } /* define user */ define('MY_IP', get_user_ip()); define('MY_BROWSER', get_user_agent(0)); define('MY_BROWSER_VERSION', get_user_agent(1)); define('MY_ENGINE', get_user_agent(2)); define('MY_MOBILE', get_user_agent(4)); define('MY_TABLET', get_user_agent(5)); /* if mobile or tablet */ if (MY_MOBILE || MY_TABLET) { define('MY_DESKTOP', ''); } else { define('MY_DESKTOP', get_user_agent(3)); } /* if logged in */ if (LOGGED_IN == TOKEN) { define('MY_ID', $_SESSION[ROOT . '/my_id']); define('MY_NAME', $_SESSION[ROOT . '/my_name']); define('MY_USER', $_SESSION[ROOT . '/my_user']); define('MY_EMAIL', $_SESSION[ROOT . '/my_email']); define('MY_GROUPS', $_SESSION[ROOT . '/my_groups']); /* define access */ $access_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users'); foreach ($access_array as $value) { define(strtoupper($value) . '_NEW', $_SESSION[ROOT . '/' . $value . '_new']); define(strtoupper($value) . '_EDIT', $_SESSION[ROOT . '/' . $value . '_edit']); define(strtoupper($value) . '_DELETE', $_SESSION[ROOT . '/' . $value . '_delete']); if (TABLE_PARAMETER == 'users' && ID_PARAMETER == MY_ID && $value == 'users') { define('USERS_EXCEPTION', 1); } else { if ($value == 'users') { define('USERS_EXCEPTION', 0); } } } define('MODULES_INSTALL', $_SESSION[ROOT . '/modules_install']); define('MODULES_EDIT', $_SESSION[ROOT . '/modules_edit']); define('MODULES_UNINSTALL', $_SESSION[ROOT . '/modules_uninstall']); define('SETTINGS_EDIT', $_SESSION[ROOT . '/settings_edit']); define('FILTER', $_SESSION[ROOT . '/filter']); } else { define('FILTER', 1); } /* define table access */ define('TABLE_NEW', constant(strtoupper(TABLE_PARAMETER) . '_NEW')); define('TABLE_INSTALL', constant(strtoupper(TABLE_PARAMETER) . '_INSTALL')); define('TABLE_EDIT', constant(strtoupper(TABLE_PARAMETER) . '_EDIT')); define('TABLE_DELETE', constant(strtoupper(TABLE_PARAMETER) . '_DELETE')); define('TABLE_UNINSTALL', constant(strtoupper(TABLE_PARAMETER) . '_UNINSTALL')); /* define time */ define('GMDATE', gmdate('D, d M Y H:i:s') . ' GMT'); define('GMDATE_PLUS_WEEK', gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT'); define('GMDATE_PLUS_YEAR', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT'); define('NOW', date('Y-m-d H:i:s')); define('DELAY', date('Y-m-d H:i:s', strtotime('+1 minute'))); define('TODAY', date('Y-m-d')); /* future update */ define('UPDATE', $_SESSION[ROOT . '/update']); if (UPDATE == '') { future_update('articles'); future_update('extras'); $_SESSION[ROOT . '/update'] = DELAY; } else { if (UPDATE < NOW) { $_SESSION[ROOT . '/update'] = ''; } } }
/** * admin process * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_process() { $aliasValidator = new Redaxscript\Validator\Alias(); $loginValidator = new Redaxscript\Validator\Login(); $specialFilter = new Redaxscript\Filter\Special(); /* clean post */ switch (TABLE_PARAMETER) { /* categories */ case 'categories': $parent = $r['parent'] = clean($_POST['parent'], 0); /* articles */ /* articles */ case 'articles': $r['keywords'] = clean($_POST['keywords'], 5); $r['template'] = clean($_POST['template'], 0); /* extras */ /* extras */ case 'extras': $title = $r['title'] = clean($_POST['title'], 5); if (TABLE_PARAMETER != 'categories') { $r['headline'] = clean($_POST['headline'], 0); } $r['sibling'] = clean($_POST['sibling'], 0); /* comments */ /* comments */ case 'comments': if (TABLE_PARAMETER == 'comments') { $r['url'] = clean($_POST['url'], 4); } $author = $r['author'] = clean($_POST['author'], 0); if (TABLE_PARAMETER != 'categories') { $text = $r['text'] = clean($_POST['text'], 1); $date = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'] . ' ' . $_POST['hour'] . ':' . $_POST['minute'] . ':00'; $date = $r['date'] = clean($date, 5); } $rank = $r['rank'] = clean($_POST['rank'], 0); /* groups */ /* groups */ case 'groups': if (TABLE_PARAMETER != 'comments') { $alias = $r['alias'] = clean($_POST['alias'], 2); } /* users */ /* users */ case 'users': if (TABLE_PARAMETER != 'groups') { $language = $r['language'] = clean($_POST['language'], 0); } /* modules */ /* modules */ case 'modules': $alias = clean($_POST['alias'], 2); $status = $r['status'] = clean($_POST['status'], 0); if (TABLE_PARAMETER != 'groups' && TABLE_PARAMETER != 'users' && GROUPS_EDIT == 1) { $access = array_map(array($specialFilter, 'sanitize'), $_POST['access']); $access = array_map('clean', $access); $access_string = implode(', ', $access); if ($access_string == '') { $access_string = null; } $access = $r['access'] = $access_string; } if (TABLE_PARAMETER != 'extras' && TABLE_PARAMETER != 'comments') { $r['description'] = clean($_POST['description'], 5); } $token = $_POST['token']; break; } /* clean contents post */ if (TABLE_PARAMETER == 'articles') { $r['infoline'] = clean($_POST['infoline'], 0); $comments = $r['comments'] = clean($_POST['comments'], 0); if ($category && ID_PARAMETER == '') { $status = $r['status'] = Redaxscript\Db::forTablePrefix('categories')->where('id', $category)->findOne()->status; } } if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') { $category = $r['category'] = clean($_POST['category'], 0); } if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras' || TABLE_PARAMETER == 'comments') { if ($date > NOW) { $status = $r['status'] = 2; } else { $date = $r['date'] = NOW; } } if (TABLE_PARAMETER == 'extras' || TABLE_PARAMETER == 'comments') { $article = $r['article'] = clean($_POST['article'], 0); } if (TABLE_PARAMETER == 'comments' && ID_PARAMETER == '') { $status = $r['status'] = Redaxscript\Db::forTablePrefix('articles')->where('id', $article)->findOne()->status; } if (TABLE_PARAMETER == 'comments' || TABLE_PARAMETER == 'users') { $email = $r['email'] = clean($_POST['email'], 3); } /* clean groups post */ if (TABLE_PARAMETER == 'groups' && (ID_PARAMETER == '' || ID_PARAMETER > 1)) { $groups_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users', 'modules'); foreach ($groups_array as $value) { ${$value} = array_map(array($specialFilter, 'sanitize'), $_POST[$value]); ${$value} = array_map('clean', ${$value}); $groups_string = implode(', ', ${$value}); if ($groups_string == '') { $groups_string = 0; } $r[$value] = $groups_string; } $r['settings'] = clean($_POST['settings'], 0); $r['filter'] = clean($_POST['filter'], 0); } if ((TABLE_PARAMETER == 'groups' || TABLE_PARAMETER == 'users') && ID_PARAMETER == 1) { $status = $r['status'] = 1; } if (TABLE_PARAMETER == 'groups' || TABLE_PARAMETER == 'users' || TABLE_PARAMETER == 'modules') { $name = $r['name'] = clean($_POST['name'], 0); } /* clean users post */ if (TABLE_PARAMETER == 'users') { if ($_POST['user']) { $user = $r['user'] = clean($_POST['user'], 0); } else { $user = $r['user'] = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('id', ID_PARAMETER)->findOne()->user; } $password_check = $password_confirm = 1; if ($_POST['edit'] && $_POST['password'] == '' && $_POST['password_confirm'] == '' || $_POST['delete']) { $password_check = 0; } if ($_POST['password'] != $_POST['password_confirm']) { $password_confirm = 0; } $password = clean($_POST['password'], 0); if ($password_check == 1 && $password_confirm == 1) { $passwordHash = new Redaxscript\Hash(Redaxscript\Config::getInstance()); $passwordHash->init($password); $r['password'] = $passwordHash->getHash(); } if ($_POST['new']) { $r['first'] = $r['last'] = NOW; } if (ID_PARAMETER == '' || ID_PARAMETER > 1) { $groups = array_map(array($specialFilter, 'sanitize'), $_POST['groups']); $groups = array_map('clean', $groups); $groups_string = implode(', ', $groups); if ($groups_string == '') { $groups_string = 0; } $groups = $r['groups'] = $groups_string; } } $r_keys = array_keys($r); $last = end($r_keys); /* validate post */ switch (TABLE_PARAMETER) { /* contents */ case 'categories': case 'articles': case 'extras': if ($title == '') { $error = l('title_empty'); } else { $title_id = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('id', ID_PARAMETER)->findOne()->title; $id_title = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('title', $title)->findOne()->id; } if ($id_title && strcasecmp($title_id, $title) < 0) { $error = l('title_exists'); } if (TABLE_PARAMETER == 'categories') { $opponent_id = Redaxscript\Db::forTablePrefix('articles')->where('alias', $alias)->findOne()->id; } if (TABLE_PARAMETER == 'articles') { $opponent_id = Redaxscript\Db::forTablePrefix('categories')->where('alias', $alias)->findOne()->id; } if ($opponent_id) { $error = l('alias_exists'); } if (TABLE_PARAMETER != 'groups' && $aliasValidator->validate($alias, Redaxscript\Validator\Alias::MODE_GENERAL) == Redaxscript\Validator\ValidatorInterface::PASSED || $aliasValidator->validate($alias, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::PASSED) { $error = l('alias_incorrect'); } /* groups */ /* groups */ case 'groups': if ($alias == '') { $error = l('alias_empty'); } else { $alias_id = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('id', ID_PARAMETER)->findOne()->alias; $id_alias = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('alias', $alias)->findOne()->id; } if ($id_alias && strcasecmp($alias_id, $alias) < 0) { $error = l('alias_exists'); } } /* validate general post */ switch (TABLE_PARAMETER) { case 'articles': case 'extras': case 'comments': if ($text == '') { $error = l('text_empty'); } break; case 'groups': case 'users': case 'modules': if ($name == '') { $error = l('name_empty'); } break; } /* validate users post */ if (TABLE_PARAMETER == 'users') { if ($user == '') { $error = l('user_incorrect'); } else { $user_id = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('id', ID_PARAMETER)->findOne()->user; $id_user = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('user', $user)->findOne()->id; } if ($id_user && strcasecmp($user_id, $user) < 0) { $error = l('user_exists'); } if ($loginValidator->validate($user) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('user_incorrect'); } if ($password_check == 1) { if ($password == '') { $error = l('password_empty'); } if ($password_confirm == 0 || $loginValidator->validate($password) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('password_incorrect'); } } } /* validate last post */ $emailValidator = new Redaxscript\Validator\Email(); switch (TABLE_PARAMETER) { case 'comments': if ($author == '') { $error = l('author_empty'); } case 'users': if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('email_incorrect'); } } $route = 'admin'; /* handle error */ if ($error) { if (ID_PARAMETER == '') { $route .= '/new/' . TABLE_PARAMETER; } else { $route .= '/edit/' . TABLE_PARAMETER . '/' . ID_PARAMETER; } notification(l('error_occurred'), $error, l('back'), $route); return; } else { if (TABLE_EDIT == 1 || TABLE_DELETE == 1) { $route .= '/view/' . TABLE_PARAMETER; if ($alias) { $route .= '#' . $alias; } else { if ($user) { $route .= '#' . $user; } } } } /* process */ switch (true) { /* query new */ case $_POST['new']: Redaxscript\Db::forTablePrefix(Redaxscript\Registry::get('tableParameter'))->create()->set($r)->save(); notification(l('operation_completed'), '', l('continue'), $route); return; /* query edit */ /* query edit */ case $_POST['edit']: Redaxscript\Db::forTablePrefix(Redaxscript\Registry::get('tableParameter'))->whereIdIs(Redaxscript\Registry::get('idParameter'))->findOne()->set($r)->save(); /* query categories */ if (TABLE_PARAMETER == 'categories') { $categoryChildren = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('parent', ID_PARAMETER); $categoryArray = array_merge($categoryChildren->findArrayFlat(), array(ID_PARAMETER)); $articleChildren = Redaxscript\Db::forTablePrefix('articles')->whereIn('category', $categoryArray); $articleArray = $articleChildren->findArrayFlat(); if (count($articleArray) > 0) { Redaxscript\Db::forTablePrefix('comments')->whereIn('article', $articleArray)->findMany()->set(array('status' => $status, 'access' => $access))->save(); } $categoryChildren->findMany()->set(array('status' => $status, 'access' => $access))->save(); $articleChildren->findMany()->set(array('status' => $status, 'access' => $access))->save(); } /* query articles */ if (TABLE_PARAMETER == 'articles') { if ($comments == 0) { $status = 0; } Redaxscript\Db::forTablePrefix('comments')->where('article', ID_PARAMETER)->findMany()->set(array('status' => $status, 'access' => $access))->save(); } if (USERS_EXCEPTION == 1) { $_SESSION[ROOT . '/my_name'] = $name; $_SESSION[ROOT . '/my_email'] = $email; if (file_exists('languages/' . $language . '.php')) { $_SESSION[ROOT . '/language'] = $language; $_SESSION[ROOT . '/language_selected'] = 1; } } notification(l('operation_completed'), '', l('continue'), $route); return; } }
/** * admin process * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_process() { $aliasValidator = new Redaxscript\Validator\Alias(); $loginValidator = new Redaxscript\Validator\Login(); /* clean post */ switch (TABLE_PARAMETER) { /* categories */ case 'categories': $parent = $r['parent'] = clean($_POST['parent'], 0); /* articles */ /* articles */ case 'articles': $r['keywords'] = clean($_POST['keywords'], 1); $r['template'] = clean($_POST['template'], 0); /* extras */ /* extras */ case 'extras': $title = $r['title'] = clean($_POST['title'], 1); if (TABLE_PARAMETER != 'categories') { $r['headline'] = clean($_POST['headline'], 0); } /* comments */ /* comments */ case 'comments': if (TABLE_PARAMETER == 'comments') { $r['url'] = clean($_POST['url'], 4); } $author = $r['author'] = clean($_POST['author'], 0); if (TABLE_PARAMETER != 'categories') { $text = $r['text'] = clean($_POST['text'], 1); $date = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'] . ' ' . $_POST['hour'] . ':' . $_POST['minute'] . ':00'; $date = $r['date'] = clean($date, 1); } $rank = $r['rank'] = clean($_POST['rank'], 0); /* groups */ /* groups */ case 'groups': if (TABLE_PARAMETER != 'comments') { $alias = $r['alias'] = clean($_POST['alias'], 2); } /* users */ /* users */ case 'users': if (TABLE_PARAMETER != 'groups') { $language = $r['language'] = clean($_POST['language'], 0); } /* modules */ /* modules */ case 'modules': $alias = clean($_POST['alias'], 2); $status = $r['status'] = clean($_POST['status'], 0); if (TABLE_PARAMETER != 'groups' && TABLE_PARAMETER != 'users' && GROUPS_EDIT == 1) { $access = array_map('clean_special', $_POST['access']); $access = array_map('clean_mysql', $access); $access_string = implode(', ', $access); if ($access_string == '') { $access_string = 0; } $access = $r['access'] = $access_string; } if (TABLE_PARAMETER != 'extras' && TABLE_PARAMETER != 'comments') { $r['description'] = clean($_POST['description'], 1); } $token = $_POST['token']; break; } /* clean contents post */ if (TABLE_PARAMETER == 'articles') { $r['infoline'] = clean($_POST['infoline'], 0); $comments = $r['comments'] = clean($_POST['comments'], 0); if ($category && ID_PARAMETER == '') { $status = $r['status'] = retrieve('status', 'categories', 'id', $category); } } if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') { $category = $r['category'] = clean($_POST['category'], 0); } if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras' || TABLE_PARAMETER == 'comments') { if ($date > NOW) { $status = $r['status'] = 2; } else { $date = $r['date'] = NOW; } } if (TABLE_PARAMETER == 'extras' || TABLE_PARAMETER == 'comments') { $article = $r['article'] = clean($_POST['article'], 0); } if (TABLE_PARAMETER == 'comments' && ID_PARAMETER == '') { $status = $r['status'] = retrieve('status', 'articles', 'id', $article); } if (TABLE_PARAMETER == 'comments' || TABLE_PARAMETER == 'users') { $email = $r['email'] = clean($_POST['email'], 3); } /* clean groups post */ if (TABLE_PARAMETER == 'groups' && (ID_PARAMETER == '' || ID_PARAMETER > 1)) { $groups_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users', 'modules'); foreach ($groups_array as $value) { ${$value} = array_map('clean_special', $_POST[$value]); ${$value} = array_map('clean_mysql', ${$value}); $groups_string = implode(', ', ${$value}); if ($groups_string == '') { $groups_string = 0; } $r[$value] = $groups_string; } $r['settings'] = clean($_POST['settings'], 0); $r['filter'] = clean($_POST['filter'], 0); } if ((TABLE_PARAMETER == 'groups' || TABLE_PARAMETER == 'users') && ID_PARAMETER == 1) { $status = $r['status'] = 1; } if (TABLE_PARAMETER == 'groups' || TABLE_PARAMETER == 'users' || TABLE_PARAMETER == 'modules') { $name = $r['name'] = clean($_POST['name'], 0); } /* clean users post */ if (TABLE_PARAMETER == 'users') { $user = $r['user'] = clean($_POST['user'], 0); $password_check = $password_confirm = 1; if ($_POST['edit'] && $_POST['password'] == '' && $_POST['password_confirm'] == '' || $_POST['delete']) { $password_check = 0; } if ($_POST['password'] != $_POST['password_confirm']) { $password_confirm = 0; } $password = clean($_POST['password'], 0); if ($password_check == 1 && $password_confirm == 1) { $r['password'] = sha1($password) . SALT; } if ($_POST['new']) { $r['first'] = $r['last'] = NOW; } if (ID_PARAMETER == '' || ID_PARAMETER > 1) { $groups = array_map('clean_special', $_POST['groups']); $groups = array_map('clean_mysql', $groups); $groups_string = implode(', ', $groups); if ($groups_string == '') { $groups_string = 0; } $groups = $r['groups'] = $groups_string; } } $r_keys = array_keys($r); $last = end($r_keys); /* validate post */ switch (TABLE_PARAMETER) { /* contents */ case 'categories': case 'articles': case 'extras': if ($title == '') { $error = l('title_empty'); } else { $title_id = retrieve('title', TABLE_PARAMETER, 'id', ID_PARAMETER); $id_title = retrieve('id', TABLE_PARAMETER, 'title', $title); } if ($id_title && strcasecmp($title_id, $title) < 0) { $error = l('title_exists'); } if (TABLE_PARAMETER == 'categories') { $opponent_id = retrieve('id', 'articles', 'alias', $alias); } if (TABLE_PARAMETER == 'articles') { $opponent_id = retrieve('id', 'categories', 'alias', $alias); } if ($opponent_id) { $error = l('alias_exists'); } if (TABLE_PARAMETER != 'groups' && $aliasValidator->validate($alias, Redaxscript\Validator\Alias::MODE_GENERAL) == Redaxscript\Validator\Validator::PASSED || $aliasValidator->validate($alias, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::PASSED) { $error = l('alias_incorrect'); } /* groups */ /* groups */ case 'groups': if ($alias == '') { $error = l('alias_empty'); } else { $alias_id = retrieve('alias', TABLE_PARAMETER, 'id', ID_PARAMETER); $id_alias = retrieve('id', TABLE_PARAMETER, 'alias', $alias); } if ($id_alias && strcasecmp($alias_id, $alias) < 0) { $error = l('alias_exists'); } } /* validate general post */ switch (TABLE_PARAMETER) { case 'articles': case 'extras': case 'comments': if ($text == '') { $error = l('text_empty'); } break; case 'groups': case 'users': case 'modules': if ($name == '') { $error = l('name_empty'); } break; } /* validate users post */ if (TABLE_PARAMETER == 'users') { if ($user == '') { $error = l('user_incorrect'); } else { $user_id = retrieve('user', TABLE_PARAMETER, 'id', ID_PARAMETER); $id_user = retrieve('id', TABLE_PARAMETER, 'user', $user); } if ($id_user && strcasecmp($user_id, $user) < 0) { $error = l('user_exists'); } if ($loginValidator->validate($user) == Redaxscript\Validator\Validator::FAILED) { $error = l('user_incorrect'); } if ($password_check == 1) { if ($password == '') { $error = l('password_empty'); } if ($password_confirm == 0 || $loginValidator->validate($password) == Redaxscript\Validator\Validator::FAILED) { $error = l('password_incorrect'); } } } /* validate last post */ $emailValidator = new Redaxscript\Validator\Email(); switch (TABLE_PARAMETER) { case 'comments': if ($author == '') { $error = l('author_empty'); } case 'users': if ($emailValidator->validate($email) == Redaxscript\Validator\Validator::FAILED) { $error = l('email_incorrect'); } } $route = 'admin'; /* handle error */ if ($error) { if (ID_PARAMETER == '') { $route .= '/new/' . TABLE_PARAMETER; } else { $route .= '/edit/' . TABLE_PARAMETER . '/' . ID_PARAMETER; } notification(l('error_occurred'), $error, l('back'), $route); return null; } else { if (TABLE_EDIT == 1 || TABLE_DELETE == 1) { $route .= '/view/' . TABLE_PARAMETER; if ($alias) { $route .= '#' . $alias; } else { if ($user) { $route .= '#' . $user; } } } } /* process */ switch (true) { /* query new */ case $_POST['new']: foreach ($r as $key => $value) { $key_string .= $key; $value_string .= '\'' . $value . '\''; if ($last != $key) { $key_string .= ', '; $value_string .= ', '; } } $general_insert_query = 'INSERT INTO ' . PREFIX . TABLE_PARAMETER . ' (' . $key_string . ') VALUES (' . $value_string . ')'; mysql_query($general_insert_query); notification(l('operation_completed'), '', l('continue'), $route); return null; /* query edit */ /* query edit */ case $_POST['edit']: foreach ($r as $key => $value) { $set_string .= $key . ' = \'' . $value . '\''; if ($last != $key) { $set_string .= ', '; } } $general_update_query = 'UPDATE ' . PREFIX . TABLE_PARAMETER . ' SET ' . $set_string . ' WHERE id = ' . ID_PARAMETER . ' LIMIT 1'; /* categories */ if (TABLE_PARAMETER == 'categories') { $categories_string = admin_children('categories', ID_PARAMETER, 0); $categories_children_string = admin_children('categories', ID_PARAMETER, 2); $categories_update_query = 'UPDATE ' . PREFIX . 'categories SET status = ' . $status . ', access = \'' . $access . '\' WHERE id IN (' . $categories_string . ')'; $articles_update_query = 'UPDATE ' . PREFIX . 'articles SET status = ' . $status . ', access = \'' . $access . '\' WHERE category IN (' . $categories_string . ')'; $comments_update_query = 'UPDATE ' . PREFIX . 'comments SET status = ' . $status . ', access = \'' . $access . '\' WHERE article IN (' . $categories_children_string . ')'; mysql_query($categories_update_query); mysql_query($articles_update_query); } /* articles */ if (TABLE_PARAMETER == 'articles') { if ($comments == 0) { $status = 0; } $comments_update_query = 'UPDATE ' . PREFIX . 'comments SET status = ' . $status . ', access = \'' . $access . '\' WHERE article = ' . ID_PARAMETER; } /* general */ mysql_query($general_update_query); if ($comments_update_query) { mysql_query($comments_update_query); } if (USERS_EXCEPTION == 1) { $_SESSION[ROOT . '/my_name'] = $name; $_SESSION[ROOT . '/my_email'] = $email; if (file_exists('languages/' . $language . '.php')) { $_SESSION[ROOT . '/language'] = $language; $_SESSION[ROOT . '/language_selected'] = 1; } } notification(l('operation_completed'), '', l('continue'), $route); return null; } }
/** * admin process * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_process() { $aliasFilter = new Redaxscript\Filter\Alias(); $emailFilter = new Redaxscript\Filter\Email(); $urlFilter = new Redaxscript\Filter\Url(); $htmlFilter = new Redaxscript\Filter\Html(); $aliasValidator = new Redaxscript\Validator\Alias(); $loginValidator = new Redaxscript\Validator\Login(); $specialFilter = new Redaxscript\Filter\Special(); $messenger = new Redaxscript\Admin\Messenger(Redaxscript\Registry::getInstance()); $filter = Redaxscript\Registry::get('filter'); $tableParameter = Redaxscript\Registry::get('tableParameter'); $idParameter = Redaxscript\Registry::get('idParameter'); /* clean post */ switch ($tableParameter) { /* categories */ case 'categories': $parent = $r['parent'] = $specialFilter->sanitize($_POST['parent']); /* articles */ /* articles */ case 'articles': $r['keywords'] = $_POST['keywords']; $r['robots'] = $specialFilter->sanitize($_POST['robots']); $r['template'] = $specialFilter->sanitize($_POST['template']); /* extras */ /* extras */ case 'extras': $title = $r['title'] = $_POST['title']; if ($tableParameter != 'categories') { $r['headline'] = $specialFilter->sanitize($_POST['headline']); } $r['sibling'] = $specialFilter->sanitize($_POST['sibling']); $author = $r['author'] = Redaxscript\Registry::get('myUser'); /* comments */ /* comments */ case 'comments': if ($tableParameter == 'comments') { $r['url'] = $urlFilter->sanitize($_POST['url']); $author = $r['author'] = $_POST['author']; } if ($tableParameter != 'categories') { $text = $r['text'] = $filter ? $htmlFilter->sanitize($_POST['text']) : $_POST['text']; $date = $r['date'] = $_POST['date']; } $rank = $r['rank'] = $specialFilter->sanitize($_POST['rank']); /* groups */ /* groups */ case 'groups': if ($tableParameter != 'comments') { $alias = $r['alias'] = $aliasFilter->sanitize($_POST['alias']); } /* users */ /* users */ case 'users': if ($tableParameter != 'groups') { $language = $r['language'] = $specialFilter->sanitize($_POST['language']); } /* modules */ /* modules */ case 'modules': $alias = $aliasFilter->sanitize($_POST['alias']); $status = $r['status'] = $specialFilter->sanitize($_POST['status']); if ($tableParameter != 'groups' && $tableParameter != 'users' && Redaxscript\Registry::get('groupsEdit')) { $access = array_map([$specialFilter, 'sanitize'], $_POST['access']); $access_string = implode(', ', $access); if (!$access_string) { $access_string = null; } $access = $r['access'] = $access_string; } if ($tableParameter != 'extras' && $tableParameter != 'comments') { $r['description'] = $_POST['description']; } $token = $_POST['token']; break; } /* clean contents post */ if ($tableParameter == 'articles') { $r['byline'] = $specialFilter->sanitize($_POST['byline']); $comments = $r['comments'] = $specialFilter->sanitize($_POST['comments']); if ($category && !$idParameter) { $status = $r['status'] = Redaxscript\Db::forTablePrefix('categories')->where('id', $category)->findOne()->status; } } if ($tableParameter == 'articles' || $tableParameter == 'extras') { $category = $r['category'] = $specialFilter->sanitize($_POST['category']); } if ($tableParameter == 'articles' || $tableParameter == 'extras' || $tableParameter == 'comments') { if ($date > Redaxscript\Registry::get('now')) { $status = $r['status'] = 2; } if (!$date) { $r['date'] = Redaxscript\Registry::get('now'); } } if ($tableParameter == 'extras' || $tableParameter == 'comments') { $article = $r['article'] = $specialFilter->sanitize($_POST['article']); } if ($tableParameter == 'comments' && !$idParameter) { $status = $r['status'] = Redaxscript\Db::forTablePrefix('articles')->where('id', $article)->findOne()->status; } if ($tableParameter == 'comments' || $tableParameter == 'users') { $email = $r['email'] = $emailFilter->sanitize($_POST['email']); } /* clean groups post */ if ($tableParameter == 'groups' && (!$idParameter || $idParameter > 1)) { $groups_array = ['categories', 'articles', 'extras', 'comments', 'groups', 'users', 'modules']; foreach ($groups_array as $value) { ${$value} = array_map([$specialFilter, 'sanitize'], $_POST[$value]); $groups_string = implode(', ', ${$value}); if (!$groups_string) { $groups_string = 0; } $r[$value] = $groups_string; } $r['settings'] = $specialFilter->sanitize($_POST['settings']); $r['filter'] = $specialFilter->sanitize($_POST['filter']); } if (($tableParameter == 'groups' || $tableParameter == 'users') && $idParameter == 1) { $status = $r['status'] = 1; } if ($tableParameter == 'groups' || $tableParameter == 'users' || $tableParameter == 'modules') { $name = $r['name'] = $specialFilter->sanitize($_POST['name']); } /* clean users post */ if ($tableParameter == 'users') { if ($_POST['user']) { $user = $r['user'] = $specialFilter->sanitize($_POST['user']); } else { $user = $r['user'] = Redaxscript\Db::forTablePrefix($tableParameter)->where('id', $idParameter)->findOne()->user; } $password_check = $password_confirm = 1; if ($_POST['edit'] && !$_POST['password'] && !$_POST['password_confirm'] || $_POST['delete']) { $password_check = 0; } if ($_POST['password'] != $_POST['password_confirm']) { $password_confirm = 0; } $password = $specialFilter->sanitize($_POST['password']); if ($password_check == 1 && $password_confirm == 1) { $passwordHash = new Redaxscript\Hash(Redaxscript\Config::getInstance()); $passwordHash->init($password); $r['password'] = $passwordHash->getHash(); } if ($_POST['new']) { $r['first'] = $r['last'] = Redaxscript\Registry::get('now'); } if (!$idParameter || $idParameter > 1) { $groups = array_map([$specialFilter, 'sanitize'], $_POST['groups']); $groups_string = implode(', ', $groups); if (!$groups_string) { $groups_string = 0; } $groups = $r['groups'] = $groups_string; } } $r_keys = array_keys($r); $last = end($r_keys); /* validate post */ switch ($tableParameter) { /* contents */ case 'categories': case 'articles': case 'extras': if (!$title) { $error = Redaxscript\Language::get('title_empty'); } if ($tableParameter == 'categories') { $opponent_id = Redaxscript\Db::forTablePrefix('articles')->where('alias', $alias)->findOne()->id; } if ($tableParameter == 'articles') { $opponent_id = Redaxscript\Db::forTablePrefix('categories')->where('alias', $alias)->findOne()->id; } if ($opponent_id) { $error = Redaxscript\Language::get('alias_exists'); } if ($tableParameter != 'groups' && $aliasValidator->validate($alias, Redaxscript\Validator\Alias::MODE_GENERAL) == Redaxscript\Validator\ValidatorInterface::PASSED || $aliasValidator->validate($alias, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::PASSED) { $error = Redaxscript\Language::get('alias_incorrect'); } /* groups */ /* groups */ case 'groups': if (!$alias) { $error = Redaxscript\Language::get('alias_empty'); } else { $alias_id = Redaxscript\Db::forTablePrefix($tableParameter)->where('id', $idParameter)->findOne()->alias; $id_alias = Redaxscript\Db::forTablePrefix($tableParameter)->where('alias', $alias)->findOne()->id; } if ($id_alias && strcasecmp($alias_id, $alias) < 0) { $error = Redaxscript\Language::get('alias_exists'); } } /* validate general post */ switch ($tableParameter) { case 'articles': case 'extras': case 'comments': if (!$text) { $error = Redaxscript\Language::get('text_empty'); } break; case 'groups': case 'users': case 'modules': if (!$name) { $error = Redaxscript\Language::get('name_empty'); } break; } /* validate users post */ if ($tableParameter == 'users') { if (!$user) { $error = Redaxscript\Language::get('user_incorrect'); } else { $user_id = Redaxscript\Db::forTablePrefix($tableParameter)->where('id', $idParameter)->findOne()->user; $id_user = Redaxscript\Db::forTablePrefix($tableParameter)->where('user', $user)->findOne()->id; } if ($id_user && strcasecmp($user_id, $user) < 0) { $error = Redaxscript\Language::get('user_exists'); } if ($loginValidator->validate($user) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = Redaxscript\Language::get('user_incorrect'); } if ($password_check == 1) { if (!$password) { $error = Redaxscript\Language::get('password_empty'); } if ($password_confirm == 0 || $loginValidator->validate($password) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = Redaxscript\Language::get('password_incorrect'); } } } /* validate last post */ $emailValidator = new Redaxscript\Validator\Email(); switch ($tableParameter) { case 'comments': if (!$author) { $error = Redaxscript\Language::get('author_empty'); } case 'users': if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = Redaxscript\Language::get('email_incorrect'); } } $route = 'admin'; /* handle error */ if ($error) { if (!$idParameter) { $route .= '/new/' . $tableParameter; } else { $route .= '/edit/' . $tableParameter . '/' . $idParameter; } /* show error */ echo $messenger->setRoute(Redaxscript\Language::get('back'), $route)->error($error, Redaxscript\Language::get('error_occurred')); return; } else { if (Redaxscript\Registry::get('tableEdit') == 1 || Redaxscript\Registry::get('tableEdit') == 1) { $route .= '/view/' . $tableParameter; if ($alias) { $route .= '#' . $alias; } else { if ($user) { $route .= '#' . $user; } } } } /* select to null */ foreach ($r as $key => $value) { if ($value == 'select') { $r[$key] = null; } } /* process */ switch (true) { /* query new */ case $_POST['new']: Redaxscript\Db::forTablePrefix(Redaxscript\Registry::get('tableParameter'))->create()->set($r)->save(); /* show success */ echo $messenger->setRoute(Redaxscript\Language::get('continue'), $route)->doRedirect()->success(Redaxscript\Language::get('operation_completed')); return; /* query edit */ /* query edit */ case $_POST['edit']: Redaxscript\Db::forTablePrefix(Redaxscript\Registry::get('tableParameter'))->whereIdIs(Redaxscript\Registry::get('idParameter'))->findOne()->set($r)->save(); /* query categories */ if ($tableParameter == 'categories') { $categoryChildren = Redaxscript\Db::forTablePrefix($tableParameter)->where('parent', $idParameter); $categoryArray = array_merge($categoryChildren->findFlatArray(), [$idParameter]); $articleChildren = Redaxscript\Db::forTablePrefix('articles')->whereIn('category', $categoryArray); $articleArray = $articleChildren->findFlatArray(); if (count($articleArray) > 0) { Redaxscript\Db::forTablePrefix('comments')->whereIn('article', $articleArray)->findMany()->set(['status' => $status, 'access' => $access])->save(); } $categoryChildren->findMany()->set(['status' => $status, 'access' => $access])->save(); $articleChildren->findMany()->set(['status' => $status, 'access' => $access])->save(); } /* query articles */ if ($tableParameter == 'articles') { if ($comments == 0) { $status = 0; } Redaxscript\Db::forTablePrefix('comments')->where('article', $idParameter)->findMany()->set(['status' => $status, 'access' => $access])->save(); } if ($tableParameter == 'users' && $idParameter == Redaxscript\Registry::get('myId')) { $auth = new Redaxscript\Auth(Redaxscript\Request::getInstance()); $auth->init(); $auth->setUser('name', $name); $auth->setUser('email', $email); $auth->setUser('language', $language); $auth->save(); Redaxscript\Request::setSession('language', $language); } /* show success */ echo $messenger->setRoute(Redaxscript\Language::get('continue'), $route)->doRedirect()->success(Redaxscript\Language::get('operation_completed')); return; } }
/** * contents * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs */ function contents() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); $aliasValidator = new Redaxscript\Validator\Alias(); /* query contents */ $query = 'SELECT id, title, author, text, language, date, headline, infoline, comments, access FROM ' . PREFIX . 'articles WHERE status = 1'; if (ARTICLE) { $query .= ' && id = ' . ARTICLE; } else { if (CATEGORY) { $query .= ' && (language = \'' . LANGUAGE . '\' || language = \'\') && category = ' . CATEGORY . ' 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'); } else { $query .= ' LIMIT 0'; } } $result = mysql_query($query); $num_rows_active = mysql_num_rows($result); /* handle error */ if (DB_CONNECTED == 0) { $error = l('database_failed'); } else { if (CATEGORY && $num_rows == '') { $error = l('article_no'); } else { if ($result == '' || $num_rows_active == '' || CONTENT_ERROR) { $error = l('content_not_found'); } 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); } } if (LAST_TABLE == 'categories' || FULL_ROUTE == '' || $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::PASSED) { $route = build_route('articles', $id); } /* 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('article_start', $id); if ($headline == 1) { $output .= '<h2 class="title_content">'; if (LAST_TABLE == 'categories' || FULL_ROUTE == '' || $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::PASSED) { $output .= anchor_element('internal', '', '', $title, $route); } else { $output .= $title; } $output .= '</h2>'; } /* collect box output */ $output .= '<div class="box_content">' . $parser->getOutput(); $output .= '</div>' . Redaxscript\Hook::trigger('article_end', $id); /* prepend admin dock */ if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') { $output .= admin_dock('articles', $id); } /* infoline */ if ($infoline == 1) { $output .= infoline('articles', $id, $author, $date); } } else { $counter++; } } /* handle access */ if (LAST_TABLE == 'categories') { if ($num_rows_active == $counter) { $error = l('access_no'); } } else { if (LAST_TABLE == 'articles' && $counter == 1) { $error = l('access_no'); } } } } } } /* handle error */ if ($error) { notification(l('something_wrong'), $error); } else { $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; /* call comments as needed */ if (ARTICLE) { /* comments replace */ if ($comments == 1 && COMMENTS_REPLACE == 1) { Redaxscript\Hook::trigger('comments_replace'); } else { if ($comments > 0) { $route = build_route('articles', ARTICLE); comments(ARTICLE, $route); /* comment form */ if ($comments == 1 || COMMENTS_NEW == 1 && $comments == 3) { comment_form(ARTICLE, $language, $access); } } } } } /* call pagination as needed */ if ($sub_maximum > 1 && s('pagination') == 1) { $route = build_route('categories', CATEGORY); pagination($sub_active, $sub_maximum, $route); } }
/** * contents * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs */ function contents() { $output = Redaxscript\Hook::trigger('contentStart'); $aliasValidator = new Redaxscript\Validator\Alias(); $lastId = Redaxscript\Registry::get('lastId'); $lastTable = Redaxscript\Registry::get('lastTable'); $categoryId = Redaxscript\Registry::get('categoryId'); $articleId = Redaxscript\Registry::get('articleId'); $firstParameter = Redaxscript\Registry::get('firstParameter'); /* query articles */ $articles = Redaxscript\Db::forTablePrefix('articles')->where('status', 1); $articles->whereLanguageIs(Redaxscript\Registry::get('language')); /* handle sibling */ if ($lastId) { $sibling = Redaxscript\Db::forTablePrefix($lastTable)->where('id', $lastId)->findOne()->sibling; /* query sibling collection */ $sibling_array = Redaxscript\Db::forTablePrefix($lastTable)->whereIn('sibling', [$lastId, $sibling > 0 ? $sibling : null])->where('language', Redaxscript\Registry::get('language'))->select('id')->findFlatArray(); /* process sibling array */ foreach ($sibling_array as $value) { $id_array[] = $value; } } /* handle article */ if ($articleId) { $id_array[] = $sibling; $id_array[] = $articleId; $articles->whereIn('id', $id_array); } else { if ($categoryId) { if (!$id_array) { if ($sibling > 0) { $id_array[] = $sibling; } else { $id_array[] = $categoryId; } } $articles->whereIn('category', $id_array)->orderGlobal('rank'); /* handle sub parameter */ $result = $articles->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') . ', '; } } $articles->limit($offset_string . Redaxscript\Db::getSetting('limit')); } else { $articles->limit(0); } } /* query result */ $result = $articles->findArray(); $num_rows_active = count($result); /* handle error */ if ($categoryId && !$num_rows) { $error = Redaxscript\Language::get('article_no'); } else { if (!$result || !$num_rows_active || Redaxscript\Registry::get('contentError')) { $error = Redaxscript\Language::get('content_not_found'); } 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} = $value; } } if ($lastTable == 'categories' || !Redaxscript\Registry::get('fullRoute') || $aliasValidator->validate($firstParameter, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::PASSED) { $route = build_route('articles', $id); } /* parser */ $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); $parser->init($text, ['route' => $route]); /* collect headline output */ $output .= Redaxscript\Hook::trigger('contentFragmentStart', $r); if ($headline == 1) { $output .= '<h2 class="rs-title-content" id="article-' . $alias . '">'; if ($lastTable == 'categories' || !Redaxscript\Registry::get('fullRoute') || $aliasValidator->validate($firstParameter, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::PASSED) { $output .= '<a href="' . Redaxscript\Registry::get('parameterRoute') . $route . '">' . $title . '</a>'; } else { $output .= $title; } $output .= '</h2>'; } /* collect box output */ $output .= '<div class="rs-box-content">' . $parser->getOutput() . '</div>'; if ($byline == 1) { $output .= byline('articles', $id, $author, $date); } $output .= Redaxscript\Hook::trigger('contentFragmentEnd', $r); /* admin dock */ if (Redaxscript\Registry::get('loggedIn') == Redaxscript\Registry::get('token') && $firstParameter != 'logout') { $output .= admin_dock('articles', $id); } } else { $counter++; } } /* handle access */ if ($lastTable == 'categories') { if ($num_rows_active == $counter) { $error = Language::get('access_no'); } } else { if ($lastTable == 'articles' && $counter == 1) { $error = Redaxscript\Language::get('access_no'); } } } } } /* handle error */ if ($error) { /* show error */ $messenger = new Redaxscript\Messenger(Redaxscript\Registry::getInstance()); echo $messenger->error($error, Redaxscript\Language::get('something_wrong')); } else { $output .= Redaxscript\Hook::trigger('contentEnd'); echo $output; /* call comments as needed */ if ($articleId) { /* comments replace */ if ($comments == 1 && Redaxscript\Registry::get('commentReplace')) { Redaxscript\Hook::trigger('commentReplace'); } else { if ($comments > 0) { $route = build_route('articles', $articleId); comments($articleId, $route); /* comment form */ if ($comments == 1 || Redaxscript\Registry::get('commentNew') && $comments == 3) { $commentForm = new Redaxscript\View\CommentForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $commentForm->render($articleId); } } } } } /* call pagination as needed */ if ($sub_maximum > 1 && Redaxscript\Db::getSetting('pagination') == 1) { $route = build_route('categories', $categoryId); pagination($sub_active, $sub_maximum, $route); } }
/** * startup * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Startup * @author Henry Ruhs */ function startup() { /* ini set */ if (function_exists('ini_set')) { if (error_reporting() == 0) { ini_set('display_startup_errors', 0); ini_set('display_errors', 0); } ini_set('session.use_trans_sid', 0); ini_set('url_rewriter.tags', 0); ini_set('mbstring.substitute_character', 0); } /* define general */ $request = Redaxscript\Request::getInstance(); $registry = Redaxscript\Registry::getInstance(); $file = new Redaxscript\Server\File($request); $root = new Redaxscript\Server\Root($request); $host = new Redaxscript\Server\Host($request); $registry->set('file', $file->getOutput()); $registry->set('root', $root->getOutput()); $registry->set('host', $host->getOutput()); /* session */ session_start(); /* prevent session hijacking */ $request->refreshSession(); if (!$request->getSession('regenerateId')) { session_regenerate_id(); $request->setSession('regenerateId', true); } /* database status */ $registry->set('dbStatus', Redaxscript\Db::getStatus()); /* define token */ $token = new Redaxscript\Server\Token($request); $auth = new Redaxscript\Auth($request); $registry->set('token', $token->getOutput()); if ($auth->getStatus()) { $registry->set('loggedIn', $token->getOutput()); } /* setup charset */ if (function_exists('ini_set') && $registry->get('dbStatus') === 2) { ini_set('default_charset', Redaxscript\Db::getSetting('charset')); } /* define status */ $pdoDriverArray = PDO::getAvailableDrivers(); $fallbackModuleArray = ['mod_deflate', 'mod_headers', 'mod_rewrite']; $apacheModuleArray = function_exists('apache_get_modules') ? apache_get_modules() : $fallbackModuleArray; $registry->set('phpOs', strtolower(php_uname('s'))); $registry->set('phpVersion', phpversion()); $registry->set('pdoDriverArray', $pdoDriverArray); $registry->set('apacheModuleArray', $apacheModuleArray); $registry->set('sessionStatus', session_status()); /* define parameter */ $parameter = new Redaxscript\Router\Parameter($request); $parameter->init(); $registry->set('firstParameter', $parameter->getFirst()); $registry->set('firstSubParameter', $parameter->getSub()); $registry->set('secondParameter', $parameter->getSecond()); $registry->set('secondSubParameter', $parameter->getSub()); $registry->set('thirdParameter', $parameter->getThird()); $registry->set('thirdSubParameter', $parameter->getSub()); if ($registry->get('loggedIn') == $registry->get('token') && $registry->get('firstParameter') == 'admin') { $registry->set('adminParameter', $parameter->getAdmin()); $registry->set('tableParameter', $parameter->getTable()); $registry->set('idParameter', $parameter->getId()); $registry->set('aliasParameter', $parameter->getAlias()); } $registry->set('lastParameter', $parameter->getLast()); $registry->set('lastSubParameter', $parameter->getSub()); $registry->set('tokenParameter', $parameter->getToken()); /* define routes */ $resolver = new Redaxscript\Router\Resolver($request); $resolver->init(); $registry->set('liteRoute', $resolver->getLite()); $registry->set('fullRoute', $resolver->getFull()); if (!in_array('mod_rewrite', $registry->get('apacheModuleArray')) || !file_exists('.htaccess') || $registry->get('file') == 'install.php') { $registry->set('parameterRoute', '?p='); $registry->set('languageRoute', '&l='); $registry->set('templateRoute', '&t='); } else { $registry->set('parameterRoute', null); $registry->set('languageRoute', '.'); $registry->set('templateRoute', '.'); } /* define tables */ if ($registry->get('dbStatus') === 2) { if (!$registry->get('fullRoute') || $registry->get('firstParameter') == 'admin' && !$registry->get('secondParameter')) { /* check for homepage */ if (Redaxscript\Db::getSetting('homepage') > 0) { $table = 'articles'; $id = Redaxscript\Db::getSetting('homepage'); } else { $table = 'categories'; $id = 0; /* check order */ if (Redaxscript\Db::getSetting('order') == 'asc') { $rank = Redaxscript\Db::forTablePrefix($table)->min('rank'); } else { if (Redaxscript\Db::getSetting('order') == 'desc') { $rank = Redaxscript\Db::forTablePrefix($table)->max('rank'); } } /* category is published */ if ($rank) { $status = Redaxscript\Db::forTablePrefix($table)->where('rank', $rank)->findOne()->status; if ($status == 1) { $id = Redaxscript\Db::forTablePrefix($table)->where('rank', $rank)->findOne()->id; } } } $registry->set('firstTable', $table); $registry->set('lastTable', $table); } else { if ($registry->get('firstParameter')) { $registry->set('firstTable', query_table($registry->get('firstParameter'))); } if ($registry->get('firstTable')) { $registry->set('secondTable', query_table($registry->get('secondParameter'))); } if ($registry->get('secondTable')) { $registry->set('thirdTable', query_table($registry->get('thirdParameter'))); } if ($registry->get('lastParameter')) { $registry->set('lastTable', query_table($registry->get('lastParameter'))); } if ($registry->get('lastTable')) { $id = Redaxscript\Db::forTablePrefix($registry->get('lastTable'))->where('alias', $registry->get('lastParameter'))->findOne()->id; } } } /* define ids */ $aliasValidator = new Redaxscript\Validator\Alias(); if ($registry->get('firstParameter') === 'admin' || $aliasValidator->validate($registry->get('firstParameter'), Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::FAILED) { if ($registry->get('lastTable') == 'categories') { $registry->set('categoryId', $id); $registry->set('lastId', $id); } else { if ($registry->get('lastTable') == 'articles') { $registry->set('articleId', $id); $registry->set('lastId', $id); } } } /* define content error */ if (!$registry->get('lastId') && $aliasValidator->validate($registry->get('firstParameter'), Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\ValidatorInterface::FAILED) { $registry->set('contentError', true); } else { $registry->set('contentError', false); } /* define user */ $browser = new Redaxscript\Client\Browser($request); $version = new Redaxscript\Client\Version($request); $engine = new Redaxscript\Client\Engine($request); $mobile = new Redaxscript\Client\Mobile($request); $tablet = new Redaxscript\Client\Tablet($request); $desktop = new Redaxscript\Client\Desktop($request); $registry->set('myBrowser', $browser->getOutput()); $registry->set('myBrowserVersion', $version->getOutput()); $registry->set('myEngine', $engine->getOutput()); $registry->set('myMobile', $mobile->getOutput()); $registry->set('myTablet', $tablet->getOutput()); if (!$registry->get('myMobile') || !$registry->get('myTablet')) { $registry->set('myDesktop', $desktop->getOutput()); } /* auth */ Redaxscript\Request::refreshSession(); $auth->init(); if ($auth->getStatus()) { $registry->set('myId', $auth->getUser('id')); $registry->set('myName', $auth->getUser('name')); $registry->set('myUser', $auth->getUser('user')); $registry->set('myEmail', $auth->getUser('email')); $registry->set('myLanguage', $auth->getUser('language')); $registry->set('myGroups', $auth->getUser('groups')); $registry->set('categoriesNew', $auth->getPermissionNew('categories')); $registry->set('categoriesEdit', $auth->getPermissionEdit('categories')); $registry->set('categoriesDelete', $auth->getPermissionDelete('categories')); $registry->set('articlesNew', $auth->getPermissionNew('articles')); $registry->set('articlesEdit', $auth->getPermissionEdit('articles')); $registry->set('articlesDelete', $auth->getPermissionDelete('articles')); $registry->set('extrasNew', $auth->getPermissionNew('extras')); $registry->set('extrasEdit', $auth->getPermissionEdit('extras')); $registry->set('extrasDelete', $auth->getPermissionDelete('extras')); $registry->set('commentsNew', $auth->getPermissionNew('comments')); $registry->set('commentsEdit', $auth->getPermissionEdit('comments')); $registry->set('commentsDelete', $auth->getPermissionDelete('comments')); $registry->set('groupsNew', $auth->getPermissionNew('groups')); $registry->set('groupsEdit', $auth->getPermissionEdit('groups')); $registry->set('groupsDelete', $auth->getPermissionDelete('groups')); $registry->set('usersNew', $auth->getPermissionNew('users')); $registry->set('usersEdit', $auth->getPermissionEdit('users')); $registry->set('usersDelete', $auth->getPermissionDelete('users')); $registry->set('modulesInstall', $auth->getPermissionInstall('modules')); $registry->set('modulesEdit', $auth->getPermissionEdit('modules')); $registry->set('modulesUninstall', $auth->getPermissionUninstall('modules')); $registry->set('settingsEdit', $auth->getPermissionEdit('settings')); } $registry->set('filter', $auth->getFilter()); /* define table access */ $tableParameter = $registry->get('tableParameter'); $registry->set('tableNew', $registry->get($tableParameter . 'New')); $registry->set('tableInstall', $registry->get($tableParameter . 'Install')); $registry->set('tableEdit', $registry->get($tableParameter . 'Edit')); $registry->set('tableDelete', $registry->get($tableParameter . 'Delete')); $registry->set('tableUninstall', $registry->get($tableParameter . 'Uninstall')); /* define time */ $registry->set('now', date('Y-m-d H:i:s')); /* cron update */ $registry->set('cronUpdate', false); if (!Redaxscript\Request::getSession('timerUpdate') && $registry->get('dbStatus') === 2 && function_exists('future_update')) { Redaxscript\Request::setSession('timerUpdate', date('Y-m-d H:i:s', strtotime('+1 minute'))); $registry->set('cronUpdate', true); } else { if (Redaxscript\Request::getSession('timerUpdate') < $registry->get('now')) { Redaxscript\Request::setSession('timerUpdate', false); } } /* future update */ if ($registry->get('cronUpdate')) { Redaxscript\Hook::trigger('cronUpdate'); future_update('categories'); future_update('articles'); future_update('comments'); future_update('extras'); } /* cache */ $registry->set('noCache', false); $filterBoolean = new Redaxscript\Filter\Boolean(); $noCache = $filterBoolean->sanitize($request->getQuery('no-cache')); if ($registry->get('loggedIn') == $registry->get('token') || $noCache) { $registry->set('noCache', true); } }