コード例 #1
0
ファイル: reminder.php プロジェクト: ITw3/redaxscript
/**
 * 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\Validator::FAILED) {
            $error = l('email_incorrect');
        } else {
            if ($captchaValidator->validate($task, $solution) == Redaxscript\Validator\Validator::FAILED) {
                $error = l('captcha_incorrect');
            } else {
                if (retrieve('id', 'users', 'email', $email) == '') {
                    $error = l('email_unknown');
                } else {
                    /* query users */
                    $query = 'SELECT id, user, password FROM ' . PREFIX . 'users WHERE email = \'' . $email . '\' && status = 1';
                    $result = mysql_query($query);
                    if ($result) {
                        while ($r = mysql_fetch_assoc($result)) {
                            if ($r) {
                                foreach ($r as $key => $value) {
                                    ${$key} = stripslashes($value);
                                }
                            }
                            /* send reminder information */
                            $passwordResetRoute = ROOT . '/' . REWRITE_ROUTE . 'password_reset/' . $id . '/' . $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($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'] = '';
}
コード例 #2
0
/**
 * 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 . '/' . $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'] = '';
}
コード例 #3
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * db backup admin panel panel list modules
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @return string
 */
function db_backup_admin_panel_list_modules()
{
    $output = '<li>' . anchor_element('internal', '', '', l('database_backup', 'db_backup')) . '<ul class="js_list_panel_children_admin list_panel_children_admin">';
    $output .= '<li>' . anchor_element('internal', '', '', l('download', 'db_backup'), 'admin/db-backup/download') . '</li>';
    $output .= '<li>' . anchor_element('internal', '', '', l('send_email', 'db_backup'), 'admin/db-backup/send') . '</li>';
    $output .= '</ul></li>';
    return $output;
}
コード例 #4
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * share this
 *
 * @since 2.0.2
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @return string
 */
function share_this($route = '')
{
    $code = 'target="_blank" rel="nofollow"';
    $networks = array('facebook' => array('url' => 'http://facebook.com/sharer.php?u='), 'googleplusone' => array('url' => 'http://plusone.google.com/_/+1/confirm?url='), 'twitter' => array('url' => 'http://twitter.com/share?url=', 'code' => ' data-height="340"'), 'pinterest' => array('url' => 'http://pinterest.com/pin/create/button/?url='), 'linkedin' => array('url' => 'http://linkedin.com/shareArticle?url=', 'code' => ' data-height="490" data-width="850"'), 'stumbleupon' => array('url' => 'http://stumbleupon.com/submit?url='), 'delicious' => array('url' => 'http://del.icio.us/post?url=', 'code' => ' data-height="580"'));
    /* collect output */
    if ($route) {
        $output = '<ul class="list_share_this clearfix">';
        /* handle each network */
        foreach ($networks as $key => $value) {
            $output .= '<li>' . anchor_element('external', '', 'js_link_share_this link_share_this link_' . $key, ucfirst($key), $value['url'] . $route, '', $code . ' data-type="' . $key . '"' . $value['code']) . '</li>';
        }
        $output .= '</ul>';
        return $output;
    }
}
コード例 #5
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * recent view
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @param integer $limit
 * @return string
 */
function recent_view($limit = '')
{
    $recent_view_log = recent_view_logger();
    if ($recent_view_log) {
        $output = '<ul class="list_recent_view">';
        foreach ($recent_view_log as $value) {
            /* break if limit reached */
            if (++$counter > $limit && $limit) {
                break;
            }
            $output .= '<li>' . anchor_element('internal', '', '', $value, $value) . '</li>';
        }
        $output .= '</ul>';
    }
    return $output;
}
コード例 #6
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * feed list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 */
function feed_list()
{
    $articles_total = query_total('articles', 'access', 0);
    $comments_total = query_total('comments', 'access', 0);
    /* collect output */
    if ($articles_total > 0) {
        $output = '<li>' . anchor_element('internal', '', '', l('feed_articles', 'feed_generator'), 'feed/articles', '', 'rel="nofollow"') . '</li>';
    }
    if ($comments_total > 0) {
        $output .= '<li>' . anchor_element('internal', '', '', l('feed_comments', 'feed_generator'), 'feed/comments', '', 'rel="nofollow"') . '</li>';
    }
    if ($articles_total > 0 || $comments_total > 0) {
        $output = '<ul class="list_feed">' . $output . '</ul>';
    }
    echo $output;
}
コード例 #7
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;
}
コード例 #8
0
/**
 * install
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Install
 * @author Henry Ruhs
 */
function install()
{
    global $name, $user, $password, $email;
    /* installer */
    $installer = new Redaxscript\Installer();
    $installer->init(Redaxscript\Config::getInstance());
    $installer->rawDrop();
    $installer->rawCreate();
    $installer->insertData(array('adminName' => $name, 'adminUser' => $user, 'adminPassword' => $password, 'adminEmail' => $email));
    /* send login information */
    $urlLink = anchor_element('external', '', '', ROOT, ROOT);
    $toArray = $fromArray = array($name => $email);
    $subject = l('installation');
    $bodyArray = array('<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink);
    /* mailer object */
    $mailer = new Redaxscript\Mailer();
    $mailer->init($toArray, $fromArray, $subject, $bodyArray);
    $mailer->send();
}
コード例 #9
0
/**
 * notification
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Contents
 * @author Henry Ruhs
 *
 * @param string $title
 * @param string $text
 * @param string $action
 * @param string $route
 */
function notification($title = '', $text = '', $action = '', $route = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* detect needed mode */
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin') {
        $suffix = '_admin';
    } else {
        $suffix = '_default';
    }
    /* collect output */
    if ($title) {
        $output .= '<h2 class="title_content title_notification">' . $title . '</h2>';
    }
    $output .= '<div class="box_content box_notification">';
    /* collect text output */
    if (is_string($text)) {
        $text = array($text);
    }
    foreach ($text as $value) {
        if ($value) {
            $output .= '<p class="text_notification">' . $value . l('point') . '</p>';
        }
    }
    /* collect button output */
    if ($action && $route) {
        $output .= anchor_element('internal', '', 'js_forward_notification button' . $suffix, $action, $route);
    }
    $output .= '</div>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #10
0
/**
 * 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;
}
コード例 #11
0
/**
 * 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'] = '';
}
コード例 #12
0
/**
 * templates list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 *
 * @param array $options
 */
function templates_list($options = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* templates directory object */
    $templates_directory = new Redaxscript\Directory();
    $templates_directory->init('templates', array('admin', 'install'));
    $templates_directory_array = $templates_directory->getArray();
    /* collect templates output */
    foreach ($templates_directory_array as $value) {
        $class_string = ' class="template_' . $value;
        if ($value == Redaxscript\Registry::get('template')) {
            $class_string .= ' item_active';
        }
        $class_string .= '"';
        $output .= '<li' . $class_string . '>' . anchor_element('internal', '', '', $value, FULL_ROUTE . TEMPLATE_ROUTE . $value, '', 'rel="nofollow"') . '</li>';
    }
    /* 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_templates"';
    }
    /* collect list output */
    if ($output) {
        $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #13
0
/**
 * 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'] = '';
}
コード例 #14
0
/**
 * login list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 */
function login_list()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    if (LOGGED_IN == TOKEN && FIRST_PARAMETER != 'logout') {
        $output .= '<li class="item_logout">' . anchor_element('internal', '', '', l('logout'), 'logout', '', 'rel="nofollow"') . '</li>';
        $output .= '<li class="item_administration">' . anchor_element('internal', '', '', l('administration'), 'admin', '', 'rel="nofollow"') . '</li>';
    } else {
        $output .= '<li class="item_login">' . anchor_element('internal', '', '', l('login'), 'login', '', 'rel="nofollow"') . '</li>';
        if (s('reminder') == 1) {
            $output .= '<li class="item_reminder">' . anchor_element('internal', '', '', l('reminder'), 'reminder', '', 'rel="nofollow"') . '</li>';
        }
        if (s('registration') == 1) {
            $output .= '<li class="item_registration">' . anchor_element('internal', '', '', l('registration'), 'registration', '', 'rel="nofollow"') . '</li>';
        }
    }
    $output = '<ul class="list_login">' . $output . '</ul>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #15
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * github tracker
 *
 * @since 2.1.0
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @param string $type
 * @param array $options
 */
function github_tracker($type = '', $options = '')
{
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* fallback */
    if ($option_limit_milestones == '') {
        $option_limit_milestones = s('limit');
    }
    if ($option_limit_issues == '') {
        $option_limit_issues = s('limit');
    }
    /* get contents */
    $contents = github_tracker_get_contents($type);
    /* decode contents */
    if ($contents) {
        $contents = json_decode($contents);
        $data = $contents;
    }
    /* collect milestones output */
    if ($data && $type == 'milestones') {
        foreach ($data as $value) {
            /* break if limit reached */
            if (++$milestones_counter > $option_limit_milestones) {
                break;
            }
            $total_issues = $value->closed_issues + $value->open_issues;
            /* collect milestones output */
            $output .= '<ul class="list_github_tracker_milestones">';
            $output .= '<li><h3 class="title_github_tracker_milestones">' . $value->title . '</h3></li>';
            $output .= '<li><span class="text_github_tracker_milestones_description">' . $value->description . '</span></li>';
            $output .= '<li><progress class="progress_github_tracker_milestones" value="' . $value->closed_issues . '" max="' . $total_issues . '"></progress></li>';
            $output .= '<li><span class="text_github_tracker_milestones_status">' . $value->closed_issues . ' ' . l('closed_issues', 'github_tracker') . s('divider') . $value->open_issues . ' ' . l('open_issues', 'github_tracker') . '</span></li>';
            $output .= '</ul>';
        }
    }
    /* collect issues output */
    if ($data && $type == 'issues') {
        $output = '<div class="wrapper_table_default"><table class="table table_default table_github_tracker_milestones">';
        $output .= '<thead><tr><th class="s3o6 column_first">' . l('issues', 'github_tracker') . '</th><th class="column_second">' . l('created', 'github_tracker') . '</th><th class="column_third">' . l('updated', 'github_tracker') . '</th><th class="column_last">' . l('milestones', 'github_tracker') . '</th></tr></thead>';
        $output .= '<tfoot><tr><td class="column_first">' . l('issues', 'github_tracker') . '</td><td class="column_second">' . l('created', 'github_tracker') . '</td><td class="column_third">' . l('updated', 'github_tracker') . '</td><td class="column_last">' . l('milestones', 'github_tracker') . '</td></tr></tfoot>';
        foreach ($data as $value) {
            /* break if limit reached */
            if (++$issues_counter > $option_limit_issues) {
                break;
            }
            /* collect issues output */
            $output .= '<tr>';
            $output .= '<td class="column_first">' . anchor_element('external', '', 'js_confirm link_github_tracker_issues', $value->title, $value->html_url) . '</td>';
            $output .= '<td class="column_second">' . date(s('date'), strtotime($value->created_at)) . '</td>';
            $output .= '<td class="column_third">' . date(s('date'), strtotime($value->updated_at)) . '</td>';
            $output .= '<td class="column_last">' . $value->milestone->title . '</td>';
            $output .= '</tr>';
        }
        $output .= '</tbody></table></div>';
    }
    echo $output;
}
コード例 #16
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * fb group user link
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @param integer $id
 * @param string $name
 * @return string
 */
function fb_group_user_link($id = '', $name = '')
{
    $output = anchor_element('external', '', 'link_fb_group_user', $name, FB_GROUP_FACEBOOK_URL . '/profile.php?id=' . $id, '', 'rel="nofollow"');
    return $output;
}
コード例 #17
0
/**
 * 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(__FUNCTION__ . '_start');
    /* 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="item_control_admin link_install">' . anchor_element('internal', '', 'install', l('install'), 'admin/install/' . $table . '/' . $alias . '/' . TOKEN) . '</li>';
    }
    /* collect contents output */
    if ($type == 'contents') {
        if ($status == 2) {
            $output .= '<li class="item_control_admin item_future_posting"><span>' . l('future_posting') . '</span></li>';
        }
        if ($edit == 1) {
            if ($status == 1) {
                $output .= '<li class="item_control_admin item_unpublish">' . anchor_element('internal', '', '', l('unpublish'), 'admin/unpublish/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
            } else {
                if ($status == 0) {
                    $output .= '<li class="item_control_admin item_publish">' . anchor_element('internal', '', '', l('publish'), 'admin/publish/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
                }
            }
        }
    }
    /* collect access and system output */
    if ($edit == 1 && ($type == 'access' && $id > 1 || $type == 'modules_installed')) {
        if ($status == 1) {
            $output .= '<li class="item_control_admin item_disable">' . anchor_element('internal', '', '', l('disable'), 'admin/disable/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
        } else {
            if ($status == 0) {
                $output .= '<li class="item_control_admin item_enable">' . anchor_element('internal', '', '', l('enable'), 'admin/enable/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
            }
        }
    }
    /* collect general edit and delete output */
    if ($edit == 1) {
        $output .= '<li class="item_control_admin item_edit">' . anchor_element('internal', '', '', l('edit'), 'admin/edit/' . $table . '/' . $id) . '</li>';
    }
    if ($delete == 1) {
        if ($type == 'modules_installed') {
            $output .= '<li class="item_control_admin item_uninstall">' . anchor_element('internal', '', 'js_confirm', l('uninstall'), 'admin/uninstall/' . $table . '/' . $alias . '/' . TOKEN) . '</li>';
        } else {
            $output .= '<li class="item_control_admin item_delete">' . anchor_element('internal', '', 'js_confirm', l('delete'), 'admin/delete/' . $table . '/' . $id . '/' . TOKEN) . '</li>';
        }
    }
    /* collect list output */
    if ($output) {
        $output = '<ul class="list_control_admin">' . $output . '</ul>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    return $output;
}
コード例 #18
0
ファイル: password.php プロジェクト: ITw3/redaxscript
/**
 * password reset post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Password
 * @author Henry Ruhs
 */
function password_reset_post()
{
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/password_reset'] == 'visited') {
        $post_id = clean($_POST['id'], 0);
        $post_password = clean($_POST['password'], 0);
        $password = hash_generator(10);
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* query user information */
    if ($post_id && $post_password) {
        $users_query = 'SELECT id, name, email, password FROM ' . PREFIX . 'users WHERE id = ' . $post_id . ' && password = \'' . $post_password . '\' && status = 1';
        $users_result = mysql_query($users_query);
        while ($r = mysql_fetch_assoc($users_result)) {
            foreach ($r as $key => $value) {
                $key = 'my_' . $key;
                ${$key} = stripslashes($value);
            }
        }
    }
    /* validate post */
    if ($post_id == '' || $post_password == '') {
        $error = l('input_incorrect');
    } else {
        if (sha1($task) != $solution) {
            $error = l('captcha_incorrect');
        } else {
            if ($my_id == '' || $my_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($toArray, $fromArray, $subject, $bodyArray);
                $mailer->send();
                /* update password */
                $query = 'UPDATE ' . PREFIX . 'users SET password = \'' . sha1($password) . SALT . '\' WHERE id = ' . $post_id . ' && password = \'' . $post_password . '\' && status = 1';
                mysql_query($query);
            }
        }
    }
    /* 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'] = '';
}
コード例 #19
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * file manager
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @param string $directory
 */
function file_manager($directory = '')
{
    if (!is_dir($directory)) {
        mkdir($directory, 0777);
    }
    if (!is_dir($directory)) {
        $output = '<div class="box_note note_error">' . l('directory_create', 'file_manager') . l('colon') . ' ' . $directory . l('point') . '</div>';
    } else {
        if (!is_writable($directory)) {
            $output = '<div class="box_note note_error">' . l('directory_permission_grant', 'file_manager') . l('colon') . ' ' . $directory . l('point') . '</div>';
        }
    }
    /* collect listing output */
    $output .= '<h2 class="title_content">' . l('file_manager', 'file_manager') . '</h2>';
    $output .= form_element('form', 'form_file_manager', 'js_form_file_manager form_file_manager', '', '', '', 'action="' . REWRITE_ROUTE . 'admin/file-manager/upload" method="post" enctype="multipart/form-data"');
    $output .= form_element('file', '', 'js_file field_file hide_if_js', 'file', '', l('browse', 'file_manager'));
    $output .= '<button type="submit" class="js_upload field_upload button_admin hide_if_js">' . l('upload', 'file_manager') . '</span></span></button>';
    $output .= '</form>';
    $output .= '<div class="wrapper_table_admin"><table class="table table_admin">';
    /* collect thead and tfoot */
    $output .= '<thead><tr><th class="s4o6 column_first">' . l('name') . '</th><th class="s1o6 column_second">' . l('file_size', 'file_manager') . '</th><th class="s1o6 column_last">' . l('date') . '</th></tr></thead>';
    $output .= '<tfoot><tr><td class="column_first">' . l('name') . '</td><td class="column_second">' . l('file_size', 'file_manager') . '</td><td class="column_last">' . l('date') . '</td></tr></tfoot>';
    /* file manager directory object */
    $file_manager_directory = new Redaxscript\Directory($directory);
    $file_manager_directory_array = $file_manager_directory->get();
    /* collect directory output */
    if (count($file_manager_directory_array)) {
        $output .= '<tbody>';
        foreach ($file_manager_directory_array as $key => $value) {
            $output .= '<tr><td class="column_first">';
            $path = $directory . '/' . $value;
            if (function_exists('exif_imagetype') && exif_imagetype($path)) {
                $output .= anchor_element('external', '', '', $value, ROOT . '/' . $path);
            } else {
                $output .= $value;
            }
            /* collect control output */
            $output .= '<ul class="list_control_admin"><li class="item_delete">' . anchor_element('internal', '', 'js_confirm', l('delete'), 'admin/file-manager/delete/' . $key . '/' . TOKEN) . '</li></ul>';
            /* collect filesize and filetime output */
            $output .= '</td><td class="column_second">' . ceil(filesize($path) / 1024) . ' Kb</td><td class="column_last">' . date(s('date'), filectime($path)) . '</td></tr>';
        }
        $output .= '</tbody>';
    } else {
        $error = l('file_no', 'file_manager') . l('point');
    }
    /* handle error */
    if ($error) {
        $output .= '<tbody><tr><td colspan="2">' . $error . '</td></tr></tbody>';
    }
    $output .= '</table></div>';
    echo $output;
}
コード例 #20
0
/**
 * 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'] = '';
}
コード例 #21
0
ファイル: search.php プロジェクト: ITw3/redaxscript
/**
 * search post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Search
 * @author Henry Ruhs
 */
function search_post()
{
    /* clean post */
    if (ATTACK_BLOCKED < 10) {
        $search_terms = clean($_POST['search_terms'], 1);
    }
    /* validate post */
    if (strlen($search_terms) < 3 || $search_terms == l('search_terms')) {
        $error = l('input_incorrect');
    } else {
        $search = array_filter(explode(' ', $search_terms));
        $search_keys = array_keys($search);
        $last = end($search_keys);
        /* query search */
        $query = 'SELECT id, title, alias, description, date, category, access FROM ' . PREFIX . 'articles WHERE (language = \'' . LANGUAGE . '\' || language = \'\') && status = 1';
        if ($search) {
            $query .= ' && (';
            foreach ($search as $key => $value) {
                $query .= 'title LIKE \'%' . $value . '%\' || description LIKE \'%' . $value . '%\' || keywords LIKE \'%' . $value . '%\' || text LIKE \'%' . $value . '%\'';
                if ($last != $key) {
                    $query .= ' || ';
                }
            }
            $query .= ')';
        }
        $query .= ' ORDER BY date DESC LIMIT 50';
        $result = mysql_query($query);
        $num_rows = mysql_num_rows($result);
        if ($result == '' || $num_rows == '') {
            $error = l('search_no');
        } else {
            if ($result) {
                $accessValidator = new Redaxscript\Validator\Access();
                $output = '<h2 class="title_content title_search_result">' . l('search') . '</h2>';
                $output .= form_element('fieldset', '', 'set_search_result', '', '', '<span class="title_content_sub title_search_result_sub">' . l('articles') . '</span>') . '<ol class="list_search_result">';
                while ($r = mysql_fetch_assoc($result)) {
                    $access = $r['access'];
                    $check_access = $accessValidator->validate($access, MY_GROUPS);
                    /* if access granted */
                    if ($check_access == 1) {
                        if ($r) {
                            foreach ($r as $key => $value) {
                                ${$key} = stripslashes($value);
                            }
                        }
                        /* prepare metadata */
                        if ($description == '') {
                            $description = $title;
                        }
                        $date = date(s('date'), strtotime($date));
                        /* build route */
                        if ($category == 0) {
                            $route = $alias;
                        } else {
                            $route = build_route('articles', $id);
                        }
                        /* collect item output */
                        $output .= '<li class="item_search_result">' . anchor_element('internal', '', 'link_search_result', $title, $route, $description) . '<span class="date_search_result">' . $date . '</span></li>';
                    } else {
                        $counter++;
                    }
                }
                $output .= '</ol></fieldset>';
                /* handle access */
                if ($num_rows == $counter) {
                    $error = l('access_no');
                }
            }
        }
    }
    /* handle error */
    if ($error) {
        notification(l('something_wrong'), $error);
    } else {
        echo $output;
    }
}
コード例 #22
0
ファイル: install.php プロジェクト: ITw3/redaxscript
/**
 * install
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Install
 * @author Henry Ruhs
 */
function install()
{
    global $d_host, $d_name, $d_user, $d_password, $d_prefix, $d_salt, $name, $user, $password, $email;
    $r['create_database'] = 'CREATE DATABASE IF NOT EXISTS ' . $d_name;
    $r['grant_privileges'] = 'GRANT ALL PRIVILEGES ON ' . $d_name . '.* TO \'' . $d_user . '\'@\'' . $d_host . '\' IDENTIFIED BY \'' . $d_password . '\'';
    $r['flush_privileges'] = 'FLUSH PRIVILEGES';
    $r['create_articles'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'articles (
		id int(10) NOT NULL AUTO_INCREMENT,
		title varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		keywords varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		text longtext COLLATE utf8_unicode_ci,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		template varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		date datetime DEFAULT NULL,
		category int(10) DEFAULT NULL,
		headline int(1) DEFAULT NULL,
		infoline int(1) DEFAULT NULL,
		comments int(1) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		rank int(10) DEFAULT NULL,
		access varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 2';
    $r['create_categories'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'categories (
		id int(10) NOT NULL AUTO_INCREMENT,
		title varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		keywords varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		template varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		parent int(10) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		rank int(10) DEFAULT NULL,
		access varchar(255)COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 2';
    $r['create_comments'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'comments (
		id int(10) NOT NULL AUTO_INCREMENT,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		email varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		url varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		text longtext COLLATE utf8_unicode_ci,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		date datetime DEFAULT NULL,
		article int(10) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		rank int(10) DEFAULT NULL,
		access varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 1';
    $r['create_extras'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'extras (
		id int(10) NOT NULL AUTO_INCREMENT,
		title varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		text longtext COLLATE utf8_unicode_ci,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		date datetime DEFAULT NULL,
		category int(10) DEFAULT NULL,
		article int(10) DEFAULT NULL,
		headline int(1) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		rank int(10) DEFAULT NULL,
		access varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 6';
    $r['create_groups'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'groups (
		id int(10) NOT NULL AUTO_INCREMENT,
		name varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		categories varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		articles varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		extras varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		comments varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		groups varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		users varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		modules varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		settings int(1) DEFAULT NULL,
		filter int(1) DEFAULT NULL,
		status int(1) DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 3';
    $r['create_modules'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'modules (
		id int(10) NOT NULL AUTO_INCREMENT,
		name varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		alias varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		author varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		version varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		status int(1) DEFAULT NULL,
		access varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 2';
    $r['create_settings'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'settings (
		id int(10) NOT NULL AUTO_INCREMENT,
		name varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		value varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 27';
    $r['create_users'] = 'CREATE TABLE IF NOT EXISTS ' . $d_name . '.' . $d_prefix . 'users (
		id int(10) NOT NULL AUTO_INCREMENT,
		name varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		user varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		password varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		email varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		description varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		language char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
		first datetime DEFAULT NULL,
		last datetime DEFAULT NULL,
		status int(1) DEFAULT NULL,
		groups varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
		PRIMARY KEY(id)
	)
	ENGINE = MyISAM
	DEFAULT CHARSET = utf8
	COLLATE = utf8_unicode_ci
	AUTO_INCREMENT = 2';
    $r['insert_articles'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'articles (id, title, alias, author, description, keywords, text, language, template, date, category, headline, infoline, comments, status, rank, access) VALUES (1, \'Welcome\', \'welcome\', \'' . $user . '\', \'\', \'\', \'<p>Congratulations! Redaxscript has been successfully installed.</p>\', \'\', \'\', \'' . NOW . '\', 1, 1, 0, 0, 1, 1, \'0\')';
    $r['insert_categories'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'categories (id, title, alias, author, description, keywords, language, template, parent, status, rank, access) VALUES (1, \'Home\', \'home\', \'' . $user . '\', \'\', \'\', \'\', \'\', 0, 1, 1, \'0\')';
    $r['insert_extras'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'extras (id, title, alias, author, text, language, date, category, article, headline, status, rank, access) VALUES (1, \'Categories\', \'categories\', \'' . $user . '\', \'<function>\\n{\\n\\t"navigation_list":\\n\\t{\\n\\t\\t"table": "categories",\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar",\\n\\t\\t\\t"children": 1\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 1, 1, \'0\'), (2, \'Articles\', \'articles\', \'' . $user . '\', \'<function>\\n{\\n\\t"navigation_list":\\n\\t{\\n\\t\\t"table": "articles",\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar"\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 1, 2, \'0\'), (3, \'Comments\', \'comments\', \'' . $user . '\', \'<function>\\n{\\n\\t"navigation_list":\\n\\t{\\n\\t\\t"table": "comments",\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar"\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 1, 3, \'0\'), (4, \'Languages\', \'languages\', \'' . $user . '\', \'<function>\\n{\\n\\t"languages_list":\\n\\t{\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar"\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 0, 4, \'0\'), (5, \'Templates\', \'templates\', \'' . $user . '\', \'<function>\\n{\\n\\t"templates_list":\\n\\t{\\n\\t\\t"options":\\n\\t\\t{\\n\\t\\t\\t"class": "list_sidebar"\\n\\t\\t}\\n\\t}\\n}\\n</function>\', \'\', \'' . NOW . '\', 0, 0, 1, 0, 5, \'0\'), (6, \'Footer\', \'footer\', \'' . $user . '\', \'<div class="box_first grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/general" title="General">General</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/introduction" title="Introduction">Introduction</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/feature-list" title="Feature list">Feature list</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/benchmark" title="Benchmark">Benchmark</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/service" title="Service">Service</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/general/about" title="About">About</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\\n\\n<div class="box_second grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/download" title="Download">Download</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/download/releases" title="Releases">Releases</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/download/templates" title="Templates">Templates</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/download/languages" title="Languages">Languages</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/download/modules" title="Modules">Modules</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\\n\\n<div class="box_third grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/support" title="Support">Support</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/support/getting-started" title="Getting started">Getting started</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/support/installation-guide" title="Installation guide">Installation guide</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/support/troubleshooting" title="Troubleshooting">Troubleshooting</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/support/faq" title="FAQ">FAQ</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\\n\\n<div class="box_fourth grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/develop" title="Develop">Develop</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/source-code" title="Source code">Source code</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/github-guide" title="Github guide">Github guide</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/documentation" title="Documentation">Documentation</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/roadmap" title="Roadmap">Roadmap</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/develop/changelog" title="Changelog">Changelog</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\\n\\n<div class="box_last grid_space s1o5">\\n\\t<h3 class="title_footer">\\n\\t\\t<a href="http://redaxscript.com/community" title="Community">Community</a>\\n\\t</h3>\\n\\t<ul class="list_footer">\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/community/facebook-group" title="Facebook group">Facebook group</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/community/team" title="Team">Team</a>\\n\\t\\t</li>\\n\\t\\t<li>\\n\\t\\t\\t<a href="http://redaxscript.com/community/contribute" title="Contribute">Contribute</a>\\n\\t\\t</li>\\n\\t</ul>\\n</div>\', \'\', \'' . NOW . '\', 0, 0, 0, 0, 6, \'0\')';
    $r['insert_groups'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'groups (id, name, alias, description, categories, articles, extras, comments, groups, users, modules, settings, filter, status) VALUES (1, \'Administrators\', \'administrators\', \'Unlimited access\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', \'1, 2, 3\', 1, 0, 1), (2, \'Members\', \'members\', \'Default members group\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', 0, 1, 1)';
    $r['insert_settings'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'settings (id, name, value) VALUES (1, \'language\', \'detect\'), (2, \'template\', \'default\'), (3, \'title\', \'Redaxscript\'), (4, \'author\', \'\'), (5, \'copyright\', \'\'), (6, \'description\', \'Ultra lightweight CMS\'), (7, \'keywords\', \'\'), (8, \'robots\', \'all\'), (9, \'email\', \'' . $email . '\'), (10, \'subject\', \'Redaxscript\'), (11, \'notification\', \'0\'), (12, \'charset\', \'utf-8\'), (13, \'divider\', \' • \'), (14, \'time\', \'H:i\'), (15, \'date\', \'d.m.Y\'), (16, \'homepage\', \'0\'), (17, \'limit\', \'10\'), (18, \'order\', \'asc\'), (19, \'pagination\', \'1\'), (20, \'moderation\', \'0\'), (21, \'registration\', \'1\'), (22, \'verification\', \'0\'), (23, \'reminder\', \'1\'), (24, \'captcha\', \'0\'), (25, \'blocker\', \'1\'), (26, \'version\', \'' . l('redaxscript_version') . '\')';
    if (file_exists('modules/call_home/install.php')) {
        $r['insert_modules'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'modules (name, alias, author, description, version, status, access) VALUES (\'Call home\', \'call_home\', \'Redaxmedia\', \'Call home module\', \'' . l('redaxscript_version') . '\', 1, 0)';
    }
    $r['insert_users'] = 'INSERT INTO ' . $d_name . '.' . $d_prefix . 'users (id, name, user, password, email, description, language, first, last, status, groups) VALUES (1, \'' . $name . '\', \'' . $user . '\', \'' . sha1($password) . $d_salt . '\', \'' . $email . '\', \'God admin\', \'\', \'' . NOW . '\', \'' . NOW . '\', 1, \'1\')';
    /* install database */
    foreach ($r as $key => $value) {
        mysql_query($value);
    }
    /* send login information */
    $urlLink = anchor_element('external', '', '', ROOT, ROOT);
    $toArray = $fromArray = array($name => $email);
    $subject = l('installation');
    $bodyArray = array('<strong>' . l('user') . l('colon') . '</strong> ' . $user, '<br />', '<strong>' . l('password') . l('colon') . '</strong> ' . $password, '<br />', '<strong>' . l('url') . l('colon') . '</strong> ' . $urlLink);
    /* mail object */
    $mail = new Redaxscript\Mailer($toArray, $fromArray, $subject, $bodyArray);
    $mail->send();
}
コード例 #23
0
ファイル: admin_groups.php プロジェクト: ITw3/redaxscript
/**
 * 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 */
        $query = 'SELECT * FROM ' . PREFIX . 'groups WHERE id = ' . ID_PARAMETER;
        $result = mysql_query($query);
        $r = mysql_fetch_assoc($result);
        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_admin', '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_admin 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_admin 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_admin button_submit_admin', ADMIN_PARAMETER, $wording_submit);
    }
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #24
0
/**
 * search post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Search
 * @author Henry Ruhs
 */
function search_post()
{
    /* clean post */
    if (ATTACK_BLOCKED < 10) {
        $search_terms = clean($_POST['search_terms'], 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;
    }
}
コード例 #25
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * feed reader
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @param string $url
 * @param array $options
 */
function feed_reader($url = '', $options = '')
{
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* fallback */
    if ($option_truncate_title == '') {
        $option_truncate_title = 80;
    }
    if ($option_truncate_text == '') {
        $option_truncate_text = 1000;
    }
    if ($option_limit == '') {
        $option_limit = s('limit');
    }
    /* get contents */
    $contents = file_get_contents($url);
    if ($contents) {
        $feed = new SimpleXMLElement($contents);
        /* detect feed type */
        if ($feed->entry) {
            $type = 'atom';
            $feed_object = $feed->entry;
        } else {
            if ($feed->channel) {
                $type = 'rss';
                $feed_object = $feed->channel->item;
            }
        }
        /* collect output */
        foreach ($feed_object as $value) {
            /* define variables */
            $title = entity(trim($value->title));
            if ($title) {
                $title = truncate(strip_tags($title), $option_truncate_title, '...');
            }
            /* if atom feed */
            if ($type == 'atom') {
                $route = $value->link['href'];
                $time = date(s('time'), strtotime($value->updated));
                $date = date(s('date'), strtotime($value->updated));
                $text = entity(trim($value->content));
            } else {
                if ($type == 'rss') {
                    $route = $value->link;
                    $time = date(s('time'), strtotime($value->pubDate));
                    $date = date(s('date'), strtotime($value->pubDate));
                    $text = entity(trim($value->description));
                }
            }
            if ($text) {
                $text = truncate(strip_tags($text, '<a>'), $option_truncate_text, '...');
            }
            /* if filter is invalid */
            if ($option_filter == '') {
                $filter_no = 1;
            } else {
                $position_title = strpos($title, $option_filter);
                $position_text = strpos($text, $option_filter);
                $filter_no = 0;
            }
            if ($filter_no || $position_title || $position_text) {
                /* break if limit reached */
                if (++$counter > $option_limit) {
                    break;
                }
                /* collect title output */
                if ($title) {
                    $output .= '<h3 class="title_feed_reader clearfix">';
                    if ($route) {
                        $output .= anchor_element('external', '', 'title_first', $title, $route, '', 'rel="nofollow"');
                    } else {
                        $output .= '<span class="title_first">' . $title . '</span>';
                    }
                    /* collect date output */
                    if ($time && $date) {
                        $output .= '<span class="title_second">' . $date . ' ' . l('at') . ' ' . $time . '</span>';
                    }
                    $output .= '</h3>';
                }
                /* collect text output */
                if ($text) {
                    $output .= '<div class="box_feed_reader">' . $text . '</div>';
                }
            }
        }
    }
    echo $output;
}
コード例 #26
0
ファイル: index.php プロジェクト: EtienneBruines/redaxscript
/**
 * gallery
 *
 * @since 2.0.2
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @param string $directory
 * @param array $options
 * @param string $command
 */
function gallery($directory = '', $options = '', $command = '')
{
    global $gallery_counter;
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    } else {
        if ($options === 'build' || $options === 'delete') {
            $command = $options;
        }
    }
    /* gallery directory object */
    $gallery_directory = new Redaxscript\Directory();
    $gallery_directory->init($directory, 'thumbs');
    $gallery_directory_array = $gallery_directory->getArray();
    /* reverse order */
    if ($option_order == 'desc') {
        $gallery_directory_array = array_reverse($gallery_directory_array);
    }
    /* delete gallery thumbs directory */
    if ($command == 'delete') {
        $gallery_directory->remove('thumbs');
    } else {
        /* collect gallery */
        $gallery_total = count($gallery_directory_array);
        $gallery_id = str_replace('/', '_', $directory) . '_' . ++$gallery_counter;
        if ($gallery_total) {
            foreach ($gallery_directory_array as $value) {
                $path = $directory . '/' . $value;
                $thumb_route = $directory . '/thumbs/' . $value;
                /* build thumb */
                if (file_exists($thumb_route) == '' || $command == 'build') {
                    gallery_build_thumb($value, $directory, $options);
                }
                if (file_exists($thumb_route)) {
                    /* read exif data */
                    $image_data = exif_read_data($path);
                    if ($image_data) {
                        $image_artist = $image_data['Artist'];
                        $image_datetime = $image_data['DateTime'];
                        if ($image_datetime) {
                            $image_date = date(s('date'), strtotime($image_datetime));
                        } else {
                            $image_date = '';
                        }
                        $image_description = $image_data['ImageDescription'];
                    }
                    /* build data string */
                    $data_string = 'data-counter="' . ++$image_counter . '" data-total="' . $gallery_total . '" data-id="' . $gallery_id . '"';
                    if ($image_artist) {
                        $data_string .= ' data-artist="' . $image_artist . '"';
                    }
                    if ($image_date) {
                        $data_string .= ' data-date="' . $image_date . '"';
                    }
                    if ($image_description) {
                        $data_string .= ' data-description="' . $image_description . '"';
                        $alt_string = ' alt="' . $image_description . '"';
                    } else {
                        $alt_string = ' alt="' . str_replace('_', ' ', pathinfo($value, PATHINFO_FILENAME)) . '"';
                    }
                    /* collect image output */
                    $image = '<img src="' . $thumb_route . '" class="image image_gallery"' . $alt_string . ' />';
                    $output .= '<li class="item_gallery">' . anchor_element('', '', 'link_gallery', $image, $path, $image_description, $data_string) . '</li>';
                }
            }
            /* collect list output */
            if ($output) {
                $output = '<ul id="' . $gallery_id . '" class="js_list_gallery list_gallery ' . $gallery_id . ' clearfix">' . $output . '</ul>';
                echo $output;
            }
        } else {
            $gallery_directory->remove('thumbs');
        }
    }
}
コード例 #27
0
/**
 * 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;
}
コード例 #28
0
ファイル: index.php プロジェクト: EtienneBruines/redaxscript
/**
 * contact post
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 */
function contact_post()
{
    $emailValidator = new Redaxscript\Validator\Email();
    $captchaValidator = new Redaxscript\Validator\Captcha();
    $urlValidator = new Redaxscript\Validator\Url();
    /* clean post */
    if (ATTACK_BLOCKED < 10 && $_SESSION[ROOT . '/contact'] == 'visited') {
        $author = clean($_POST['author'], 0);
        $email = clean($_POST['email'], 3);
        $url = clean($_POST['url'], 4);
        $text = break_up($_POST['text']);
        $text = clean($text, 1);
        $task = $_POST['task'];
        $solution = $_POST['solution'];
    }
    /* validate post */
    if ($author == '') {
        $error = l('author_empty');
    } else {
        if ($email == '') {
            $error = l('email_empty');
        } else {
            if ($text == '') {
                $error = l('message_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 {
                            /* prepare body parts */
                            $emailLink = anchor_element('email', '', '', $email, $email);
                            if ($url) {
                                $urlLink = anchor_element('external', '', '', $url, $url);
                            }
                            /* prepare mail inputs */
                            $toArray = array(s('author') => s('email'));
                            $fromArray = array($author => $email);
                            $subject = l('contact');
                            $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 />', '<br />', '<strong>' . l('message') . l('colon') . '</strong> ' . $text);
                            /* 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('home'), ROOT);
    } else {
        notification(l('operation_completed'), l('message_sent', '_contact'), l('home'), ROOT);
    }
    $_SESSION[ROOT . '/contact'] = '';
}
コード例 #29
0
/**
 * 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;
}
コード例 #30
0
/**
 * 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;
}