/** * reminder post * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Reminder * @author Henry Ruhs */ function reminder_post() { $emailValidator = new Redaxscript\Validator\Email(); $captchaValidator = new Redaxscript\Validator\Captcha(); /* clean post */ if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/reminder'] == 'visited') { $email = clean($_POST['email'], 3); $task = $_POST['task']; $solution = $_POST['solution']; } /* validate post */ if ($email == '') { $error = l('email_empty'); } else { if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('email_incorrect'); } else { if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('captcha_incorrect'); } else { if (Redaxscript\Db::forTablePrefix('users')->where('email', $email)->findOne()->id == '') { $error = l('email_unknown'); } else { /* query users */ $result = Redaxscript\Db::forTablePrefix('users')->where(array('email' => $email, 'status' => 1))->findArray(); if ($result) { foreach ($result as $r) { if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } /* send reminder information */ $passwordResetRoute = ROOT . '/' . REWRITE_ROUTE . 'password_reset/' . $id . '/' . sha1($password); $passwordResetLink = anchor_element('external', '', '', $passwordResetRoute, $passwordResetRoute); $toArray = array(s('author') => s('email')); $fromArray = array($name => $email); $subject = l('reminder'); $bodyArray = array('<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password_reset') . l('colon') . '</strong> ' . $passwordResetLink); /* mailer object */ $mailer = new Redaxscript\Mailer(); $mailer->init($toArray, $fromArray, $subject, $bodyArray); $mailer->send(); } } } } } } /* handle error */ if ($error) { if (s('blocker') == 1) { $_SESSION[ROOT . '/attack_blocked']++; } notification(l('error_occurred'), $error, l('back'), 'reminder'); } else { notification(l('operation_completed'), l('reminder_sent'), l('login'), 'login'); } $_SESSION[ROOT . '/reminder'] = ''; }
/** * contact uninstall * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Modules * @author edmonsur */ function YahooWeather_uninstall() { Redaxscript\Db::forTablePrefix('modules')->where('alias', 'YahooWeather')->findMany()->delete(); /** Drop yahooweather tabelle */ $query = file_get_contents('modules/YahooWeather/database/mysql/drop/drop_YahooWeather.mysql'); if ($query) { if ($this->_config->get('dbPrefix')) { $query = str_replace($this->_prefixPlaceholder, $this->_config->get('dbPrefix'), $query); } Redaxscript\Db::rawExecute($query); } /** Drop yahooweather tabelle */ }
/** * 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; } }
/** * fb group uninstall * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Modules * @author Henry Ruhs */ function fb_group_uninstall() { Redaxscript\Db::forTablePrefix('modules')->where('alias', 'fb_group')->findMany()->delete(); }
/** * github tracker uninstall * * @since 2.1.0 * @deprecated 2.0.0 * * @package Redaxscript * @category Modules * @author Henry Ruhs */ function github_tracker_uninstall() { Redaxscript\Db::forTablePrefix('modules')->where('alias', 'github_tracker')->findMany()->delete(); }
/** * 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; }
/** * login post * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Login * @author Henry Ruhs */ function login_post() { $passwordValidator = new Redaxscript\Validator\Password(); $loginValidator = new Redaxscript\Validator\Login(); $emailValidator = new Redaxscript\Validator\Email(); $captchaValidator = new Redaxscript\Validator\Captcha(); /* clean post */ if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/login'] == 'visited') { $post_user = $_POST['user']; $post_password = $_POST['password']; $task = $_POST['task']; $solution = $_POST['solution']; $login_by_email = 0; $users = Redaxscript\Db::forTablePrefix('users'); if ($emailValidator->validate($post_user) == Redaxscript\Validator\ValidatorInterface::FAILED) { $post_user = clean($post_user, 0); $users->where('user', $post_user); } else { $post_user = clean($post_user, 3); $login_by_email = 1; $users->where('email', $post_user); } $users_result = $users->findArray(); foreach ($users_result as $r) { foreach ($r as $key => $value) { $key = 'my_' . $key; ${$key} = stripslashes($value); } } } /* validate post */ if ($post_user == '') { $error = l('user_empty'); } else { if ($post_password == '') { $error = l('password_empty'); } else { if ($login_by_email == 0 && $loginValidator->validate($post_user) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('user_incorrect'); } else { if ($login_by_email == 1 && $emailValidator->validate($post_user) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('email_incorrect'); } else { if ($passwordValidator->validate($post_password, $my_password) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('password_incorrect'); } else { if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('captcha_incorrect'); } else { if ($my_id == '') { $error = l('login_incorrect'); } else { if ($my_status == 0) { $error = l('access_no'); } else { /* setup login session */ $_SESSION[ROOT . '/logged_in'] = TOKEN; $_SESSION[ROOT . '/my_id'] = $my_id; $_SESSION[ROOT . '/my_name'] = $my_name; $_SESSION[ROOT . '/my_user'] = $my_user; $_SESSION[ROOT . '/my_email'] = $my_email; if (file_exists('languages/' . $my_language . '.php')) { $_SESSION[ROOT . '/language'] = $my_language; $_SESSION[ROOT . '/language_selected'] = 1; } $_SESSION[ROOT . '/my_groups'] = $my_groups; /* query groups */ $groups_result = Redaxscript\Db::forTablePrefix('groups')->whereIdIn(explode(',', $my_groups))->where('status', 1)->findArray(); if ($groups_result) { $num_rows = count($groups_result); foreach ($groups_result as $r) { if ($r) { foreach ($r as $key => $value) { $key = 'groups_' . $key; ${$key} .= stripslashes($value); if (++$counter < $num_rows) { ${$key} .= ', '; } } } } } /* setup access session */ $access_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users'); foreach ($access_array as $value) { $groups_value = 'groups_' . $value; $position_new = strpos(${$groups_value}, '1'); $position_edit = strpos(${$groups_value}, '2'); $position_delete = strpos(${$groups_value}, '3'); $_SESSION[ROOT . '/' . $value . '_delete'] = $_SESSION[ROOT . '/' . $value . '_edit'] = $_SESSION[ROOT . '/' . $value . '_new'] = 0; if ($position_new > -1) { $_SESSION[ROOT . '/' . $value . '_new'] = 1; } if ($position_edit > -1) { $_SESSION[ROOT . '/' . $value . '_edit'] = 1; } if ($position_delete > -1) { $_SESSION[ROOT . '/' . $value . '_delete'] = 1; } } $position_modules_install = strpos($groups_modules, '1'); $position_modules_edit = strpos($groups_modules, '2'); $position_modules_uninstall = strpos($groups_modules, '3'); $position_settings_edit = strpos($groups_settings, '1'); $position_filter = strpos($groups_filter, '0'); $_SESSION[ROOT . '/filter'] = 1; $_SESSION[ROOT . '/settings_edit'] = $_SESSION[ROOT . '/modules_uninstall'] = $_SESSION[ROOT . '/modules_edit'] = $_SESSION[ROOT . '/modules_install'] = 0; if ($position_modules_install > -1) { $_SESSION[ROOT . '/modules_install'] = 1; } if ($position_modules_edit > -1) { $_SESSION[ROOT . '/modules_edit'] = 1; } if ($position_modules_uninstall > -1) { $_SESSION[ROOT . '/modules_uninstall'] = 1; } if ($position_settings_edit > -1) { $_SESSION[ROOT . '/settings_edit'] = 1; } if ($position_filter > -1) { $_SESSION[ROOT . '/filter'] = 0; } $_SESSION[ROOT . '/update'] = NOW; } } } } } } } } /* handle error */ if ($error) { if (s('blocker') == 1) { $_SESSION[ROOT . '/attack_blocked']++; } notification(l('error_occurred'), $error, l('back'), 'login'); } else { notification(l('welcome'), l('logged_in'), l('continue'), 'admin'); } $_SESSION[ROOT . '/login'] = ''; }
/** * comment post * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Comments * @author Henry Ruhs */ function comment_post() { $emailValidator = new Redaxscript\Validator\Email(); $captchaValidator = new Redaxscript\Validator\Captcha(); $urlValidator = new Redaxscript\Validator\Url(); /* clean post */ if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/comment'] == 'visited') { $author = $r['author'] = clean($_POST['author'], 0); $email = $r['email'] = clean($_POST['email'], 3); $url = $r['url'] = clean($_POST['url'], 4); $text = break_up($_POST['text']); $text = $r['text'] = clean($text, 1); $r['language'] = clean($_POST['language'], 0); $r['date'] = clean($_POST['date'], 5); $article = $r['article'] = clean($_POST['article'], 0); $r['rank'] = Redaxscript\Db::forTablePrefix('comments')->max('rank') + 1; $r['access'] = Redaxscript\Db::forTablePrefix('articles')->whereIdIs($article)->access; if ($r['access'] == '') { $r['access'] = null; } $task = $_POST['task']; $solution = $_POST['solution']; $route = build_route('articles', $article); } /* validate post */ if ($author == '') { $error = l('author_empty'); } else { if ($email == '') { $error = l('email_empty'); } else { if ($text == '') { $error = l('comment_empty'); } else { if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('email_incorrect'); } else { if ($url && $urlValidator->validate($url) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('url_incorrect'); } else { if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('captcha_incorrect'); } else { if (COMMENTS_NEW == 0 && s('moderation') == 1) { $r['status'] = 0; $success = l('comment_moderation'); } else { $r['status'] = 1; $success = l('comment_sent'); } /* send comment notification */ if (s('notification') == 1) { /* prepare body parts */ $emailLink = anchor_element('email', '', '', $email); if ($url) { $urlLink = anchor_element('external', '', '', $url); } $articleRoute = ROOT . '/' . REWRITE_ROUTE . $route; $articleLink = anchor_element('external', '', '', $articleRoute, $articleRoute); /* prepare mail inputs */ $toArray = array(s('author') => s('email')); $fromArray = array($author => $email); $subject = l('comment_new'); $bodyArray = array('<strong>' . l('author') . l('colon') . '</strong> ' . $author, '<br />', '<strong>' . l('email') . l('colon') . '</strong> ' . $emailLink, '<br />', '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink, '<br />', '<strong>' . l('article') . l('colon') . '</strong> ' . $articleLink, '<br />', '<br />', '<strong>' . l('comment') . l('colon') . '</strong> ' . $text); /* mailer object */ $mailer = new Redaxscript\Mailer(); $mailer->init($toArray, $fromArray, $subject, $bodyArray); $mailer->send(); } /* create comment */ Redaxscript\Db::forTablePrefix('comments')->create()->set($r)->save(); } } } } } } /* handle error */ if ($error) { if (s('blocker') == 1) { $_SESSION[ROOT . '/attack_blocked']++; } notification(l('error_occurred'), $error, l('back'), $route); } else { notification(l('operation_completed'), $success, l('continue'), $route); } $_SESSION[ROOT . '/comment'] = ''; }
/** * infoline * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs * * @param string $table * @param integer $id * @param string $author * @param string $date * * @return string */ function infoline($table = '', $id = '', $author = '', $date = '') { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); $time = date(s('time'), strtotime($date)); $date = date(s('date'), strtotime($date)); if ($table == 'articles') { $comments_total = Redaxscript\Db::forTablePrefix('comments')->where('article', $id)->count(); } /* collect output */ $output .= '<div class="box_infoline box_infoline_' . $table . '">'; /* collect author output */ if ($table == 'articles') { $output .= '<span class="infoline_posted_by">' . l('posted_by') . ' ' . $author . '</span>'; $output .= '<span class="infoline_on"> ' . l('on') . ' </span>'; } /* collect date and time output */ $output .= '<span class="infoline_date">' . $date . '</span>'; $output .= '<span class="infoline_at"> ' . l('at') . ' </span>'; $output .= '<span class="infoline_time">' . $time . '</span>'; /* collect comment output */ if ($comments_total) { $output .= '<span class="divider">' . s('divider') . '</span><span class="infoline_total">' . $comments_total . ' '; if ($comments_total == 1) { $output .= l('comment'); } else { $output .= l('comments'); } $output .= '</span>'; } $output .= '</div>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); return $output; }
/** * settings shortcut * * @since 2.2.0 * @deprecated 2.0.0 * * @package Redaxscript * @category Migrate * @author Henry Ruhs * * @param string $key * * @return string */ function s($key = null) { $output = Redaxscript\Db::getSettings($key); return $output; }
/** * admin last update * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_last_update() { if (MY_ID) { Redaxscript\Db::forTablePrefix('users')->where('id', MY_ID)->findOne()->set('last', NOW)->save(); } }
/** * password reset post * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Password * @author Henry Ruhs */ function password_reset_post() { $captchaValidator = new Redaxscript\Validator\Captcha(); /* clean post */ if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/password_reset'] == 'visited') { $post_id = clean($_POST['id'], 0); $post_password = clean($_POST['password'], 0); $password = substr(sha1(uniqid()), 0, 10); $task = $_POST['task']; $solution = $_POST['solution']; } /* query user information */ if ($post_id && $post_password) { $users_result = Redaxscript\Db::forTablePrefix('users')->where(array('id' => $post_id, 'status' => 1))->findArray(); foreach ($users_result as $r) { foreach ($r as $key => $value) { $key = 'my_' . $key; ${$key} = stripslashes($value); } } } /* validate post */ if ($post_id == '' || $post_password == '') { $error = l('input_incorrect'); } else { if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('captcha_incorrect'); } else { if ($my_id == '' || sha1($my_password) != $post_password) { $error = l('access_no'); } else { /* send new password */ $loginRoute = ROOT . '/' . REWRITE_ROUTE . 'login'; $loginLink = anchor_element('external', '', '', $loginRoute, $loginRoute); $toArray = array($my_name => $my_email); $fromArray = array(s('author') => s('email')); $subject = l('password_new'); $bodyArray = array('<strong>' . l('password_new') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('login') . l('colon') . '</strong> ' . $loginLink); /* mailer object */ $mailer = new Redaxscript\Mailer(); $mailer->init($toArray, $fromArray, $subject, $bodyArray); $mailer->send(); /* update password */ $passwordHash = new Redaxscript\Hash(Redaxscript\Config::getInstance()); $passwordHash->init($password); Redaxscript\Db::forTablePrefix('users')->where(array('id' => $post_id, 'status' => 1))->findOne()->set('password', $passwordHash->getHash())->save(); } } } /* handle error */ if ($error) { if (s('blocker') == 1) { $_SESSION[ROOT . '/attack_blocked']++; } if ($post_id && $post_password) { $back_route = 'password_reset/' . $post_id . '/' . $post_password; } else { $back_route = 'reminder'; } notification(l('error_occurred'), $error, l('back'), $back_route); } else { notification(l('operation_completed'), l('password_sent'), l('login'), 'login'); } $_SESSION[ROOT . '/password_reset'] = ''; }
/** * registration post * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Registration * @author Henry Ruhs */ function registration_post() { /* clean post */ if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/registration'] == 'visited') { $name = $r['name'] = clean($_POST['name'], 0); $user = $r['user'] = clean($_POST['user'], 0); $email = $r['email'] = clean($_POST['email'], 3); $password = substr(sha1(uniqid()), 0, 10); $passwordHash = new Redaxscript\Hash(Redaxscript\Config::getInstance()); $passwordHash->init($password); $r['password'] = $passwordHash->getHash(); $r['description'] = ''; $r['language'] = Redaxscript\Registry::get('language'); $r['first'] = $r['last'] = NOW; $r['groups'] = Redaxscript\Db::forTablePrefix('groups')->where('alias', 'members')->findOne()->id; if ($r['groups'] == '') { $r['groups'] = 0; } $task = $_POST['task']; $solution = $_POST['solution']; } /* validate post */ $loginValidator = new Redaxscript\Validator\Login(); $emailValidator = new Redaxscript\Validator\Email(); $captchaValidator = new Redaxscript\Validator\Captcha(); if ($name == '') { $error = l('name_empty'); } else { if ($user == '') { $error = l('user_empty'); } else { if ($email == '') { $error = l('email_empty'); } else { if ($loginValidator->validate($user) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('user_incorrect'); } else { if ($emailValidator->validate($email) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('email_incorrect'); } else { if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\ValidatorInterface::FAILED) { $error = l('captcha_incorrect'); } else { if (Redaxscript\Db::forTablePrefix('users')->where('user', $user)->findOne()->id) { $error = l('user_exists'); } else { if (USERS_NEW == 0 && s('verification') == 1) { $r['status'] = 0; $success = l('registration_verification'); } else { $r['status'] = 1; $success = l('registration_sent'); } /* send login information */ $loginRoute = ROOT . '/' . REWRITE_ROUTE . 'login'; $loginLink = anchor_element('external', '', '', $loginRoute, $loginRoute); $toArray = array($name => $email); if (s('notification') == 1) { $toArray[s('author')] = s('email'); } $fromArray = array($author => $email); $subject = l('registration'); $bodyArray = array('<strong>' . l('name') . l('colon') . '</strong> ' . $name, '<br />', '<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('login') . l('colon') . '<strong> ' . $loginLink); /* mailer object */ $mailer = new Redaxscript\Mailer(); $mailer->init($toArray, $fromArray, $subject, $bodyArray); $mailer->send(); /* create user */ Redaxscript\Db::forTablePrefix('users')->create()->set($r)->save(); } } } } } } } /* handle error */ if ($error) { if (s('blocker') == 1) { $_SESSION[ROOT . '/attack_blocked']++; } notification(l('error_occurred'), $error, l('back'), 'registration'); } else { notification(l('operation_completed'), $success, l('login'), 'login'); } $_SESSION[ROOT . '/registration'] = ''; }
/** * 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); } }
/** * 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; }
/** * future update * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Query * @author Henry Ruhs * * @param string $table */ function future_update($table = '') { Redaxscript\Db::forTablePrefix($table)->where('status', 2)->whereLt('date', Redaxscript\Registry::get('now'))->findMany()->set('status', 1)->save(); }
/** * 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; }
/** * 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'); }
/** * 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; }
/** * contact uninstall * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Modules * @author Henry Ruhs */ function contact_uninstall() { Redaxscript\Db::forTablePrefix('modules')->where('alias', 'contact')->findMany()->delete(); }
/** * admin groups form * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_groups_form() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); /* define fields for existing group */ if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) { /* query user */ $result = Redaxscript\Db::forTablePrefix('groups')->where('id', ID_PARAMETER)->findArray(); $r = $result[0]; if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } $wording_headline = $name; $wording_submit = l('save'); $route = 'admin/process/groups/' . $id; } else { if (ADMIN_PARAMETER == 'new') { $categories = 0; $articles = 0; $extras = 0; $comments = 0; $groups = 0; $users = 0; $modules = 0; $settings = 0; $filter = 1; $status = 1; $wording_headline = l('group_new'); $wording_submit = l('create'); $route = 'admin/process/groups'; } } $access_array = array(l('create') => 1, l('edit') => 2, l('delete') => 3); $modules_access_array = array(l('install') => 1, l('edit') => 2, l('uninstall') => 3); /* collect output */ $output .= '<h2 class="title_content">' . $wording_headline . '</h2>'; $output .= form_element('form', 'form_admin', 'js_validate_form js_tab form_admin hidden_legend', '', '', '', 'action="' . REWRITE_ROUTE . $route . '" method="post"'); /* collect tab list output */ $output .= '<ul class="js_list_tab list_tab list_tab_admin">'; $output .= '<li class="js_item_active item_first item_active">' . anchor_element('internal', '', '', l('group'), FULL_ROUTE . '#tab-1') . '</li>'; if ($id == '' || $id > 1) { $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('access'), FULL_ROUTE . '#tab-2') . '</li>'; $output .= '<li class="item_last">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-3') . '</li>'; } $output .= '</ul>'; /* collect tab box output */ $output .= '<div class="js_box_tab box_tab box_tab_admin">'; /* collect group set */ $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l('group')) . '<ul>'; $output .= '<li>' . form_element('text', 'name', 'js_generate_alias_input field_text_admin field_note', 'name', $name, l('name'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>'; $output .= '<li>' . form_element('text', 'alias', 'js_generate_alias_output field_text_admin field_note', 'alias', $alias, l('alias'), 'maxlength="50" required="required"') . '</li>'; $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small', 'description', $description, l('description'), 'rows="1" cols="15"') . '</li>'; $output .= '</ul></fieldset>'; if ($id == '' || $id > 1) { /* collect access set */ $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('acccess')) . '<ul>'; $output .= '<li>' . select_element('categories', 'field_select_admin', 'categories', $access_array, $categories, l('categories'), 'multiple="multiple"') . '</li>'; $output .= '<li>' . select_element('articles', 'field_select_admin', 'articles', $access_array, $articles, l('articles'), 'multiple="multiple"') . '</li>'; $output .= '<li>' . select_element('extras', 'field_select_admin', 'extras', $access_array, $extras, l('extras'), 'multiple="multiple"') . '</li>'; $output .= '<li>' . select_element('comments', 'field_select_admin', 'comments', $access_array, $comments, l('comments'), 'multiple="multiple"') . '</li>'; $output .= '<li>' . select_element('groups', 'field_select_admin', 'groups', $access_array, $groups, l('groups'), 'multiple="multiple"') . '</li>'; $output .= '<li>' . select_element('users', 'field_select_admin', 'users', $access_array, $users, l('users'), 'multiple="multiple"') . '</li>'; $output .= '<li>' . select_element('modules', 'field_select_admin', 'modules', $modules_access_array, $modules, l('modules'), 'multiple="multiple"') . '</li>'; $output .= '<li>' . select_element('settings', 'field_select_admin', 'settings', array(l('none') => 0, l('edit') => 1), $settings, l('settings')) . '</li>'; $output .= '</ul></fieldset>'; /* collect customize set */ $output .= form_element('fieldset', 'tab-3', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>'; $output .= '<li>' . select_element('filter', 'field_select_admin', 'filter', array(l('enable') => 1, l('disable') => 0), $filter, l('filter')) . '</li>'; $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('enable') => 1, l('disable') => 0), $status, l('status')) . '</li>'; $output .= '</ul></fieldset>'; } $output .= '</div>'; /* collect hidden output */ $output .= form_element('hidden', '', '', 'token', TOKEN); /* cancel button */ if (GROUPS_EDIT == 1 || GROUPS_DELETE == 1) { $cancel_route = 'admin/view/groups'; } else { $cancel_route = 'admin'; } $output .= anchor_element('internal', '', 'js_cancel button_admin button_large button_cancel_admin', l('cancel'), $cancel_route); /* delete button */ if (GROUPS_DELETE == 1 && $id > 1) { $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large button_delete_admin', l('delete'), 'admin/delete/groups/' . $id . '/' . TOKEN); } /* submit button */ if (GROUPS_NEW == 1 || GROUPS_EDIT == 1) { $output .= form_element('button', '', 'js_submit button_admin button_large button_submit_admin', ADMIN_PARAMETER, $wording_submit); } $output .= '</form>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; }
/** * gallery uninstall * * @since 2.0.2 * @deprecated 2.0.0 * * @package Redaxscript * @category Modules * @author Henry Ruhs */ function gallery_uninstall() { Redaxscript\Db::forTablePrefix('modules')->where('alias', 'gallery')->findMany()->delete(); }
/** * admin users form * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_users_form() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); /* define fields for existing user */ if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) { /* query user */ $result = Redaxscript\Db::forTablePrefix('users')->where('id', ID_PARAMETER)->findArray(); $r = $result[0]; if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } $wording_headline = $name; $wording_submit = l('save'); $route = 'admin/process/users/' . $id; } else { if (ADMIN_PARAMETER == 'new') { $status = 1; $groups = 0; $wording_headline = l('user_new'); $wording_submit = l('create'); $route = 'admin/process/users'; $code_required = ' required="required"'; } } /* collect output */ $output .= '<h2 class="title_content">' . $wording_headline . '</h2>'; $output .= form_element('form', 'form_admin', 'js_validate_form js_tab form_admin hidden_legend', '', '', '', 'action="' . REWRITE_ROUTE . $route . '" method="post"'); /* collect tab list output */ $output .= '<ul class="js_list_tab list_tab list_tab_admin">'; $output .= '<li class="js_item_active item_first item_active">' . anchor_element('internal', '', '', l('user'), FULL_ROUTE . '#tab-1') . '</li>'; $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li></ul>'; /* collect tab box output */ $output .= '<div class="js_box_tab box_tab box_tab_admin">'; /* collect user set */ $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l('user')) . '<ul>'; $output .= '<li>' . form_element('text', 'name', 'field_text_admin field_note', 'name', $name, l('name'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>'; if ($id == '') { $output .= '<li>' . form_element('text', 'user', 'field_text_admin field_note', 'user', $user, l('user'), 'maxlength="50" required="required"') . '</li>'; } $output .= '<li>' . form_element('password', 'password', 'js_unmask_password field_text_admin field_note', 'password', '', l('password'), 'maxlength="50" autocomplete="off"' . $code_required) . '</li>'; $output .= '<li>' . form_element('password', 'password_confirm', 'js_unmask_password field_text_admin field_note', 'password_confirm', '', l('password_confirm'), 'maxlength="50" autocomplete="off"' . $code_required) . '</li>'; $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', $email, l('email'), 'maxlength="50" required="required"') . '</li>'; $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small', 'description', $description, l('description'), 'rows="1" cols="15"') . '</li>'; $output .= '</ul></fieldset>'; /* collect customize set */ $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>'; /* languages directory object */ $languages_directory = new Redaxscript\Directory(); $languages_directory->init('languages'); $languages_directory_array = $languages_directory->getArray(); /* build languages select */ $language_array[l('select')] = ''; foreach ($languages_directory_array as $value) { $value = substr($value, 0, 2); $language_array[l($value, '_index')] = $value; } $output .= '<li>' . select_element('language', 'field_select_admin', 'language', $language_array, $language, l('language')) . '</li>'; if ($id == '' || $id > 1) { $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('enable') => 1, l('disable') => 0), $status, l('status')) . '</li>'; /* build groups select */ if (GROUPS_EDIT == 1 && USERS_EDIT == 1) { $groups_result = Redaxscript\Db::forTablePrefix('groups')->orderByAsc('name')->findArray(); if ($groups_result) { foreach ($groups_result as $g) { $groups_array[$g['name']] = $g['id']; } } $output .= '<li>' . select_element('groups', 'field_select_admin', 'groups', $groups_array, $groups, l('groups'), 'multiple="multiple"') . '</li>'; } } $output .= '</ul></fieldset></div>'; /* collect hidden output */ $output .= form_element('hidden', '', '', 'token', TOKEN); /* collect button output */ if (USERS_EDIT == 1 || USERS_DELETE == 1) { $cancel_route = 'admin/view/users'; } else { $cancel_route = 'admin'; } $output .= anchor_element('internal', '', 'js_cancel button_admin button_large button_cancel_admin', l('cancel'), $cancel_route); /* delete button */ if ((USERS_DELETE == 1 || USERS_EXCEPTION == 1) && $id > 1) { $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large button_delete_admin', l('delete'), 'admin/delete/users/' . $id . '/' . TOKEN); } /* submit button */ if (USERS_NEW == 1 || USERS_EDIT == 1 || USERS_EXCEPTION == 1) { $output .= form_element('button', '', 'js_submit button_admin button_large button_submit_admin', ADMIN_PARAMETER, $wording_submit); } $output .= '</form>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; }
/** * file manager uninstall * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Modules * @author Henry Ruhs */ function file_manager_uninstall() { Redaxscript\Db::forTablePrefix('modules')->where('alias', 'file_manager')->findMany()->delete(); }
/** * router * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Center * @author Henry Ruhs */ function router() { $firstParameter = Redaxscript\Registry::get('firstParameter'); $secondParameter = Redaxscript\Registry::get('secondParameter'); $thirdParameter = Redaxscript\Registry::get('thirdParameter'); $thirdSubParameter = Redaxscript\Registry::get('thirdSubParameter'); $config = Redaxscript\Config::getInstance(); Redaxscript\Hook::trigger('routerStart'); if (Redaxscript\Registry::get('routerBreak')) { return; } /* check token */ $messenger = new Redaxscript\Messenger(Redaxscript\Registry::getInstance()); if ($_POST && $_POST['token'] != Redaxscript\Registry::get('token')) { echo $messenger->setRoute(Redaxscript\Language::get('home'), Redaxscript\Registry::get('root'))->error(Redaxscript\Language::get('token_incorrect'), Redaxscript\Language::get('error_occurred')); return; } /* install routing */ if (Redaxscript\Registry::get('file') === 'install.php' && $config->get('env') !== 'production') { if (Redaxscript\Request::getPost('Redaxscript\\View\\InstallForm')) { $installController = new Redaxscript\Controller\Install(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance(), Redaxscript\Config::getInstance()); echo $installController->process(); return; } else { $systemStatus = new Redaxscript\View\SystemStatus(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); $installForm = new Redaxscript\View\InstallForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $systemStatus->render() . $installForm->render(); return; } } /* general routing */ $post_list = ['Redaxscript\\View\\LoginForm' => 'Redaxscript\\Controller\\Login', 'Redaxscript\\View\\RegisterForm' => 'Redaxscript\\Controller\\Register', 'Redaxscript\\View\\ResetForm' => 'Redaxscript\\Controller\\Reset', 'Redaxscript\\View\\RecoverForm' => 'Redaxscript\\Controller\\Recover', 'Redaxscript\\View\\CommentForm' => 'Redaxscript\\Controller\\Comment']; foreach ($post_list as $key => $value) { if (Redaxscript\Request::getPost($key)) { if (class_exists($value)) { $controller = new $value(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance()); echo $controller->process(); } return; } } /* search routing */ if (Redaxscript\Request::getPost('Redaxscript\\View\\SearchForm')) { $messenger = new Redaxscript\Messenger(Redaxscript\Registry::getInstance()); $table = Redaxscript\Request::getPost('table'); if ($table) { $table = '/' . $table; } echo $messenger->setRoute(Redaxscript\Language::get('continue'), 'search' . $table . '/' . Redaxscript\Request::getPost('search'))->doRedirect(0)->success(Redaxscript\Language::get('search')); } /* parameter routing */ switch ($firstParameter) { case 'admin': if (Redaxscript\Registry::get('loggedIn') == Redaxscript\Registry::get('token')) { admin_router(); } else { echo $messenger->setRoute(Language::get('login'), 'login')->error(Language::get('access_no'), Language::get('error_occurred')); } return; case 'login': switch ($secondParameter) { case 'recover': if (Redaxscript\Db::getSetting('recovery') == 1) { $recoverForm = new Redaxscript\View\RecoverForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $recoverForm->render(); return; } case 'reset': if (Redaxscript\Db::getSetting('recovery') == 1 && $thirdParameter && $thirdSubParameter) { $resetForm = new Redaxscript\View\ResetForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $resetForm->render(); return; } /* show error */ echo $messenger->setRoute(Language::get('login'), 'login')->error(Language::get('access_no'), Language::get('error_occurred')); return; default: $loginForm = new Redaxscript\View\LoginForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $loginForm->render(); return; } case 'logout': if (Redaxscript\Registry::get('loggedIn') == Redaxscript\Registry::get('token')) { $logoutController = new Redaxscript\Controller\Logout(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance()); echo $logoutController->process(); return; } /* show error */ echo $messenger->setRoute(Language::get('login'), 'login')->error(Language::get('access_no'), Language::get('error_occurred')); return; case 'register': if (Redaxscript\Db::getSetting('registration')) { $registerForm = new Redaxscript\View\RegisterForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $registerForm->render(); return; } /* show error */ echo $messenger->setRoute(Language::get('home'), Redaxscript\Registry::get('root'))->error(Language::get('access_no'), Language::get('error_occurred')); return; case 'search': $searchController = new Redaxscript\Controller\Search(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), Redaxscript\Request::getInstance()); echo $searchController->process(); return; default: contents(); return; } Redaxscript\Hook::trigger('routerEnd'); }
/** * admin modules form * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_modules_form() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); /* define fields for existing user */ if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) { /* query modules */ $result = Redaxscript\Db::forTablePrefix('modules')->where('id', ID_PARAMETER)->findArray(); $r = $result[0]; if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } $wording_headline = $name; $wording_submit = l('save'); $route = 'admin/process/modules/' . $id; } /* directory object */ $docs_directory = new Redaxscript\Directory(); $docs_directory->init('modules/' . $alias . '/docs'); $docs_directory_array = $docs_directory->getArray(); /* collect output */ $output .= '<h2 class="title_content">' . $wording_headline . '</h2>'; $output .= form_element('form', 'form_admin', 'js_validate_form js_tab form_admin hidden_legend', '', '', '', 'action="' . REWRITE_ROUTE . $route . '" method="post"'); /* collect tab list output */ $output .= '<ul class="js_list_tab list_tab list_tab_admin">'; $output .= '<li class="js_item_active item_first item_active">' . anchor_element('internal', '', '', l('module'), FULL_ROUTE . '#tab-1') . '</li>'; $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li>'; foreach ($docs_directory_array as $key => $value) { $output .= '<li class="item_third">' . anchor_element('internal', '', '', str_replace('.phtml', '', $value), FULL_ROUTE . '#tab-' . ($key + 3)) . '</li>'; } $output .= '</ul>'; /* collect tab box output */ $output .= '<div class="js_box_tab box_tab box_tab_admin">'; /* collect module set */ $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l('user')) . '<ul>'; $output .= '<li>' . form_element('text', 'name', 'field_text_admin field_note', 'name', $name, l('name'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>'; $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small', 'description', $description, l('description'), 'rows="1" cols="15"') . '</li>'; $output .= '</ul></fieldset>'; /* collect customize set */ $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>'; $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('enable') => 1, l('disable') => 0), $status, l('status')) . '</li>'; /* build access select */ if (GROUPS_EDIT == 1) { $access_array[l('all')] = null; $access_result = Redaxscript\Db::forTablePrefix('groups')->orderByAsc('name')->findArray(); if ($access_result) { foreach ($access_result as $g) { $access_array[$g['name']] = $g['id']; } } $output .= '<li>' . select_element('access', 'field_select_admin', 'access', $access_array, $access, l('access'), 'multiple="multiple"') . '</li></ul></fieldset>'; } /* template object */ $template = new Redaxscript\Template(); /* collect docs set */ foreach ($docs_directory_array as $key => $value) { $output .= form_element('fieldset', 'tab-' . ($key + 3), 'js_set_tab set_tab set_tab_admin', '', '', 'docs') . '<ul>'; $output .= '<li>' . $template->partial('modules/' . $alias . '/docs/' . $value) . '</li></ul></fieldset>'; } $output .= '</div>'; /* collect hidden output */ $output .= form_element('hidden', '', '', 'alias', $alias); $output .= form_element('hidden', '', '', 'token', TOKEN); /* cancel button */ if (MODULES_EDIT == 1 || MODULES_UNINSTALL == 1) { $cancel_route = 'admin/view/modules'; } else { $cancel_route = 'admin'; } $output .= anchor_element('internal', '', 'js_cancel button_admin button_large button_cancel_admin', l('cancel'), $cancel_route); /* uninstall button */ if (MODULES_UNINSTALL == 1) { $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large button_uninstall_admin', l('uninstall'), 'admin/uninstall/modules/' . $alias . '/' . TOKEN); } /* submit button */ if (MODULES_EDIT == 1) { $output .= form_element('button', '', 'js_submit button_admin button_large button_submit_admin', ADMIN_PARAMETER, $wording_submit); } $output .= '</form>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; }
/** * 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'] = ''; } } }
/** * admin last update * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_last_update() { if (Redaxscript\Registry::get('myId')) { Redaxscript\Db::forTablePrefix('users')->where('id', Redaxscript\Registry::get('myId'))->findOne()->set('last', Redaxscript\Registry::get('now'))->save(); } }
/** * admin contents form * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_contents_form() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); /* switch table */ switch (TABLE_PARAMETER) { case 'categories': $wording_single = 'category'; $wording_sibling = 'category_sibling'; break; case 'articles': $wording_single = 'article'; $wording_sibling = 'article_sibling'; break; case 'extras': $wording_single = 'extra'; $wording_sibling = 'extra_sibling'; break; case 'comments': $wording_single = 'comment'; break; } /* define fields for existing user */ if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) { /* query content */ $result = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->where('id', ID_PARAMETER)->findArray(); $r = $result[0]; if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } if (TABLE_PARAMETER == 'comments') { $wording_headline = $author; } else { $wording_headline = $title; } if (TABLE_PARAMETER != 'categories') { $text = htmlspecialchars($text); } $wording_submit = l('save'); $route = 'admin/process/' . TABLE_PARAMETER . '/' . $id; } else { if (ADMIN_PARAMETER == 'new') { if (TABLE_PARAMETER == 'comments') { $author = MY_USER; $email = MY_EMAIL; $code_readonly = ' readonly="readonly"'; } if (TABLE_PARAMETER == 'categories') { $sibling = 0; $parent = 0; } if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') { $category = 0; $headline = 1; } if (TABLE_PARAMETER == 'articles') { $sibling = 0; $infoline = 0; $comments = 0; } if (TABLE_PARAMETER == 'extras') { $sibling = 0; } $status = 1; $rank = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->max('rank') + 1; $access = null; $wording_headline = l($wording_single . '_new'); $wording_submit = l('create'); $route = 'admin/process/' . TABLE_PARAMETER; } } /* collect output */ $output .= '<h2 class="title_content">' . $wording_headline . '</h2>'; $output .= form_element('form', 'form_admin', 'js_validate_form js_tab form_admin hidden_legend', '', '', '', 'action="' . REWRITE_ROUTE . $route . '" method="post"'); /* collect tab list output */ $output .= '<ul class="js_list_tab list_tab list_tab_admin">'; $output .= '<li class="js_item_active item_first item_active">' . anchor_element('internal', '', '', l($wording_single), FULL_ROUTE . '#tab-1') . '</li>'; $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li>'; if (TABLE_PARAMETER != 'categories') { $output .= '<li class="item_last">' . anchor_element('internal', '', '', l('date'), FULL_ROUTE . '#tab-3') . '</li>'; } $output .= '</ul>'; /* collect tab box output */ $output .= '<div class="js_box_tab box_tab box_tab_admin">'; /* collect content set */ $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l($wording_single)) . '<ul>'; if (TABLE_PARAMETER == 'comments') { $output .= '<li>' . form_element('text', 'author', 'field_text_admin field_note', 'author', $author, '* ' . l('author'), 'maxlength="50" required="required" autofocus="autofocus"' . $code_readonly) . '</li>'; $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', $email, '* ' . l('email'), 'maxlength="50" required="required"' . $code_readonly) . '</li>'; $output .= '<li>' . form_element('url', 'url', 'field_text_admin', 'url', $url, l('url'), 'maxlength="50"') . '</li>'; } else { $output .= '<li>' . form_element('text', 'title', 'js_generate_alias_input field_text_admin field_note', 'title', $title, l('title'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>'; $output .= '<li>' . form_element('text', 'alias', 'js_generate_alias_output field_text_admin field_note', 'alias', $alias, l('alias'), 'maxlength="50" required="required"') . '</li>'; } if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles') { $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small', 'description', $description, l('description'), 'rows="1" cols="15"') . '</li>'; $output .= '<li>' . form_element('textarea', 'keywords', 'js_auto_resize js_generate_keyword_output field_textarea_admin field_small', 'keywords', $keywords, l('keywords'), 'rows="1" cols="15"') . '</li>'; } if (TABLE_PARAMETER != 'categories') { $output .= '<li>' . form_element('textarea', 'text', 'js_auto_resize js_generate_keyword_input js_editor_textarea field_textarea_admin field_note', 'text', $text, l('text'), 'rows="5" cols="100" required="required"') . '</li>'; } $output .= '</ul></fieldset>'; /* collect customize set */ $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>'; /* languages directory object */ $languages_directory = new Redaxscript\Directory(); $languages_directory->init('languages'); $languages_directory_array = $languages_directory->getArray(); /* build languages select */ $language_array[l('select')] = ''; foreach ($languages_directory_array as $value) { $value = substr($value, 0, 2); $language_array[l($value, '_index')] = $value; } $output .= '<li>' . select_element('language', 'field_select_admin', 'language', $language_array, $language, l('language')) . '</li>'; if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles') { /* templates directory object */ $templates_directory = new Redaxscript\Directory(); $templates_directory->init('templates', array('admin', 'install')); $templates_directory_array = $templates_directory->getArray(); /* build templates select */ $template_array[l('select')] = ''; foreach ($templates_directory_array as $value) { $template_array[$value] = $value; } $output .= '<li>' . select_element('template', 'field_select_admin', 'template', $template_array, $template, l('template')) . '</li>'; } /* build sibling select */ if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') { $sibling_array[l('none')] = 0; $sibling_result = Redaxscript\Db::forTablePrefix(TABLE_PARAMETER)->orderByAsc('rank')->findArray(); if ($sibling_result) { foreach ($sibling_result as $s) { if (ID_PARAMETER != $s['id']) { $sibling_array[$s['title'] . ' (' . $s['id'] . ')'] = $s['id']; } } } $output .= '<li>' . select_element('sibling', 'field_select_admin', 'sibling', $sibling_array, $sibling, l($wording_sibling)) . '</li>'; } /* build category and parent select */ if (TABLE_PARAMETER != 'comments') { if (TABLE_PARAMETER == 'extras') { $category_array[l('all')] = 0; } else { $category_array[l('none')] = 0; } $categories_result = Redaxscript\Db::forTablePrefix('categories')->orderByAsc('rank')->findArray(); if ($categories_result) { foreach ($categories_result as $c) { if (TABLE_PARAMETER != 'categories') { $category_array[$c['title'] . ' (' . $c['id'] . ')'] = $c['id']; } else { if (ID_PARAMETER != $c['id'] && $c['parent'] == 0) { $category_array[$c['title'] . ' (' . $c['id'] . ')'] = $c['id']; } } } } if (TABLE_PARAMETER == 'categories') { $output .= '<li>' . select_element('parent', 'field_select_admin', 'parent', $category_array, $parent, l('category_parent')) . '</li>'; } else { $output .= '<li>' . select_element('category', 'field_select_admin', 'category', $category_array, $category, l('category')) . '</li>'; } } /* build article select */ if (TABLE_PARAMETER == 'extras' || TABLE_PARAMETER == 'comments') { if (TABLE_PARAMETER == 'extras') { $article_array[l('all')] = 0; } $articles = Redaxscript\Db::forTablePrefix('articles'); if (TABLE_PARAMETER == 'comments') { $articles->where('comments', 0); } $articles_result = $articles->orderByAsc('rank')->findArray(); if ($articles_result) { foreach ($articles_result as $a) { $article_array[$a['title'] . ' (' . $a['id'] . ')'] = $a['id']; } } $output .= '<li>' . select_element('article', 'field_select_admin', 'article', $article_array, $article, l('article')) . '</li>'; } if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') { $output .= '<li>' . select_element('headline', 'field_select_admin', 'headline', array(l('enable') => 1, l('disable') => 0), $headline, l('headline')) . '</li>'; } if (TABLE_PARAMETER == 'articles') { $output .= '<li>' . select_element('infoline', 'field_select_admin', 'infoline', array(l('enable') => 1, l('disable') => 0), $infoline, l('infoline')) . '</li>'; $output .= '<li>' . select_element('comments', 'field_select_admin', 'comments', array(l('enable') => 1, l('freeze') => 2, l('restrict') => 3, l('disable') => 0), $comments, l('comments')) . '</li>'; } if ($status != 2) { $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('publish') => 1, l('unpublish') => 0), $status, l('status')) . '</li>'; } /* build access select */ if (GROUPS_EDIT == 1) { $access_array[l('all')] = null; $access_result = Redaxscript\Db::forTablePrefix('groups')->orderByAsc('name')->findArray(); if ($access_result) { foreach ($access_result as $g) { $access_array[$g['name']] = $g['id']; } } $output .= '<li>' . select_element('access', 'field_select_admin', 'access', $access_array, $access, l('access'), 'multiple="multiple"') . '</li>'; } $output .= '</ul></fieldset>'; /* collect date set */ if (TABLE_PARAMETER != 'categories') { $output .= form_element('fieldset', 'tab-3', 'js_set_tab set_tab set_tab_admin', '', '', l('date')) . '<ul>'; $output .= '<li>' . select_date('day', 'field_select_admin', 'day', $date, 'd', 1, 32, l('day')) . '</li>'; $output .= '<li>' . select_date('month', 'field_select_admin', 'month', $date, 'm', 1, 13, l('month')) . '</li>'; $output .= '<li>' . select_date('year', 'field_select_admin', 'year', $date, 'Y', 2000, 2021, l('year')) . '</li>'; $output .= '<li>' . select_date('hour', 'field_select_admin', 'hour', $date, 'H', 0, 24, l('hour')) . '</li>'; $output .= '<li>' . select_date('minute', 'field_select_admin', 'minute', $date, 'i', 0, 60, l('minute')) . '</li>'; $output .= '</ul></fieldset>'; } $output .= '</div>'; /* collect hidden output */ if (TABLE_PARAMETER != 'comments') { $output .= form_element('hidden', '', '', 'author', MY_USER); } if ($status == 2) { $output .= form_element('hidden', '', '', 'publish', 2); } $output .= form_element('hidden', '', '', 'rank', $rank); $output .= form_element('hidden', '', '', 'token', TOKEN); /* cancel button */ if (TABLE_EDIT == 1 || TABLE_DELETE == 1) { $cancel_route = 'admin/view/' . TABLE_PARAMETER; } else { $cancel_route = 'admin'; } $output .= anchor_element('internal', '', 'js_cancel button_admin button_large button_cancel_admin', l('cancel'), $cancel_route); /* delete button */ if (TABLE_DELETE == 1 && $id) { $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large button_delete_admin', l('delete'), 'admin/delete/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN); } /* submit button */ if (TABLE_NEW == 1 || TABLE_EDIT == 1) { $output .= form_element('button', '', 'js_submit button_admin button_large button_submit_admin', ADMIN_PARAMETER, $wording_submit); } $output .= '</form>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; }
/** * admin settings form * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_settings_form() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); $output .= '<h2 class="title_content">' . l('settings') . '</h2>'; $output .= form_element('form', 'form_admin', 'js_validate_form js_accordion form_admin', '', '', '', 'action="' . REWRITE_ROUTE . 'admin/update/settings" method="post"'); /* collect general set */ $output .= '<fieldset class="js_set_accordion js_set_active set_accordion set_accordion_admin set_active">'; $output .= '<legend class="js_title_accordion js_title_active title_accordion title_accordion_admin title_active">' . l('general') . '</legend>'; $output .= '<ul class="js_box_accordion js_box_active box_accordion box_accordion_admin box_active">'; /* languages directory object */ $languages_directory = new Redaxscript\Directory(); $languages_directory->init('languages'); $languages_directory_array = $languages_directory->getArray(); /* build languages select */ if (count($languages_directory_array) > 1) { $language_array[l('detect')] = 'detect'; } foreach ($languages_directory_array as $value) { $value = substr($value, 0, 2); $language_array[l($value, '_index')] = $value; } $output .= '<li>' . select_element('language', 'field_select_admin', 'language', $language_array, s('language'), l('language')) . '</li>'; /* templates directory object */ $templates_directory = new Redaxscript\Directory(); $templates_directory->init('templates', array('admin', 'install')); $templates_directory_array = $templates_directory->getArray(); /* build templates select */ $output .= '<li>' . select_element('template', 'field_select_admin', 'template', $templates_directory_array, s('template'), l('template')) . '</li>'; $output .= '</ul></fieldset>'; /* collect metadata set */ $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">'; $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('metadata') . '</legend>'; $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">'; $output .= '<li>' . form_element('text', 'title', 'field_text_admin', 'title', s('title'), l('title'), 'maxlength="50"') . '</li>'; $output .= '<li>' . form_element('text', 'author', 'field_text_admin', 'author', s('author'), l('author'), 'maxlength="50"') . '</li>'; $output .= '<li>' . form_element('text', 'copyright', 'field_text_admin', 'copyright', s('copyright'), l('copyright'), 'maxlength="50"') . '</li>'; $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small', 'description', s('description'), l('description'), 'rows="1" cols="15"') . '</li>'; $output .= '<li>' . form_element('textarea', 'keywords', 'js_auto_resize field_textarea_admin field_small', 'keywords', s('keywords'), l('keywords'), 'rows="1" cols="15"') . '</li>'; $output .= '<li>' . select_element('robots', 'field_select_admin', 'robots', array(l('index') => 'all', l('index_no') => 'none'), s('robots'), l('robots')) . '</li>'; $output .= '</ul></fieldset>'; /* collect contact set */ $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">'; $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('contact') . '</legend>'; $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">'; $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', s('email'), l('email'), 'maxlength="50" required="required"') . '</li>'; $output .= '<li>' . form_element('text', 'subject', 'field_text_admin', 'subject', s('subject'), l('subject'), 'maxlength="50"') . '</li>'; $output .= '<li>' . select_element('notification', 'field_select_admin', 'notification', array(l('enable') => 1, l('disable') => 0), s('notification'), l('notification')) . '</li>'; $output .= '</ul></fieldset>'; /* collect formatting set */ $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">'; $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('formatting') . '</legend>'; $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">'; $output .= '<li>' . form_element('text', 'charset', 'field_text_admin field_note', 'charset', s('charset'), l('charset'), 'maxlength="10" required="required"') . '</li>'; $output .= '<li>' . form_element('text', 'divider', 'field_text_admin', 'divider', s('divider'), l('divider'), 'maxlength="10"') . '</li>'; $output .= '<li>' . select_element('time', 'field_select_admin', 'time', array('H:i', 'h:i'), s('time'), l('time')) . '</li>'; $output .= '<li>' . select_element('date', 'field_select_admin', 'date', array('d.m.Y', 'm.d.Y', 'Y.m.d'), s('date'), l('date')) . '</li>'; $output .= '</ul></fieldset>'; /* collect contents set */ $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">'; $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('contents') . '</legend>'; $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">'; $homepage_array[l('none')] = 0; $homepage_result = Redaxscript\Db::forTablePrefix('articles')->orderByAsc('title')->findArray(); if ($homepage_result) { foreach ($homepage_result as $r) { $homepage_array[$r['title'] . ' (' . $r['id'] . ')'] = $r['id']; } } $output .= '<li>' . select_element('homepage', 'field_select_admin', 'homepage', $homepage_array, s('homepage'), l('homepage')) . '</li>'; $output .= '<li>' . form_element('text', 'limit', 'field_text_admin field_note', 'limit', s('limit'), l('limit'), 'min="1" max="1000" required="required"') . '</li>'; $output .= '<li>' . select_element('order', 'field_select_admin', 'order', array(l('ascending') => 'asc', l('descending') => 'desc'), s('order'), l('order')) . '</li>'; $output .= '<li>' . select_element('pagination', 'field_select_admin', 'pagination', array(l('enable') => 1, l('disable') => 0), s('pagination'), l('pagination')) . '</li>'; $output .= '</ul></fieldset>'; /* collect comments set */ $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">'; $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('comments') . '</legend>'; $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">'; $output .= '<li>' . select_element('moderation', 'field_select_admin', 'moderation', array(l('enable') => 1, l('disable') => 0), s('moderation'), l('moderation')) . '</li>'; $output .= '</ul></fieldset>'; /* collect users set */ $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">'; $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('users') . '</legend>'; $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">'; $output .= '<li>' . select_element('registration', 'field_select_admin', 'registration', array(l('enable') => 1, l('disable') => 0), s('registration'), l('registration')) . '</li>'; $output .= '<li>' . select_element('verification', 'field_select_admin', 'verification', array(l('enable') => 1, l('disable') => 0), s('verification'), l('verification')) . '</li>'; $output .= '<li>' . select_element('reminder', 'field_select_admin', 'reminder', array(l('enable') => 1, l('disable') => 0), s('reminder'), l('reminder')) . '</li>'; $output .= '</ul></fieldset>'; /* collect security set */ $output .= '<fieldset class="js_set_accordion js_set_accordion_last set_accordion set_accordion_admin set_accordion_last">'; $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('security') . '</legend>'; $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">'; $output .= '<li>' . select_element('captcha', 'field_select_admin', 'captcha', array(l('random') => 1, l('addition') => 2, l('subtraction') => 3, l('disable') => 0), s('captcha'), l('captcha')) . '</li>'; $output .= '<li>' . select_element('blocker', 'field_select_admin', 'blocker', array(l('enable') => 1, l('disable') => 0), s('blocker'), l('blocker')) . '</li>'; $output .= '</ul></fieldset>'; /* collect hidden and button output */ $output .= form_element('hidden', '', '', 'token', TOKEN); $output .= anchor_element('internal', '', 'js_cancel button_admin button_large button_cancel_admin', l('cancel'), 'admin'); $output .= form_element('button', '', 'js_submit button_admin button_large button_submit_admin', 'update', l('save')); $output .= '</form>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); echo $output; }