/**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function getCreate($id)
 {
     if (Session::get('user_level') < Config::get('cms.editComments')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning');
     }
     try {
         $_SESSION['RF']['subfolder'] = 'images/';
         $meme = MemeInstance::findOrFail($id);
         $this->setLayout();
         View::share('title', Lang::get('admin.newComment') . ": " . dots($meme->first_line, 60));
         View::share('meme', $meme);
         View::share('id', $id);
         $this->layout->content = View::make('backend.puskice.memeComments.create');
     } catch (Exception $e) {
         return Redirect::to(_l(URL::action('CommentController@getIndex')))->with('message', Lang::get('admin.noSuchComment'))->with('notif', 'danger');
     }
 }
 public function postCreateMemeComment($id)
 {
     try {
         $comment = new MemeComment();
         $news = MemeInstance::findOrFail($id);
         if (Input::get('createdAt')) {
             $comment->created_at = date("Y-m-d H:i:s", strtotime(Input::get('createdAt')));
         } else {
             $comment->created_at = date("Y-m-d H:i:s", strtotime('now'));
         }
         $comment->comment_content = Input::get('commentContent');
         $akismet = new Akismet('http://www.puskice.org/', '5fa6e0236f7b');
         $akismet->setCommentAuthor($comment->username);
         $akismet->setCommentAuthorEmail($comment->email);
         $akismet->setCommentAuthorURL("");
         $akismet->setCommentContent($comment->comment_content);
         $akismet->setPermalink('http://www.puskice.org/meme/' . $news->id . '-' . $news->permalink);
         if ($akismet->isCommentSpam()) {
             $comment->deleted_at = date('Y-m-d H:i:s', strtotime('now'));
         }
         if (Input::get('user_id')) {
             $comment->published = 1;
         } else {
             $comment->published = 0;
         }
         if (Input::get('user_id')) {
             $user = User::find(Input::get('user_id'));
             $comment->username = $user->username;
             $comment->email = $user->email;
         } else {
             $comment->username = Input::get('username');
             $comment->email = Input::get('email');
         }
         if (Input::get('user_id')) {
             $comment->user_id = Input::get('user_id');
         } else {
             $comment->user_id = 0;
         }
         $comment->news_id = $id;
         $comment->ip_address = Puskice::getIP();
         $comment->save();
         if ($comment->deleted_at == null) {
             $user = array('email' => '*****@*****.**', 'name' => 'Info tim');
             // the data that will be passed into the mail view blade template
             $data = array('url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/edit/" . $comment->id, 'approve_url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/publish/" . $comment->id, 'delete_url' => "http://www.puskice.org//" . Config::get('settings.admin_url') . "/meme-comments/trash/" . $comment->id, 'username' => $comment->username, 'email' => $comment->email, 'title' => $news->title, 'news' => 1, 'news_id' => $news->id, 'content' => $comment->comment_content);
             // use Mail::send function to send email passing the data and using the $user variable in the closure
             Mail::send('emails.new_comment', $data, function ($message) use($user) {
                 $message->from('*****@*****.**', "Puškice cenzura");
                 $message->to('*****@*****.**', 'Info tim Puškice')->subject('Novi meme komentar čeka moderaciju');
             });
         }
         return Response::json(array('status' => 'success', 'message' => __("Ваш коментар је успешно прослеђен")));
     } catch (Exception $e) {
         return Response::json(array('status' => 'fail'));
     }
 }
Example #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function getInstanceDelete($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 = MemeInstance::findOrFail($id);
         $meme->delete();
         return Redirect::to(_l(URL::action('MemeController@getInstances')))->with('message', Lang::get('admin.memeInstanceDeleted'))->with('notif', 'success');
     } catch (Exception $e) {
         return Redirect::to(_l(URL::action('MemeController@getInstances')))->with('message', Lang::get('admin.noSuchMemeInstance'))->with('notif', 'danger');
     }
 }
 public function memedecode($id, $meme_id, $first_line, $second_line)
 {
     try {
         $image = Meme::findOrFail($meme_id);
         $meme = MemeInstance::findOrFail($id);
     } catch (Exception $e) {
         App::abort('404');
     }
     if (file_exists(PUBLIC_DIR . $image->img)) {
         $font = PUBLIC_DIR . 'assets/font/impact.ttf';
         $img = imagecreatefromjpeg(PUBLIC_DIR . $image->img);
         $white = imagecolorallocate($img, 255, 255, 255);
         $black = imagecolorallocate($img, 0, 0, 0);
         MemeGenerator::imagettftextoutline($img, 20, 0, 10, 45, $white, $black, $font, Trans::_t(mb_strtoupper(htmlspecialchars_decode(urldecode($meme->first_line)))), 2, 'up');
         MemeGenerator::imagettftextoutline($img, 20, 0, 10, 95, $white, $black, $font, Trans::_t(mb_strtoupper(htmlspecialchars_decode(urldecode($meme->second_line)))), 2, 'down');
         ob_start();
         imagejpeg($img);
         $data = base64_encode(ob_get_clean());
     }
     header("Content-Type: image/jpeg");
     echo base64_decode($data);
     //return Response::make("data:image/jpg;base64,".$data, 200, array('content-type' => 'image/jpg'));
 }