/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDelete($id) { if (Session::get('user_level') < Config::get('cms.deleteMemes')) { return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning'); } try { $meme = Meme::findOrFail($id); $meme->instances()->delete(); $meme->delete(); return Redirect::to(_l(URL::action('MemeController@getIndex')))->with('message', Lang::get('admin.memeDeleted'))->with('notif', 'success'); } catch (Exception $e) { return Redirect::to(_l(URL::action('MemeController@getIndex')))->with('message', Lang::get('admin.noSuchMeme'))->with('notif', 'danger'); } }
/** * Store a newly created resource in storage. * POST /frontend/publicmeme * * @return Response */ public function store() { $rules = array('first_line' => 'Required', 'second_line' => 'Required', 'meme_id' => 'Required'); $v = Validator::make(Input::all(), $rules); if ($v->passes()) { if (Input::get('antibot') == Session::get('antispam1') + Session::get('antispam2')) { $base = Meme::findOrFail(Input::get('meme_id')); $meme = new MemeInstance(); $meme->meme_id = strip_tags(Input::get("meme_id")); $meme->first_line = strip_tags(Input::get("first_line")); $meme->second_line = strip_tags(Input::get("second_line")); $akismet = new Akismet('http://www.puskice.org/', '5fa6e0236f7b'); if (Session::get("id") != null) { $meme->user_id = strip_tags(Session::get("id")); $user = User::find($meme->user_id); $akismet->setCommentAuthor($user->username); $akismet->setCommentAuthorEmail($user->email); } else { $meme->user_id = -1; $akismet->setCommentAuthor('anonymous'); $akismet->setCommentAuthorEmail('*****@*****.**'); } $meme->permalink = Puskice::url_slug(htmlspecialchars_decode($meme->first_line)); $meme->published = 1; $meme->trashed = 0; $meme->view_count = 0; $meme->thumbs_up = 0; $meme->thumbs_down = 0; $akismet->setCommentAuthorURL(""); $akismet->setCommentContent($meme->first_line . " " . $meme->second_line); $akismet->setPermalink('http://www.puskice.org/meme/' . $meme->id . '-' . $meme->permalink); if ($akismet->isCommentSpam()) { return Redirect::to(Request::root() . "/memes/new")->with('message', __("Систем каже да спамујете"))->with('notif', 'danger')->withInput(); } $meme->save(); Session::forget('antispam1'); Session::forget('antispam2'); return Redirect::to(Request::root() . "/meme/" . $meme->id . "-" . $meme->permalink); } else { return Redirect::to(Request::root() . "/memes/new")->with('message', __("Нисте добро сабрали бројеве"))->with('notif', 'danger')->withInput(); } } else { return Redirect::to(Request::root() . "/memes/new")->withErrors($v)->with('notif', 'danger'); } }