Example #1
0
 public function getThumbsDown($id)
 {
     try {
         $valid_ip = Thumb::where('ip', '=', Puskice::getIP())->where('object_type', '=', 5)->where('object_id', '=', $id)->first();
         if ($valid_ip != null) {
             throw new Exception("Error valid IP", 1);
         }
         $news = News::findOrFail($id);
         $news->thumbs_down++;
         $news->save();
         $thumb = new Thumb();
         $thumb->ip = Puskice::getIP();
         $thumb->object_id = $news->id;
         $thumb->object_type = 5;
         $thumb->save();
         $thumbs = array();
         if (Cookie::get('ps_thumbs')) {
             $cookie = Cookie::get('ps_thumbs');
             $thumbs = unserialize($cookie);
             if (isset($thumbs['page'][$news->id])) {
                 return Response::json(array('status' => 'fail', 'message' => __("Већ сте оценили ову вест")));
             }
         }
         $thumbs['page'][$news->id] = 'down';
         Cookie::queue('ps_thumbs', serialize($thumbs), 2628000);
         return Response::json(array('status' => 'success', 'message' => _("Ваш глас је забележен. Хвала на труду"), 'thumbsUp' => $news->thumbs_up, 'thumbsDown' => $news->thumbs_down));
     } catch (Exception $e) {
         return Response::json(array('status' => 'fail', 'message' => _("Већ сте оценили ову страницу")));
     }
 }
Example #2
0
 public static function rss($news)
 {
     $string = "<rss version='2.0'>";
     $string .= "<channel>";
     $string .= "<title>Puškice</title>\n\t\t\t\t\t<link>" . Request::root() . "</link>\n\t\t\t\t\t<description>Tačka spajanja studenata FON-a</description>\n\t\t\t\t\t<language>sr-rs</language>\n\t\t\t\t\t<pubDate>" . date("D, d M Y H:i:s e", strtotime("now")) . "</pubDate>\n\t\t\t\t\t<lastBuildDate>" . date("D, d M Y H:i:s e", strtotime("now")) . "</lastBuildDate>\n\t\t\t\t\t<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n\t\t\t\t\t<generator>Puškice generator</generator>\n\t\t\t\t\t<managingEditor>info@puskice.org</managingEditor>\n\t\t\t\t\t<webMaster>info@puskice.org</webMaster>";
     foreach ($news as $article) {
         $string .= "<item>\n\t\t\t\t\t\t\t<title>" . $article->title . "</title>\n\t\t\t\t\t\t\t<link>" . Request::root() . "/vest/" . Puskice::dateToUrl($article->created_at) . "/" . $article->permalink . "</link>\n\t\t\t\t\t\t\t<description><![CDATA[" . Trans::_t($article->short_content) . "]]></description>\n\t\t\t\t\t\t\t<pubDate>" . date("D, d M Y H:i:s e", strtotime($article->created_at)) . "</pubDate>\n\t\t\t\t\t\t\t<guid>" . Request::root() . "/vest/" . Puskice::dateToUrl($article->created_at) . "/" . $article->permalink . "</guid>\n\t\t\t\t\t\t</item>";
     }
     $string .= "</channel>";
     $string .= "</rss>";
     return $string;
 }
Example #3
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');
 }
 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'));
     }
 }
 public function singleSubject($year, $department, $permalink)
 {
     try {
         $permalink = str_replace("_", "-", $permalink);
         if (Session::get('user_level') >= Config::get('cms.viewAdminNews')) {
             $page = News::where('post_type', '=', 3)->where('published', '>=', 1)->where('permalink', '=', $permalink)->firstOrFail();
         } else {
             $page = News::where('post_type', '=', 3)->where('published', '=', 2)->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('permalink', '=', $permalink)->firstOrFail();
         }
         $subjects = Subject::where('news_id', '=', $page->id)->get();
         $sub = Subject::where('news_id', '=', $page->id)->first();
         $allow = false;
         foreach ($subjects as $key => $subject) {
             if ($year == Puskice::getYear($subject->semester) && Puskice::getDepartment($subject->department) == $department) {
                 $allow = true;
             }
         }
         if (!$allow) {
             App::abort(404);
         }
         $articles = News::inCategories(Config::get('settings.homepage'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(10)->get();
         $featured = News::where('published', '=', 2)->where('featured', '=', 1)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->orderBy('created_at', 'desc')->take(3)->get();
         $results = News::inCategories(Config::get('settings.results'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $featuredImage = News::inCategories(array(25))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
         $didYouKnow = News::inCategories(array(30))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
         $magazine = News::inCategories(Config::get('settings.magazine'))->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $ourComment = News::inCategories(array(17))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $feed = getFeed('http://bazaznanja.puskice.org/feed/qa.rss', 4);
         $poll = null;
         $poll = Poll::where('published', '=', '1')->where('end_date', '>', date("Y-m-d H:i:s", strtotime('now')))->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->first();
         if (isset($poll->id)) {
             $poll->pollOptions;
         }
         View::share('title', strip_tags($page->title) . " | Пушкице");
         $ogimage = firstImage($page);
         $meta = "\t<meta property='og:image' content='" . str_replace(" ", "%20", $ogimage) . "'/>\n\t\t\t\t\t\t<meta property='og:title' content='" . __($page->title . " | Пушкице") . "'/>\n\t\t\t\t\t\t<meta property='fb:app_id' content='355697367892039'/>\n\t\t\t\t\t\t<meta property='og:site_name' content='" . __("Пушкице - ФОН Андерграунд") . "'/>\n\t\t\t\t\t\t<meta property='og:type' content='article'/>\n\t\t\t\t\t\t<meta property='og:url' content='" . _l(Request::root() . "/" . Puskice::getYear($sub->semester) . "/" . Puskice::getDepartment($sub->department) . "/" . $page->permalink) . "'/>\n\t\t\t\t\t\t<meta property='og:description' content='" . __(dots(strip_tags($page->short_content), 500)) . "' />\n\t\t\t\t\t\t<meta name='twitter:card' content='summary_large_image'>\n\t\t\t\t\t\t<meta name='twitter:site' content='" . __("Пушкице - ФОН Андерграунд") . "'>\n\t\t\t\t\t\t<meta name='twitter:creator' content='@puskice'>\n\t\t\t\t\t\t<meta name='twitter:domain' content='puskice.org'>\n\t\t\t\t\t\t<meta name='twitter:app:name:iphone' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:app:name:ipad' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:title' content='" . __($page->title . " | Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:description' content='" . __(dots(strip_tags($page->short_content), 500)) . "'>\n\t\t\t\t\t\t<meta name='twitter:image' content='" . str_replace(" ", "%20", $ogimage) . "'>";
         $page->view_count++;
         $page->save();
         $data = array('articles' => $articles, 'featured' => $featured, 'results' => $results, 'ourComment' => $ourComment, 'magazine' => $magazine, 'featuredImage' => $featuredImage, 'didYouKnow' => $didYouKnow, 'feed' => $feed, 'poll' => $poll, 'meta' => $meta, 'sub' => $sub, 'page' => $page);
         $this->setLayout($data);
         $this->layout->center = View::make('frontend.content.subject', $data);
     } catch (Exception $e) {
         return App::abort(404);
     }
 }
 /**
  * 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');
     }
 }
Example #7
0
function urlToDate($url)
{
    return Puskice::urlToDate($url);
}
 /**
  * Display the specified resource.
  * GET /frontend/publiccontact/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $contact = Contact::findOrFail($id);
         $articles = News::inCategories(Config::get('settings.homepage'))->where('published', '=', 2)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(10)->get();
         $featured = News::where('published', '=', 2)->where('featured', '=', 1)->where('post_type', '=', 1)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->orderBy('created_at', 'desc')->take(3)->get();
         $results = News::inCategories(Config::get('settings.results'))->distinct('permalink')->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->groupBy('permalink')->orderBy('news.created_at', 'desc')->take(10)->get();
         $featuredImage = News::inCategories(array(25))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
         $didYouKnow = News::inCategories(array(30))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(3)->get();
         $magazine = News::inCategories(Config::get('settings.magazine'))->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('published', '=', 2)->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $ourComment = News::inCategories(array(17))->where('published', '=', 2)->where('news.created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->where('post_type', '=', 1)->distinct('permalink')->groupBy('news.id')->orderBy('news.created_at', 'desc')->take(4)->get();
         $feed = getFeed('http://bazaznanja.puskice.org/feed/qa.rss', 4);
         $poll = null;
         $poll = Poll::where('published', '=', '1')->where('end_date', '>', date("Y-m-d H:i:s", strtotime('now')))->where('created_at', '<', date("Y-m-d H:i:s", strtotime('now')))->first();
         if (isset($poll->id)) {
             $poll->pollOptions;
         }
         View::share('title', $contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице | Тачка спајања студената ФОН-а");
         $ogimage = Puskice::firstContactImage($contact);
         $meta = "\t<meta property='og:image' content='" . $ogimage . "'/>\n\t\t\t\t\t\t<meta property='og:title' content='" . __($contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице | Тачка спајања студената ФОН-а") . "'/>\n\t\t\t\t\t\t<meta property='fb:app_id' content='355697367892039'/>\n\t\t\t\t\t\t<meta property='og:site_name' content='" . __("Пушкице - ФОН Андерграунд") . "'/>\n\t\t\t\t\t\t<meta property='og:type' content='article'/>\n\t\t\t\t\t\t<meta property='og:url' content='" . _l(Request::root() . "/ljudi/" . $contact->id) . "'/>\n\t\t\t\t\t\t<meta property='og:description' content='" . __($contact->description) . "' />\n\t\t\t\t\t\t<meta name='twitter:card' content='summary_large_image'>\n\t\t\t\t\t\t<meta name='twitter:site' content='" . __("Пушкице - ФОН Андерграунд") . "'>\n\t\t\t\t\t\t<meta name='twitter:creator' content='@puskice'>\n\t\t\t\t\t\t<meta name='twitter:domain' content='puskice.org'>\n\t\t\t\t\t\t<meta name='twitter:app:name:iphone' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:app:name:ipad' content='" . __("Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:title' content='" . __($contact->title . " " . $contact->first_name . " " . $contact->last_name . " | Пушкице") . "'>\n\t\t\t\t\t\t<meta name='twitter:description' content='" . __($contact->description) . "'>\n\t\t\t\t\t\t<meta name='twitter:image' content='" . $ogimage . "'>";
         $data = array('articles' => $articles, 'featured' => $featured, 'results' => $results, 'ourComment' => $ourComment, 'magazine' => $magazine, 'featuredImage' => $featuredImage, 'didYouKnow' => $didYouKnow, 'feed' => $feed, 'poll' => $poll, 'meta' => $meta, 'contact' => $contact);
         $this->setLayout($data);
         $this->layout->center = View::make('frontend.content.contact', $data);
     } catch (Exception $e) {
         App::abort(404);
     }
 }
Example #9
0
 /**
  * Show the form for editing the specified resource.
  * GET /api/apipoll/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function postCastVote()
 {
     $this->googleAnalytics('/polls/cast-vote/');
     $rules = array('poll_id' => 'Required', 'option_id' => 'Required');
     $v = Validator::make(Input::all(), $rules);
     if ($v->passes()) {
         $ip = Puskice::getIP();
         $vote = PollVote::where('poll_id', '=', Input::get("poll_id"))->where('ip_address', '=', $ip)->first();
         if ($vote != null) {
             return Response::json(array('status' => 'fail', 'text' => __("Већ сте гласали на овој анкети. Хвала :)")));
         }
         $vote = new PollVote();
         $vote->poll_id = strip_tags(Input::get("poll_id"));
         $vote->option_id = strip_tags(Input::get("option_id"));
         $vote->ip_address = $ip;
         $vote->save();
         $option = PollOption::find(Input::get("option_id"));
         $poll = Poll::find($option->poll_id);
         if ($poll->published == 1) {
             $option->vote_count = $option->vote_count + 1;
             $option->save();
             return Response::json(array('status' => 'success', 'text' => __("Хвала што сте гласали")));
         }
         return Response::json(array('status' => 'fail', 'text' => __("Хвала што покушавате да хакујете анкету :)")));
     } else {
         return Response::json(array('status' => 'fail', 'text' => __("Десила се грешка")));
     }
 }
Example #10
0
 public static function getFacebookLoginFormLink()
 {
     // Checking Session
     $object = "";
     if (Session::get('fb_token')) {
         try {
             $session = new FacebookSession(Session::get('fb_token'));
             $response = (new FacebookRequest($session, 'GET', '/me'))->execute();
             $object = $response->getGraphObject();
         } catch (FacebookRequestException $ex) {
             return $ex->getMessage();
         } catch (\Exception $ex) {
             return $ex->getMessage();
         }
         return "<span class='skills'>" . $object->getProperty('name') . '</span>';
     } else {
         // Requested permissions - optional
         $permissions = array('email', 'publish_actions');
         // Login Healper with reditect URI
         if (Input::get('ref')) {
             $helper = new FacebookRedirectLoginHelper('http://www.puskice.org/login/redirect-here');
         }
         if (Input::get('subdomain') && Input::get('subdomain') == 'bazaznanja') {
             $helper = new FacebookRedirectLoginHelper('http://www.puskice.org/login/redirect-here');
         } else {
             $helper = new FacebookRedirectLoginHelper('http://www.puskice.org/login/redirect-here');
         }
         try {
             $session = $helper->getSessionFromRedirect();
         } catch (FacebookRequestException $ex) {
             // Exception
             return Lang::get('frontend.fb_problem');
         } catch (Exception $ex) {
             // When validation fails or other local issues
             return Lang::get('frontend.fb_our_problem');
         }
         if (isset($session)) {
             Session::put('fb_token', $session->getToken());
             // Request for user data
             $request = new FacebookRequest($session, 'GET', '/me');
             $response = $request->execute();
             // Responce
             $object = $response->getGraphObject();
             Session::put('facebook_id', $object->getProperty('id'));
             try {
                 $user = User::where('facebook_id', '=', $object->getProperty('id'))->orWhere('email', 'LIKE', $object->getProperty('email'))->firstOrFail();
                 $user->first_name = $object->getProperty('first_name');
                 $user->last_name = $object->getProperty('last_name');
                 $user->last_login = date("Y-m-d H:i:s", strtotime('now'));
                 $user->last_login_ip = Puskice::getIP();
                 $user->loginhash = md5(strtotime('now') . $user->username);
                 $user->facebook_id = $object->getProperty('id');
                 $user->email = $object->getProperty('email');
                 $user->fb_token = $session->getToken();
                 //$user->gender = $object->getProperty('gender');
                 $user->save();
                 Session::put('id', $user->id);
             } catch (Exception $e) {
                 $user = new User();
                 $user->first_name = $object->getProperty('first_name');
                 $user->last_name = $object->getProperty('last_name');
                 $password = rand(100000, 999999);
                 $i = 0;
                 while (!isset($user->username) || $user->username == "") {
                     if ($i != 0) {
                         $username .= '' . $i;
                     }
                     try {
                         $testuser = User::where('username', '=', $username)->firstOrFail();
                         $i++;
                         continue;
                     } catch (Exception $e) {
                         $user->username = $username;
                     }
                 }
                 $user->password = sha1($password);
                 $user->user_level = 1;
                 $user->published = 1;
                 $user->last_login = date("Y-m-d H:i:s", strtotime('now'));
                 $user->last_login_ip = Puskice::getIP();
                 $user->loginhash = md5(strtotime('now') . $user->username);
                 $user->facebook_id = $object->getProperty('id');
                 $user->email = $object->getProperty('email');
                 $user->fb_token = $session->getToken();
                 $user->gender = $object->getProperty('gender');
                 $user->save();
                 $sender = array('email' => '*****@*****.**', 'name' => 'Puškice nalog', 'user_email' => $user->email, 'user_name' => $user->username);
                 // the data that will be passed into the mail view blade template
                 $data = array('username' => $user->username, 'password' => $password);
                 // use Mail::send function to send email passing the data and using the $user variable in the closure
                 Mail::send('emails.fbnewuser', $data, function ($message) use($sender) {
                     $message->from('*****@*****.**', 'Info tim Puškice');
                     $message->to($sender['user_email'], $sender['user_name'])->subject('Puškice nalog');
                 });
                 Session::put('id', $user->id);
             }
             return "<li>" . $object->getProperty('name') . '</li>';
         } else {
             // Login URL if session not found
             //return '<div class="fb-login-button" data-max-rows="1" data-scope="public_profile,email" data-size="medium" data-show-faces="false" data-auto-logout-link="false"></div>';
             return '<a href="' . $helper->getLoginUrl($permissions) . '"><img src="' . Request::root() . '/assets/frontend/img/facebook_login.png" alt="Facebook login" width="200px"/></a>';
         }
     }
 }