/** * reminder form * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Reminder * @author Henry Ruhs */ function reminder_form() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); /* disable fields if attack blocked */ if (ATTACK_BLOCKED > 9) { $code_disabled = ' disabled="disabled"'; } /* captcha object */ $captcha = new Redaxscript\Captcha(Redaxscript\Language::getInstance()); $captcha->init(); /* collect output */ $output .= '<h2 class="title_content">' . l('reminder') . '</h2>'; $output .= form_element('form', 'form_reminder', 'js_validate_form form_default form_reminder', '', '', '', 'action="' . REWRITE_ROUTE . 'reminder" method="post"'); $output .= form_element('fieldset', '', 'set_reminder', '', '', l('reminder_request') . l('point')) . '<ul>'; $output .= '<li>' . form_element('email', 'email', 'field_text field_note', 'email', '', l('email'), 'maxlength="50" required="required" autofocus="autofocus"' . $code_disabled) . '</li>'; /* collect captcha task output */ $output .= '<li>' . form_element('number', 'task', 'field_text field_note', 'task', '', $captcha->getTask(), 'min="1" max="20" required="required"' . $code_disabled) . '</li>'; $output .= '</ul></fieldset>'; /* collect captcha solution output */ $captchaHash = new Redaxscript\Hash(Redaxscript\Config::getInstance()); $captchaHash->init($captcha->getSolution()); $output .= form_element('hidden', '', '', 'solution', $captchaHash->getHash()); /* collect hidden and button output */ $output .= form_element('hidden', '', '', 'token', TOKEN); $output .= form_element('button', '', 'js_submit button_default', 'reminder_post', l('submit'), '', $code_disabled); $output .= '</form>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); $_SESSION[ROOT . '/reminder'] = 'visited'; echo $output; }
/** * login form * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Login * @author Henry Ruhs */ function login_form() { $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); /* disable fields if attack blocked */ if (ATTACK_BLOCKED > 9) { $code_disabled = ' disabled="disabled"'; } /* captcha object */ if (s('captcha') > 0) { $captcha = new Redaxscript\Captcha(Redaxscript\Language::getInstance()); $captcha->init(); } /* reminder question */ if (s('reminder') == 1) { $legend = anchor_element('internal', '', 'link_legend', l('reminder_question') . l('question_mark'), 'reminder', '', 'rel="nofollow"'); } else { $legend = l('fields_limited') . l('point'); } /* collect output */ $output .= '<h2 class="title_content">' . l('login') . '</h2>'; $output .= form_element('form', 'form_login', 'js_validate_form form_default form_login', '', '', '', 'action="' . REWRITE_ROUTE . 'login" method="post"'); $output .= form_element('fieldset', '', 'set_login', '', '', $legend) . '<ul>'; $output .= '<li>' . form_element('text', 'user', 'field_text field_note', 'user', '', l('user'), 'maxlength="50" required="required" autofocus="autofocus"' . $code_disabled) . '</li>'; $output .= '<li>' . form_element('password', 'password', 'js_unmask_password field_text field_note', 'password', '', l('password'), 'maxlength="50" required="required" autocomplete="off"' . $code_disabled) . '</li>'; /* collect captcha task output */ if (LOGGED_IN != TOKEN && s('captcha') > 0) { $output .= '<li>' . form_element('number', 'task', 'field_text field_note', 'task', '', $captcha->getTask(), 'min="1" max="20" required="required"' . $code_disabled) . '</li>'; } $output .= '</ul></fieldset>'; /* collect captcha solution output */ if (s('captcha') > 0) { $captchaHash = new Redaxscript\Hash(Redaxscript\Config::getInstance()); $captchaHash->init($captcha->getSolution()); if (LOGGED_IN == TOKEN) { $output .= form_element('hidden', '', '', 'task', $captchaHash->getRaw()); } $output .= form_element('hidden', '', '', 'solution', $captchaHash->getHash()); } /* collect hidden and button output */ $output .= form_element('hidden', '', '', 'token', TOKEN); $output .= form_element('button', '', 'js_submit button_default', 'login_post', l('submit'), '', $code_disabled); $output .= '</form>'; $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); $_SESSION[ROOT . '/login'] = '******'; echo $output; }
/** * contact form * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Modules * @author Henry Ruhs */ function contact_form() { /* disable fields if attack blocked */ if (ATTACK_BLOCKED > 9) { $code_readonly = $code_disabled = ' disabled="disabled"'; } else { if (LOGGED_IN == TOKEN) { $author = MY_USER; $email = MY_EMAIL; $code_readonly = ' readonly="readonly"'; } } /* captcha object */ if (s('captcha') > 0) { $captcha = new Redaxscript\Captcha(Redaxscript\Language::getInstance()); $captcha->init(); } /* collect output */ $output = form_element('form', 'form_contact', 'js_validate_form form_default form_contact', '', '', '', 'method="post"'); $output .= form_element('fieldset', '', 'set_contact', '', '', l('fields_required') . l('point')) . '<ul>'; $output .= '<li>' . form_element('text', 'author', 'field_text field_note', 'author', $author, '* ' . l('author'), 'maxlength="50" required="required"' . $code_readonly) . '</li>'; $output .= '<li>' . form_element('email', 'email', 'field_text field_note', 'email', $email, '* ' . l('email'), 'maxlength="50" required="required"' . $code_readonly) . '</li>'; $output .= '<li>' . form_element('url', 'url', 'field_text', 'url', '', l('url'), 'maxlength="50"' . $code_disabled) . '</li>'; $output .= '<li>' . form_element('textarea', 'text', 'js_auto_resize js_editor_textarea field_textarea field_note', 'text', '', '* ' . l('message'), 'rows="5" cols="100" required="required"' . $code_disabled) . '</li>'; /* collect captcha task output */ if (LOGGED_IN != TOKEN && s('captcha') > 0) { $output .= '<li>' . form_element('number', 'task', 'field_text field_note', 'task', '', $captcha->getTask(), 'min="1" max="20" required="required"' . $code_disabled) . '</li>'; } $output .= '</ul></fieldset>'; /* collect captcha solution output */ if (s('captcha') > 0) { if (LOGGED_IN == TOKEN) { $output .= form_element('hidden', '', '', 'task', $captcha->getSolution('raw')); } $output .= form_element('hidden', '', '', 'solution', $captcha->getSolution()); } /* collect hidden and button output */ $output .= form_element('hidden', '', '', 'token', TOKEN); $output .= form_element('button', '', 'js_submit button_default', 'contact_post', l('submit'), '', $code_disabled); $output .= '</form>'; $_SESSION[ROOT . '/contact'] = 'visited'; echo $output; }
/** * scripts transport * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Loader * @author Henry Ruhs * * @param string|boolean $minify * @return string */ function scripts_transport($minify = '') { /* languages object */ $language = Redaxscript\Language::getInstance(); /* languages transport */ $output = 'var l = ' . json_encode($language->get()) . ';' . PHP_EOL; /* extend redaxscript object */ $public_constants = array('TOKEN', 'LOGGED_IN', 'FIRST_PARAMETER', 'FIRST_SUB_PARAMETER', 'SECOND_PARAMETER', 'SECOND_SUB_PARAMETER', 'THIRD_PARAMETER', 'THIRD_SUB_PARAMETER', 'ADMIN_PARAMETER', 'TABLE_PARAMETER', 'ID_PARAMETER', 'ALIAS_PARAMETER', 'LAST_PARAMETER', 'LAST_SUB_PARAMETER', 'FIRST_TABLE', 'SECOND_TABLE', 'THIRD_TABLE', 'LAST_TABLE', 'FULL_ROUTE', 'FULL_TOP_ROUTE', 'REWRITE_ROUTE', 'LANGUAGE_ROUTE', 'TEMPLATE_ROUTE', 'REFRESH_ROUTE', 'MY_IP', 'MY_BROWSER', 'MY_BROWSER_VERSION', 'MY_ENGINE', 'MY_DESKTOP', 'MY_MOBILE', 'MY_TABLET'); /* collect output */ $output .= 'if (typeof r === \'object\')' . PHP_EOL; $output .= '{' . PHP_EOL; /* add constants */ $output .= 'r.constants = {};'; foreach ($public_constants as $value) { $output .= 'r.constants.' . $value . ' = \'' . constant($value) . '\';' . PHP_EOL; } /* baseURL fallback */ $output .= 'if (r.baseURL === \'\')' . PHP_EOL; $output .= '{' . PHP_EOL; $output .= 'r.baseURL = \'' . ROOT . '\\/\';' . PHP_EOL; $output .= '}' . PHP_EOL; /* generator and version */ $output .= 'r.generator = \'' . l('name', '_package') . ' ' . l('version', '_package') . '\';' . PHP_EOL; $output .= 'r.version = \'' . l('version', '_package') . '\';' . PHP_EOL; $output .= '}' . PHP_EOL; /* minify */ if ($minify) { $output = minify('scripts', $output); } return $output; }
} case USERS_NEW == 1: case USERS_EDIT == 1: case USERS_DELETE == 1: case USERS_EXCEPTION == 1: if (TABLE_PARAMETER == 'users') { include_once 'includes/admin_users.php'; } break; } } /* module files as needed */ $modules_include = Redaxscript\Hook::get(); if ($modules_include) { /* language object */ $language = Redaxscript\Language::getInstance(); /* process modules */ foreach ($modules_include as $value) { /* language */ $language->load(array('modules/' . $value . '/languages/en.json', 'modules/' . $value . '/languages/' . LANGUAGE . '.json')); /* config */ if (file_exists('modules/' . $value . '/config.php')) { include_once 'modules/' . $value . '/config.php'; } /* index */ if (file_exists('modules/' . $value . '/index.php')) { include_once 'modules/' . $value . '/index.php'; } } } /* call loader else render template */
/** * extras * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs * * @param mixed $filter */ function extras($filter = '') { if ($filter == '') { $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); } /* query extras */ $extras = Redaxscript\Db::forTablePrefix('extras')->whereIn('language', array(Redaxscript\Registry::get('language'), '')); /* has filter */ if ($filter) { $id = Redaxscript\Db::forTablePrefix('extras')->where('alias', $filter)->findOne()->id; /* handle sibling */ $sibling = Redaxscript\Db::forTablePrefix('extras')->where('id', $id)->findOne()->sibling; /* query sibling collection */ $sibling_array = Redaxscript\Db::forTablePrefix('extras')->whereIn('sibling', array($id, $sibling > 0 ? $sibling : null))->where('language', Redaxscript\Registry::get('language'))->select('id')->findArrayFlat(); /* process sibling array */ foreach ($sibling_array as $value) { $id_array[] = $value; } $id_array[] = $sibling; $id_array[] = $id; } else { $id_array = $extras->where('status', 1)->orderByAsc('rank')->select('id')->findArrayFlat(); } /* query result */ $result = $extras->whereIn('id', $id_array)->findArray(); /* collect output */ if ($result) { $accessValidator = new Redaxscript\Validator\Access(); foreach ($result as $r) { $access = $r['access']; /* access granted */ if ($accessValidator->validate($access, MY_GROUPS) === Redaxscript\Validator\ValidatorInterface::PASSED) { if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } /* show if cagegory or article matched */ if ($category == CATEGORY || $article == ARTICLE || $category == 0 && $article == 0) { /* parser object */ $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); $parser->init($text, array('className' => array('readmore' => 'link_read_more', 'codequote' => 'js_code_quote box_code'), 'route' => $route)); /* collect headline output */ $output .= Redaxscript\Hook::trigger('extra_start', $r); if ($headline == 1) { $output .= '<h3 class="title_extra" id="extra-' . $alias . '">' . $title . '</h3>'; } /* collect box output */ $output .= '<div class="box_extra">' . $parser->getOutput() . '</div>' . Redaxscript\Hook::trigger('extra_end', $r); /* prepend admin dock */ if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') { $output .= admin_dock('extras', $id); } } } } } if ($filter == '') { $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); } echo $output; }
/** * extras * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs * * @param mixed $filter */ function extras($filter = '') { if ($filter == '') { $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); } /* query extras */ $extras = Redaxscript\Db::forTablePrefix('extras')->whereIn('language', array(Redaxscript\Registry::get('language'), '')); /* setup filter */ if (is_numeric($filter)) { $extras->where('rank', $filter); } else { if ($filter) { $extras->where('alias', $filter); } else { $extras->where('status', 1); } } $extras->orderByAsc('rank'); /* query result */ $result = $extras->findArray(); /* collect output */ if ($result) { $accessValidator = new Redaxscript\Validator\Access(); foreach ($result as $r) { $access = $r['access']; /* if access granted */ if ($accessValidator->validate($access, MY_GROUPS) === Redaxscript\Validator\ValidatorInterface::PASSED) { if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } /* show if cagegory or article matched */ if ($category == CATEGORY || $article == ARTICLE || $category == 0 && $article == 0) { /* parser object */ $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); $parser->init($text, $route, array('className' => array('break' => 'link_read_more', 'code' => 'box_code'))); /* collect headline output */ $output .= Redaxscript\Hook::trigger('extra_start', $r); if ($headline == 1) { $output .= '<h3 class="title_extra">' . $title . '</h3>'; } /* collect box output */ $output .= '<div class="box_extra">' . $parser->getOutput() . '</div>' . Redaxscript\Hook::trigger('extra_end', $r); /* prepend admin dock */ if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') { $output .= admin_dock('extras', $id); } } } } } if ($filter == '') { $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); } echo $output; }
/** * language shortcut * * @since 2.2.0 * @deprecated 2.0.0 * * @package Redaxscript * @category Migrate * @author Henry Ruhs * * @param string $key * @param string $index * * @return string */ function l($key = null, $index = null) { $language = Redaxscript\Language::getInstance(); $output = $language->get($key, $index); return $output; }
/** * scripts transport * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Loader * @author Henry Ruhs * * @param string|boolean $minify * @return string */ function scripts_transport($minify = '') { /* extend redaxscript object */ $public_registry = array('token', 'loggedIn', 'firstParameter', 'secondParameter', 'thirdParameter', 'adminParameter', 'tableParameter', 'idParameter', 'aliasParameter', 'lastParameter', 'firstTable', 'secondTable', 'thirdTable', 'lastTable', 'fullRoute', 'fullTopRoute', 'rewriteRoute', 'languageRoute', 'templateRoute', 'refreshRoute', 'myBrowser', 'myBrowserVersion', 'myEngine', 'myDesktop', 'myMobile', 'myTablet'); /* collect output */ $output = 'if (typeof rs === \'object\')' . PHP_EOL; $output .= '{' . PHP_EOL; /* languages object */ $language = Redaxscript\Language::getInstance(); /* add language */ $output .= 'rs.language = ' . json_encode($language->get()) . ';' . PHP_EOL; /* add registry */ $output .= 'rs.registry = {};'; foreach ($public_registry as $value) { $output .= 'rs.registry.' . $value . ' = \'' . Redaxscript\Registry::get($value) . '\';' . PHP_EOL; } /* baseURL fallback */ $output .= 'if (rs.baseURL === \'\')' . PHP_EOL; $output .= '{' . PHP_EOL; $output .= 'rs.baseURL = \'' . ROOT . '\\/\';' . PHP_EOL; $output .= '}' . PHP_EOL; /* generator and version */ $output .= 'rs.generator = \'' . l('name', '_package') . ' ' . l('version', '_package') . '\';' . PHP_EOL; $output .= 'rs.version = \'' . l('version', '_package') . '\';' . PHP_EOL; $output .= '}' . PHP_EOL; /* minify */ if ($minify) { $minifier = new Redaxscript\Minifier(); $output = $minifier->scripts($output); } return $output; }
/** * admin update * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_update() { $tableParameter = Redaxscript\Registry::get('tableParameter'); if ($tableParameter == 'settings') { $specialFilter = new Redaxscript\Filter\Special(); $emailFilter = new Redaxscript\Filter\Email(); /* clean post */ $r['language'] = $specialFilter->sanitize($_POST['language']); $r['template'] = $specialFilter->sanitize($_POST['template']); $r['title'] = $_POST['title']; $r['author'] = $_POST['author']; $r['copyright'] = $_POST['copyright']; $r['description'] = $_POST['description']; $r['keywords'] = $_POST['keywords']; $r['robots'] = $specialFilter->sanitize($_POST['robots']); $r['email'] = $emailFilter->sanitize($_POST['email']); $r['subject'] = $_POST['subject']; $r['notification'] = $specialFilter->sanitize($_POST['notification']); $r['charset'] = !$r['charset'] ? 'utf-8' : $r['charset']; $r['divider'] = $_POST['divider']; $r['time'] = $_POST['time']; $r['date'] = $_POST['date']; $r['homepage'] = $specialFilter->sanitize($_POST['homepage']); $r['limit'] = !$specialFilter->sanitize($_POST['limit']) ? 10 : $specialFilter->sanitize($_POST['limit']); $r['order'] = $specialFilter->sanitize($_POST['order']); $r['pagination'] = $specialFilter->sanitize($_POST['pagination']); $r['moderation'] = $specialFilter->sanitize($_POST['moderation']); $r['registration'] = $specialFilter->sanitize($_POST['registration']); $r['verification'] = $specialFilter->sanitize($_POST['verification']); $r['recovery'] = $specialFilter->sanitize($_POST['recovery']); $r['captcha'] = $specialFilter->sanitize($_POST['captcha']); /* update settings */ foreach ($r as $key => $value) { if ($value == 'select') { $value = null; } Redaxscript\Db::forTablePrefix($tableParameter)->where('name', $key)->findOne()->set('value', $value)->save(); } /* show success */ $messenger = new Redaxscript\Admin\Messenger(Redaxscript\Registry::getInstance()); echo $messenger->setRoute(Redaxscript\Language::get('continue'), 'admin/edit/settings')->doRedirect()->success(Redaxscript\Language::get('operation_completed')); } }
/** * pagination * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs * * @param integer $sub_active * @param integer $sub_maximum * @param string $route */ function pagination($sub_active, $sub_maximum, $route) { $output = Redaxscript\Hook::trigger('paginationStart'); $output .= '<ul class="rs-list-pagination">'; /* collect first and previous output */ if ($sub_active > 1) { $first_route = $route; $previous_route = $route . '/' . ($sub_active - 1); $output .= '<li class="rs-item-first"><a href="' . Redaxscript\Registry::get('parameterRoute') . $first_route . '">' . Redaxscript\Language::get('first') . '</a></li>'; $output .= '<li class="rs-item-previous"><a href="' . Redaxscript\Registry::get('parameterRoute') . $previous_route . '" rel="previous">' . Redaxscript\Language::get('previous') . '</a></li>'; } /* collect center output */ $j = 2; if ($sub_active == 2 || $sub_active == $sub_maximum - 1) { $j++; } if ($sub_active == 1 || $sub_active == $sub_maximum) { $j = $j + 2; } for ($i = $sub_active - $j; $i < $sub_active + $j; $i++) { if ($i == $sub_active) { $j++; $output .= '<li class="rs-item-number rs-item-active"><span>' . $i . '</span></li>'; } else { if ($i > 0 && $i < $sub_maximum + 1) { $output .= '<li class="rs-item-number"><a href="' . Redaxscript\Registry::get('parameterRoute') . $route . '/' . $i . '">' . $i . '</a></li>'; } } } /* collect next and last output */ if ($sub_active < $sub_maximum) { $next_route = $route . '/' . ($sub_active + 1); $last_route = $route . '/' . $sub_maximum; $output .= '<li class="rs-item-next"><a href="' . Redaxscript\Registry::get('parameterRoute') . $next_route . '" rel="next">' . Redaxscript\Language::get('next') . '</a></li>'; $output .= '<li class="rs-item-last"><a href="' . Redaxscript\Registry::get('parameterRoute') . $last_route . '">' . Redaxscript\Language::get('last') . '</a></li>'; } $output .= '</ul>'; $output .= Redaxscript\Hook::trigger('paginationEnd'); echo $output; }
/** * comments * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Comments * @author Henry Ruhs * * @param integer $article * @param string $route */ function comments($article, $route) { $output = Redaxscript\Hook::trigger('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); } }
/** * languages list * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Navigation * @author Henry Ruhs * * @param array $options */ function languages_list($options) { /* define option variables */ if (is_array($options)) { foreach ($options as $key => $value) { $key = 'option_' . $key; ${$key} = $value; } } /* languages directory */ $languages_directory = new Redaxscript\Directory(); $languages_directory->init('languages'); $languages_directory_array = $languages_directory->getArray(); /* collect languages output */ foreach ($languages_directory_array as $value) { $value = substr($value, 0, 2); $class_string = null; if ($value == Redaxscript\Registry::get('language')) { $class_string = ' class="rs-item-active"'; } $output .= '<li' . $class_string . '><a href="' . Redaxscript\Registry::get('parameterRoute') . Redaxscript\Registry::get('fullRoute') . Redaxscript\Registry::get('languageRoute') . $value . '" rel="nofollow">' . Redaxscript\Language::get($value, '_index') . '</a>'; } /* 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-languages"'; } /* collect list output */ if ($output) { $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>'; } echo $output; }
/** * admin control * * @since 2.0.0 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs * * @param string $type * @param string $table * @param integer $id * @param string $alias * @param integer $status * @param string $new * @param string $edit * @param string $delete * @return string */ function admin_control($type, $table, $id, $alias, $status, $new, $edit, $delete) { $output = Redaxscript\Hook::trigger('adminControlStart'); /* define access variables */ if ($type == 'access' && $id == 1) { $delete = 0; } if ($type == 'modules_not_installed') { $edit = $delete = 0; } /* collect modules output */ if ($new == 1 && $type == 'modules_not_installed') { $output .= '<li class="rs-admin-item-control rs-admin-item-install"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/install/' . $table . '/' . $alias . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('install') . '</a></li>'; } /* collect contents output */ if ($type == 'contents') { if ($status == 2) { $output .= '<li class="rs-admin-item-control rs-admin-item-future-posting"><span>' . Redaxscript\Language::get('future_posting') . '</span></li>'; } if ($edit == 1) { if ($status == 1) { $output .= '<li class="rs-admin-item-control rs-admin-item-unpublish"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/unpublish/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('unpublish') . '</a></li>'; } else { if ($status == 0) { $output .= '<li class="rs-admin-item-control rs-admin-item-publish"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/publish/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('publish') . '</a></li>'; } } } } /* collect access and system output */ if ($edit == 1 && ($type == 'access' && $id > 1 || $type == 'modules_installed')) { if ($status == 1) { $output .= '<li class="rs-admin-item-control rs-admin-item-disable"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/disable/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('disable') . '</a></li>'; } else { if ($status == 0) { $output .= '<li class="rs-admin-item-control rs-admin-item-enable"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/enable/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '">' . Redaxscript\Language::get('enable') . '</a></li>'; } } } /* collect general edit and delete output */ if ($edit == 1) { $output .= '<li class="rs-admin-item-control rs-admin-item-edit"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/edit/' . $table . '/' . $id . '">' . Redaxscript\Language::get('edit') . '</a></li>'; } if ($delete == 1) { if ($type == 'modules_installed') { $output .= '<li class="rs-admin-item-control rs-admin-item-uninstall"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/uninstall/' . $table . '/' . $alias . '/' . Redaxscript\Registry::get('token') . '" class="rs-admin-js-confirm">' . Redaxscript\Language::get('uninstall') . '</a></li>'; } else { $output .= '<li class="rs-admin-item-control rs-admin-item-delete"><a href="' . Redaxscript\Registry::get('parameterRoute') . 'admin/delete/' . $table . '/' . $id . '/' . Redaxscript\Registry::get('token') . '" class="rs-admin-js-confirm">' . Redaxscript\Language::get('delete') . '</a></li>'; } } /* collect list output */ if ($output) { $output = '<ul class="rs-admin-list-control">' . $output . '</ul>'; } $output .= Redaxscript\Hook::trigger('adminControlEnd'); return $output; }
/** * admin modules list * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_modules_list() { $output = Redaxscript\Hook::trigger('adminModuleListStart'); /* query modules */ $result = Redaxscript\Db::forTablePrefix('modules')->orderByAsc('name')->findArray(); $num_rows = count($result); /* collect listing output */ $output .= '<h2 class="rs-admin-title-content">' . Redaxscript\Language::get('modules') . '</h2>'; $output .= '<div class="rs-admin-wrapper-table"><table class="rs-admin-table-default rs-admin-table-module">'; /* collect thead and tfoot */ $output .= '<thead><tr><th class="rs-admin-col-name">' . Redaxscript\Language::get('name') . '</th><th class="rs-admin-col-alias">' . Redaxscript\Language::get('alias') . '</th><th class="rs-admin-col-version">' . Redaxscript\Language::get('version') . '</th></tr></thead>'; $output .= '<tfoot><tr><td>' . Redaxscript\Language::get('name') . '</td><td>' . Redaxscript\Language::get('alias') . '</td><td>' . Redaxscript\Language::get('version') . '</td></tr></tfoot>'; if (!$result || !$num_rows) { $error = Redaxscript\Language::get('module_no') . Redaxscript\Language::get('point'); } else { if ($result) { $accessValidator = new Redaxscript\Validator\Access(); $output .= '<tbody>'; foreach ($result as $r) { $access = $r['access']; /* access granted */ if ($accessValidator->validate($access, Redaxscript\Registry::get('myGroups')) === Redaxscript\Validator\ValidatorInterface::PASSED) { if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } $modules_installed_array[] = $alias; /* build class string */ if ($status == 1) { $class_status = null; } else { $class_status = 'rs-admin-is-disabled'; } /* collect table row */ $output .= '<tr'; if ($alias) { $output .= ' id="' . $alias . '"'; } if ($class_status) { $output .= ' class="' . $class_status . '"'; } $output .= '><td>' . $name; /* collect control output */ $output .= admin_control('modules_installed', 'modules', $id, $alias, $status, Redaxscript\Registry::get('tableInstall'), Redaxscript\Registry::get('tableEdit'), Redaxscript\Registry::get('tableUninstall')); /* collect alias and version output */ $output .= '</td><td>' . $alias . '</td><td>' . $version . '</td></tr>'; } else { $counter++; } } $output .= '</tbody>'; /* handle access */ if ($num_rows == $counter) { $error = Redaxscript\Language::get('access_no') . Redaxscript\Language::get('point'); } } } /* handle error */ if ($error) { $output .= '<tbody><tr><td colspan="3">' . $error . '</td></tr></tbody>'; } /* modules not installed */ if (Redaxscript\Registry::get('modulesInstall') == 1) { /* modules directory */ $modules_directory = new Redaxscript\Directory(); $modules_directory->init('modules'); $modules_directory_array = $modules_directory->getArray(); if ($modules_directory_array && $modules_installed_array) { $modules_not_installed_array = array_diff($modules_directory_array, $modules_installed_array); } else { if ($modules_directory_array) { $modules_not_installed_array = $modules_directory_array; } } if ($modules_not_installed_array) { $output .= '<tbody><tr class="rs-admin-row-group"><td colspan="3">' . Redaxscript\Language::get('install') . '</td></tr>'; foreach ($modules_not_installed_array as $alias) { /* collect table row */ $output .= '<tr'; if ($alias) { $output .= ' id="' . $alias . '"'; } $output .= '><td colspan="3">' . $alias; /* collect control output */ $output .= admin_control('modules_not_installed', 'modules', $id, $alias, $status, Redaxscript\Registry::get('tableInstall'), Redaxscript\Registry::get('tableEdit'), Redaxscript\Registry::get('tableUninstall')); $output .= '</td></tr>'; } $output .= '</tbody>'; } } $output .= '</table></div>'; $output .= Redaxscript\Hook::trigger('adminModuleListEnd'); echo $output; }
/** * extras * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Contents * @author Henry Ruhs * * @param mixed $filter */ function extras($filter = '') { if ($filter == '') { $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_start'); } /* query extras */ $query = 'SELECT id, title, text, category, article, headline, access FROM ' . PREFIX . 'extras WHERE (language = \'' . LANGUAGE . '\' || language = \'\')'; if (is_numeric($filter)) { $query .= ' && rank = ' . $filter; } else { if ($filter) { $query .= ' && alias = \'' . $filter . '\''; } else { $query .= ' && status = 1'; } } $query .= ' ORDER BY rank'; $result = mysql_query($query); /* collect output */ if ($result) { $accessValidator = new Redaxscript\Validator\Access(); while ($r = mysql_fetch_assoc($result)) { $access = $r['access']; $check_access = $accessValidator->validate($access, MY_GROUPS); /* if access granted */ if ($check_access == 1) { if ($r) { foreach ($r as $key => $value) { ${$key} = stripslashes($value); } } /* show if cagegory or article matched */ if ($category == CATEGORY || $article == ARTICLE || $category == 0 && $article == 0) { /* parser object */ $parser = new Redaxscript\Parser(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance(), $text, $route, array('className' => array('break' => 'link_read_more', 'code' => 'box_code'))); /* collect headline output */ $output .= Redaxscript\Hook::trigger('extra_start', $id); if ($headline == 1) { $output .= '<h3 class="title_extra">' . $title . '</h3>'; } /* collect box output */ $output .= '<div class="box_extra">' . $parser->getOutput() . '</div>' . Redaxscript\Hook::trigger('extra_end', $id); /* prepend admin dock */ if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') { $output .= admin_dock('extras', $id); } } } } } if ($filter == '') { $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end'); } echo $output; }
/** * admin router * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Admin * @author Henry Ruhs */ function admin_router() { $firstParameter = Redaxscript\Registry::get('firstParameter'); $adminParameter = Redaxscript\Registry::get('adminParameter'); $tableParameter = Redaxscript\Registry::get('tableParameter'); $idParameter = Redaxscript\Registry::get('idParameter'); $aliasParameter = Redaxscript\Registry::get('aliasParameter'); $tokenParameter = Redaxscript\Registry::get('tokenParameter'); $usersException = $tableParameter == 'users' && $idParameter == Redaxscript\Registry::get('myId'); $messenger = new Redaxscript\Admin\Messenger(Redaxscript\Registry::getInstance()); Redaxscript\Hook::trigger('adminRouterStart'); if (Redaxscript\Registry::get('adminRouterBreak') == 1) { return; } /* last seen update */ if ($firstParameter == 'admin' && !$adminParameter || $adminParameter == 'view' && $tableParameter == 'users' || Redaxscript\Registry::get('cronUpdate')) { admin_last_update(); } /* validate routing */ switch (true) { case $adminParameter && !in_array($adminParameter, ['new', 'view', 'edit', 'up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable', 'install', 'uninstall', 'delete', 'process', 'update']): case $adminParameter == 'process' && !$_POST['new'] && !$_POST['edit']: case $adminParameter == 'update' && !$_POST['update']: case $adminParameter && !in_array($tableParameter, ['categories', 'articles', 'extras', 'comments', 'groups', 'users', 'modules', 'settings']): case !$aliasParameter && ($adminParameter == 'install' || $adminParameter == 'uninstall'): case !$idParameter && in_array($adminParameter, ['edit', 'up', 'down', 'publish', 'unpublish', 'enable', 'disable']) && $tableParameter != 'settings': case is_numeric($idParameter) && !Redaxscript\Db::forTablePrefix($tableParameter)->where('id', $idParameter)->findOne()->id: /* show error */ echo $messenger->setRoute(Redaxscript\Language::get('back'), 'admin')->error(Redaxscript\Language::get('something_wrong')); return; } /* define access variables */ if ($adminParameter && $tableParameter) { if ($tableParameter == 'modules') { $install = Redaxscript\Registry::get('modulesInstall'); $uninstall = Redaxscript\Registry::get('modulesUninstall'); } else { if ($tableParameter != 'settings') { $new = Redaxscript\Registry::get('tableNew'); if ($tableParameter == 'comments') { $articles_total = Redaxscript\Db::forTablePrefix('articles')->count(); $articles_comments_disable = Redaxscript\Db::forTablePrefix('articles')->where('comments', 0)->count(); if ($articles_total == $articles_comments_disable) { $new = 0; } } $delete = Redaxscript\Registry::get('tableDelete'); } } $edit = Redaxscript\Registry::get('tableEdit'); } if ($edit == 1 || $delete == 1) { $accessValidator = new Redaxscript\Validator\Access(); $access = Redaxscript\Db::forTablePrefix($tableParameter)->where('id', $idParameter)->findOne()->access; $check_access = $accessValidator->validate($access, Redaxscript\Registry::get('myGroups')); } /* validate access */ switch (true) { case $adminParameter == 'new' && $new == 0: case $adminParameter == 'view' && in_array($tableParameter, ['categories', 'articles', 'extras', 'comments', 'groups', 'users']) && $new == 0 && $edit == 0 && $delete == 0: case $adminParameter == 'view' && $tableParameter == 'settings': case $adminParameter == 'view' && $tableParameter == 'modules' && $edit == 0 && $install == 0 && $uninstall == 0: case $adminParameter == 'edit' && $edit == 0 && !$usersException: case in_array($adminParameter, ['up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable']) && $edit == 0: case $adminParameter == 'install' && $install == 0: case $adminParameter == 'uninstall' && $uninstall == 0: case $adminParameter == 'delete' && $delete == 0 && !$usersException: case $adminParameter == 'process' && $_POST['new'] && $new == 0: case $adminParameter == 'process' && $_POST['edit'] && $edit == 0 && !$usersException: case $adminParameter == 'process' && $_POST['groups'] && !Redaxscript\Registry::get('groupsEdit'): case $adminParameter == 'update' && $edit == 0: case $idParameter == 1 && ($adminParameter == 'disable' || $adminParameter == 'delete') && ($tableParameter == 'groups' || $tableParameter == 'users'): case is_numeric($idParameter) && $tableParameter && $check_access == 0 && !$usersException: /* show error */ echo $messenger->setRoute(Redaxscript\Language::get('back'), 'admin')->error(Redaxscript\Language::get('error_occurred'), Redaxscript\Language::get('access_no')); return; } /* check token */ if (in_array($adminParameter, ['up', 'down', 'sort', 'publish', 'unpublish', 'enable', 'disable', 'install', 'uninstall', 'delete']) && !$tokenParameter) { /* show error */ echo $messenger->setRoute(Redaxscript\Language::get('back'), 'admin')->error(Redaxscript\Language::get('error_occurred'), Redaxscript\Language::get('token_no')); return; } /* admin routing */ if ($firstParameter == 'admin' && !$adminParameter) { contents(); } switch ($adminParameter) { case 'new': if ($tableParameter == 'categories') { $categoryForm = new Redaxscript\Admin\View\CategoryForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $categoryForm->render(); } if ($tableParameter == 'articles') { $articleForm = new Redaxscript\Admin\View\ArticleForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $articleForm->render(); } if ($tableParameter == 'extras') { $extraForm = new Redaxscript\Admin\View\ExtraForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $extraForm->render(); } if ($tableParameter == 'comments') { $commentForm = new Redaxscript\Admin\View\CommentForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $commentForm->render(); } if ($tableParameter == 'groups') { $groupForm = new Redaxscript\Admin\View\GroupForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $groupForm->render(); } if ($tableParameter == 'users') { $userForm = new Redaxscript\Admin\View\UserForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $userForm->render(); } return; case 'view': if (in_array($tableParameter, ['categories', 'articles', 'extras', 'comments'])) { admin_contents_list(); } if (in_array($tableParameter, ['groups', 'users', 'modules'])) { call_user_func('admin_' . $tableParameter . '_list'); } return; case 'edit': if ($tableParameter == 'categories') { $categoryForm = new Redaxscript\Admin\View\CategoryForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $categoryForm->render($idParameter); } if ($tableParameter == 'articles') { $articleForm = new Redaxscript\Admin\View\ArticleForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $articleForm->render($idParameter); } if ($tableParameter == 'extras') { $extraForm = new Redaxscript\Admin\View\ExtraForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $extraForm->render($idParameter); } if ($tableParameter == 'comments') { $commentForm = new Redaxscript\Admin\View\CommentForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $commentForm->render($idParameter); } if ($tableParameter == 'groups') { $groupForm = new Redaxscript\Admin\View\GroupForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $groupForm->render($idParameter); } if ($tableParameter == 'users') { $userForm = new Redaxscript\Admin\View\UserForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $userForm->render($idParameter); } if ($tableParameter == 'modules') { $moduleForm = new Redaxscript\Admin\View\ModuleForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $moduleForm->render($idParameter); } if ($tableParameter == 'settings') { $settingForm = new Redaxscript\Admin\View\SettingForm(Redaxscript\Registry::getInstance(), Redaxscript\Language::getInstance()); echo $settingForm->render(); } return; case 'up': case 'down': admin_move(); return; case 'sort': admin_sort(); return; case 'publish': case 'enable': admin_status(1); return; case 'unpublish': case 'disable': admin_status(0); return; case 'install': case 'uninstall': admin_install(); return; case 'delete': case 'process': case 'update': call_user_func('admin_' . $adminParameter); return; } Redaxscript\Hook::trigger('adminRouterEnd'); }