Exemplo n.º 1
0
 public function toText($txt)
 {
     $tab = explode('-', $txt);
     $date = Carbon::createFromTimeStamp($tab[0])->toDateString();
     $tab[1] == 'm' ? $day = 'matin' : ($day = 'après-midi');
     return $date . ' ' . $day;
 }
Exemplo n.º 2
0
function email_date($dateTime)
{
    $date = \Carbon::createFromTimeStamp(strtotime($dateTime));
    if ($date->isToday()) {
        return $date->format('h:i a');
    } elseif ($date->year == date('Y')) {
        return $date->format('M d');
    } else {
        return $date->format('M d, Y');
    }
}
Exemplo n.º 3
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');
 }
 /**
  * Follow the leader...
  *
  * @return void
  */
 public function leader()
 {
     if (count(Input::all()) == 0) {
         return Redirect::to('/generator');
     }
     $this->text['fonts'] = ['normal' => public_path() . '/fonts/Arial.ttf', 'bold' => public_path() . '/fonts/Arial-Bold.ttf'];
     $result = Input::only(['user', 'num', 'type', 'error']);
     // I use this for error testing...
     $forceError = isset($result['error']) ? true : false;
     // The validation rules
     $rules = ['user' => ['required', 'regex:/^[a-z]([a-z0-9_-]){2,14}$/i', 'min:2', 'max:15'], 'num' => 'required|integer|between:1,10', 'type' => 'in:,link'];
     $messages = ['user.required' => 'Your Last.fm <code>user</code>name is required', 'user.regex' => 'Your Last.fm <code>user</code>name contains invalid characters', 'user.min' => 'Your Last.fm <code>user</code>name is too short', 'user.max' => 'Your Last.fm <code>user</code>name is too long', 'num.required' => 'You must supply an album number', 'num.integer' => 'The var number must be a number', 'num.min' => 'The number is too short', 'type.in' => 'The <code>type</code> should be link, otherwise don\'t supply it'];
     $validator = Validator::make($result, $rules, $messages);
     if ($validator->passes()) {
         $this->username = $result['user'];
         $this->number = $result['num'];
         $this->type = $result['type'];
     } else {
         return Redirect::to('/generator')->withErrors($validator);
     }
     $client = new GuzzleHttp\Client(['base_url' => ['http://ws.audioscrobbler.com/2.0/?method=library.getalbums&api_key=561e763a09d252d2bbf70beec4897d91&user={username}&limit=10&format=json', ['username' => $this->username]], 'headers' => ['User-Agent' => 'yesdevnull.net/lastfm Last.fm Album Image Generator'], 'timeout' => 5]);
     $response = $client->get();
     // Ruh-roh!
     if ($response->getStatusCode() != 200) {
         Log::error('Unable to connect to Last.fm', ['message' => 'Guzzle Error: ' . $response->getReasonPhrase(), 'url' => $response->getEffectiveUrl(), 'code' => $response->getStatusCode()]);
         // Unknown error connecting to Last.fm
         return $this->generateImage(false, $response->getStatusCode() . ' Error when connecting to Last.fm');
     }
     $this->result = $this->getApiResult($response->json(), $this->number);
     if ($this->type == 'link') {
         Log::info('Sending user away to Last.fm', ['url' => $this->result['url'], 'code' => 307, 'user' => $this->username, 'number' => $this->number]);
         // Redirect time, send them to Last.fm
         return Redirect::away($this->result['url'], 307);
     }
     $image = $this->generateImage($this->imageUrl, $forceError);
     /**
      * Browser Caching from: http://laravelsnippets.com/snippets/display-php-loaded-image-with-browser-cache-support
      * Thanks, Philo!
      */
     $request = Request::instance();
     $responseImage = gettype($image) == 'resource' ? $image->encoded : $image;
     $size = strlen($responseImage);
     $headers = ['Content-Type' => 'image/png', 'Content-Length' => $size, 'X-Powered-By' => 'yesdevnull.net/lastfm Last.fm Album Image Generator'];
     $response = Response::make($responseImage, 200, $headers);
     $filetime = filemtime($this->filename);
     $etag = md5($filetime);
     $time = Carbon::createFromTimeStamp($filetime)->toRFC2822String();
     $expires = Carbon::createFromTimeStamp($filetime)->addWeeks(1)->toRFC2822String();
     $response->setEtag($etag);
     $response->setLastModified(new DateTime($time));
     $response->setExpires(new DateTime($expires));
     $response->setPublic();
     if ($response->isNotModified($request)) {
         Log::info('Request is not modified, send empty response', ['filesize' => $size]);
         return $response;
     } else {
         Log::info('Request is modified, send new response', ['filesize' => $size]);
         $response->prepare($request);
         return $response;
     }
 }
Exemplo n.º 5
0
 /**
  * Returns a DateTime object from the hour
  */
 public function getCarbon()
 {
     return Carbon::createFromTimeStamp($this->time->sec);
 }
Exemplo n.º 6
0
 public static function timestampToString($timestamp, $timezone = false, $format)
 {
     if (!$timestamp) {
         return '';
     }
     $date = Carbon::createFromTimeStamp($timestamp);
     if ($timezone) {
         $date->tz = $timezone;
     }
     if ($date->year < 1900) {
         return '';
     }
     return $date->format($format);
 }
Exemplo n.º 7
0
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="home">

                @if($friend== null || $friend=="")

                <div style="margin-top:15px;padding: 15px 15px;background: #efefef;" id="noreview" name="noreview"> 
                    <b>Welcome to Berdict</b><br>
                    Follow some critics or friends to show some activity here.<br>
                </div>ime
                @endif



                @foreach ($friend as $action)
                <?php 
$time = Carbon::createFromTimeStamp($action->action_date)->diffForHumans();
?>

                @if ($action->type_id=="10")
                <?php 
$film = DB::table('film')->where('fl_id', $action->object_id)->join('rating', 'rating.rt_fl_id', '=', 'film.fl_id')->where('rt_usr_id', $action->id)->first();
?>
                <div class="row-fluid res-review " style="">
                    <div class="res-review-user col-md-12 pad0">
                        <a class="left" href="{{Config::get('url.home')}}{{$action->username}}">
                            <img class="lazy img-responsive " src="{{Config::get('url.home')}}berdict/img/avatar_50.png" data-original="{{Config::get('url.web')}}user_uploads/1000/{{$action->id}}/{{$action->usr_image}}" alt="" style="height:36px;width: 36px; display: inline;">
                        </a>
                        <div class="feed-rate-user-details">
                            <a href="{{Config::get('url.home')}}{{$action->username}}">{{$action->usr_fname}}</a> <span class="helper">rated</span> <a href="{{Config::get('url.home')}}movie/{{$film->fl_id}}/{{\Helpers\Helper::cleanUrl($film->fl_name)}}">{{$film->fl_name}}</a> 
                        </div>
                    </div>
 public function graphDays($meta, $start, $end)
 {
     $dates = array();
     $copy_start = \Carbon::createFromTimeStamp($start->timestamp);
     while ($copy_start <= $end) {
         $dates[str_pad($copy_start->month, 2, '0', STR_PAD_LEFT) . "/" . str_pad($copy_start->day, 2, '0', STR_PAD_LEFT)] = 0;
         $copy_start->addDay();
     }
     $results = $this->yearCounter->where("updated_at", ">", $start)->orWhere("created_at", "<", $end)->whereRaw(array("meta" => $meta))->get();
     $start->day = 1;
     $start->hour = 0;
     $start->minute = 0;
     $start->second = 0;
     foreach ($results as $result) {
         $date = $result["created_at"];
         for ($month = 0; $month < 12; $month++) {
             if ($date >= $start && $date <= $end) {
                 foreach ($result["day"][$date->month - 1] as $day => $value) {
                     $day += 1;
                     $date_string = str_pad($result["created_at"]->month, 2, '0', STR_PAD_LEFT) . "/" . str_pad($day, 2, '0', STR_PAD_LEFT);
                     if (isset($dates[$date_string])) {
                         $dates[$date_string] = $value;
                     }
                 }
             }
             $date->addMonth();
         }
     }
     return $dates;
 }
Exemplo n.º 9
0
@section('container')
<?php 
$random = rand(2, 100);
$randomuser = User::find($random);
?>


@if(Auth::check())
<?php 
$like = DB::table('review_likes')->where('review_id', $review->fr_id)->where('user_id', $random)->first();
?>

@endif
<?php 
$likeCount = DB::table('review_likes')->where('review_id', $review->fr_id)->count();
$time = Carbon::createFromTimeStamp($review->fr_date)->diffForHumans();
?>

@if(!Auth::check())
<div class="container" id="mainframe">
    <section class="res-main  pbot" style="text-align: center;padding:15px 0px 15px 10px;	">
        <img class="lazy" src="{{Config::get('url.home')}}berdict/img/berdict_prom.jpg" alt="" style="width:650px;max-height:150px;;display: inline;">
    </section>
</div>  
@endif


<div class="container" id="mainframe">
    <div class="row-fluid" style="min-height: 50px; "> 
        <h2 style="font-weight:700;text-transform: uppercase;margin:">                    
            Short Review of 
Exemplo n.º 10
0
 public function since()
 {
     $since = Carbon::createFromTimeStamp(strtotime($this->created_at))->diffForHumans();
     return $since;
 }
Exemplo n.º 11
0
                        $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));
            }
        }
    }
});
Event::listen('subscriptions.check', function () {
    Subscription::chunk(200, function ($subscriptions) {
        $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()) {
                    $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;
Exemplo n.º 12
0
 /**
  * [resultRequestDownload description]
  * @param  [type] $req_id [description]
  * @return [type]         [description]
  */
 public function resultRequestDownload($req_id)
 {
     $download_paht = Config::get('nhc/site.download_paht');
     // /Library/WebServer/Documents/lv_nhc/sites/app/downlad/
     $data = QueryData::queryDataNHCAll($req_id);
     $req_info = RequestData::find($req_id);
     $filename = Carbon::createFromTimeStamp(strtotime($req_info['updated_at']))->format('Y_m_d');
     $path = $download_paht . $req_info['agency_code'];
     $full_path_file = $path . '/' . $req_info['agency_code'] . '_' . $filename . '.csv';
     if (!file_exists($full_path_file)) {
         system('mkdir -p ' . $path);
         //echo $path;exit; //
     }
     if (file_exists($full_path_file)) {
         //$full_path_file = $path.'/'.$req_info['agency_code'].'_'.$filename.'.csv';
         $req_info->downloaded = true;
         $req_info->save();
         return Response::download($full_path_file, $req_info['agency_code'] . '_' . $filename . '.csv', array('content-type' => 'text/csv'));
     } else {
         $file = fopen($full_path_file, 'w');
         foreach ($data as $row) {
             fputcsv($file, (array) $row);
         }
         fclose($file);
         $req_info->downloaded = true;
         $req_info->save();
         return Response::download($full_path_file, $req_info['agency_code'] . '_' . $filename . '.csv', array('content-type' => 'text/csv'));
     }
 }
Exemplo n.º 13
0
<?php

$time = Carbon::createFromTimeStamp($latest->fr_date)->diffForHumans();
?>

<div class="row-fluid col-md-12" style="margin-bottom:30px;" id="data-review-{{$latest->fr_id}}">
   <div class="res-review-user col-md-12 pad0" style="height: 50px;">
      <a class="left" href="{{Config::get('url.home')}}{{$user->username}}">
        <img class="lazy img-responsive " src="{{Config::get('url.home')}}berdict/img/avatar_50.png" data-original="{{Config::get('url.web')}}user_uploads/1000/{{$user->id}}/{{$user->usr_image}}" alt="" style="height:36px;width: 36px; display: inline;border-radius:50px;">
      </a>
      <div class="feed-rate-user-details">
         <a href="{{Config::get('url.home')}}{{$user->username}}"><span class="helper">{{$user->usr_fname.' '.$user->usr_lname}} </span></a> 
      </div>
      <div class="feed-rate-user-details">
         <span style="color: rgba(0,0,0,0.3);font-size: 13px;line-height: 1.5;">Wrote a review - </span><span style="color: rgba(0,0,0,0.3);font-size: 13px;line-height: 1.5;"> {{$time}}</span>
      </div>
   </div>
   <div class="res-review-header col-md-12 pad0" style="height:30px;">
      <div class="res-review-user col-md-12 col-xs-9 pad0" style="">
         <div data-review-id="{{$latest->fr_id}}" class="res-review-body review-profile feed-review-body" style="font-weight: 800;font-size: 22px;margin-bottom:0;">
            <a class="review-headline" href=""> {{$latest->fr_review}} </a>
         </div>
         <div class="hidden" style="">

         </div>
      </div>
      <div class="res-review-rating col-md-3 col-xs-3 pad0 hidden" style="width:80px:">
         <img class="img-responsive" src="{{Config::get('url.home')}}rate_{{$latest->fr_vote}}.jpg" alt="" style="width:42px;display: inline;float:right;">
         <span style="background:#dbdbdb;;width:42px;height:42px;display: inline;float:right;font-size:24px;font-weight:600;padding:5px 0px;color:#666;text-align:center;">
         {{$latest->fr_vote}}                                      
         </span>
Exemplo n.º 14
0
 public static function timestampToString($timestamp, $timezone = false, $format)
 {
     if (!$timestamp) {
         return '';
     }
     $date = Carbon::createFromTimeStamp($timestamp);
     // if ($timezone) {
     // 	$date->tz = $timezone;
     // }
     // if ($date->year < 1900) {
     // 	return '';
     // }
     // return $date->format($format);
     $datef = strtotime($date);
     $year = date("Y", $datef);
     $month = date("m", $datef);
     $day = date("d", $datef);
     if ($month == '1') {
         $new_month = 'Ene';
     }
     if ($month == '2') {
         $new_month = 'Feb';
     }
     if ($month == '3') {
         $new_month = 'Mar';
     }
     if ($month == '4') {
         $new_month = 'Abr';
     }
     if ($month == '5') {
         $new_month = 'May';
     }
     if ($month == '6') {
         $new_month = 'Jun';
     }
     if ($month == '7') {
         $new_month = 'Jul';
     }
     if ($month == '8') {
         $new_month = 'Ago';
     }
     if ($month == '9') {
         $new_month = 'Sep';
     }
     if ($month == '10') {
         $new_month = 'Oct';
     }
     if ($month == '11') {
         $new_month = 'Nov';
     }
     if ($month == '12') {
         $new_month = 'Dic';
     }
     $new_date = $day . " " . $new_month . " " . $year;
     return $new_date;
 }