예제 #1
0
 /**
  * Editor window for creating a revision
  *
  * @param  string  $urlkey
  * @return \Illuminate\Support\Facades\View|\Illuminate\Support\Facades\Redirect
  */
 public function getRevision($urlkey)
 {
     $paste = Paste::where('urlkey', $urlkey)->first();
     // Paste was not found
     if (is_null($paste)) {
         App::abort(404);
         // Not found
     } else {
         // We only allow the user to revise public pastes
         // Private pastes need to be toggled before being revised
         if ($paste->private or $paste->password) {
             Session::flash('messages.error', Lang::get('create.revise_private'));
             return Redirect::to(URL::previous())->withInput();
         }
         // Now that we are good, we save the paste ID in session so that
         // when the edited paste is POSTed, we can validate against this
         Session::put('paste.revision', $paste->id);
     }
     // Output the view
     $data = array('languages' => Highlighter::make()->languages(), 'language' => 'text', 'paste' => $paste, 'action' => 'CreateController@postRevision', 'disabled' => 'disabled', 'attach' => FALSE);
     return View::make('site/create', $data);
 }
예제 #2
0
 /**
  * Creates a new paste via the API
  *
  * @param  string  $mode
  * @return \Illuminate\Support\Facades\View
  */
 public function postCreate($mode)
 {
     $api = API::make($mode);
     // Set custom messages for validation module
     $custom = array('title.max' => 'title_max_30', 'data.required' => 'data_required', 'data.auth' => 'cannot_post', 'data.mbmax' => 'data_too_big', 'language.required' => 'lang_required', 'language.in' => 'lang_invalid', 'expire.integer' => 'expire_integer', 'expire.in' => 'expire_invalid');
     // Define validation rules
     $validator = Validator::make(Input::all(), array('title' => 'max:30', 'data' => 'required|auth|mbmax:' . Site::config('general')->maxPasteSize, 'language' => 'required|in:' . Highlighter::make()->languages(TRUE), 'expire' => 'integer|in:' . Paste::getExpiration('create', TRUE)), $custom);
     // Run validations
     if ($validator->fails()) {
         return $api->error($validator->messages()->first());
     }
     // Set custom messages for the antispam module
     $custom = array('ipban' => 'antispam_ipban', 'stealth' => 'antispam_stealth', 'censor' => 'antispam_censor', 'noflood' => 'antispam_noflood', 'php' => 'antispam_php');
     // Instantiate the antispam module
     $antispam = Antispam::make('api_call', 'data', $custom);
     // Run the anti-spam modules
     if ($antispam->fails()) {
         return $api->error($antispam->message());
     }
     // Create the paste like a boss!
     $paste = Paste::createNew('api', Input::all());
     // All done! Now we need to output the urlkey and hash
     $data = array('urlkey' => $paste->urlkey, 'hash' => $paste->hash);
     // Return the output
     return $api->out('create', $data);
 }