/** * Gets Medium data * @return mixed */ public static function getAnalytics() { $cacheFile = dirname(__FILE__) . "/../../../storage/analytics.js"; if (!FileCache::cached($cacheFile)) { $url = "http://www.google-analytics.com/analytics.js"; $content = Request::get($url); file_put_contents($cacheFile, $content); } else { $content = file_get_contents($cacheFile); } return response($content)->withHeaders(['Content-Type' => 'application/javascript']); }
/** * Gets Medium data * @return mixed */ public static function getData() { $cacheFile = dirname(__FILE__) . "/../../../storage/instagram.json"; if (!FileCache::cached($cacheFile)) { $url = "https://api.instagram.com/v1/users/" . $_ENV['INSTAGRAM_USER_ID'] . "/media/recent/?access_token=" . $_ENV['INSTAGRAM_ACCESS_TOKEN'] . "&count=3"; $data = Request::get($url); $content = self::parseData($data); file_put_contents($cacheFile, json_encode($content)); } else { $content = json_decode(file_get_contents($cacheFile), true); } return response()->json($content); }
/** * Gets Medium data * @return mixed */ public static function getData() { $cacheFile = dirname(__FILE__) . "/../../../storage/github.json"; if (!FileCache::cached($cacheFile)) { $url = "https://api.github.com/users/voxmachina/repos?sort=updated&per_page=3"; $data = Request::get($url); $content = self::parseData($data); file_put_contents($cacheFile, json_encode($content)); } else { $content = json_decode(file_get_contents($cacheFile), true); } return response()->json($content); }
/** * Gets Medium data * @return mixed */ public static function getData() { $cacheFile = dirname(__FILE__) . "/../../../storage/medium.json"; if (!FileCache::cached($cacheFile)) { $url = 'https://medium.com/@peugenio/latest?format=json'; $data = Request::get($url); $content = self::parseData($data); file_put_contents($cacheFile, json_encode($content)); } else { $content = json_decode(file_get_contents($cacheFile), true); } return response()->json($content); }
public function handle($request, Closure $next, $guard = null) { \App::setLocale(config('gtcmslang.defaultAdminLocale')); $showLoginMessage = true; if (config('gtcms.adminAutoLogin') && \Auth::guest()) { $user = User::where('role', 'admin')->first(); \Auth::login($user); $showLoginMessage = false; } $allowedUserRoles = config('gtcms.allowedUserRoles'); if (\Auth::guest() || !in_array(\Auth::user()->role, $allowedUserRoles)) { if (\Route::current()->uri() != "admin/login") { if (\Request::ajax() && \Request::get('getIgnore_isAjax')) { $data = array('success' => false, 'message' => "Session timeout", 'redirectToLogin' => true); return \Response::json($data); } else { return \Redirect::to('/admin/login'); } } } else { if (\Route::current()->uri() == "admin/login") { if ($showLoginMessage) { MessageManager::setError(trans('gtcms.alreadyLoggedIn')); } return \Redirect::to("/admin"); } } if (\Session::get('accessDenied')) { if (\Route::currentRouteName() != "restricted") { \Session::put('accessDenied', true); return \Redirect::to('/access-denied'); } } else { if (\Route::currentRouteName() == "restricted") { MessageManager::setError(trans('gtcms.accessGranted')); \Session::put('accessDenied', false); return \Redirect::to("/admin"); } } return $next($request); }