/** * Show the application dashboard. * * @return Response */ public function getCount(\Illuminate\Http\Request $request) { // Validate API Key $apiKey = \App\Models\ApiKey::where('api_key', $request->get('apiKey'))->where('active', 1)->first(); if (!$apiKey) { return \Response::json(['status' => 'Error', 'error' => 'Invalid API Key.'], 401); } // Validate Data if (!$request->has('name')) { return \Response::json(['status' => 'Error', 'error' => 'The name field is required.'], 400); } if (!$request->has('count') && !$request->has('value')) { return \Response::json(['status' => 'Error', 'error' => 'Either the count or value field is required.'], 400); } $user = $apiKey->user; $counter = $user->counters()->where('name', $request->get('name'))->first(); if (!$counter) { $counter = \App\Models\Counter::create(['user_id' => $user->id, 'name' => $request->get('name'), 'type' => $request->has('count') ? \App\Models\Counter::CounterTypeCount : \App\Models\Counter::CounterTypeValue]); } else { if ($counter->type == \App\Models\Counter::CounterTypeCount && !$request->has('count')) { return \Response::json(['status' => 'Error', 'error' => 'Stat "' . $request->get('name') . '" already exists and is a counter stat, but the "count" field was not included.'], 422); } if ($counter->type == \App\Models\Counter::CounterTypeValue && !$request->has('value')) { return \Response::json(['status' => 'Error', 'error' => 'Stat "' . $request->get('name') . '" already exists and is a value stat, but the "value" field was not included.'], 422); } } $bean = \App\Models\Bean::create(['counter_id' => $counter->id, 'value' => $counter->type == \App\Models\Counter::CounterTypeCount ? $request->get('count') : $request->get('value')]); if ($request->has('timestamp')) { $bean->created_at = \Carbon\Carbon::createFromTimestampUTC($request->get('timestamp')); $bean->save(); } return \Response::json(['status' => 'Success'], 200); }
public function logToConsole($tx_event) { if ($_debugLogTxTiming = Config::get('xchain.debugLogTxTiming')) { PHP_Timer::start(); } if (!isset($GLOBALS['XCHAIN_GLOBAL_COUNTER'])) { $GLOBALS['XCHAIN_GLOBAL_COUNTER'] = 0; } $count = ++$GLOBALS['XCHAIN_GLOBAL_COUNTER']; $xcp_data = $tx_event['counterpartyTx']; if ($tx_event['network'] == 'counterparty') { if ($xcp_data['type'] == 'send') { $this->wlog("from: {$xcp_data['sources'][0]} to {$xcp_data['destinations'][0]}: {$xcp_data['quantity']} {$xcp_data['asset']} [{$tx_event['txid']}]"); } else { $this->wlog("[" . date("Y-m-d H:i:s") . "] XCP TX FOUND: {$xcp_data['type']} at {$tx_event['txid']}"); } } else { if (rand(1, 100) === 1) { $c = Carbon::createFromTimestampUTC(floor($tx_event['timestamp']))->timezone(new \DateTimeZone('America/Chicago')); $this->wlog("heard {$count} tx. Last tx time: " . $c->format('Y-m-d h:i:s A T')); } } if ($_debugLogTxTiming) { Log::debug("[" . getmypid() . "] Time for logToConsole: " . PHP_Timer::secondsToTimeString(PHP_Timer::stop())); } }
public function localizeFilter(\DateTime $dateTime, string $format = null) { $carbon = Carbon::createFromTimestampUTC($dateTime->getTimestamp()); $carbon->setTimezone(new \DateTimeZone('Europe/Amsterdam')); setlocale(LC_ALL, 'nl_NL'); $carbon->setTimezone(new \DateTimeZone('Europe/Amsterdam')); return $carbon->formatLocalized($format); }
public function farFuture($years) { if ($years < 2) { throw new \InvalidArgumentException('farFuture() requires $year argument to be at least 2 years or more.'); } $upper = strtotime('+' . ($years + 1) . ' years'); $lower = strtotime('+' . ($years - 1) . ' years'); return Carbon::createFromTimestampUTC($this->generator->math->between($lower, $upper)); }
/** * Execute the console command. * * @return mixed */ public function handle() { $files = Storage::disk('s3')->files('backups'); foreach ($files as $file) { $modified = Storage::disk('s3')->lastModified($file); $date = Carbon\Carbon::createFromTimestampUTC($modified); if ($date < Carbon\Carbon::now()->subMonth(1)) { Storage::disk('s3')->delete($file); $this->info("Deleted " . $file); } } }
public function testGetScheduledMeetings() { $meetings = $this->meetingService->getScheduledMeetings(); $this->assertNotEmpty($meetings); $actualMeeting = $meetings[0]; $this->assertInstanceOf('\\kenobi883\\GoToMeeting\\Models\\Meeting', $actualMeeting); $this->assertAttributeNotEmpty('meetingId', $actualMeeting); $this->assertAttributeInstanceOf('\\DateTime', 'startTime', $actualMeeting); $startTime = Carbon::createFromTimestampUTC($actualMeeting->getStartTime()->getTimestamp()); $this->assertTrue($startTime->between(Carbon::now('UTC')->subYear(), Carbon::now('UTC')->addYear())); $this->assertAttributeInstanceOf('\\DateTime', 'endTime', $actualMeeting); $endTime = Carbon::createFromTimestampUTC($actualMeeting->getEndTime()->getTimestamp()); $this->assertTrue($endTime->between(Carbon::now('UTC')->subYear(), Carbon::now('UTC')->addYear())); }
public function processCertificate($certificateInfo) { if (!empty($certificateInfo['subject']) && !empty($certificateInfo['subject']['CN'])) { $this->certificateDomain = $certificateInfo['subject']['CN']; } if (!empty($certificateInfo['validTo_time_t'])) { $validTo = Carbon::createFromTimestampUTC($certificateInfo['validTo_time_t']); $this->certificateExpiration = $validTo->toDateString(); $this->certificateDaysUntilExpiration = -$validTo->diffInDays(Carbon::now(), false); } if (!empty($certificateInfo['extensions']) && !empty($certificateInfo['extensions']['subjectAltName'])) { $this->certificateAdditionalDomains = []; $domains = explode(', ', $certificateInfo['extensions']['subjectAltName']); foreach ($domains as $domain) { $this->certificateAdditionalDomains[] = str_replace('DNS:', '', $domain); } } }
public function convert($datetime) { if (is_array($datetime)) { if (count($datetime) <= 6) { $datetime = array_pad($datetime, 6, null); } $datetime[] = $this->getOption('timezone'); $method = new ReflectionMethod('Carbon\\Carbon', 'create'); return $method->invokeArgs(null, $datetime); } elseif ('timestamp' == $this->getOption('format')) { return Carbon::createFromTimestamp($datetime, $this->getOption('timezone')); } elseif ('utc_timestamp' == $this->getOption('format')) { return Carbon::createFromTimestampUTC($datetime, $this->getOption('timezone')); } elseif ($format = $this->getOption('format')) { return Carbon::createFromFormat($format, $datetime, $this->getOption('timezone')); } return new Carbon($datetime, $this->getOption('timezone')); }
/** * @todo refactor all these if statements * * @param LaravelMixpanel $mixPanel * @param $transaction * @param $user * @param array $originalValues */ private function recordSubscription(LaravelMixpanel $mixPanel, $transaction, $user, array $originalValues = []) { $planStatus = array_key_exists('status', $transaction) ? $transaction['status'] : null; $planName = isset($transaction['plan']['name']) ? $transaction['plan']['name'] : null; $planStart = array_key_exists('start', $transaction) ? $transaction['start'] : null; $planAmount = isset($transaction['plan']['amount']) ? $transaction['plan']['amount'] : null; $oldPlanName = isset($originalValues['plan']['name']) ? $originalValues['plan']['name'] : null; $oldPlanAmount = isset($originalValues['plan']['amount']) ? $originalValues['plan']['amount'] : null; if ($planStatus === 'canceled') { $mixPanel->people->set($user->id, ['Subscription' => 'None', 'Churned' => Carbon::now('UTC')->format('Y-m-d\\Th:i:s'), 'Plan When Churned' => $planName, 'Paid Lifetime' => Carbon::createFromTimestampUTC($planStart)->diffInDays(Carbon::now('UTC')) . ' days']); $mixPanel->track('Subscription', ['Status' => 'Canceled', 'Upgraded' => false]); $mixPanel->track('Churn! :-('); } if (count($originalValues)) { if ($planAmount && $oldPlanAmount) { if ($planAmount < $oldPlanAmount) { $mixPanel->people->set($user->id, ['Subscription' => $planName, 'Churned' => Carbon::now('UTC')->format('Y-m-d\\Th:i:s'), 'Plan When Churned' => $oldPlanName]); $mixPanel->track('Subscription', ['Upgraded' => false, 'FromPlan' => $oldPlanName, 'ToPlan' => $planName]); $mixPanel->track('Churn! :-('); } if ($planAmount > $oldPlanAmount) { $mixPanel->people->set($user->id, ['Subscription' => $planName]); $mixPanel->track('Subscription', ['Upgraded' => true, 'FromPlan' => $oldPlanName, 'ToPlan' => $planName]); $mixPanel->track('Unchurn! :-)'); } } else { if ($planStatus === 'trialing' && !$oldPlanName) { $mixPanel->people->set($user->id, ['Subscription' => $planName]); $mixPanel->track('Subscription', ['Upgraded' => true, 'FromPlan' => 'Trial', 'ToPlan' => $planName]); $mixPanel->track('Unchurn! :-)'); } } } else { if ($planStatus === 'active') { $mixPanel->people->set($user->id, ['Subscription' => $planName]); $mixPanel->track('Subscription', ['Status' => 'Created']); } if ($planStatus === 'trialing') { $mixPanel->people->set($user->id, ['Subscription' => 'Trial']); $mixPanel->track('Subscription', ['Status' => 'Trial']); } } }
<?php echo GridView::widget(['id' => 'template-category-grid', 'dataProvider' => $dataProvider, 'resizableColumns' => false, 'pjax' => false, 'export' => false, 'responsive' => true, 'bordered' => false, 'striped' => true, 'panelTemplate' => '<div class="panel {type}"> {panelHeading} {panelBefore} {items} <div style="text-align: center">{pager}</div> </div>', 'panel' => ['type' => GridView::TYPE_INFO, 'heading' => Yii::t('app', 'Templates') . ' <small class="panel-subtitle hidden-xs">' . Yii::t('app', 'By Categories') . '</small>', 'footer' => false, 'before' => ActionBar::widget(['grid' => 'template-category-grid', 'templates' => ['{create}' => ['class' => 'col-xs-6 col-md-8'], '{bulk-actions}' => ['class' => 'col-xs-6 col-md-2 col-md-offset-2']], 'bulkActionsItems' => [Yii::t('app', 'General') => ['general-delete' => Yii::t('app', 'Delete')]], 'bulkActionsOptions' => ['options' => ['general-delete' => ['url' => Url::toRoute('delete-multiple'), 'data-confirm' => Yii::t('app', 'Are you sure you want to delete these template categories? All data related to each item will be deleted. This action cannot be undone.')]], 'class' => 'form-control'], 'elements' => ['create' => Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'Create Category'), ['create'], ['class' => 'btn btn-primary']) . ' ' . Html::a(Yii::t('app', 'Need to extend the app functionality?'), ['/addons'], ['data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('app', 'With our add-ons you can add great features and integrations to your forms. Try them now!'), 'class' => 'text hidden-xs hidden-sm'])], 'class' => 'form-control'])], 'toolbar' => false, 'columns' => [['class' => '\\kartik\\grid\\CheckboxColumn', 'headerOptions' => ['class' => 'kartik-sheet-style'], 'rowSelectedClass' => GridView::TYPE_WARNING], ['attribute' => 'name', 'format' => 'raw', 'value' => function ($model) { return Html::a(Html::encode($model->name), ['templates/category', 'id' => $model->id]); }], ['attribute' => 'description', 'value' => function ($model) { if (isset($model->description)) { return StringHelper::truncateWords(Html::encode($model->description), 15); } return null; }], ['attribute' => 'updated_at', 'value' => function ($model) { if (isset($model->updated_at)) { return Carbon::createFromTimestampUTC($model->updated_at)->diffForHumans(); } return null; }, 'label' => Yii::t('app', 'Last updated')], ['class' => 'kartik\\grid\\ActionColumn', 'dropdown' => true, 'dropdownButton' => ['class' => 'btn btn-primary'], 'dropdownOptions' => ['class' => 'pull-right'], 'buttons' => ['view' => function ($url) { $options = array_merge(['title' => Yii::t('app', 'View'), 'aria-label' => Yii::t('app', 'View'), 'data-pjax' => '0'], []); return '<li>' . Html::a('<span class="glyphicon glyphicon-eye-open"></span> ' . Yii::t('app', 'View Record'), $url, $options) . '</li>'; }, 'update' => function ($url) { $options = array_merge(['title' => Yii::t('app', 'Update'), 'aria-label' => Yii::t('app', 'Update'), 'data-pjax' => '0'], []); return '<li>' . Html::a('<span class="glyphicon glyphicon-pencil"></span> ' . Yii::t('app', 'Update'), $url, $options) . '</li>'; }, 'delete' => function ($url) { $options = array_merge(['title' => Yii::t('app', 'Delete'), 'aria-label' => Yii::t('app', 'Delete'), 'data-confirm' => Yii::t('app', 'Are you sure you want to delete this template category? All data related to this item will be deleted. This action cannot be undone.'), 'data-method' => 'post', 'data-pjax' => '0'], []); return '<li>' . Html::a('<span class="glyphicon glyphicon-bin"></span> ' . Yii::t('app', 'Delete'), $url, $options) . '</li>'; }]]]]); ?>
public function expirationDate() : Carbon { return Carbon::createFromTimestampUTC($this->rawCertificateFields['validTo_time_t']); }
$this->params['breadcrumbs'][] = $this->title; Carbon::setLocale(substr(Yii::$app->language, 0, 2)); // eg. en-US to en ?> <div class="template-category-view box box-big box-light"> <div class="pull-right" style="margin-top: -5px"> <?php echo Html::a('<span class="glyphicon glyphicon-pencil"></span> ', ['update', 'id' => $model->id], ['title' => Yii::t('app', 'Update Template'), 'class' => 'btn btn-sm btn-info']); ?> <?php echo Html::a('<span class="glyphicon glyphicon-bin"></span> ', ['delete', 'id' => $model->id], ['title' => Yii::t('app', 'Delete Template'), 'class' => 'btn btn-sm btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this template category? All data related to this item will be deleted. This action cannot be undone.'), 'method' => 'post']]); ?> </div> <div class="box-header"> <h3 class="box-title"><?php echo Yii::t('app', 'Template Category'); ?> <span class="box-subtitle"><?php echo Html::encode($this->title); ?> </span> </h3> </div> <?php echo DetailView::widget(['model' => $model, 'condensed' => false, 'hover' => true, 'mode' => DetailView::MODE_VIEW, 'enableEditMode' => false, 'hideIfEmpty' => true, 'options' => ['class' => 'kv-view-mode'], 'attributes' => ['id', 'name', 'description', ['attribute' => 'created_at', 'value' => isset($model->created_at) ? Carbon::createFromTimestampUTC($model->created_at)->diffForHumans() : null, 'label' => Yii::t('app', 'Created')], ['attribute' => 'updated_at', 'value' => isset($model->updated_at) ? Carbon::createFromTimestampUTC($model->updated_at)->diffForHumans() : null, 'label' => Yii::t('app', 'Last updated')]]]); ?> </div>
?> </div> <div class="list-group"> <?php foreach ($lastUpdatedForms as $form) { ?> <a href="<?php echo Url::to(['form/view', 'id' => $form['id']]); ?> " class="list-group-item"><?php echo Html::encode($form['name']); ?> <span class="label label-info"> <?php echo Carbon::createFromTimestampUTC($form['updated_at'])->diffForHumans(); ?> </span> </a> <?php } ?> <?php if (count($lastUpdatedForms) == 0) { ?> <div class="list-group-item"><?php echo Yii::t('app', 'No data'); ?> </div> <?php }
/** * @param $date * @return static */ public static function convert($date) { $date2 = (int) ($date / 1000); $date_string = Carbon::createFromTimestampUTC($date2)->toDayDateTimeString(); return $date_string; }
public function activeHours() { $hours = array_fill(0, 24, 0); foreach ($this->getSubmissions() as $submission) { $time = Carbon::createFromTimestampUTC($submission->data->created_utc); // $time->timezone = new DateTimeZone('America/Vancouver'); $hour = $time->hour; $hours[$hour]++; } return $hours; }
public function getLastEditTime() { return $this->make('fileLastEditTime', function () { return \Carbon\Carbon::createFromTimestampUTC(filemtime($this->url)); }); }
/** * Get a Carbon instance for the end date. * * @return \Carbon\Carbon */ public function endDateAsCarbon() { if ($this->isSubscription()) { return Carbon::createFromTimestampUTC($this->item->period->end); } }
<?php echo Html::a('<span class="glyphicon glyphicon-bin"></span> ', ['delete', 'id' => $model->id], ['title' => Yii::t('app', 'Delete Template'), 'class' => 'btn btn-sm btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this template? All data related to this item will be deleted. This action cannot be undone.'), 'method' => 'post']]); ?> </div> <div class="box-header"> <h3 class="box-title"><?php echo Yii::t('app', 'Template'); ?> <span class="box-subtitle"><?php echo Html::encode($this->title); ?> </span> </h3> </div> <?php echo DetailView::widget(['model' => $model, 'condensed' => false, 'hover' => true, 'mode' => DetailView::MODE_VIEW, 'enableEditMode' => false, 'hideIfEmpty' => true, 'options' => ['class' => 'kv-view-mode'], 'attributes' => ['id', 'name', ['attribute' => 'category', 'value' => isset($model->category) ? Html::encode($model->category->name) : null, 'label' => Yii::t('app', 'Category')], 'description', ['attribute' => 'html', 'format' => 'raw', 'value' => Html::decode($model->html), 'label' => Yii::t('app', 'Preview')], ['attribute' => 'promoted', 'format' => 'raw', 'value' => $model->promoted === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-default"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'author', 'value' => $model->author->username, 'label' => Yii::t('app', 'Created by')], ['attribute' => 'created_at', 'value' => isset($model->created_at) ? Carbon::createFromTimestampUTC($model->created_at)->diffForHumans() : null, 'label' => Yii::t('app', 'Created')], ['attribute' => 'lastEditor', 'value' => $model->lastEditor->username, 'label' => Yii::t('app', 'Last Editor')], ['attribute' => 'updated_at', 'value' => isset($model->updated_at) ? Carbon::createFromTimestampUTC($model->updated_at)->diffForHumans() : null, 'label' => Yii::t('app', 'Last updated')]]]); ?> </div> <?php // Disable form submit $js = <<<JS jQuery(document).ready(function(){ jQuery('form').submit(function() { return false; }); }); JS; $this->registerJs($js, $this::POS_END);
echo Html::a('<span class="glyphicon glyphicon-flowchart"></span> ' . Yii::t('app', 'Rules'), ['rules', 'id' => $formModel->id], ['title' => Yii::t('app', 'Conditional Rules'), 'class' => 'btn btn-sm btn-info']); ?> </div> <?php echo Html::a('<span class="glyphicon glyphicon-send"></span> ' . Yii::t('app', 'Submissions'), ['submissions', 'id' => $formModel->id], ['title' => Yii::t('app', 'Submissions'), 'class' => 'btn btn-sm btn-warning']); ?> <div class="btn-group" role="group"> <?php echo Html::a('<span class="glyphicon glyphicon-pie-chart"></span> ' . Yii::t('app', 'Report'), ['report', 'id' => $formModel->id], ['title' => Yii::t('app', 'Submissions Report'), 'class' => 'btn btn-sm btn-default']); ?> <?php echo Html::a('<span class="glyphicon glyphicon-stats"></span> ' . Yii::t('app', 'Performance'), ['analytics', 'id' => $formModel->id], ['title' => Yii::t('app', 'Performance Analytics'), 'class' => 'btn btn-sm btn-default']); ?> <?php echo Html::a('<span class="glyphicon glyphicon-charts"></span> ' . Yii::t('app', 'Analytics'), ['stats', 'id' => $formModel->id], ['title' => Yii::t('app', 'Submissions Analytics'), 'class' => 'btn btn-sm btn-default']); ?> </div> <?php echo Html::a('<span class="glyphicon glyphicon-share"></span> ' . Yii::t('app', 'Publish & Share'), ['share', 'id' => $formModel->id], ['title' => Yii::t('app', 'Publish & Share'), 'class' => 'btn btn-sm btn-success']); ?> <?php echo Html::a('<span class="glyphicon glyphicon-bin"></span> ' . Yii::t('app', 'Delete'), ['delete', 'id' => $formModel->id], ['title' => Yii::t('app', 'Delete'), 'class' => 'btn btn-sm btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </div> <?php echo DetailView::widget(['model' => $formModel, 'condensed' => false, 'hover' => true, 'mode' => DetailView::MODE_VIEW, 'hideIfEmpty' => true, 'enableEditMode' => false, 'options' => ['class' => 'kv-view-mode'], 'attributes' => [['group' => true, 'label' => Yii::t('app', 'Form Info'), 'rowOptions' => ['class' => 'info']], 'id', 'name', ['attribute' => 'language', 'value' => $formModel->languageLabel], ['attribute' => 'status', 'format' => 'raw', 'value' => $formModel->status === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'save', 'format' => 'raw', 'value' => $formModel->save === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'analytics', 'format' => 'raw', 'value' => $formModel->analytics === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'honeypot', 'format' => 'raw', 'value' => $formModel->honeypot === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'recaptcha', 'format' => 'raw', 'value' => $formModel->recaptcha === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'total_limit', 'format' => 'raw', 'value' => $formModel->total_limit === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'ip_limit', 'format' => 'raw', 'value' => $formModel->ip_limit === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'schedule', 'format' => 'raw', 'value' => $formModel->schedule === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]]], ['attribute' => 'author', 'value' => $formModel->author->username, 'label' => Yii::t('app', 'Created by')], ['attribute' => 'created_at', 'value' => isset($formModel->created_at) ? Carbon::createFromTimestampUTC($formModel->created_at)->diffForHumans() : null, 'label' => Yii::t('app', 'Created')], ['attribute' => 'lastEditor', 'value' => $formModel->lastEditor->username, 'label' => Yii::t('app', 'Last Editor')], ['attribute' => 'updated_at', 'value' => isset($formModel->updated_at) ? Carbon::createFromTimestampUTC($formModel->updated_at)->diffForHumans() : null, 'label' => Yii::t('app', 'Last updated')], ['group' => true, 'label' => Yii::t('app', 'Confirmation Info'), 'rowOptions' => ['class' => 'info']], ['attribute' => 'formConfirmation', 'value' => $formModel->formConfirmation->getTypeLabel(), 'label' => Yii::t('app', 'How to')], ['attribute' => 'formConfirmation', 'value' => Html::encode($formModel->formConfirmation->message), 'label' => Yii::t('app', 'Message')], ['attribute' => 'formConfirmation', 'value' => Html::encode($formModel->formConfirmation->url), 'label' => Yii::t('app', 'Url')], ['attribute' => 'formConfirmation', 'format' => 'raw', 'value' => $formModel->formConfirmation->send_email === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]], 'label' => Yii::t('app', 'Send Email')], ['attribute' => 'formConfirmation', 'value' => Html::encode($formModel->formConfirmation->mail_from), 'label' => Yii::t('app', 'Reply To')], ['attribute' => 'formConfirmation', 'value' => Html::encode($formModel->formConfirmation->mail_subject), 'label' => Yii::t('app', 'Subject')], ['attribute' => 'formConfirmation', 'value' => Html::encode($formModel->formConfirmation->mail_from_name), 'label' => Yii::t('app', 'Name or Company')], ['attribute' => 'formConfirmation', 'format' => 'raw', 'value' => $formModel->formConfirmation->mail_receipt_copy === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]], 'label' => Yii::t('app', 'Includes a Submission Copy')], ['group' => true, 'label' => Yii::t('app', 'Notification Info'), 'rowOptions' => ['class' => 'info']], ['attribute' => 'formEmail', 'value' => Html::encode($formModel->formEmail->subject), 'label' => Yii::t('app', 'Subject')], ['attribute' => 'formEmail', 'value' => Html::encode($formModel->formEmail->to), 'label' => Yii::t('app', 'Recipient')], ['attribute' => 'formEmail', 'value' => Html::encode($formModel->formEmail->cc), 'label' => Yii::t('app', 'Cc')], ['attribute' => 'formEmail', 'value' => Html::encode($formModel->formEmail->bcc), 'label' => Yii::t('app', 'Bcc')], ['attribute' => 'formEmail', 'value' => $formModel->formEmail->typeLabel, 'label' => Yii::t('app', 'Contents')], ['attribute' => 'formEmail', 'format' => 'raw', 'value' => $formModel->formEmail->attach === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]], 'label' => Yii::t('app', 'Attach')], ['attribute' => 'formEmail', 'format' => 'raw', 'value' => $formModel->formEmail->plain_text === 1 ? '<span class="label label-success"> ' . Yii::t('app', 'ON') . ' </span>' : '<span class="label label-danger"> ' . Yii::t('app', 'OFF') . ' </span>', 'type' => DetailView::INPUT_SWITCH, 'widgetOptions' => ['pluginOptions' => ['onText' => Yii::t('app', 'ON'), 'offText' => Yii::t('app', 'OFF')]], 'label' => Yii::t('app', 'Only Plain Text')]]]); ?> </div>
/** * Get a Carbon date for the invoice. * * @param \DateTimeZone|string $timezone * * @return \Carbon\Carbon */ public function date($timezone = null) { $carbon = Carbon::createFromTimestampUTC($this->invoice->date); return $timezone ? $carbon->setTimezone($timezone) : $carbon; }
public function importInfinityPost($post, Board &$board, &$threads) { $thread = null; if (!$post->thread) { $thread = null; } else { if (isset($threads[$post->thread])) { $thread = $threads[$post->thread]; } else { return false; } } $createdAt = Carbon::now(); $editedAt = $createdAt; $bumpedLast = $createdAt; // Yes. Vichan database records for time can be malformed. // Handle them carefully. try { $createdAt = Carbon::createFromTimestampUTC($post->time); } catch (\Exception $e) { } try { if ($post->edited_at) { $editedAt = Carbon::createFromTimestampUTC($post->edited_at); } } catch (\Exception $e) { } try { if ($post->bump) { $bumpedLast = Carbon::createFromTimestampUTC($post->bump); } } catch (\Exception $e) { } return ['board_uri' => $board->board_uri, 'board_id' => (int) $post->id, 'reply_to' => $thread ? (int) $thread->post_id : null, 'reply_to_board_id' => $thread ? (int) $thread->board_id : null, 'created_at' => $createdAt, 'updated_at' => $editedAt, 'updated_by' => null, 'deleted_at' => null, 'bumped_last' => $bumpedLast, 'stickied' => !($post->thread || !$post->sticky), 'stickied_at' => $post->thread || !$post->sticky ? null : $createdAt, 'locked_at' => $post->thread || !$post->locked ? null : $createdAt, 'body' => null, 'body_parsed' => null, 'body_parsed_at' => null, 'body_html' => (string) $post->body, 'body_too_long' => null, 'body_parsed_preview' => null, 'subject' => $post->subject ?: null, 'author' => $post->name ?: null, 'author_id' => null, 'author_ip' => $post->ip ? new IP($post->ip) : null, 'email' => (string) $post->email, 'insecure_tripcode' => $post->trip ? ltrim("{$post->trip}", "!") : null, 'password' => null]; }
/** * Updated at with format * * @return string */ public function getUpdated() { return Carbon::createFromTimestampUTC($this->updated_at)->diffForHumans(); }
public function testCreateFromTimestampGMTDoesNotUseDefaultTimezone() { $d = Carbon::createFromTimestampUTC(0); $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); $this->assertTrue($d->offset === 0); }
/** * @param $token * @param bool $allowExpireRefresh * @return bool */ function is_jwt_token_valid_for_refresh($token, $allowExpireRefresh = false) { $is_jwt_token_valid_for_refresh = false; try { $payload = \JWTAuth::getPayload($token); $exp = $payload->get('exp'); $nbf = $payload->get('nbf'); if ($exp > 0 && $nbf > 0) { $nowTime = \Carbon\Carbon::now('UTC'); $expireTime = \Carbon\Carbon::createFromTimestampUTC($exp); $validTime = \Carbon\Carbon::createFromTimestampUTC($nbf); // if now time is after valid time if ($nowTime->gt($validTime)) { $minutesAfterValid = $nowTime->diffInMinutes($validTime); $minutesBeforeExpire = $nowTime->diffInMinutes($expireTime); $totalValidLength = $validTime->diffInMinutes($expireTime); $halfAmountOfMinutes = floor($totalValidLength / 2); if ($minutesAfterValid >= $halfAmountOfMinutes) { $is_jwt_token_valid_for_refresh = true; } } } } catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) { if ($allowExpireRefresh) { $is_jwt_token_valid_for_refresh = true; } } catch (\Tymon\JWTAuth\Exceptions\JWTException $e) { } return $is_jwt_token_valid_for_refresh; }
/** * @param $value * * @return Carbon */ private function createCarbonFromDateTime(DateTime $value) { return Carbon::createFromTimestampUTC($value->getTimestamp()); }
Carbon::setLocale(substr(Yii::$app->language, 0, 2)); // eg. en-US to en ?> <div class="theme-view box box-big box-light"> <div class="pull-right" style="margin-top: -5px"> <?php echo Html::a('<span class="glyphicon glyphicon-pencil"></span> ', ['update', 'id' => $themeModel->id], ['title' => Yii::t('app', 'Update Theme'), 'class' => 'btn btn-sm btn-info']); ?> <?php echo Html::a('<span class="glyphicon glyphicon-bin"></span> ', ['delete', 'id' => $themeModel->id], ['title' => Yii::t('app', 'Delete Theme'), 'class' => 'btn btn-sm btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this theme? All data related to this item will be deleted. This action cannot be undone.'), 'method' => 'post']]); ?> </div> <div class="box-header"> <h3 class="box-title"><?php echo Yii::t('app', 'Theme'); ?> <span class="box-subtitle"><?php echo Html::encode($this->title); ?> </span> </h3> </div> <?php echo DetailView::widget(['model' => $themeModel, 'condensed' => false, 'hover' => true, 'mode' => DetailView::MODE_VIEW, 'enableEditMode' => false, 'hideIfEmpty' => true, 'options' => ['class' => 'kv-view-mode'], 'attributes' => ['id', 'name', 'description', ['attribute' => 'color', 'format' => 'raw', 'value' => "<span class='badge' style='background-color: {$themeModel->color}'> </span> <code>" . $themeModel->color . '</code>', 'type' => DetailView::INPUT_COLOR], ['attribute' => 'author', 'value' => $themeModel->author->username, 'label' => Yii::t('app', 'Created by')], ['attribute' => 'created_at', 'value' => isset($themeModel->created_at) ? Carbon::createFromTimestampUTC($themeModel->created_at)->diffForHumans() : null, 'label' => Yii::t('app', 'Created')], ['attribute' => 'lastEditor', 'value' => $themeModel->lastEditor->username, 'label' => Yii::t('app', 'Last Editor')], ['attribute' => 'updated_at', 'value' => isset($themeModel->updated_at) ? Carbon::createFromTimestampUTC($themeModel->updated_at)->diffForHumans() : null, 'label' => Yii::t('app', 'Last updated')]]]); ?> </div>
protected function createFileResponse($path, SymfonyRequest $request) { // Get the accepted encodings from Request instance. $acceptEncoding = $request->headers->get('Accept-Encoding'); if (!is_null($acceptEncoding)) { $acceptEncoding = array_map('trim', explode(',', $acceptEncoding)); } else { $acceptEncoding = array(); } // Create a Response instance. $response = new Response(file_get_contents($path), 200); // Setup the Last-Modified header. $lastModified = Carbon::createFromTimestampUTC(filemtime($path)); $response->headers->set('Last-Modified', $lastModified->format('D, j M Y H:i:s') . ' GMT'); return $this->compressResponseContent($response, $acceptEncoding); }
public function getMailBox() { $mailboxes = array('label' => 'Gmail', 'enable' => true, 'mailbox' => '{imap.gmail.com:993/ssl}[Gmail]/Sent Mail', 'username' => '*****@*****.**', 'password' => '4N?@vwJn@resijt'); $stream = imap_open($mailboxes['mailbox'], $mailboxes['username'], $mailboxes['password']); if (!$stream) { return 'err1'; //return Redirect::back()->withInput()->withErrors('An error occured. Please try again.'); } $emails = imap_search($stream, 'ALL'); if (!$emails) { return 'err2'; } else { rsort($emails); } $emailList = array(); $count = 0; foreach ($emails as $item) { $overview = imap_fetch_overview($stream, $item, 0); $emailList[$count] = $overview; $emailList[$count]['agoTime'] = Carbon::createFromTimestampUTC(strtotime($overview[0]->date))->diffForHumans(); $count++; } imap_close($stream); return $emailList; }