Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Started...');
     Subscription::chunk(200, function ($subscriptions) {
         $accepted = 0;
         $declined = 0;
         $client = new Paylane\PayLaneRestClient('adubiel', 'dru9pra2');
         foreach ($subscriptions as $subscription) {
             $expiration = Carbon::createFromTimeStamp(strtotime($subscription->expires_at));
             if ($expiration->isToday() || $expiration->isPast()) {
                 $sale = $subscription->payment()->orderBy('id', 'desc')->where('is_success', '=', 1)->orWhere('is_success', '=', 2)->first();
                 if ($sale->is_success == 2) {
                     $resale_params = array('id_authorization' => $sale->sale_id, 'amount' => 149.0, 'currency' => 'PLN', 'description' => 'Subskrypcja Hasztag.info');
                     $status = $client->resaleByAuthorization($resale_params);
                 } else {
                     if ($sale->is_success == 1) {
                         $params = array('id_sale' => $sale->sale_id, 'amount' => 149.0, 'currency' => 'PLN', 'description' => 'Subskrypcja Hasztag.info');
                         $status = $client->resaleBySale($params);
                     }
                 }
                 if ($client->isSuccess()) {
                     $accepted++;
                     $payment = Payment::create(array('user_id' => $subscription->user_id, 'subscription_id' => $subscription->id, 'sale_id' => $status['id_sale']));
                     $subscription->expires_at = Carbon::now()->addDays(30);
                     $subscription->is_active = 1;
                     $subscription->save();
                     $user = User::find($subscription->user_id);
                     $user->level = 2;
                     $user->save();
                     $configs = BoardConfig::where('user_id', '=', $subscription->user_id)->get();
                     if ($configs->count() > 0) {
                         foreach ($configs as $config) {
                             $config->is_active = 1;
                             $config->save();
                         }
                     }
                     EmailNotification::where('subscription_id', '=', $subscription->id)->delete();
                     $faktura = $subscription->company_id == 0 ? false : true;
                     Event::fire('invoice.email', array($subscription->user_id, $subscription->id, $payment->id, $faktura));
                 } else {
                     $declined++;
                     $payment = Payment::create(array('user_id' => $subscription->user_id, 'subscription_id' => $subscription->id, 'is_success' => 0, 'sale_id' => $status['error']['error_number']));
                     Event::fire('deactivate.subscription', array($subscription->id, $payment->created_at));
                 }
             }
         }
         $this->info('Accepted:' . $accepted);
         $this->info('Declined:' . $declined);
     });
     $this->info('Done');
 }
Exemplo n.º 2
0
 /**
 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;
 }
Exemplo n.º 3
0
 public function postAddBoard()
 {
     if (Auth::check()) {
         $rules = array('hashtag' => 'required|min:3', 'avatar' => 'mimes:jpg,jpeg,png|image|max:1024|image_size:>=300', 'cover' => 'mimes:jpg,jpeg,png|image|max:3072|image_size:>=1200,>=150', 'presentation_cover' => 'mimes:jpg,jpeg,png|image|max:4096|image_size:>=1200,*', 'website_url' => 'url', 'refresh_interval' => 'integer|min:10|max:120', 'refresh_count' => 'integer|min:1|max:100');
         $user = Auth::user();
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             $messages = $validator->messages();
             return Redirect::to('/konto/tablica/dodaj')->withInput(Input::flash())->withErrors($validator)->with('alert', array('type' => 'error', 'content' => 'Błąd! Sprawdź wszystkie pola.'));
         } else {
             $data = Input::get('hashtag');
             $data = explode(' ', trim($data));
             $result = preg_replace('/#([\\w-]+)/i', '$1', $data[0]);
             $hashtag = Sanitize::string($result);
             $board = Board::create(array('hashtag' => $hashtag, 'description' => Input::get('description'), 'avatar' => Input::file('avatar'), 'cover' => Input::file('cover'), 'presentation_cover' => Input::file('presentation_cover'), 'fb_user' => Input::get('fb_user'), 'tw_user' => Input::get('tw_user'), 'insta_user' => Input::get('insta_user'), 'google_user' => Input::get('google_user'), 'website_url' => Input::get('website_url')));
             $fb = Input::has('has_fb') ? 0 : -1;
             $insta = Input::has('has_insta') ? 0 : -1;
             $tw = Input::has('has_tw') ? 0 : -1;
             $google = Input::has('has_google') ? 0 : -1;
             $vine = Input::has('has_vine') ? 0 : -1;
             $refreshInterval = Input::has('refresh_interval') ? Input::get('refresh_interval') : 30;
             $refreshCount = Input::has('refresh_count') ? Input::get('refresh_count') : 2;
             $bannedUsers = Input::has('banned_users') ? Input::get('banned_users') : '';
             $filter = Input::has('filters') ? Input::get('filters') : '';
             $live = Input::has('live') ? 1 : 0;
             $presentation = Input::has('presentation') ? 1 : 0;
             $color = Input::has('color') ? Input::get('color') : '';
             $config = BoardConfig::create(array('board_id' => $board->id, 'user_id' => $user->id, 'has_fb' => $fb, 'has_insta' => $insta, 'has_tw' => $tw, 'has_google' => $google, 'has_vine' => $vine, 'refresh_interval' => $refreshInterval, 'refresh_count' => $refreshCount, 'presentation' => $presentation, 'color' => $color, 'live' => $live, 'banned_users' => $bannedUsers, 'filter' => $filter));
             Stat::create(array('board_id' => $board->id));
             return Redirect::to('/konto/tablice')->with('alert', array('type' => 'success', 'content' => 'Tablica utworzona!'));
         }
     }
 }
Exemplo n.º 4
0
             $status = $client->resaleByAuthorization($resale_params);
         } else {
             if ($sale->is_success == 1) {
                 $params = array('id_sale' => $sale->sale_id, 'amount' => 149.0, 'currency' => 'PLN', 'description' => 'Subskrypcja Hasztag.info');
                 $status = $client->resaleBySale($params);
             }
         }
         if ($client->isSuccess()) {
             $payment = Payment::create(array('user_id' => $subscription->user_id, 'subscription_id' => $subscription->id, 'sale_id' => $status['id_sale']));
             $subscription->expires_at = Carbon::now()->addDays(30);
             $subscription->is_active = 1;
             $subscription->save();
             $user = User::find($subscription->user_id);
             $user->level = 2;
             $user->save();
             $configs = BoardConfig::where('user_id', '=', $subscription->user_id)->get();
             if ($configs->count() > 0) {
                 foreach ($configs as $config) {
                     $config->is_active = 1;
                     $config->save();
                 }
             }
             EmailNotification::where('subscription_id', '=', $subscription->id)->delete();
             $faktura = $subscription->company_id == 0 ? false : true;
             Event::fire('invoice.email', array($subscription->user_id, $subscription->id, $payment->id, $faktura));
         } else {
             $payment = Payment::create(array('user_id' => $subscription->user_id, 'subscription_id' => $subscription->id, 'is_success' => 0));
             Event::fire('deactivate.subscription', array($subscription->id, $payment->created_at));
         }
     }
 }
Exemplo n.º 5
0
 public function showBoard($query, $id = NULL, $presentation = NULL)
 {
     Asset::add('//cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.0.0/isotope.pkgd.min.js', 'footer');
     Asset::add('//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.min.js', 'footer');
     Asset::add('/js/libs/jquery.dropdown.js', 'footer');
     //Asset::add('/js/posts.js', 'footer');
     Asset::add('/js/posts-new.js', 'footer');
     //check if board exists
     if (strlen($query) > 2) {
         $query = explode(' ', trim($query));
         $result = preg_replace('/#([\\w-]+)/i', '$1', $query[0]);
         $query = Sanitize::string($result);
     } else {
         App::abort(404);
     }
     if (isset($id)) {
         $board = Board::find($id);
         if (!is_null($board)) {
             if ($board->hashtag != $query || $board->config()->first()->user_id == 0) {
                 App::abort(404);
             }
         } else {
             App::abort(404);
         }
     } else {
         $board = Board::where('hashtag', '=', $query)->whereHas('config', function ($q) {
             $q->where('user_id', '=', 0);
         })->first();
         if (is_null($board)) {
             $board = Board::create(array('hashtag' => $query));
             $visit = Visit::create(array('ip' => Request::ip()));
             $config = BoardConfig::create(array('board_id' => $board->id));
         }
     }
     if ($board->config()->first()->is_active == 1) {
         if (!is_null($board->cover_file_name)) {
             $data['layout'] = $this->layout->cover = 'with-cover';
         } else {
             $data['layout'] = $this->layout->cover = 'no-cover';
         }
         if (Auth::check()) {
             $user = Auth::user();
             $data['username'] = preg_replace('/@.*?$/', '', $user->email);
             $data['userBoards'] = Board::byUserId($user)->orderBy('created_at', 'asc')->get();
             $data['user'] = $user;
             if ($user->id == $board->config()->first()->user_id) {
                 $userOwned = true;
             }
             if (!is_null($user->provider()->first()) && $user->provider()->first()->provider == 'facebook') {
                 $data['avatar'] = '<img src="http://graph.facebook.com/' . $user->provider()->first()->provider_id . '/picture?type=small" alt="avatar" />';
             }
         }
         if (Session::get('session-stat') != $board->id) {
             $stats = Stat::firstOrCreate(array('board_id' => $board->id))->increment('hits');
             Session::put('session-stat', $board->id);
         }
         $data['board'] = $board;
         $data['boardData'] = $this->layout->boardData = $board;
         $data['title'] = $this->layout->title = $board->hashtag;
         $data['bodyClass'] = $this->layout->bodyClass = $board->hashtag . (isset($userOwned) ? ' user-owned' : '');
         if (isset($presentation) && $presentation != 'live') {
             App::abort(404);
         }
         if (isset($id) && $presentation == 'live' && $board->config()->first()->presentation == 1) {
             $data['bodyClass'] = $this->layout->bodyClass = $board->hashtag . (isset($userOwned) ? ' user-owned' : '') . ' board-presentation';
             $this->layout->content = View::make('boards.board-presentation', $data);
         } else {
             $this->layout->content = View::make('boards.index', $data);
         }
     } else {
         App::abort(404);
     }
 }