/** * current - get current active AuthToken instance * @static * @return AuthToken|null */ public static function current() { $token = Request::header('X-Auth-Token', Input::get('X-Auth-Token')); if (static::$_current === null && $token) { static::$_current = static::where('token', $token)->where('expire_at', '>=', Carbon::now())->first(); } return static::$_current; }
public function notify() { if (!(Context::getKey()->isServer() && Request::header('X-Scheduled-Task'))) { throw new ForbiddenException("Need a 'device' key to perform this action."); } $notifier = new PushNotification\Notifier(); $messages = Model\App::collection('push_messages')->where('status', Model\PushMessage::STATUS_QUEUE); return $notifier->push_messages($messages); }
public function show404() { if (Request::isPost()) { $page = App::collection(self::PAGES_COLLECTION)->create(Input::get('page')); Request::redirect($page->slug); } $layouts = array(); $layout_files = glob(Router::config('paths')['root'] . 'app/views/layouts/*'); foreach ($layout_files as $layout_file) { $layout_ext = pathinfo($layout_file, PATHINFO_EXTENSION); $layout_name = basename($layout_file, '.' . $layout_ext); $words = preg_split('/_/', $layout_name); $layout_label = join(' ', array_map(function ($word) { return ucfirst($word); }, $words)); $layouts[$layout_name] = $layout_label; } $this->render('cms/404', array('request_path' => Request::path(), 'layouts' => $layouts)); }
public static function isAllowedIP() { $allowed = false; $allowed_ip_addresses = Context::config('allowed_ip_addresses'); if ($allowed_ip_addresses && !empty($allowed_ip_addresses)) { $allowed = in_array("*", $allowed_ip_addresses) || in_array(Request::ip(), $allowed_ip_addresses); } return $allowed; }
public static function getData() { // TODO: refactoring if (Request::isPost()) { $data = Request::post('d', Request::post('data', Request::post())); } else { $data = Input::get('d', Input::get('data', Input::get())); } $attached_files = array(); // Check for base64-encoded files foreach ($data as $key => $value) { if (Model\File::base64($value)) { $attached_files[$key] = $value; } } if (!empty($_FILES)) { $attached_files = array_merge($attached_files, $_FILES); } if (!empty($attached_files)) { $data[Model\Collection::ATTACHED_FILES] = $attached_files; } return $data; }
public static function javascript($args, $attributes) { $url = preg_replace('/index\\.php\\//', '', str_finish(Request::getRootUri(), '/')) . $args[0]; // Request::getRootUri() return array('<script src="' . $url . '"></script>', 'raw'); }
public function getLogout() { Cookie::delete('is_admin'); Request::redirect('/admin'); }
public function ip() { $ip = Request::ip(); return json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"), true); }
public function index() { Cookie::set('admin', 1); Request::redirect('/hook-framework'); }
protected function getQueryParams() { $keep_query_keys = array_filter(array('X-App-Id', 'X-App-Key', 'X-Auth-Token', 'options'), function ($param) { return Request::get($param); }); $keep_query_values = array_map(function ($param) { return Request::get($param); }, $keep_query_keys); return '?' . http_build_query(array_combine($keep_query_keys, $keep_query_values)); }