/** * @return bool * @throws \DreamFactory\Oasys\Exceptions\OasysException */ public function sync() { if (!isset($_SESSION) || PHP_SESSION_DISABLED == session_status()) { throw new OasysException('No session active. Session storage not available.'); } $_settings = $this->contents(); if (!empty($_settings)) { $_SESSION[static::KEY_PREFIX . '.data'] = Storage::freeze($_settings); } return true; }
/** * Creates a compact string representing $data * * @param array $data * * @return string */ protected static function _encodeState($data = array()) { return Storage::freeze($data); }
/** * Construct a link to authorize the application * * @param array $payload * * @return string */ public function getAuthorizationUrl($payload = array()) { $_map = $this->_config->getEndpoint(EndpointTypes::AUTHORIZE); $_scope = $this->getConfig('scope'); $_referrer = Option::get($this->_requestPayload, 'referrer', Option::server('HTTP_REFERER', Curl::currentUrl()), true); $_redirectUri = $this->getConfig('redirect_uri', $_referrer); $_origin = $this->getConfig('origin_uri', $_redirectUri); $_proxyUrl = $this->getConfig('redirect_proxy_url'); $_state = array('request' => array('method' => Option::server('REQUEST_METHOD'), 'referrer' => $_referrer, 'query_string' => Option::server('QUERY_STRING'), 'remote_addr' => Option::server('REMOTE_ADDR'), 'time' => microtime(true), 'uri' => Option::server('REQUEST_URI'), 'payload' => $this->_requestPayload), 'origin' => $_origin, 'api_key' => sha1($_origin), 'redirect_uri' => $_redirectUri); Log::debug('Request state built: ' . print_r($_state, true)); $_payload = array_merge(array('client_id' => $this->getConfig('client_id'), 'redirect_uri' => $_redirectUri, 'response_type' => 'code', 'scope' => is_array($_scope) ? implode(' ', $_scope) : $_scope, 'state' => Storage::freeze($_state)), Option::clean(Option::get($_map, 'parameters', array()))); if (!empty($_proxyUrl)) { Log::info('Proxying request through: ' . $_proxyUrl); $_payload['redirect_uri'] = $_proxyUrl; } $_qs = http_build_query($_payload); $this->setConfig('authorize_url', $_authorizeUrl = $_map['endpoint'] . Curl::urlSeparator($_map['endpoint']) . $_qs); Log::debug('Authorization URL created: ' . $_authorizeUrl); return $_authorizeUrl; }
/** * Saves off any data to the file system */ protected function _save() { $_file = $this->_storagePath . DIRECTORY_SEPARATOR . $this->_fileName; $_data = json_encode($this->contents()); if ($this->_compressStore) { $_data = Utility\Storage::freeze($this->contents()); } if (false === file_put_contents($_file, $_data)) { Utility\Log::error('Unable to store Oasys data in "' . $_file . '". System error.'); return false; } return true; }
/** * Serialize */ public static function __sleep() { // Save options out to session... if (static::$_awake && isset($_SESSION)) { // Freeze the options and stow, but not the autoloader $_SESSION[CoreSettings::SESSION_KEY] = static::$_options; // Remove the autoloader from the SESSION. Option::remove($_SESSION[CoreSettings::SESSION_KEY], CoreSettings::AUTO_LOADER); // Remove the autoloader at this key if there is one (some apps used the wrong key) Option::remove($_SESSION[CoreSettings::SESSION_KEY], 'app.autoloader'); // Now store our options $_SESSION[CoreSettings::SESSION_KEY] = Storage::freeze($_SESSION[CoreSettings::SESSION_KEY]); } }