当前位置: 首页>>代码示例>>PHP>>正文


PHP Utils::trim方法代码示例

本文整理汇总了PHP中FeatherBB\Core\Utils::trim方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::trim方法的具体用法?PHP Utils::trim怎么用?PHP Utils::trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FeatherBB\Core\Utils的用法示例。


在下文中一共展示了Utils::trim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display

 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.userlist.display');
     if (User::get()->g_view_users == '0') {
         throw new Error(__('No permission'), 403);
     }
     // Determine if we are allowed to view post counts
     $show_post_count = ForumSettings::get('o_show_post_count') == '1' || User::get()->is_admmod ? true : false;
     $username = Input::query('username') && User::get()->g_search_users == '1' ? Utils::trim(Input::query('username')) : '';
     $show_group = Input::query('show_group') ? intval(Input::query('show_group')) : -1;
     $sort_by = Input::query('sort_by') && (in_array(Input::query('sort_by'), array('username', 'registered')) || Input::query('sort_by') == 'num_posts' && $show_post_count) ? Input::query('sort_by') : 'username';
     $sort_dir = Input::query('sort_dir') && Input::query('sort_dir') == 'DESC' ? 'DESC' : 'ASC';
     $num_users = $this->model->fetch_user_count($username, $show_group);
     // Determine the user offset (based on $page)
     $num_pages = ceil($num_users / 50);
     $p = !Input::query('p') || $page <= 1 || $page > $num_pages ? 1 : intval($page);
     $start_from = 50 * ($p - 1);
     if (User::get()->g_search_users == '1') {
         $focus_element = array('userlist', 'username');
     } else {
         $focus_element = array();
     }
     // Generate paging links
     $paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate_old($num_pages, $p, '?username=' . urlencode($username) . '&amp;show_group=' . $show_group . '&amp;sort_by=' . $sort_by . '&amp;sort_dir=' . $sort_dir);
     View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('User list')), 'active_page' => 'userlist', 'page_number' => $p, 'paging_links' => $paging_links, 'focus_element' => $focus_element, 'is_indexed' => true, 'username' => $username, 'show_group' => $show_group, 'sort_by' => $sort_by, 'sort_dir' => $sort_dir, 'show_post_count' => $show_post_count, 'dropdown_menu' => $this->model->generate_dropdown_menu($show_group), 'userlist_data' => $this->model->print_users($username, $start_from, $sort_by, $sort_dir, $show_group)))->addTemplate('userlist.php')->display();
 }
开发者ID:featherbb,项目名称:featherbb,代码行数:26,代码来源:Userlist.php

示例2: display

 public function display($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.maintenance.display');
     $action = '';
     if (Input::post('action')) {
         $action = Input::post('action');
     } elseif (Input::query('action')) {
         $action = Input::query('action');
     }
     if ($action == 'rebuild') {
         $this->model->rebuild();
         View::setPageInfo(array('page_title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Rebuilding search index')), 'query_str' => $this->model->get_query_str()))->addTemplate('admin/maintenance/rebuild.php')->display();
     }
     if ($action == 'prune') {
         $prune_from = Utils::trim(Input::post('prune_from'));
         $prune_sticky = intval(Input::post('prune_sticky'));
         AdminUtils::generateAdminMenu('maintenance');
         if (Input::post('prune_comply')) {
             $this->model->prune_comply($prune_from, $prune_sticky);
         }
         View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Prune')), 'active_page' => 'admin', 'admin_console' => true, 'prune_sticky' => $prune_sticky, 'prune_from' => $prune_from, 'prune' => $this->model->get_info_prune($prune_sticky, $prune_from)))->addTemplate('admin/maintenance/prune.php')->display();
     }
     AdminUtils::generateAdminMenu('maintenance');
     View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Maintenance')), 'active_page' => 'admin', 'admin_console' => true, 'first_id' => $this->model->get_first_id(), 'categories' => $this->model->get_categories()))->addTemplate('admin/maintenance/admin_maintenance.php')->display();
 }
开发者ID:featherbb,项目名称:featherbb,代码行数:25,代码来源:Maintenance.php

示例3: add_category

 public function add_category()
 {
     $cat_name = Utils::trim($this->request->post('cat_name'));
     if ($cat_name == '') {
         Url::redirect($this->feather->urlFor('adminCategories'), __('Must enter name message'));
     }
     if ($this->model->add_category($cat_name)) {
         Url::redirect($this->feather->urlFor('adminCategories'), __('Category added redirect'));
     } else {
         //TODO, add error message
         Url::redirect($this->feather->urlFor('adminCategories'), __('Category added redirect'));
     }
 }
开发者ID:bohwaz,项目名称:featherbb,代码行数:13,代码来源:Categories.php

示例4: add

 public function add($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.categories.add');
     $cat_name = Utils::trim(Input::post('cat_name'));
     if ($cat_name == '') {
         return Router::redirect(Router::pathFor('adminCategories'), __('Must enter name message'));
     }
     if ($this->model->add_category($cat_name)) {
         return Router::redirect(Router::pathFor('adminCategories'), __('Category added redirect'));
     } else {
         //TODO, add error message
         return Router::redirect(Router::pathFor('adminCategories'), __('Category added redirect'));
     }
 }
开发者ID:featherbb,项目名称:featherbb,代码行数:14,代码来源:Categories.php

示例5: update_word

 public function update_word()
 {
     $id = intval(key($this->request->post('update')));
     $search_for = Utils::trim($this->request->post('search_for')[$id]);
     $replace_with = Utils::trim($this->request->post('replace_with')[$id]);
     if ($search_for == '') {
         throw new Error(__('Must enter word message'), 400);
     }
     $set_search_word = array('search_for' => $search_for, 'replace_with' => $replace_with);
     $set_search_word = $this->hook->fire('update_censoring_word_start', $set_search_word);
     $result = DB::for_table('censoring')->find_one($id)->set($set_search_word)->save();
     // Regenerate the censoring cache
     $this->feather->cache->store('search_for', Cache::get_censoring('search_for'));
     $this->feather->cache->store('replace_with', Cache::get_censoring('replace_with'));
     Url::redirect($this->feather->urlFor('adminCensoring'), __('Word updated redirect'));
 }
开发者ID:bohwaz,项目名称:featherbb,代码行数:16,代码来源:Censoring.php

示例6: update_word

 public function update_word()
 {
     $id = intval(key(Input::post('update')));
     $search_for = Utils::trim(Input::post('search_for')[$id]);
     $replace_with = Utils::trim(Input::post('replace_with')[$id]);
     if ($search_for == '') {
         throw new Error(__('Must enter word message'), 400);
     }
     $set_search_word = array('search_for' => $search_for, 'replace_with' => $replace_with);
     $set_search_word = Container::get('hooks')->fire('model.admin.censoring.update_censoring_word_start', $set_search_word);
     $result = DB::for_table('censoring')->find_one($id)->set($set_search_word)->save();
     // Regenerate the censoring cache
     Container::get('cache')->store('search_for', Cache::get_censoring('search_for'));
     Container::get('cache')->store('replace_with', Cache::get_censoring('replace_with'));
     return Router::redirect(Router::pathFor('adminCensoring'), __('Word updated redirect'));
 }
开发者ID:featherbb,项目名称:featherbb,代码行数:16,代码来源:Censoring.php

示例7: forget

 public function forget()
 {
     if (!$this->feather->user->is_guest) {
         Url::redirect($this->feather->urlFor('home'), 'Already logged in');
     }
     if ($this->feather->request->isPost()) {
         // Validate the email address
         $email = strtolower(Utils::trim($this->feather->request->post('req_email')));
         if (!$this->feather->email->is_valid_email($email)) {
             throw new Error(__('Invalid email'), 400);
         }
         $user = ModelAuth::get_user_from_email($email);
         if ($user) {
             // Load the "activate password" template
             $mail_tpl = trim(file_get_contents($this->feather->forum_env['FEATHER_ROOT'] . 'featherbb/lang/' . $this->feather->user->language . '/mail_templates/activate_password.tpl'));
             $mail_tpl = $this->feather->hooks->fire('mail_tpl_password_forgotten', $mail_tpl);
             // The first row contains the subject
             $first_crlf = strpos($mail_tpl, "\n");
             $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8));
             $mail_message = trim(substr($mail_tpl, $first_crlf));
             // Do the generic replacements first (they apply to all emails sent out here)
             $mail_message = str_replace('<base_url>', Url::base() . '/', $mail_message);
             $mail_message = str_replace('<board_mailer>', $this->feather->forum_settings['o_board_title'], $mail_message);
             $mail_message = $this->feather->hooks->fire('mail_message_password_forgotten', $mail_message);
             if ($user->last_email_sent != '' && time() - $user->last_email_sent < 3600 && time() - $user->last_email_sent >= 0) {
                 throw new Error(sprintf(__('Email flood'), intval((3600 - (time() - $user->last_email_sent)) / 60)), 429);
             }
             // Generate a new password and a new password activation code
             $new_password = Random::pass(12);
             $new_password_key = Random::pass(8);
             ModelAuth::set_new_password($new_password, $new_password_key, $user->id);
             // Do the user specific replacements to the template
             $cur_mail_message = str_replace('<username>', $user->username, $mail_message);
             $cur_mail_message = str_replace('<activation_url>', $this->feather->urlFor('profileAction', ['action' => 'change_pass']) . '?key=' . $new_password_key, $cur_mail_message);
             $cur_mail_message = str_replace('<new_password>', $new_password, $cur_mail_message);
             $cur_mail_message = $this->feather->hooks->fire('cur_mail_message_password_forgotten', $cur_mail_message);
             $this->feather->email->feather_mail($email, $mail_subject, $cur_mail_message);
             Url::redirect($this->feather->urlFor('home'), __('Forget mail') . ' <a href="mailto:' . $this->feather->utils->escape($this->feather->forum_settings['o_admin_email']) . '">' . $this->feather->utils->escape($this->feather->forum_settings['o_admin_email']) . '</a>.', 200);
         } else {
             throw new Error(__('No email match') . ' ' . Utils::escape($email) . '.', 400);
         }
     }
     $this->feather->template->setPageInfo(array('active_page' => 'login', 'title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), __('Request pass')), 'required_fields' => array('req_email' => __('Email')), 'focus_element' => array('request_pass', 'req_email')))->addTemplate('login/password_forgotten.php')->display();
 }
开发者ID:bohwaz,项目名称:featherbb,代码行数:44,代码来源:Auth.php

示例8: display

 public function display()
 {
     $action = '';
     if ($this->feather->request->post('action')) {
         $action = $this->feather->request->post('action');
     } elseif ($this->feather->request->get('action')) {
         $action = $this->feather->request->get('action');
     }
     if ($action == 'rebuild') {
         $this->model->rebuild();
         $this->feather->template->setPageInfo(array('page_title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), __('Rebuilding search index')), 'query_str' => $this->model->get_query_str()))->addTemplate('admin/maintenance/rebuild.php')->display();
     }
     if ($action == 'prune') {
         $prune_from = Utils::trim($this->feather->request->post('prune_from'));
         $prune_sticky = intval($this->feather->request->post('prune_sticky'));
         AdminUtils::generateAdminMenu('maintenance');
         if ($this->feather->request->post('prune_comply')) {
             $this->model->prune_comply($prune_from, $prune_sticky);
         }
         $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), __('Admin'), __('Prune')), 'active_page' => 'admin', 'admin_console' => true, 'prune_sticky' => $prune_sticky, 'prune_from' => $prune_from, 'prune' => $this->model->get_info_prune($prune_sticky, $prune_from)))->addTemplate('admin/maintenance/prune.php')->display();
     }
     AdminUtils::generateAdminMenu('maintenance');
     $this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), __('Admin'), __('Maintenance')), 'active_page' => 'admin', 'admin_console' => true, 'first_id' => $this->model->get_first_id(), 'categories' => $this->model->get_categories()))->addTemplate('admin/maintenance/admin_maintenance.php')->display();
 }
开发者ID:bohwaz,项目名称:featherbb,代码行数:24,代码来源:Maintenance.php

示例9:

" /><br /></label>
<?php 
}
?>
                        <label class="required"><strong><?php 
_e('Message');
?>
 <span><?php 
_e('Required');
?>
</span></strong><br />
                        <textarea name="req_message" id="req_message" rows="20" cols="95" tabindex="<?php 
echo $cur_index++;
?>
"><?php 
echo Input::post('req_message') ? Utils::linebreaks(Utils::trim(Utils::escape(Input::post('req_message')))) : (isset($quote) ? $quote : '');
?>
</textarea><br /></label>
                        <ul class="bblinks">
                            <li><span><a href="<?php 
echo Router::pathFor('help') . '#bbcode';
?>
" onclick="window.open(this.href); return false;"><?php 
_e('BBCode');
?>
ok</a> <?php 
echo ForumSettings::get('p_message_bbcode') == '1' ? __('on') : __('off');
?>
</span></li>
                            <li><span><a href="<?php 
echo Router::pathFor('help') . '#url';
开发者ID:featherbb,项目名称:featherbb,代码行数:31,代码来源:post.php

示例10: get_info_prune

 public function get_info_prune($prune_sticky, $prune_from)
 {
     $prune = array();
     $prune['days'] = Utils::trim(Input::post('req_prune_days'));
     if ($prune['days'] == '' || preg_match('%[^0-9]%', $prune['days'])) {
         throw new Error(__('Days must be integer message'), 400);
     }
     $prune['date'] = time() - $prune['days'] * 86400;
     $prune = Container::get('hooks')->fire('model.admin.maintenance.get_info_prune.prune_dates', $prune);
     // Concatenate together the query for counting number of topics to prune
     $query = DB::for_table('topics')->where_lt('last_post', $prune['date'])->where_null('moved_to');
     if ($prune_sticky == '0') {
         $query = $query->where('sticky', 0);
     }
     if ($prune_from != 'all') {
         $query = $query->where('forum_id', intval($prune_from));
         // Fetch the forum name (just for cosmetic reasons)
         $forum = DB::for_table('forums')->where('id', $prune_from);
         $forum = Container::get('hooks')->fireDB('model.admin.maintenance.get_info_prune.forum_query', $forum);
         $forum = $forum->find_one_col('forum_name');
         $prune['forum'] = '"' . Utils::escape($forum) . '"';
     } else {
         $prune['forum'] = __('All forums');
     }
     $prune['num_topics'] = $query->count('id');
     if (!$prune['num_topics']) {
         throw new Error(sprintf(__('No old topics message'), $prune['days']), 404);
     }
     $prune = Container::get('hooks')->fire('model.admin.maintenance.get_info_prune.prune', $prune);
     return $prune;
 }
开发者ID:featherbb,项目名称:featherbb,代码行数:31,代码来源:Maintenance.php

示例11: update_options

 public function update_options()
 {
     $form = array('board_title' => Utils::trim($this->request->post('form_board_title')), 'board_desc' => Utils::trim($this->request->post('form_board_desc')), 'base_url' => Utils::trim($this->request->post('form_base_url')), 'default_timezone' => floatval($this->request->post('form_default_timezone')), 'default_dst' => $this->request->post('form_default_dst') != '1' ? '0' : '1', 'default_lang' => Utils::trim($this->request->post('form_default_lang')), 'default_style' => Utils::trim($this->request->post('form_default_style')), 'time_format' => Utils::trim($this->request->post('form_time_format')), 'date_format' => Utils::trim($this->request->post('form_date_format')), 'timeout_visit' => intval($this->request->post('form_timeout_visit')) > 0 ? intval($this->request->post('form_timeout_visit')) : 1, 'timeout_online' => intval($this->request->post('form_timeout_online')) > 0 ? intval($this->request->post('form_timeout_online')) : 1, 'redirect_delay' => intval($this->request->post('form_redirect_delay')) >= 0 ? intval($this->request->post('form_redirect_delay')) : 0, 'show_version' => $this->request->post('form_show_version') != '1' ? '0' : '1', 'show_user_info' => $this->request->post('form_show_user_info') != '1' ? '0' : '1', 'show_post_count' => $this->request->post('form_show_post_count') != '1' ? '0' : '1', 'smilies' => $this->request->post('form_smilies') != '1' ? '0' : '1', 'smilies_sig' => $this->request->post('form_smilies_sig') != '1' ? '0' : '1', 'make_links' => $this->request->post('form_make_links') != '1' ? '0' : '1', 'topic_review' => intval($this->request->post('form_topic_review')) >= 0 ? intval($this->request->post('form_topic_review')) : 0, 'disp_topics_default' => intval($this->request->post('form_disp_topics_default')), 'disp_posts_default' => intval($this->request->post('form_disp_posts_default')), 'indent_num_spaces' => intval($this->request->post('form_indent_num_spaces')) >= 0 ? intval($this->request->post('form_indent_num_spaces')) : 0, 'quote_depth' => intval($this->request->post('form_quote_depth')) > 0 ? intval($this->request->post('form_quote_depth')) : 1, 'quickpost' => $this->request->post('form_quickpost') != '1' ? '0' : '1', 'users_online' => $this->request->post('form_users_online') != '1' ? '0' : '1', 'censoring' => $this->request->post('form_censoring') != '1' ? '0' : '1', 'signatures' => $this->request->post('form_signatures') != '1' ? '0' : '1', 'show_dot' => $this->request->post('form_show_dot') != '1' ? '0' : '1', 'topic_views' => $this->request->post('form_topic_views') != '1' ? '0' : '1', 'quickjump' => $this->request->post('form_quickjump') != '1' ? '0' : '1', 'gzip' => $this->request->post('form_gzip') != '1' ? '0' : '1', 'search_all_forums' => $this->request->post('form_search_all_forums') != '1' ? '0' : '1', 'additional_navlinks' => Utils::trim($this->request->post('form_additional_navlinks')), 'feed_type' => intval($this->request->post('form_feed_type')), 'feed_ttl' => intval($this->request->post('form_feed_ttl')), 'report_method' => intval($this->request->post('form_report_method')), 'mailing_list' => Utils::trim($this->request->post('form_mailing_list')), 'avatars' => $this->request->post('form_avatars') != '1' ? '0' : '1', 'avatars_dir' => Utils::trim($this->request->post('form_avatars_dir')), 'avatars_width' => intval($this->request->post('form_avatars_width')) > 0 ? intval($this->request->post('form_avatars_width')) : 1, 'avatars_height' => intval($this->request->post('form_avatars_height')) > 0 ? intval($this->request->post('form_avatars_height')) : 1, 'avatars_size' => intval($this->request->post('form_avatars_size')) > 0 ? intval($this->request->post('form_avatars_size')) : 1, 'admin_email' => strtolower(Utils::trim($this->request->post('form_admin_email'))), 'webmaster_email' => strtolower(Utils::trim($this->request->post('form_webmaster_email'))), 'forum_subscriptions' => $this->request->post('form_forum_subscriptions') != '1' ? '0' : '1', 'topic_subscriptions' => $this->request->post('form_topic_subscriptions') != '1' ? '0' : '1', 'smtp_host' => Utils::trim($this->request->post('form_smtp_host')), 'smtp_user' => Utils::trim($this->request->post('form_smtp_user')), 'smtp_ssl' => $this->request->post('form_smtp_ssl') != '1' ? '0' : '1', 'regs_allow' => $this->request->post('form_regs_allow') != '1' ? '0' : '1', 'regs_verify' => $this->request->post('form_regs_verify') != '1' ? '0' : '1', 'regs_report' => $this->request->post('form_regs_report') != '1' ? '0' : '1', 'rules' => $this->request->post('form_rules') != '1' ? '0' : '1', 'rules_message' => Utils::trim($this->request->post('form_rules_message')), 'default_email_setting' => intval($this->request->post('form_default_email_setting')), 'announcement' => $this->request->post('form_announcement') != '1' ? '0' : '1', 'announcement_message' => Utils::trim($this->request->post('form_announcement_message')), 'maintenance' => $this->request->post('form_maintenance') != '1' ? '0' : '1', 'maintenance_message' => Utils::trim($this->request->post('form_maintenance_message')));
     $form = $this->hook->fire('options.update_options.form', $form);
     if ($form['board_title'] == '') {
         throw new Error(__('Must enter title message'), 400);
     }
     // Make sure base_url doesn't end with a slash
     if (substr($form['base_url'], -1) == '/') {
         $form['base_url'] = substr($form['base_url'], 0, -1);
     }
     // Convert IDN to Punycode if needed
     if (preg_match('/[^\\x00-\\x7F]/', $form['base_url'])) {
         if (!function_exists('idn_to_ascii')) {
             throw new Error(__('Base URL problem'), 400);
         } else {
             $form['base_url'] = idn_to_ascii($form['base_url']);
         }
     }
     $languages = \FeatherBB\Core\Lister::getLangs();
     if (!in_array($form['default_lang'], $languages)) {
         throw new Error(__('Bad request'), 404);
     }
     $styles = \FeatherBB\Core\Lister::getStyles();
     if (!in_array($form['default_style'], $styles)) {
         throw new Error(__('Bad request'), 404);
     }
     if ($form['time_format'] == '') {
         $form['time_format'] = 'H:i:s';
     }
     if ($form['date_format'] == '') {
         $form['date_format'] = 'Y-m-d';
     }
     if (!$this->email->is_valid_email($form['admin_email'])) {
         throw new Error(__('Invalid e-mail message'), 400);
     }
     if (!$this->email->is_valid_email($form['webmaster_email'])) {
         throw new Error(__('Invalid webmaster e-mail message'), 400);
     }
     if ($form['mailing_list'] != '') {
         $form['mailing_list'] = strtolower(preg_replace('%\\s%S', '', $form['mailing_list']));
     }
     // Make sure avatars_dir doesn't end with a slash
     if (substr($form['avatars_dir'], -1) == '/') {
         $form['avatars_dir'] = substr($form['avatars_dir'], 0, -1);
     }
     if ($form['additional_navlinks'] != '') {
         $form['additional_navlinks'] = Utils::trim(Utils::linebreaks($form['additional_navlinks']));
     }
     // Change or enter a SMTP password
     if ($this->request->post('form_smtp_change_pass')) {
         $smtp_pass1 = $this->request->post('form_smtp_pass1') ? Utils::trim($this->request->post('form_smtp_pass1')) : '';
         $smtp_pass2 = $this->request->post('form_smtp_pass2') ? Utils::trim($this->request->post('form_smtp_pass2')) : '';
         if ($smtp_pass1 == $smtp_pass2) {
             $form['smtp_pass'] = $smtp_pass1;
         } else {
             throw new Error(__('SMTP passwords did not match'), 400);
         }
     }
     if ($form['announcement_message'] != '') {
         $form['announcement_message'] = Utils::linebreaks($form['announcement_message']);
     } else {
         $form['announcement_message'] = __('Enter announcement here');
         $form['announcement'] = '0';
     }
     if ($form['rules_message'] != '') {
         $form['rules_message'] = Utils::linebreaks($form['rules_message']);
     } else {
         $form['rules_message'] = __('Enter rules here');
         $form['rules'] = '0';
     }
     if ($form['maintenance_message'] != '') {
         $form['maintenance_message'] = Utils::linebreaks($form['maintenance_message']);
     } else {
         $form['maintenance_message'] = __('Default maintenance message');
         $form['maintenance'] = '0';
     }
     // Make sure the number of displayed topics and posts is between 3 and 75
     if ($form['disp_topics_default'] < 3) {
         $form['disp_topics_default'] = 3;
     } elseif ($form['disp_topics_default'] > 75) {
         $form['disp_topics_default'] = 75;
     }
     if ($form['disp_posts_default'] < 3) {
         $form['disp_posts_default'] = 3;
     } elseif ($form['disp_posts_default'] > 75) {
         $form['disp_posts_default'] = 75;
     }
     if ($form['feed_type'] < 0 || $form['feed_type'] > 2) {
         throw new Error(__('Bad request'), 400);
     }
     if ($form['feed_ttl'] < 0) {
         throw new Error(__('Bad request'), 400);
     }
     if ($form['report_method'] < 0 || $form['report_method'] > 2) {
         throw new Error(__('Bad request'), 400);
     }
     if ($form['default_email_setting'] < 0 || $form['default_email_setting'] > 2) {
         throw new Error(__('Bad request'), 400);
     }
//.........这里部分代码省略.........
开发者ID:bohwaz,项目名称:featherbb,代码行数:101,代码来源:Options.php

示例12: edit_positions

 public function edit_positions($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.forums.edit_positions');
     foreach (Input::post('position') as $args['forum_id'] => $position) {
         $position = (int) Utils::trim($position);
         $this->model->update_positions($args['forum_id'], $position);
     }
     // Regenerate the quick jump cache
     Container::get('cache')->store('quickjump', Cache::get_quickjump());
     return Router::redirect(Router::pathFor('adminForums'), __('Forums updated redirect'));
 }
开发者ID:featherbb,项目名称:featherbb,代码行数:11,代码来源:Forums.php

示例13: insert_report

 public function insert_report($post_id)
 {
     $post_id = $this->hook->fire('insert_report_start', $post_id);
     // Clean up reason from POST
     $reason = Utils::linebreaks(Utils::trim($this->request->post('req_reason')));
     if ($reason == '') {
         throw new Error(__('No reason'), 400);
     } elseif (strlen($reason) > 65535) {
         // TEXT field can only hold 65535 bytes
         throw new Error(__('Reason too long'), 400);
     }
     if ($this->user->last_report_sent != '' && time() - $this->user->last_report_sent < $this->user->g_report_flood && time() - $this->user->last_report_sent >= 0) {
         throw new Error(sprintf(__('Report flood'), $this->user->g_report_flood, $this->user->g_report_flood - (time() - $this->user->last_report_sent)), 429);
     }
     // Get the topic ID
     $topic = DB::for_table('posts')->select('topic_id')->where('id', $post_id);
     $topic = $this->hook->fireDB('insert_report_topic_id', $topic);
     $topic = $topic->find_one();
     if (!$topic) {
         throw new Error(__('Bad request'), 404);
     }
     // Get the subject and forum ID
     $report['select'] = array('subject', 'forum_id');
     $report = DB::for_table('topics')->select_many($report['select'])->where('id', $topic['topic_id']);
     $report = $this->hook->fireDB('insert_report_get_subject', $report);
     $report = $report->find_one();
     if (!$report) {
         throw new Error(__('Bad request'), 404);
     }
     // Should we use the internal report handling?
     if ($this->config['o_report_method'] == '0' || $this->config['o_report_method'] == '2') {
         // Insert the report
         $query['insert'] = array('post_id' => $post_id, 'topic_id' => $topic['topic_id'], 'forum_id' => $report['forum_id'], 'reported_by' => $this->user->id, 'created' => time(), 'message' => $reason);
         $query = DB::for_table('reports')->create()->set($query['insert']);
         $query = $this->hook->fireDB('insert_report_query', $query);
         $query = $query->save();
     }
     // Should we email the report?
     if ($this->config['o_report_method'] == '1' || $this->config['o_report_method'] == '2') {
         // We send it to the complete mailing-list in one swoop
         if ($this->config['o_mailing_list'] != '') {
             // Load the "new report" template
             $mail_tpl = trim(file_get_contents($this->feather->forum_env['FEATHER_ROOT'] . 'featherbb/lang/' . $this->user->language . '/mail_templates/new_report.tpl'));
             $mail_tpl = $this->hook->fire('insert_report_mail_tpl', $mail_tpl);
             // The first row contains the subject
             $first_crlf = strpos($mail_tpl, "\n");
             $mail_subject = trim(substr($mail_tpl, 8, $first_crlf - 8));
             $mail_message = trim(substr($mail_tpl, $first_crlf));
             $mail_subject = str_replace('<forum_id>', $report['forum_id'], $mail_subject);
             $mail_subject = str_replace('<topic_subject>', $report['subject'], $mail_subject);
             $mail_message = str_replace('<username>', $this->user->username, $mail_message);
             $mail_message = str_replace('<post_url>', $this->feather->urlFor('viewPost', ['pid' => $post_id]) . '#p' . $post_id, $mail_message);
             $mail_message = str_replace('<reason>', $reason, $mail_message);
             $mail_message = str_replace('<board_mailer>', $this->config['o_board_title'], $mail_message);
             $mail_message = $this->hook->fire('insert_report_mail_message', $mail_message);
             $this->email->feather_mail($this->config['o_mailing_list'], $mail_subject, $mail_message);
         }
     }
     $last_report_sent = DB::for_table('users')->where('id', $this->user->id)->find_one()->set('last_report_sent', time());
     $last_report_sent = $this->hook->fireDB('insert_last_report_sent', $last_report_sent);
     $last_report_sent = $last_report_sent->save();
     Url::redirect($this->feather->urlFor('viewPost', ['pid' => $post_id]) . '#p' . $post_id, __('Report redirect'));
 }
开发者ID:bohwaz,项目名称:featherbb,代码行数:63,代码来源:Misc.php

示例14: split_posts

 public function split_posts($tid, $fid, $p = null)
 {
     $posts = $this->request->post('posts') ? $this->request->post('posts') : array();
     $posts = $this->hook->fire('split_posts_start', $posts, $tid, $fid);
     if (empty($posts)) {
         throw new Error(__('No posts selected'), 404);
     }
     if ($this->request->post('split_posts_comply')) {
         if (@preg_match('%[^0-9,]%', $posts)) {
             throw new Error(__('Bad request'), 400);
         }
         $move_to_forum = $this->request->post('move_to_forum') ? intval($this->request->post('move_to_forum')) : 0;
         if ($move_to_forum < 1) {
             throw new Error(__('Bad request'), 400);
         }
         // How many posts did we just split off?
         $num_posts_splitted = substr_count($posts, ',') + 1;
         // Verify that the post IDs are valid
         $posts_array = explode(',', $posts);
         $result = DB::for_table('posts')->where_in('id', $posts_array)->where('topic_id', $tid);
         $result = $this->hook->fireDB('split_posts_first_query', $result);
         $result = $result->find_many();
         if (count($result) != $num_posts_splitted) {
             throw new Error(__('Bad request'), 400);
         }
         unset($result);
         // Verify that the move to forum ID is valid
         $result['where'] = array(array('fp.post_topics' => 'IS NULL'), array('fp.post_topics' => '1'));
         $result = DB::for_table('forums')->table_alias('f')->left_outer_join('forum_perms', array('fp.forum_id', '=', $move_to_forum), 'fp', true)->left_outer_join('forum_perms', array('fp.group_id', '=', $this->user->g_id), null, true)->where_any_is($result['where'])->where_null('f.redirect_url');
         $result = $this->hook->fireDB('split_posts_second_query', $result);
         $result = $result->find_one();
         if (!$result) {
             throw new Error(__('Bad request'), 404);
         }
         // Check subject
         $new_subject = $this->request->post('new_subject') ? Utils::trim($this->request->post('new_subject')) : '';
         if ($new_subject == '') {
             throw new Error(__('No subject'), 400);
         } elseif (Utils::strlen($new_subject) > 70) {
             throw new Error(__('Too long subject'), 400);
         }
         // Get data from the new first post
         $select_first_post = array('id', 'poster', 'posted');
         $first_post_data = DB::for_table('posts')->select_many($select_first_post)->where_in('id', $posts_array)->order_by_asc('id')->find_one();
         // Create the new topic
         $topic['insert'] = array('poster' => $first_post_data['poster'], 'subject' => $new_subject, 'posted' => $first_post_data['posted'], 'first_post_id' => $first_post_data['id'], 'forum_id' => $move_to_forum);
         $topic = DB::for_table('topics')->create()->set($topic['insert']);
         $topic = $this->hook->fireDB('split_posts_topic_query', $topic);
         $topic = $topic->save();
         $new_tid = DB::get_db()->lastInsertId($this->feather->forum_settings['db_prefix'] . 'topics');
         // Move the posts to the new topic
         $move_posts = DB::for_table('posts')->where_in('id', $posts_array)->find_one()->set('topic_id', $new_tid);
         $move_posts = $this->hook->fireDB('split_posts_move_query', $move_posts);
         $move_posts = $move_posts->save();
         // Apply every subscription to both topics
         DB::for_table('topic_subscriptions')->raw_query('INSERT INTO ' . $this->feather->forum_settings['db_prefix'] . 'topic_subscriptions (user_id, topic_id) SELECT user_id, ' . $new_tid . ' FROM ' . $this->feather->forum_settings['db_prefix'] . 'topic_subscriptions WHERE topic_id=:tid', array('tid' => $tid));
         // Get last_post, last_post_id, and last_poster from the topic and update it
         $last_old_post_data['select'] = array('id', 'poster', 'posted');
         $last_old_post_data = DB::for_table('posts')->select_many($last_old_post_data['select'])->where('topic_id', $tid)->order_by_desc('id');
         $last_old_post_data = $this->hook->fireDB('split_posts_last_old_post_data_query', $last_old_post_data);
         $last_old_post_data = $last_old_post_data->find_one();
         // Update the old topic
         $update_old_topic['insert'] = array('last_post' => $last_old_post_data['posted'], 'last_post_id' => $last_old_post_data['id'], 'last_poster' => $last_old_post_data['poster']);
         $update_old_topic = DB::for_table('topics')->where('id', $tid)->find_one()->set($update_old_topic['insert'])->set_expr('num_replies', 'num_replies-' . $num_posts_splitted);
         $update_old_topic = $this->hook->fireDB('split_posts_update_old_topic_query', $update_old_topic);
         $update_old_topic = $update_old_topic->save();
         // Get last_post, last_post_id, and last_poster from the new topic and update it
         $last_new_post_data['select'] = array('id', 'poster', 'posted');
         $last_new_post_data = DB::for_table('posts')->select_many($last_new_post_data['select'])->where('topic_id', $new_tid)->order_by_desc('id');
         $last_new_post_data = $this->hook->fireDB('split_posts_last_new_post_query', $last_new_post_data);
         $last_new_post_data = $last_new_post_data->find_one();
         // Update the new topic
         $update_new_topic['insert'] = array('last_post' => $last_new_post_data['posted'], 'last_post_id' => $last_new_post_data['id'], 'last_poster' => $last_new_post_data['poster']);
         $update_new_topic = DB::for_table('topics')->where('id', $new_tid)->find_one()->set($update_new_topic['insert'])->set_expr('num_replies', 'num_replies-' . $num_posts_splitted - 1);
         $update_new_topic = $this->hook->fireDB('split_posts_update_new_topic_query', $update_new_topic);
         $update_new_topic = $update_new_topic->save();
         Forum::update($fid);
         Forum::update($move_to_forum);
         Url::redirect($this->feather->urlFor('Topic', array('id' => $new_tid)), __('Split posts redirect'));
     }
     $posts = $this->hook->fire('split_posts', $posts);
     return $posts;
 }
开发者ID:bohwaz,项目名称:featherbb,代码行数:83,代码来源:Moderate.php

示例15: get_user_search

 public function get_user_search()
 {
     $form = $this->request->get('form') ? $this->request->get('form') : array();
     $form = $this->hook->fire('model.users.get_user_search.form', $form);
     $search = array();
     // trim() all elements in $form
     $form = array_map('trim', $form);
     $posts_greater = $this->request->get('posts_greater') ? Utils::trim($this->request->get('posts_greater')) : '';
     $posts_less = $this->request->get('posts_less') ? Utils::trim($this->request->get('posts_less')) : '';
     $last_post_after = $this->request->get('last_post_after') ? Utils::trim($this->request->get('last_post_after')) : '';
     $last_post_before = $this->request->get('last_post_before') ? Utils::trim($this->request->get('last_post_before')) : '';
     $last_visit_after = $this->request->get('last_visit_after') ? Utils::trim($this->request->get('last_visit_after')) : '';
     $last_visit_before = $this->request->get('last_visit_before') ? Utils::trim($this->request->get('last_visit_before')) : '';
     $registered_after = $this->request->get('registered_after') ? Utils::trim($this->request->get('registered_after')) : '';
     $registered_before = $this->request->get('registered_before') ? Utils::trim($this->request->get('registered_before')) : '';
     $order_by = $search['order_by'] = $this->request->get('order_by') && in_array($this->request->get('order_by'), array('username', 'email', 'num_posts', 'last_post', 'last_visit', 'registered')) ? $this->request->get('order_by') : 'username';
     $direction = $search['direction'] = $this->request->get('direction') && $this->request->get('direction') == 'DESC' ? 'DESC' : 'ASC';
     $user_group = $this->request->get('user_group') ? intval($this->request->get('user_group')) : -1;
     $search['query_str'][] = 'order_by=' . $order_by;
     $search['query_str'][] = 'direction=' . $direction;
     $search['query_str'][] = 'user_group=' . $user_group;
     if (preg_match('%[^0-9]%', $posts_greater . $posts_less)) {
         throw new Error(__('Non numeric message'), 400);
     }
     $search['conditions'] = array();
     // Try to convert date/time to timestamps
     if ($last_post_after != '') {
         $search['query_str'][] = 'last_post_after=' . $last_post_after;
         $last_post_after = strtotime($last_post_after);
         if ($last_post_after === false || $last_post_after == -1) {
             throw new Error(__('Invalid date time message'), 400);
         }
         $search['conditions'][] = 'u.last_post>' . $last_post_after;
     }
     if ($last_post_before != '') {
         $search['query_str'][] = 'last_post_before=' . $last_post_before;
         $last_post_before = strtotime($last_post_before);
         if ($last_post_before === false || $last_post_before == -1) {
             throw new Error(__('Invalid date time message'), 400);
         }
         $search['conditions'][] = 'u.last_post<' . $last_post_before;
     }
     if ($last_visit_after != '') {
         $search['query_str'][] = 'last_visit_after=' . $last_visit_after;
         $last_visit_after = strtotime($last_visit_after);
         if ($last_visit_after === false || $last_visit_after == -1) {
             throw new Error(__('Invalid date time message'), 400);
         }
         $search['conditions'][] = 'u.last_visit>' . $last_visit_after;
     }
     if ($last_visit_before != '') {
         $search['query_str'][] = 'last_visit_before=' . $last_visit_before;
         $last_visit_before = strtotime($last_visit_before);
         if ($last_visit_before === false || $last_visit_before == -1) {
             throw new Error(__('Invalid date time message'), 400);
         }
         $search['conditions'][] = 'u.last_visit<' . $last_visit_before;
     }
     if ($registered_after != '') {
         $search['query_str'][] = 'registered_after=' . $registered_after;
         $registered_after = strtotime($registered_after);
         if ($registered_after === false || $registered_after == -1) {
             throw new Error(__('Invalid date time message'), 400);
         }
         $search['conditions'][] = 'u.registered>' . $registered_after;
     }
     if ($registered_before != '') {
         $search['query_str'][] = 'registered_before=' . $registered_before;
         $registered_before = strtotime($registered_before);
         if ($registered_before === false || $registered_before == -1) {
             throw new Error(__('Invalid date time message'), 400);
         }
         $search['conditions'][] = 'u.registered<' . $registered_before;
     }
     $like_command = $this->feather->forum_settings['db_type'] == 'pgsql' ? 'ILIKE' : 'LIKE';
     foreach ($form as $key => $input) {
         if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note'))) {
             $search['conditions'][] = 'u.' . str_replace("'", "''", $key) . ' ' . $like_command . ' \'' . str_replace("'", "''", str_replace('*', '%', $input)) . '\'';
             $search['query_str'][] = 'form%5B' . $key . '%5D=' . urlencode($input);
         }
     }
     if ($posts_greater != '') {
         $search['query_str'][] = 'posts_greater=' . $posts_greater;
         $search['conditions'][] = 'u.num_posts>' . $posts_greater;
     }
     if ($posts_less != '') {
         $search['query_str'][] = 'posts_less=' . $posts_less;
         $search['conditions'][] = 'u.num_posts<' . $posts_less;
     }
     if ($user_group > -1) {
         $search['conditions'][] = 'u.group_id=' . $user_group;
     }
     $search = $this->hook->fire('model.users.get_user_search.search', $search);
     return $search;
 }
开发者ID:bohwaz,项目名称:featherbb,代码行数:95,代码来源:Users.php


注:本文中的FeatherBB\Core\Utils::trim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。