public function hasAccessObject() { if (Cache::has('citrix_access_object')) { return true; } return false; }
/** * @inheritdoc */ public function handle($arguments) { if (!Cache::has('site-' . $arguments)) { $this->replyWithMessage("Não foi encontrado nenhum site com esse argumento."); return; } $site = Cache::get('site-' . $arguments); // Validate if the URL isn't on the database yet if (Site::where('url', '=', $site)->first() != null) { $this->replyWithMessage("O site {$site} já se encontra na base de dados."); return; } $site_obj = new Site(); $site_obj->url = $site; $site_obj->save(); $this->replyWithMessage($site . " foi adicionado à base de dados.", true); // Notify the sitesbloqueados.pt about the new site $url = 'https://sitesbloqueados.pt/wp-json/ahoy/refresh'; $cmd = "curl -X GET -H 'Content-Type: application/json'"; $cmd .= " " . "'" . $url . "'"; $cmd .= " > /dev/null 2>&1 &"; exec($cmd, $output); // Flush the PAC cache Cache::tags(['generate_pac'])->flush(); // Remove the cache Cache::forget('site-' . $arguments); Cache::forget('site-list'); }
public function prettifyOnlineStatus($presence, $accounts) { $key = 'online_status'; if (Cache::has($key)) { return Cache::get($key); } else { $user_string = '<strong>Online Status</strong><br/>'; $found = false; foreach ($presence as $seo => $response) { $data = json_decode($response->getBody(), true); if (isset($data['state']) && $data['state'] == "Online") { foreach ($data['devices'] as $device) { if ($device['type'] == "XboxOne") { foreach ($device['titles'] as $title) { if (in_array($title['id'], $this->acceptedGameIds)) { $found = true; $gt = $accounts->where('seo', $seo)->first(); $user_string .= "<strong>" . $gt->gamertag . ": </strong>" . $title['name']; if (isset($title['activity'])) { $user_string .= " (" . $title['activity']['richPresence'] . ")"; } $user_string .= "<br/>"; } } } } } } if (!$found) { $user_string = 'No-one is online. Pity us.'; } Cache::put($key, $user_string, 5); return $user_string; } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Cache::has('session.key')) { return redirect('/trips'); } return $next($request); }
public function latest() { if ($this->isLoggedIn && $this->request->has('personal') && $this->request->get('personal') == 'true') { $isCached = false; $bans = $this->repository->getPersonalBans($this->user->settings()->playerIds()); } else { $isCached = Cache::has('bans.latest'); $bans = $this->repository->getLatestBans(); } if ($this->request->has('type') && $this->request->get('type') == 'rss') { $feed = Feed::make(); $feed->title = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title')); $feed->description = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title')); $feed->setDateFormat('datetime'); $feed->link = URL::to('api/bans/latest?type=rss'); $feed->lang = 'en'; foreach ($bans as $ban) { $title = sprintf('%s banned for %s', $ban['player']['SoldierName'], $ban['record']['record_message']); $view = View::make('system.rss.ban_entry_content', ['playerId' => $ban['player']['PlayerID'], 'playerName' => $ban['player']['SoldierName'], 'banreason' => $ban['record']['record_message'], 'sourceName' => $ban['record']['source_name'], 'sourceId' => $ban['record']['source_id'], 'banReason' => $ban['record']['record_message']]); $feed->add($title, $ban['record']['source_name'], $ban['player']['profile_url'], $ban['ban_startTime'], $title, $view->render()); } return $feed->render('atom'); } return MainHelper::response(['cols' => Lang::get('dashboard.bans.columns'), 'bans' => $bans], null, null, null, $isCached, true); }
public function render($format = 'atom', $cache = FALSE, $cacheTime = 3600) { $channel = $this->channel; $channel->pubdate = $this->formatDate($this->channel->pubdate, $format); $items = $this->items; foreach ($items as $item) { $item->pubdate = $this->formatDate($item->pubdate, $format); } if ($format == 'atom') { $this->content_type = 'application/atom+xml'; } else { $this->content_type = 'application/rss+xml'; } if ($cache == TRUE && Cache::has('feed-' . $format)) { return response()->view('feed::' . $format, Cache::get('feed-' . $format))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml'); } elseif ($cache == TRUE) { Cache::put('feed-' . $format, compact('channel', 'items'), $cacheTime); return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml'); } elseif ($cache == FALSE && Cache::has('feed-' . $format)) { Cache::forget('feed-' . $format); return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml'); } else { return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml'); } }
/** * Return a simple list of entries in the table. * * May cache the results for up to 60 minutes. * * @return array of Fluent objects */ public static function tableToArray() { $me = new static(); $cache_key = $me->cacheKey(); // Return the array from the cache if it is present. if (Cache::has($cache_key)) { return (array) Cache::get($cache_key); } // Otherwise put the results into the cache and return them. $results = []; $query = static::all(); // If the current model uses softDeletes then fix the // query to exclude those objects. foreach (class_uses(__CLASS__) as $traitName) { if ($traitName == 'SoftDeletes') { $query = static::whereNull('deleted_at')->get(); break; } } /** @var Cacheable $row */ foreach ($query as $row) { $results[$row->getIndexKey()] = $row->toFluent(); } Cache::put($cache_key, $results, 60); return $results; }
/** * Shows the player profile * * @param integer $id * @param string $name */ public function profile($id, $name = '') { // Cache key $key = sprintf('player.%u', $id); // Is there already a cached version for the player $isCached = Cache::has($key); // Get or Set cache for player $player = Cache::remember($key, 5, function () use($id) { $json = $this->repository->setopts(['ban.previous.server', 'ban.record.server', 'reputation', 'infractionsGlobal', 'infractionsServer.server', 'stats.server', 'specialGroups'], true)->getPlayerById($id)->toJson(); return json_decode($json); }); $charts = Cache::remember(sprintf('player.%u.charts', $id), 5, function () use($id) { $charts = []; $charts['overview'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandOverview.sql'), [$id])); $charts['spline'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandHistory.sql'), [$id])); $charts['aliases'] = Record::where('command_type', 48)->where('target_id', $id)->select(DB::raw('record_message AS `player_name`, COUNT(record_id) AS `seen`'))->groupBy('player_name')->get(); $charts['iphistory'] = Record::where('command_type', 49)->where('target_id', $id)->where('record_message', '!=', 'No previous IP on record')->select(DB::raw('record_message AS `ip`, COUNT(record_id) AS `seen`'))->groupBy('ip')->get(); $charts['overview'] = $charts['overview']->map(function ($command) { return [$command->label, intval($command->value)]; }); $charts['aliases'] = $charts['aliases']->map(function ($a) { return [$a->player_name, intval($a->seen)]; }); $charts['iphistory'] = $charts['iphistory']->map(function ($ip) { return [$ip->ip, intval($ip->seen)]; }); return $charts; }); $groups = MainHelper::specialGroups($player->special_groups, 'player_group'); $page_title = !empty($player->ClanTag) ? sprintf('[%s] %s', $player->ClanTag, $player->SoldierName) : $player->SoldierName; return View::make('player.profile', compact('player', 'page_title', 'charts', 'isCached', 'groups')); }
/** * Returns true/false depending if the entry * has been marked read (exists inside the cache). * * @return bool */ public function isRead() { if (Cache::has($this->makeCacheKey())) { return true; } return false; }
/** * Fetch the stored config from the cache. * * @return mixed */ public function fetchConfig() { if (Cache::has($this->getCacheKey())) { return Cache::get($this->getCacheKey()); } return null; }
/** * Determine the current website data. * * Returns null if the web site is not found in the websites table. * * @return array */ public static function currentWebsiteData() { static $current_data; $BASE_URL = static::currentServerName(); $cache_key = 'website-data.' . $BASE_URL; // Get the current ID from the cache if it is present. if (empty($current_data)) { if (Cache::has($cache_key)) { return Cache::get($cache_key); } } // If the cache doesn't have it then get it from the database. if (empty($current_data)) { // Have to do this using a raw query because Laravel doesn't INSTR. try { /** @var Website $result */ $result = static::whereRaw("INSTR('" . $BASE_URL . "', `http_host`) > 0")->orderBy(DB::raw('LENGTH(`http_host`)'), 'desc')->first(); if (empty($result)) { $current_data = null; } else { $current_data = $result->toArray(); } Cache::put($cache_key, $current_data, 60); } catch (\Exception $e) { $current_data = null; } } return $current_data; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!Cache::has('loginVisitor')) { return redirect()->guest('auth/oauth/github'); } return $next($request); }
/** * Execute the console command. * * @return void * * @throws \Exception */ public function fire() { $uploadPath = env('UPLOAD_DIR', 'uploads'); // Use UPLOAD_DIR either as an absolute path, or relative to the base path if (!($path = realpath($uploadPath))) { $path = base_path($uploadPath); } $importedSomething = false; foreach (scandir($path) as $file) { if (in_array($file, ['.', '..', '.gitignore', '.gitkeep'])) { continue; } $version = $this->import($file, $path); if ($version) { $importedSomething = true; $identifier = $version->package->identifier; $versionNumber = $version->name; $this->info("Imported \"<comment>{$identifier}</comment>\" (@ {$versionNumber})"); // Make sure the directory exists if (!file_exists(dirname($version->storagePath))) { mkdir(dirname($version->storagePath)); } rename($path . '/' . $file, $version->storagePath); } } if ($importedSomething) { if (Cache::has('xml.renderedPath')) { unlink(Cache::pull('xml.renderedPath')); } } else { $this->info('No files found to import.'); } }
/** * @return string */ protected function getTimestampMigrationName() { if (!Cache::has(static::CACHENAME)) { Cache::forever(static::CACHENAME, date('Y_m_d_His') . '_' . $this->getMigrationName()); } return Cache::get(static::CACHENAME); }
public function put(Route $route, Request $request, Response $response) { $key = $this->makeCacheKey($request->url()); if (!Cache::has($key)) { Cache::put($key, $response->getContent(), 10); } }
public function isAdmin() { if (Cache::has('role.' . Auth::id()) && Cache::get('role.' . Auth::id()) === 'admin') { return true; } return false; }
public function unlink() { if (Cache::has($this->name)) { return Cache::forget($this->name); } return FALSE; }
/** * Get the current current cache for the Api key * * @param ApiKey $apiKey - The api key in question * @return StdClass Object containing rate limiting details */ public static function get($public_key) { if (!Cache::has($public_key)) { return false; } return json_decode(Cache::get($public_key)); }
public function get($key) { if (Cache::has($key)) { return Cache::get($key); } return false; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!Cache::has('session.key')) { return redirect('/')->with('error', 'You must log in in order to view that page.'); } return $next($request); }
public static function remember($key, $callback) { if (!Cache::has($key)) { $value = $callback(); Cache::put($key, $value, 60); } return Cache::get($key); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!Cache::has('settings')) { $settings = json_decode(Storage::get('settings.json'), true); Cache::forever('settings', $settings); } return $next($request); }
public function generateUniqueID() { $id = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10); if (Cache::has('site-' . $id)) { return $this->generateUniqueID(); } return $id; }
/** * Admin Theme Color Change * * @param Request $request * @return \Illuminate\Http\Response */ public function getThemeColorChange(Request $request) { if (Cache::has('theme_color')) { Cache::forget('theme_color'); } Cache::forever('theme_color', $request->all()); return response()->json(['result' => true]); }
public static function remember($key, $callback) { if (!Cache::has($key)) { $value = $callback(); Cache::tags(self::TAG)->put($key, $value, 60); } return Cache::tags(self::TAG)->get($key); }
/** * Return the content of the Site Map */ public function getSiteMap() { if (Cache::has('site-map')) { return Cache::get('site-map'); } $siteMap = $this->buildSiteMap(); Cache::add('site-map', $siteMap, 120); return $siteMap; }
/** * After request. If the cache key not exist. Cache the contents * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $response = $next($request); $key = $this->makeCacheKey($request->url()); if (!Cache::has($key)) { Cache::put($key, $response->getContent(), 60); } return $response; }
/** * Return the content of the RSS feed */ public function getRSS() { if (Cache::has('rss-feed')) { return Cache::get('rss-feed'); } $rss = $this->buildRssData(); Cache::add('rss-feed', $rss, 120); return $rss; }
/** * @param View $view */ public function compose(View $view) { if (!Cache::has('this_user')) { Cache::rememberForever('this_user', function () { return $this->user->thisUser($this->auth->user()->id); }); } $view->with('user', Cache::get('this_user')); }
/** * Checks if content is cached * * @return bool */ public function isCached() { if ($this->model->getUseCache()) { if (Cache::has($this->model->getCacheKey())) { return true; } } return false; }