/** * Handles POST requests to the antispam config form * * @access public * @return \Illuminate\Support\Facades\Redirect */ public function postAntispam() { // Define Akismet key validation logic Validator::extend('akismet_key', function ($attribute, $value, $parameters) { $akismet = new Akismet(Request::url(), $value); return $akismet->isKeyValid(); }); // Define validation rules $validator = Validator::make(Input::all(), array('php_key' => 'required_if:flag_php,1', 'php_days' => 'required_if:flag_php,1|integer|between:0,255', 'php_score' => 'required_if:flag_php,1|integer|between:0,255', 'php_type' => 'required_if:flag_php,1|integer|between:0,255', 'flood_threshold' => 'required_if:flag_noflood,1|integer|between:0,60', 'akismet_key' => 'required_if:flag_akismet,1|akismet_key')); // Run the validator if ($validator->passes()) { $services = Antispam::services(); $flags = array(); // Convert the service flags to CSV foreach ($services as $service) { if (Input::has('flag_' . $service)) { $flags[] = $service; } } // Inject flag data to the configuration $config = array_merge(Input::all(), array('services' => implode('|', $flags))); Site::config('antispam', $config); Session::flash('messages.success', Lang::get('admin.antispam_updated')); return Redirect::to('admin/antispam'); } else { Session::flash('messages.error', $validator->messages()->all('<p>:message</p>')); return Redirect::to('admin/antispam')->withInput(); } }