protected function seedConfig() { // Enable/disable avatars depending on file_uploads setting in PHP configuration $avatars = in_array(strtolower(@ini_get('file_uploads')), array('on', 'true', '1')) ? 1 : 0; // Insert config data $config = array('o_cur_version' => FLUXBB_VERSION, 'o_board_title' => trans('fluxbb::seed_data.board_title'), 'o_board_desc' => trans('fluxbb::seed_data.board_desc'), 'o_default_timezone' => 0, 'o_time_format' => 'H:i:s', 'o_date_format' => 'Y-m-d', 'o_timeout_visit' => 1800, 'o_timeout_online' => 300, 'o_redirect_delay' => 1, 'o_show_version' => 0, 'o_show_user_info' => 1, 'o_show_post_count' => 1, 'o_signatures' => 1, 'o_smilies' => 1, 'o_smilies_sig' => 1, 'o_make_links' => 1, 'o_default_lang' => Laravel\Config::get('application.language'), 'o_default_style' => 'Air', 'o_default_user_group' => 4, 'o_topic_review' => 15, 'o_disp_topics_default' => 30, 'o_disp_posts_default' => 25, 'o_indent_num_spaces' => 4, 'o_quote_depth' => 3, 'o_quickpost' => 1, 'o_users_online' => 1, 'o_show_dot' => 0, 'o_topic_views' => 1, 'o_quickjump' => 1, 'o_gzip' => 0, 'o_additional_navlinks' => '', 'o_report_method' => 0, 'o_regs_report' => 0, 'o_default_email_setting' => 1, 'o_mailing_list' => 'email', 'o_avatars' => $avatars, 'o_avatars_dir' => 'img/avatars', 'o_avatars_width' => 60, 'o_avatars_height' => 60, 'o_avatars_size' => 10240, 'o_search_all_forums' => 1, 'o_admin_email' => 'email', 'o_webmaster_email' => 'email', 'o_forum_subscriptions' => 1, 'o_topic_subscriptions' => 1, 'o_smtp_host' => null, 'o_smtp_user' => null, 'o_smtp_pass' => null, 'o_smtp_ssl' => 0, 'o_regs_allow' => 1, 'o_regs_verify' => 0, 'o_announcement' => 0, 'o_announcement_message' => trans('fluxbb::seed_data.announcement'), 'o_rules' => 0, 'o_rules_message' => trans('fluxbb::seed_data.rules'), 'o_maintenance' => 0, 'o_maintenance_message' => trans('fluxbb::seed_data.maintenance_message'), 'o_default_dst' => 0, 'o_feed_type' => 2, 'o_feed_ttl' => 0, 'p_message_bbcode' => 1, 'p_message_img_tag' => 1, 'p_message_all_caps' => 1, 'p_subject_all_caps' => 1, 'p_sig_all_caps' => 1, 'p_sig_bbcode' => 1, 'p_sig_img_tag' => 0, 'p_sig_length' => 400, 'p_sig_lines' => 4, 'p_allow_banned_email' => 1, 'p_allow_dupe_email' => 0, 'p_force_guest_email' => 1); foreach ($config as $conf_name => $conf_value) { Config::set($conf_name, $conf_value); } Config::save(); }
/** * Run the action and return a response for the user. * * @return void */ protected function run() { $rules = $this->getValidationRules(); $validation = $this->validator->make($this->input, $rules); if ($validation->fails()) { return $this->mergeErrors($validation->errors()); } $userData = array('username' => $this->input['user'], 'group_id' => Config::get('o_default_user_group'), 'password' => $this->input['password'], 'email' => $this->input['email'], 'email_setting' => Config::get('o_default_email_setting'), 'timezone' => Config::get('o_default_timezone'), 'dst' => Config::get('o_default_dst'), 'language' => Config::get('o_default_lang'), 'style' => Config::get('o_default_style'), 'registration_ip' => $this->request->getClientIp(), 'last_visit' => $this->request->server('REQUEST_TIME', time())); $user = User::create($userData); $this->trigger('user.registered', array($user)); }
public function subscribe($subscribe = true) { // To subscribe or not to subscribe, that ... if (!Config::enabled('o_topic_subscriptions') || !Auth::check()) { return false; } if ($subscribe && !$this->isUserSubscribed()) { $this->subscription()->insert(array('user_id' => User::current()->id)); } elseif (!$subscribe && $this->isUserSubscribed()) { $this->subscription()->delete(); } }
public function postBoardConfig() { $rules = array('board_title' => 'required', 'board_description' => 'required'); $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { return Response::json(array('status' => 'failed', 'errors' => $validation->errors())); } Config::set('o_board_title', Input::get('board_title')); Config::set('o_board_desc', Input::get('board_description')); Config::save(); return 'success'; }
/** * Delete all expired sessions from persistent storage. * * @param int $expiration * @return void */ public function sweep($expiration) { $expiration = Request::time() - Config::get('o_timeout_online'); // Fetch all sessions that are older than o_timeout_online $result = $this->table()->where('user_id', '!=', 1)->where('last_visit', '<', $expiration)->get(); $delete_ids = array(); foreach ($result as $cur_session) { $delete_ids[] = $cur_session->id; $result = $this->connection->table('users')->where_id($cur_session->user_id)->update(array('last_visit' => $cur_session->last_visit)); } // Make sure logged-in users have no more than ten sessions alive if (Auth::check()) { $uid = User::current()->id; $session_ids = $this->table()->where_user_id($uid)->order_by('last_visit', 'desc')->lists('id'); $prune_ids = array_slice($session_ids, 10); $delete_ids = array_merge($delete_ids, $prune_ids); } if (!empty($delete_ids)) { $this->table()->where_in('id', $delete_ids)->or_where('last_visit', '<', $expiration)->delete(); } }
public function post_register() { $rules = array('user' => 'Required|Between:2,25|username_not_guest|no_ip|username_not_reserved|no_bbcode|not_censored|Unique:users,username|username_not_banned'); // If email confirmation is enabled if (Config::enabled('o_regs_verify')) { $rules['email'] = 'Required|Email|Confirmed|unique:users,email|email_not_banned'; } else { $rules['password'] = '******'; $rules['email'] = 'Required|Email|Unique:users,email'; } // Agree to forum rules if (Config::enabled('o_rules')) { $rules['rules'] = 'Accepted'; } $validation = $this->make_validator(\Input::all(), $rules); if ($validation->fails()) { return \Redirect::route('register')->withInput(\Input::all())->with('errors', $validation->getMessages()); } $user_data = array('username' => \Input::get('user'), 'group_id' => Config::enabled('o_regs_verify') ? Group::UNVERIFIED : Config::get('o_default_user_group'), 'password' => \Input::get('password'), 'email' => \Input::get('email'), 'email_setting' => Config::get('o_default_email_setting'), 'timezone' => Config::get('o_default_timezone'), 'dst' => Config::get('o_default_dst'), 'language' => Config::get('o_default_lang'), 'style' => Config::get('o_default_style'), 'registered' => \Request::time(), 'registration_ip' => \Request::ip(), 'last_visit' => \Request::time()); $user = User::create($user_data); return \Redirect::action('fluxbb::home@index')->with('message', trans('fluxbb::register.reg_complete')); }
public function put_topic($fid) { $forum = Forum::with(array('perms'))->where('id', '=', $fid)->first(); if ($forum === NULL) { return \Event::first('404'); } // TODO: Flood protection $rules = array('req_subject' => 'required|max:70', 'req_message' => 'required'); // TODO: More validation if (\Auth::isGuest()) { if (Config::enabled('p_force_guest_email') || \Input::get('email') != '') { $rules['req_email'] = 'required|email'; } // TODO: banned email } $validation = $this->make_validator(Input::all(), $rules); if ($validation->fails()) { return \Redirect::to_action('fluxbb::posting@topic', array($fid))->with_input()->with_errors($validation); } $topic_data = array('poster' => User::current()->username, 'subject' => \Input::get('req_subject'), 'posted' => \Request::time(), 'last_post' => \Request::time(), 'last_poster' => User::current()->username, 'sticky' => \Input::get('stick_topic') ? '1' : '0', 'forum_id' => $fid); if (\Auth::isGuest()) { $topic_data['poster'] = $topic_data['last_poster'] = \Input::get('req_username'); } // Create the topic $topic = Topic::create($topic_data); // To subscribe or not to subscribe $topic->subscribe(\Input::get('subscribe')); $post_data = array('poster' => User::current()->username, 'poster_id' => User::current()->id, 'poster_ip' => \Request::ip(), 'message' => \Input::get('req_message'), 'hide_smilies' => \Input::get('hide_smilies') ? '1' : '0', 'posted' => \Request::time(), 'topic_id' => $topic->id); if (\Auth::isGuest()) { $post_data['poster'] = \Input::get('req_username'); $post_data['poster_email'] = Config::enabled('p_force_guest_email') ? \Input::get('req_email') : \Input::get('email'); } // Create the post ("topic post") $post = Post::create($post_data); // Update the topic with last_post_id $topic->last_post_id = $topic->first_post_id = $post->id; $topic->save(); // Update forum (maybe $forum->update_forum() ?) $forum->num_posts += 1; $forum->num_topics += 1; $forum->last_post = $topic->last_post; $forum->last_post_id = $topic->last_post_id; $forum->last_poster = $topic->last_poster; $forum->save(); // TODO: update_search_index(); // If the posting user is logged in, increment his/her post count $user = User::current(); if (\Auth::isAuthed()) { $user->num_posts += 1; $user->last_post = \Request::time(); $user->save(); // TODO: Promote this user to a new group if enabled } else { $user->online()->update(array('last_post' => \Request::time())); } return \Redirect::to_action('fluxbb::topic', array($topic->id))->with('message', trans('fluxbb::topic.topic_added')); }
public function dispPosts() { return $this->disp_posts ?: Config::get('o_disp_posts_default'); }
protected function update_version($new_version) { Config::set('o_cur_version', $new_version); Config::save(); }
<?php use FluxBB\Models\Config; use FluxBB\Core; View::composer('fluxbb::layout.main', function ($view) { $view->with('language', trans('fluxbb::common.lang_identifier'))->with('direction', trans('fluxbb::common.lang_direction'))->with('charset', \Config::get('fluxbb.database.charset'))->with('head', '')->with('page', 'index')->with('board_title', Config::get('o_board_title'))->with('board_description', Config::get('o_board_desc'))->with('navlinks', '<ul><li><a href="#">Home</a></li></ul>')->with('status', 'You are not logged in.')->with('announcement', ''); }); View::composer('fluxbb::user.profile.menu', function ($view) { $items = array('essentials' => trans('fluxbb::profile.section_essentials'), 'personal' => trans('fluxbb::profile.section_personal'), 'personality' => trans('fluxbb::profile.section_personality'), 'display' => trans('fluxbb::profile.section_display'), 'privacy' => trans('fluxbb::profile.section_privacy')); if (Auth::check() && Auth::user()->isAdmin()) { $items['admin'] = trans('fluxbb::profile.section_admin'); } // TODO: Determine current action $view->with('action', 'profile')->with('items', $items); }); View::composer('fluxbb::admin.layout.main', function ($view) { $view->with('language', trans('fluxbb::common.lang_identifier'))->with('direction', trans('fluxbb::common.lang_direction'))->with('charset', \Config::get('fluxbb.database.charset'))->with('board_title', Config::get('o_board_title'))->with('board_description', Config::get('o_board_desc'))->with('version', Core::version()); });
protected function handleRequest(Request $request) { $this->data['rules'] = Config::get('o_rules_message'); }