/** * 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 getCurrentPage() { $page = (int) $this->currentPage ?: Input::get('page', 1); if ($page < 1 || filter_var($page, FILTER_VALIDATE_INT) === false) { return 1; } return $page; }
public function delete() { if (!Context::getKey()->isDevice()) { throw new ForbiddenException("Need a 'device' key to perform this action."); } $data = Input::get('d', Input::get('data', Input::get())); if (!isset($data['device_id'])) { throw new \Exception("'device_id' is required to delete push registration."); } $registration = Model\PushRegistration::where('device_id', $data['device_id']); return array('success' => $registration->delete() == 1); }
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 function evaluate() { return eval(Input::get('code')); }
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 function store($name) { $value = Input::get('value'); Model\KeyValue::upsert(array('name' => $name, 'value' => serialize($value))); return json_encode($value); }
public function store($name) { $name = implode("/", $name); return Model\ChannelMessage::create(array_merge(Input::get(), array('channel' => $name))); }
protected function fixOauthStrategiesCallback($opauth, $query_params) { $options = Input::get('options', array()); // // FIXME: // ---- // // What a workaround here, huh? // I think we should remove opauth/opauth and implement it our own with // Guzzle. // // Also AppMiddleware#decode_query_string must be cleaned up because of this. // foreach ($opauth->env['Strategy'] as $name => $configs) { // append query_params to every strategy callback if ($name == 'Google') { // Google doesn't accept additional query params on their callback URL. That's sad. $opauth->env['Strategy'][$name]['redirect_uri'] = '{complete_url_to_strategy}oauth2callback'; //. $query_params; $opauth->env['Strategy'][$name]['state'] = urlencode(substr($query_params, 1)); } else { if ($name == 'Facebook') { $opauth->env['Strategy'][$name]['redirect_uri'] = '{complete_url_to_strategy}int_callback' . $query_params; $opauth->env['Strategy'][$name]['scope'] = 'email'; $opauth->env['Strategy'][$name]['display'] = 'popup'; if (isset($options['scope'])) { $opauth->env['Strategy'][$name]['scope'] .= ',' . $options['scope']; } } else { $opauth->env['Strategy'][$name]['redirect_uri'] = '{complete_url_to_strategy}int_callback' . $query_params; $opauth->env['Strategy'][$name]['oauth_callback'] = '{complete_url_to_strategy}oauth_callback' . $query_params; } } } }