/** * Attribution pixel * * @param PixelRequest $request * @return Image */ public function store(PixelRequest $request) { $this->agent->setUserAgent($request->header('user-agent')); ignore_user_abort(true); // Turn off gzip compression if (function_exists('apache_setenv')) { apache_setenv('no-gzip', 1); } ini_set('zlib.output_compression', 0); // Turn on output buffering if necessary if (ob_get_level() == 0) { ob_start(); } // Remove any content encoding header('Content-encoding: none', true); if (!$request->isMethod('post')) { // Create attribution entry $attribution = Attribution::create(['landing_page_id' => $request->get('lp'), 'email' => $request->get('em'), 'tracking_id' => $request->get('t'), 'converting_source' => $request->get('cs'), 'converting_medium' => $request->get('cm'), 'converting_keyword' => $request->get('ck'), 'converting_content' => $request->get('ccn'), 'converting_campaign' => $request->get('cc'), 'converting_landing_page' => $request->get('cl'), 'converting_timestamp' => Carbon::createFromTimeStamp($request->get('ct'))->toDateTimeString(), 'original_source' => $request->get('os'), 'original_medium' => $request->get('om'), 'original_keyword' => $request->get('ok'), 'original_content' => $request->get('ocn'), 'original_campaign' => $request->get('oc'), 'original_landing_page' => $request->get('ol'), 'original_timestamp' => Carbon::createFromTimeStamp($request->get('ot'))->toDateTimeString(), 'refer_url' => $request->get('r'), 'platform' => $this->agent->platform(), 'device' => $this->agent->device(), 'browser' => $this->agent->browser(), 'version' => $this->agent->version($this->agent->browser())]); // Link attribution entry to lead \Event::fire(new AttributionSubmitted($attribution)); // Return 1x1 pixel transparent gif header("Content-type: image/gif"); header("Content-Length: 42"); header("Cache-Control: private, no-cache, no-cache=Set-Cookie, proxy-revalidate"); header("Pragma: no-cache"); echo base64_decode('R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEA'); } // Flush output buffers ob_flush(); flush(); ob_end_flush(); }
/** * Store a newly created resource in storage. * POST /actions * * @return Response */ public function store() { $response = new stdClass(); $statusCode = 201; $in = Input::only('tid', 'created_at'); $rules = array('tid' => 'required | integer'); $vd = Validator::make($in, $rules); if ($vd->fails()) { $errs = $vd->messages(); $statusCode = 400; $response = $errs->all(); } else { $authId = Auth::user()->id; // 先檢查是否在 Target 有登記 $uid = Target::where(array('id' => $in['tid'], 'uid' => $authId))->pluck('uid'); // 取得使用者的教會 $cid = UserChurch::where(array('uid' => $authId))->pluck('cid'); if ($uid == $authId) { $in['uid'] = Auth::user()->id; $in['cid'] = $cid; $action = Action::create($in); if ($in['created_at']) { $in['created_at'] = Carbon::createFromTimeStamp($in['created_at'], 'Asia/Taipei')->toDateTimeString(); $action->setCreatedAt($in['created_at']); $action->save(); } } else { $statusCode = 403; } } return Response::json($response, $statusCode); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->info(''); $this->info('------------------------------------------'); $this->info(''); $feeds = Feeds::all(); foreach ($feeds as $f) { $feed = SimpleFeeds::make($f->url); $count = 0; $story['source'] = $feed->get_title(); $story['source_url'] = $feed->get_permalink(); foreach ($feed->get_items() as $item) { $date = strtotime($item->get_date()); // $dom = new \Htmldom($item->get_permalink()); // echo $response->getBody(); $story['headline'] = $item->get_title(); $story['url'] = $item->get_permalink(); $story['feed_id'] = $f->id; // $story['image'] = (isset($item->get_thumbnail())) ? $item->get_thumbnail() : ''; // $story['excerpt'] = (isset($dom->find($f->excerpt)[0]->find('p')[0])) ? $dom->find($f->excerpt)[0]->find('p')[0]->plaintext : 'empty'; $story['pub_date'] = Carbon::createFromTimeStamp($date)->format('Y-m-d G:i'); if ($item->get_description() && $f->use_description) { $story['excerpt'] = $item->get_description(); $story['approved'] = true; } if (!Stories::where('headline', '=', $story['headline'])->first()) { Stories::create($story); $count++; } } $this->info('Added ' . $count . ' stories from ' . $f->name); } }
/** * @param $data * @return mixed */ public function data($data, $parameters = []) { if (is_numeric($data)) { return Carbon::createFromTimeStamp($data); } return ''; }
public static function index() { $feeds = Feeds::all(); $stories = []; foreach ($feeds as $f) { $feed = SimpleFeeds::make($f->url); $count = 0; $story['source'] = $feed->get_title(); $story['source_url'] = $feed->get_permalink(); foreach ($feed->get_items() as $item) { $date = strtotime($item->get_date()); // $dom = new \Htmldom($item->get_permalink()); // echo $response->getBody(); $story['headline'] = $item->get_title(); $story['url'] = $item->get_permalink(); $story['feed_id'] = $f->id; // $story['image'] = (isset($item->get_thumbnail())) ? $item->get_thumbnail() : ''; // $story['excerpt'] = (isset($dom->find($f->excerpt)[0]->find('p')[0])) ? $dom->find($f->excerpt)[0]->find('p')[0]->plaintext : 'empty'; $story['pub_date'] = Carbon::createFromTimeStamp($date)->format('Y-m-d G:i'); if (!Stories::where('headline', '=', $story['headline'])->first()) { $stories[] = $story; Stories::create($story); $count++; } } } usort($stories, function ($a, $b) { $t1 = strtotime($a['pub_date']); $t2 = strtotime($b['pub_date']); return $t2 - $t1; }); return response()->json($stories); }
/** * @param $data * @return mixed */ public function data($data, $parameters = []) { if (is_numeric($data)) { return Carbon::createFromTimeStamp($data)->format(Config::get('coanda::coanda.datetime_format')); } return ''; }
public function retrieve(Request $request, Weather $weather) { if (!$request->has('lat') || !$request->has('lon')) { return response('Please provide a lat and lon', 400); } $input = $request->all(); // We grab the lat and lon $lat = $input['lat']; $lon = $input['lon']; // We grab the latest data from this lat and long $rawData = file_get_contents('http://api.openweathermap.org/data/2.5/weather?lat=' . $lat . '&lon=' . $lon); if (!$rawData) { // We failed to retrieve data from the webservice // Just return the stuff we have return $weather->where('lat', $lat)->where('lon', $lon)->limit(10)->get(); } $jsonData = json_decode($rawData, true); // We transform this data $data = ['dt' => $jsonData['dt'], 'lat' => $lat, 'lon' => $lon, 'type' => $jsonData['weather'][0]['main'], 'temp' => $jsonData['main']['temp'] - 273.15]; // Check if we already have a record with same lat/lon and dt in our database $weatherCheck = $weather->where('lat', $lat)->where('lon', $lon)->where('dt', Carbon::createFromTimeStamp($data['dt']))->limit(1)->get(); // Record isn't in our db yet if ($weatherCheck->isEmpty()) { // We store the data in our database $weather->create($data); } // We grab the last 10 weather report from given lat/lon and return it return $weather->where('lat', $lat)->where('lon', $lon)->limit(10)->get(); }
/** * Present the start date. * * @param string $type short|medium|long * @return string */ public function date(string $type = 'long') { // $now = \Carbon\Carbon::createFromTimeStamp(strtotime(\Carbon\Carbon::now('America/New_York'))); // $start = \Carbon\Carbon::createFromTimeStamp(strtotime($this->model->start_at)); // $diffForHumans = $start->diffForHumans($now); // $diffForHumans = str_replace(['before', 'after'], ['ago', 'from now'], $diffForHumans); $timestamp = strtotime($this->model->start_at); $carbon = Carbon::createFromTimeStamp($timestamp); $date = date('l, F j, Y', $timestamp); $humanDay = null; if ($carbon->isToday()) { $humanDay = 'Today'; } elseif ($carbon->isTomorrow()) { $humanDay = 'Tomorrow'; } elseif ($carbon->isYesterday()) { $humanDay = 'Yesterday'; } switch ($type) { case 'short': return $humanDay ?: $date; case 'medium': return $date; case 'long': default: return $humanDay ? $humanDay . ', ' . $date : $date; } }
/** * Handle requests for '/sitemap.xml'. * * @return \Illuminate\Http\Response * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ public function sitemap() { if (!$this->wp->isPublic()) { abort(404); } $view = view('root.sitemap', ['appModified' => Carbon::createFromTimeStamp(app('modified'), $this->wp->timezone())]); return response($view, 200, ['content-type' => 'text/xml']); }
function createDateAntlers($date) { $timeArray = explode(' ', $date); $month = $timeArray[0]; $day = rtrim($timeArray[1], ','); $year = $timeArray[2]; $timestamp = strtotime($day . " " . $month . " " . $year); return $date = Carbon::createFromTimeStamp($timestamp); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); // Shop::truncate(); $startDate = Carbon::createFromTimeStamp($faker->dateTimeBetween('-1 years', '+1 month')->getTimestamp()); foreach (range(1, 20) as $index) { Shop::create(['name' => $faker->name, 'shopDescription' => $faker->realText($maxNbChars = 200, $indexSize = 2), 'location' => $faker->city, 'contactNumber' => $faker->phoneNumber, 'openingDate' => $startDate->toDateTimeString(), 'email' => $faker->companyEmail]); } }
/** * @Middleware("admin") * @Get("/print/week") */ public function printWeekOrders() { $week = \Input::get('week'); $date = Carbon::createFromTimeStamp($week); $dateFormatted = $date->copy()->format('d.m.Y'); $dateFormatted2 = $date->copy()->addDays(4)->format('d.m.Y'); $users = User::getWeekPrintData($date); return view('admin.orders.print-week', compact('users', 'dateFormatted', 'dateFormatted2')); }
public function updated_at() { $timestamp = strtotime($this->updated_at); if (time() < $timestamp + 86400 * 3) { return \Carbon\Carbon::createFromTimeStamp(strtotime($this->updated_at))->diffForHumans(); } else { return $this->updated_at; } }
/** * Handle a failed payment from a Stripe invoice. * * @param array $payload * * @return \Symfony\Component\HttpFoundation\Response */ protected function handleInvoicePaymentFailed(array $payload) { if ($customer = $this->getCustomer($payload['data']['object']['customer'])) { $next_attempt = Arr::get($payload, 'data.object.next_payment_attempt'); $data = array('attempt_count' => Arr::get($payload, 'data.object.attempt_count'), 'next_attempt' => Carbon::createFromTimeStamp($next_attempt)); $customer->fireCustomerEvent('invoicePaymentFailed', $customer->invoices()->find($payload['data']['object']['id']), $data); } return new Response('Webhook Handled', 200); }
public function postHelpCreate($_timestamp = 0) { //return Input::all(); $reslove_type = Input::get('reslove_type'); $workbench = Input::get('workbench'); $timestamp = Crypt::decrypt($_timestamp); $dept_id = DB::table('tb_sub_dept')->where('sub_dept_id', '=', Input::get('sub_dept_id'))->pluck('dept_id'); //Input::all(); $helpdesk = new Helpdesk(); $helpdesk->help_description = Input::get('help_description'); $helpdesk->helpdesk_type_id = Input::get('ruin_type_id'); $helpdesk->symptom_id = Input::get('symptoms_id'); $helpdesk->dept_id = $dept_id; $helpdesk->sub_dept_id = Input::get('sub_dept_id'); $helpdesk->help_date = date('Y-m-d H:i:s'); if ($timestamp > 0) { $helpdesk->callcenter_date = \Carbon\Carbon::createFromTimeStamp($timestamp)->toDateTimeString(); } $helpdesk->contact_name = Input::get('contact_name'); $helpdesk->reslove_type = $reslove_type; $helpdesk->staff_id = Input::get('staff_id'); $helpdesk->help_note = Input::get('help_note'); $helpdesk->cause = null; $helpdesk->workbench = null; $helpdesk->help_result = Input::get('help_result'); $helpdesk->forward_type = Input::get('forward_type'); $helpdesk->helpdesk_web_type = 1; $helpdesk->is_notify = 1; if ($reslove_type == '1') { $helpdesk->cause = Input::get('cause'); } else { if ($reslove_type == '2') { $helpdesk->workbench = $workbench; } } $helpdesk->save(); if ($reslove_type == '2') { switch ($workbench) { case "1": $redirect = "helpdesk/help-fix/" . Crypt::encrypt($helpdesk->id); break; case "2": $redirect = "helpdesk/help-list"; break; case "3": $redirect = "helpdesk/help-list"; break; default: $redirect = "helpdesk/help-list"; break; } return Redirect::to($redirect); } return Redirect::to('helpdesk/help-list'); }
/** * Get the time when the site was modified at. * * @return \Carbon\Carbon * * @throws \Exception */ public static function lastModified() { static $value = null; if (is_null($value)) { if (!($timestamp = static::option(static::OPTION_LAST_MODIFIED))) { throw new RuntimeException("Option [" . static::OPTION_LAST_MODIFIED . "] could not be found."); } $value = Carbon::createFromTimeStamp((int) $timestamp, static::timezone()); } return $value; }
/** * Show a list of exisisting backups. * * @return void */ protected function showListOfBackups() { if (!($files = File::files($this->destination))) { return $this->error('No backup files found'); } foreach ($files as $key => $file) { $date = Carbon::createFromTimeStamp(File::lastModified($file)); $files[$key] = [basename($file), $date->toDateTimeString(), $date->diffForHumans(), $this->bytesToHuman(File::size($file))]; } $this->table(['File', 'Date', 'Age', 'Size'], $files); }
private function buildTableRow($jobId, $timestamp, MonitoredQueue $queue, $truncate) { $job = $queue->getJob($jobId); $tries = $queue->getNumberOfTries($jobId); $implementation = $job->getImplementation(); $args = json_encode($job->getArguments(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); if ($truncate) { $args = $this->truncateArgs($args); } $age = Carbon::createFromTimeStamp($timestamp)->diffForHumans(); $humanizedTries = $this->formatTries($tries); return [$jobId, $age, $humanizedTries, $implementation, $args]; }
/** * Check if we have determined that we need to do a database check. * * @return boolean */ public function isCheckRequired() { if ($this->expired !== null) { return $this->expired; } if ($this->filesystem->exists($this->timestampFile)) { $expiryTimestamp = (int) file_get_contents($this->timestampFile); } else { $expiryTimestamp = 0; } $ts = Carbon::createFromTimeStamp($expiryTimestamp + self::CHECK_INTERVAL); return $this->expired = $ts->isPast(); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $timestamp = $request->server('REQUEST_TIME'); $hour = Carbon::createFromTimeStamp($timestamp, Config::get('app.timezone'))->hour; $message = 'こんばんは'; if (in_array($hour, range(5, 9))) { $message = 'おはよう'; } else { if (in_array($hour, range(10, 17))) { $message = 'こんにちは'; } } $this->view->share('greetingMessage', $message); return $next($request); }
/** * Sanitize input before validation. * * @return array */ public function sanitize() { $rules = []; switch ($this->segment(1)) { case 'events': $start_time = Carbon::createFromTimeStamp(strtotime($this->s_date . ' ' . $this->s_time)); $end_time = null; if ($this->e_date && $this->e_time) { $end_time = Carbon::createFromTimeStamp(strtotime($this->e_date . ' ' . $this->e_time)); } $this->merge(['start_time' => $start_time, 'end_time' => $end_time]); break; } return $this->all(); }
/** * Pseudo-relation: A single user's most recent state * @return object Illuminate\Database\Eloquent\Relations\Relation */ public function state() { $start = Carbon::createFromTimeStamp(time() - Config::get('lanager/steam.pollingInterval')); $end = Carbon::createFromTimeStamp(time() + Config::get('lanager/steam.pollingInterval')); return $this->hasOne('Zeropingheroes\\Lanager\\Domain\\States\\State')->join(DB::raw('( SELECT max(created_at) max_created_at, user_id FROM states WHERE created_at BETWEEN "' . $start . '" AND "' . $end . '" GROUP BY user_id ) s2'), function ($join) { $join->on('states.user_id', '=', 's2.user_id')->on('states.created_at', '=', 's2.max_created_at'); })->orderBy('states.user_id'); }
/** * Store a newly created resource in storage. * * Interviews are submitted as sets of tags and responses to questionnaires. * * @return Response */ public function store() { $v = Validator::make(Request::all(), ['type' => 'required|string', 'questionSet' => 'required|string', 'recordedAt' => 'required', 'questions' => 'array', 'taggable' => 'array', 'location' => 'required|string', 'area' => 'required|string', 'houseno' => 'string']); if ($v->fails()) { return Response::json(['errors' => $v->errors()], 400); } $Date = Carbon::createFromTimeStamp(Input::get('recordedAt')); $interview = Interview::firstOrNew(['date' => $Date, 'interviewer_id' => Auth::user()->id]); $Questionnaire = Questionnaire::where('name', '=', Input::get('questionSet'))->first(); // important to fail here, you shouldn't be able to submit an interview for a questionnaire that doesn't exist if (!$Questionnaire) { return Response::json(['message' => 'questionnaire "' . Input::get('questionSet') . '" does not exist'], 400); } $interview->questionnaire_id = $Questionnaire->id; $interview->type = Input::get('type'); // similarly, area has to exist already $area = Area::where(['name' => Input::get('area')])->first(); if (!$area) { return Response::json(['message' => 'area "' . Input::get('area') . '" does not exist'], 400); } // although we can allow for dynamically adding new locations as they come in. $location = Location::firstOrCreate(['name' => Input::get('location'), 'area_id' => $area->id]); $interview->location_id = $location->id; if (Input::has('houseno')) { $interview->house_number = Input::get('houseno'); } $interview->save(); if (Input::has('questions') && $interview->type === 'interview') { foreach (Input::get('questions') as $response) { InterviewResponse::create(['question' => $response['question'], 'answer' => $response['answer'], 'interview_id' => $interview->id]); } } if (Input::has('taggable') && $interview->type === 'interview') { foreach (Input::get('taggable') as $list) { if (isset($list['id'])) { $this->saveTagsToQuestionnaire($list); } $TagList = new TagList(); $TagList->name = $list['name']; $interview->tagLists()->save($TagList); foreach ($list['tagged'] as $tag) { $TagList->tags()->save(Tag::create(['name' => $tag, 'tag_list_id' => $TagList->id])); } } } $interview->push(); return Response::json(Interview::with('responses')->find($interview->id), 200); }
public static function createMenusForWeek($week) { $now = Carbon::now('Europe/Belgrade')->toDateTimeString(); $weekMon = Carbon::createFromTimeStamp((int) $week); $weekDays = ['mon' => $weekMon, 'tue' => $weekMon->copy()->addDays(1), 'wed' => $weekMon->copy()->addDays(2), 'thu' => $weekMon->copy()->addDays(3), 'fri' => $weekMon->copy()->addDays(4)]; $defaultFoods = Food::where('default', true)->get(); $newMenus = []; foreach ($weekDays as $dayAbbr => $day) { $newMenu = Menu::create(['date' => $day, 'week' => $week, 'published' => false, 'created_at' => $now, 'updated_at' => $now]); foreach ($defaultFoods as $defaultFood) { MenuFood::create(['food_id' => $defaultFood->id, 'menu_id' => $newMenu->id]); } $newMenus[] = $newMenu->id; } return self::with(['menuFoods', 'menuFoods.menu', 'menuFoods.food'])->find($newMenus); }
public function postOccasion() { $input = Input::all(); $name = $input['name']; //$id = $input['user_id']; $start = $input['start_time']; $end = $input['end_time']; $ts_start = Carbon::createFromTimeStamp($start); $ts_end = Carbon::createFromTimeStamp($end); $occasion = new Occasion(); $occasion->name = $name; $occasion->start = $ts_start->toDateTimeString(); $occasion->end = $ts_end->toDateTimeString(); $occasion->save(); //$occasion->users()->attach($id); return $occasion; }
/** * Get states at the given timestamp * @param integer $timestamp UNIX timestamp of the desired state time * @param array $options Extra query options: "order by" and "with" * @return object Collection All user states at the given timestamp */ public function at($timestamp, $options = []) { $defaults = ['orderBy' => 'states.user_id', 'with' => ['application', 'server', 'user']]; $options = array_merge($defaults, $options); $start = Carbon::createFromTimeStamp($timestamp - Config::get('lanager/steam.pollingInterval')); $end = Carbon::createFromTimeStamp($timestamp + Config::get('lanager/steam.pollingInterval')); return State::select('states.*')->join(DB::raw('( SELECT max(created_at) max_created_at, user_id FROM states WHERE created_at BETWEEN "' . $start . '" AND "' . $end . '" GROUP BY user_id ) s2'), function ($join) { $join->on('states.user_id', '=', 's2.user_id')->on('states.created_at', '=', 's2.max_created_at'); })->orderBy($options['orderBy'])->with($options['with']); }
/** * @param Factory $validator * @param Throttle $throttle * @param User $user * @return CommandResult */ public function handle(Factory $validator, Throttle $throttle, User $user) { // validate data $validationResult = $validator->make(array('email' => $this->email, 'password' => $this->password), array('email' => 'required|email', 'password' => 'required')); if ($validationResult->fails()) { return new CommandResult(false, $validationResult->getMessageBag()->first(), null, 400); } // we need to flag that a user that is authenticating has no throttle entry by default $throttleEntry = false; // check if the user exist and get its throttle entry // then we will check if the user is suspended or banned if ($user = $user->where('email', $this->email)->first()) { if (!($throttleEntry = $throttle->where('user_id', $user->id)->first())) { $throttleEntry = $throttle::create(array('user_id' => $user->id)); } // if the user is currently suspended, lets check its suspension is already expire // so we can clear its login attempts and attempt it to login again, // if not expired yet, then we will redirect it back with the suspended notice if ($throttleEntry->isSuspended()) { $now = Carbon::now(); $suspendedUntil = Carbon::createFromTimeStamp(strtotime($throttleEntry->suspended_at))->addMinutes($throttle->getSuspensionTime()); if ($now > $suspendedUntil) { $throttleEntry->clearLoginAttempts(); $throttleEntry->unSuspend(); } else { $minsRemaining = $now->diffInMinutes($suspendedUntil); return new CommandResult(false, 'This account is currently suspended. You can login after ' . $minsRemaining . ' minutes.', null, 401); } } elseif ($throttleEntry->isBanned()) { return new CommandResult(false, "This account is currently banned.", null, 401); } } // attempt to login if (Auth::attempt(array('email' => $this->email, 'password' => $this->password), $this->remember)) { $throttleEntry->clearLoginAttempts(); return new CommandResult(true, "Authentication Successful.", Auth::user(), 200); } // login attempt failed, let's increment login attempt if ($throttleEntry) { $throttleEntry->addLoginAttempt(); return new CommandResult(false, "These credentials do not match our records. Login attempt remaining: " . $throttleEntry->getRemainingLoginAttempts(), null, 401); } return new CommandResult(false, "These credentials do not match our records.", null, 401); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function store(Request $request) { $emailstat = new Emailstat(); $timestamp = new Carbon(); $date = $timestamp->createFromTimeStamp($request->input('timestamp'))->toDateString(); $domain = $request->input('domain'); $event = $request->input('event'); if ($emailstat->where('date', '=', $date)->where('domain', '=', $domain)->where('event', '=', $event)->exists()) { $emailstat = $emailstat->where('date', '=', $date)->where('domain', '=', $domain)->where('event', '=', $event)->first(); $emailstat->count += 1; $emailstat->save(); } else { $emailstat->event = $event; $emailstat->domain = $domain; $emailstat->count = 1; $emailstat->date = $date; $emailstat->save(); } }
public function getIndex() { if (!$this->checkAccessRead()) { return; } /* * Check if Laravel is compiled to one single file */ $filename = app('path.base') . '/bootstrap/cache/compiled.php'; if (File::exists($filename)) { $optimized = '1 - ' . trans('app.compiled') . ': ' . Carbon::createFromTimeStamp(filemtime($filename)); } else { $optimized = 0; } /* * Count disabled modules */ $moduleBase = app()['modules']; $disabled = sizeof($moduleBase->disabled()); /* * Create array with names and values */ $placeholder = Config::get('app.key') == '01234567890123456789012345678912'; $appClass = get_class(app()); $opcacheExists = (int) function_exists('opcache_get_status'); $opcacheEnabled = $opcacheExists and opcache_get_status()['opcache_enabled'] ? 1 : 0; $settings = ['PHP.version' => phpversion(), 'PHP.os' => PHP_OS, 'PHP.ini' => php_ini_loaded_file(), 'PHP.memory_limit' => ini_get('memory_limit'), 'PHP.max_execution_time' => ini_get('max_execution_time'), 'PHP.post_max_size' => ini_get('post_max_size'), 'PHP.upload_max_filesize' => ini_get('upload_max_filesize'), 'Laravel.version' => $appClass::VERSION, 'Artisan optimized' => $optimized, 'App.environment' => App::environment(), 'App.url' => Config::get('app.url'), 'App.debug' => (int) Config::get('app.debug'), 'App.key' => $placeholder ? '<em>' . trans('app.placeholder') . '</em>' : trans('app.valid'), 'Cache.default' => Config::get('cache.default'), 'Modules.disabled' => $disabled, 'Mail.pretend' => (int) Config::get('mail.pretend'), 'OPcache.installed' => $opcacheExists, 'OPcache.enabled' => $opcacheEnabled, 'Xdebug.enabled' => extension_loaded('xdebug') ? 1 : 0]; /* * If we use MySQL as database, add values of some MySQL variables. */ if (Config::get('database.default') == 'mysql') { $fetchMethod = Config::get('database.fetch'); DB::connection()->setFetchMode(PDO::FETCH_ASSOC); // We need to get the result as array of arrays $sqlVars = DB::select('SHOW VARIABLES'); DB::connection()->setFetchMode($fetchMethod); $settings['MySQL.max_connections'] = $this->getSqlVar($sqlVars, 'max_connections'); $settings['MySQL.max_user_connections'] = $this->getSqlVar($sqlVars, 'max_user_connections'); } $this->pageView('diag::admin_index', compact('settings')); }
/** * Trap some Model events * @see http://laravel.com/docs/5.1/eloquent#events */ protected static function boot() { parent::boot(); // Model event : creating Message::creating(function ($msg) { // "SMS" datetime are big timestamp, // divide by 1000 then format as DataTime if (is_numeric($msg->proxy_at)) { if ($msg->proxy_at > 9999999999) { $msg->proxy_at /= 1000; } $msg->proxy_at = Carbon::createFromTimeStamp($msg->proxy_at); } if (is_numeric($msg->srv_at)) { if ($msg->srv_at > 9999999999) { $msg->srv_at /= 1000; } $msg->srv_at = Carbon::createFromTimeStamp($msg->srv_at); } }); }