示例#1
0
 public function sitemap()
 {
     $sitemap = App::make("sitemap");
     // set item's url, date, priority, freq
     $sitemap->add(Request::root(), '2012-08-25T20:10:00+02:00', '1.0', 'daily');
     $sitemap->add(Request::root() . "/marketing", '2013-08-20T20:20:00+02:00', '1.0', 'monthly');
     $sitemap->add(Request::root() . "/puskice", '2013-08-20T20:20:00+02:00', '1.0', 'monthly');
     if (Cache::has('posts_query')) {
         $posts = Cache::get('posts_query');
     } else {
         $posts = News::get();
         Cache::put('posts_query', $posts, 10080);
     }
     foreach ($posts as $post) {
         if ($post->post_type == 1) {
             $sitemap->add(Request::root() . "/vest/" . Puskice::dateToUrl($post->created_at) . "/" . $post->permalink, $post->updated_at, '1.0', 'daily');
         }
         if ($post->post_type == 2) {
             $sitemap->add(Request::root() . "/stranica/" . $post->permalink, $post->updated_at, '1.0', 'daily');
         }
         if ($post->post_type == 3) {
             $subject = Subject::where('news_id', '=', $post->id)->first();
             if ($subject != null) {
                 $sitemap->add(Request::root() . "/" . Puskice::getYear($subject->semester) . "/" . Puskice::getDepartment($subject->department) . "/" . $post->permalink, $post->updated_at, '1.0', 'monthly');
             } else {
                 Log::info('Predmet za vest: ' . $post->id . ' nije definisan');
             }
         }
     }
     if (Cache::has('meme_query')) {
         $memes = Cache::get('meme_query');
     } else {
         $memes = MemeInstance::get();
         Cache::put('meme_query', $memes, 10080);
     }
     foreach ($memes as $meme) {
         $sitemap->add(Request::root() . "/meme/" . $meme->id . "-" . $meme->permalink, $meme->updated_at, '1.0', 'daily');
     }
     // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
     return $sitemap->render('xml');
 }
 /**
  * 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'));
     }
 }
示例#4
0
 public function getInstanceDestroy($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::onlyTrashed()->findOrFail($id);
         $meme->forceDelete();
         return Redirect::to(_l(URL::action('MemeController@getTrashedInstances')))->with('message', Lang::get('admin.memeInstanceDeleted'))->with('notif', 'success');
     } catch (Exception $e) {
         return Redirect::to(_l(URL::action('MemeController@getTrashedInstances')))->with('message', Lang::get('admin.noSuchMemeInstance'))->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');
     }
 }