예제 #1
0
/**
 * 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;
}
/**
 * registration form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Registration
 * @author Henry Ruhs
 */
function registration_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();
    }
    /* collect output */
    $output .= '<h2 class="title_content">' . l('account_create') . '</h2>';
    $output .= form_element('form', 'form_registration', 'js_validate_form form_default form_registration', '', '', '', 'action="' . REWRITE_ROUTE . 'registration" method="post"');
    $output .= form_element('fieldset', '', 'set_registration', '', '', l('fields_required') . l('point')) . '<ul>';
    $output .= '<li>' . form_element('text', 'name', 'field_text field_note', 'name', '', '* ' . l('name'), 'maxlength="50" required="required" autofocus="autofocus"' . $code_disabled) . '</li>';
    $output .= '<li>' . form_element('text', 'user', 'field_text field_note', 'user', '', '* ' . l('user'), 'maxlength="50" required="required"' . $code_disabled) . '</li>';
    $output .= '<li>' . form_element('email', 'email', 'field_text field_note', 'email', '', '* ' . l('email'), 'maxlength="50" 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) {
        $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', 'registration_post', l('create'), '', $code_disabled);
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    $_SESSION[ROOT . '/registration'] = 'visited';
    echo $output;
}
/**
 * comment form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Comments
 * @author Henry Ruhs
 *
 * @param integer $article
 * @param string $language
 */
function comment_form($article = '', $language = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* 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 .= '<h2 class="title_content">' . l('comment_new') . '</h2>';
    $output .= form_element('form', 'form_comment', 'js_validate_form form_default form_comment', '', '', '', 'method="post"');
    $output .= form_element('fieldset', '', 'set_comment', '', '', 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('comment'), '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 hidden output */
    $output .= form_element('hidden', '', '', 'language', $language);
    $output .= form_element('hidden', '', '', 'date', NOW);
    $output .= form_element('hidden', '', '', 'article', $article);
    /* 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', 'comment_post', l('create'), '', $code_disabled);
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    $_SESSION[ROOT . '/comment'] = 'visited';
    echo $output;
}