public function index() { // latest / fresh $data['page'] = ''; $data['video'] = Featuredvideo::find(1); $data['banners'] = Banner::orderBy('id')->get(); $data['freshpost'] = Post::orderBy('created_at', 'desc')->take(5)->get(); $data['featuredpost'] = FeaturedPost::orderBy('id', 'desc')->take(10)->with('post')->get(); $data['trendingpost'] = Post::select('posts.*', DB::raw('count(votes.id) as total'))->leftJoin('votes', 'posts.id', '=', 'votes.post_id')->groupBy('posts.id')->orderBy('total', 'desc')->take(6)->get(); return View::make('main2')->with($data); }
/** def sslify_instagram_cdn_url(url): """Intercept IG CDN urls and serve using a SSL-friendly CDN instead""" replace_prefixes = ( ('^http://images.ak.instagram.com(.*)$', '//distillery.s3.amazonaws.com%s'), ('^http://distilleryimage([0-9]*).ak.instagram.com(.*)$', '//distilleryimage%s.s3.amazonaws.com%s'), ('^http://origincache-([a-z]*).fbcdn.net(.*)$', '//origincache-%s.fbcdn.net%s'), ('^http://distilleryimage([0-9]*).s3.amazonaws.com(.*)$', '//distilleryimage%s.s3.amazonaws.com%s'), ('^http://scontent-([a-z]).cdninstagram.com(.*)$', '//scontent-%s.cdninstagram.com%s'), ('^http://photos-[a-z].ak.instagram.com/hphotos-ak-[0-9a-z]{3,4}/(.*)$', '//origincache-frc.fbcdn.net/%s'), ) for prefix, replacement in replace_prefixes: results = re.findall(prefix, url) if not results: continue return replacement % results[0] return url */ public function postsToHtml($posts, $boardId = NULL, $featured = NULL) { $html = ''; $base = URL::to('/'); if (isset($boardId)) { $config = BoardConfig::where('board_id', '=', $boardId)->first(); if (Auth::check()) { $user = Auth::user(); if ($user->id == $config->user_id) { $owned = true; } } if ($config->filter != '') { $filter = explode(',', $config->filter); } if ($config->banned_users != '') { $users = explode(',', $config->banned_users); } $featuredPosts = FeaturedPost::where('board_id', '=', $config->board_id); if ($featured == true && $featuredPosts->count() > 0) { $hasFeatured = true; foreach ($featuredPosts->get() as $post) { $html .= $post['html']; } } } shuffle($posts); foreach ($posts as $post) { if (strlen($post['username']) > 0) { if (isset($filter) && $filter != '' && !empty($post['caption'])) { if ($this->filterWords($post['caption'], $filter)) { continue; } } if (isset($users) && $users != '') { if (in_array($post['username'], $users)) { continue; } } if (isset($featured) && $featuredPosts->count() > 0) { if ($this->checkIfFeatured($featuredPosts, $post['post_id'])) { continue; } } $html .= '<div data-post-id="' . $post['post_id'] . '" class="post post-' . $post['vendor'] . ' post-type-' . $post['post_type'] . '">'; $html .= '<div class="filter filter-' . $post['vendor'] . ' pull-right"><i class="fa fa-' . $post['vendor'] . '"></i></div>'; $html .= '<div class="user-info pull-left">'; if ($post['vendor'] == 'instagram') { $profilePic = $this->sslInstagramProfilePic($post['user_img_url']); $html .= '<img src="' . $profilePic . '" alt="" />'; } else { $html .= '<img src="' . str_replace('http://', '//', $post['user_img_url']) . '" alt="" />'; } if ($post['vendor'] == 'twitter') { $html .= '<a href="http://www.twitter.com/' . $post['username'] . '" target="_blank" rel="nofollow">' . $post['username'] . '</a>'; $post['date_created'] = Carbon::createFromFormat('m-d-y H:i:s', $post['date_created'])->toIso8601String(); } else { if ($post['vendor'] == 'instagram') { $html .= '<a href="http://www.instagram.com/' . $post['username'] . '" target="_blank" rel="nofollow">' . $post['username'] . '</a>'; $post['date_created'] = Carbon::createFromFormat('m-d-y H:i:s', $post['date_created'])->toIso8601String(); } else { if ($post['vendor'] == 'google-plus') { $html .= '<a href="https://plus.google.com/' . $post['user_id'] . '" target="_blank" rel="nofollow">' . $post['username'] . '</a>'; $post['date_created'] = Carbon::parse($post['date_created'])->toIso8601String(); } else { if ($post['vendor'] == 'facebook') { $html .= '<a href="http://facebook.com/profile.php?id=' . $post['user_id'] . '" target="_blank" rel="nofollow">' . $post['username'] . '</a>'; $post['date_created'] = Carbon::parse($post['date_created'])->toIso8601String(); } else { if ($post['vendor'] == 'vine') { $html .= '<a href="https://vine.co/u/' . $post['user_id'] . '" target="_blank" rel="nofollow">' . $post['username'] . '</a>'; $post['date_created'] = Carbon::createFromFormat('Y-m-d H:i:s', $post['date_created'])->toIso8601String(); } } } } } $html .= '<p><abbr class="timeago" title="' . $post['date_created'] . '">' . $post['date_created'] . '</abbr></p>'; $html .= '</div><div class="clearfix"></div>'; if ($post['post_type'] == 'image') { $post['img_url'] = str_replace('http://', '//', $post['img_url']); if ($post['vendor'] == 'instagram') { $html .= '<a href="' . $post['img_url'] . '" class="image-link">'; $html .= '<div class="post-img">'; $html .= '<img src="' . $post['img_url'] . '" alt="" />'; $html .= '</div>'; $html .= '</a>'; } else { if ($post['vendor'] == 'twitter') { $html .= '<a href="' . $post['img_url'] . '" class="image-link">'; $html .= '<div class="post-img">'; $html .= '<img src="' . $post['img_url'] . '" alt="" />'; $html .= '</div>'; $html .= '</a>'; } else { $html .= '<a href="' . $post['img_url'] . '" class="image-link">'; $html .= '<div class="post-img">'; $html .= '<img src="' . $post['img_url'] . '" alt="" />'; $html .= '</div>'; $html .= '</a>'; } } } else { if ($post['post_type'] == 'video') { $post['embed'] = str_replace('http://', '//', $post['embed']); $post['img_url'] = str_replace('http://', '//', $post['img_url']); if ($post['vendor'] == 'facebook') { $html .= '<a href="' . $post['embed'] . '" target="_blank" class="video-link" rel="nofollow">'; $html .= '<div class="post-img">'; $html .= '<i class="fa fa-play"></i>'; $html .= '<img src="' . $post['img_url'] . '" alt="" />'; $html .= '</div>'; $html .= '</a>'; } else { if ($post['vendor'] == 'instagram') { $html .= '<a href="' . $post['img_url'] . '" target="_blank" data-video="' . $post['embed'] . '" class="video-link-popup" rel="nofollow">'; $html .= '<div class="post-img">'; $html .= '<i class="fa fa-play"></i>'; $html .= '<img src="' . $post['img_url'] . '" alt="" />'; $html .= '</div>'; $html .= '</a>'; } else { if ($post['vendor'] == 'google-plus') { $html .= '<a href="' . $post['embed'] . '" target="_blank" class="video-link" rel="nofollow">'; $html .= '<div class="post-img">'; $html .= '<i class="fa fa-play"></i>'; $html .= '<img src="' . $post['img_url'] . '" alt="" />'; $html .= '</div>'; $html .= '</a>'; } else { if ($post['vendor'] == 'vine') { $html .= '<a href="' . $post['img_url'] . '" target="_blank" data-video="' . $post['embed'] . '" class="video-link-popup" rel="nofollow">'; $html .= '<div class="post-img">'; $html .= '<i class="fa fa-play"></i>'; $html .= '<img src="' . $post['img_url'] . '" alt="" />'; $html .= '</div>'; $html .= '</a>'; } else { $html .= '<div class="post-img">'; $html .= '<img src="' . $post['img_url'] . '" alt="" />'; $html .= '</div>'; } } } } } } if (!empty($post['caption'])) { $caption = preg_replace('/(http|https|ftp|ftps)\\:\\/\\/[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(\\/\\S*)?/', '', $post['caption']); $caption = $this->removeEmoji($caption); $html .= '<div class="post-description">'; $html .= '<p>' . preg_replace('/#([^\\s#]+)/', ' <a class="hashtag" href="' . $base . '/$1/szukaj">#$1</a>', $caption) . '</p>'; $html .= '</div>'; } if (isset($owned) && $owned == true) { $html .= '<div class="featured-post"><a data-post-id="' . $post['post_id'] . '" href="#" class="js-make-featured"><i class="fa fa-star"></i></a></div>'; } $html .= '</div>'; } } return $html; }
public function deletePost($id) { // $id = Input::get('id'); $post = Post::find($id); if (Auth::user() && Auth::user()->status == 'management') { // cek fetatured post FeaturedPost::where('post_id', $id)->delete(); $post->delete(); Session::flash('warning', 'Your post deleted successfully'); return Redirect::to('/'); } if (Auth::id() == $post->user_id) { FeaturedPost::where('post_id', $id)->delete(); $post->delete(); Session::flash('warning', 'Your post deleted successfully'); return Redirect::to('/'); } else { Session::flash('warning', 'Sorry we can\'t delete this post because you are not it\'s owner'); return Redirect::back(); } // return 'success'; }
public function showBoardFeatured($hashtag, $id) { if (Auth::check() && isset($hashtag) && isset($id)) { $user = Auth::user(); $board = Board::find($id); $posts = FeaturedPost::where('board_id', '=', $id); if ($board) { if ($board->config()->first()->user_id == $user->id) { $data['user'] = $user; $data['board'] = $board; $data['posts'] = $posts; $data['title'] = $this->layout->title = 'Promowane posty tablicy #' . $board->hashtag; $this->layout->content = View::make('user.featured-post', $data); } else { return Redirect::to('/konto')->with('alert', array('type' => 'error', 'content' => 'Błąd! Coś poszło nie tak.')); } } else { return Redirect::to('/konto')->with('alert', array('type' => 'error', 'content' => 'Błąd! Coś poszło nie tak.')); } } else { return Redirect::to('/')->with('alert', array('type' => 'error', 'content' => 'Błąd! Coś poszło nie tak.')); } }