/** * @param string $sSessionName * @throws ExceptionRequest */ public static function startSession($sSessionName = null) { if (!static::hasSession()) { if ((double) PHP_VERSION >= 5.4 && session_status() == PHP_SESSION_DISABLED) { throw new ExceptionRequest('Sessions are not available'); } if ((double) PHP_VERSION >= 5.4 && session_status() == PHP_SESSION_NONE) { $oRequest = vsc::getEnv()->getHttpRequest(); if (!vsc::isCli()) { session_set_cookie_params(0, '/', $oRequest->getUriObject()->getHost(), HttpRequestA::isSecure(), true); } if (@session_start()) { $_SESSION = array(); if (!is_null($sSessionName)) { session_id($sSessionName); } } } } }
/** * This exists as the php::parse_url function sometimes breaks inexplicably * @param string $sUrl * @return Url */ protected static function parse_url($sUrl = null) { if (is_null($sUrl)) { return new Url(); } if (mb_detect_encoding($sUrl) !== 'ASCII') { $sUrl = rawurlencode($sUrl); } $oUrl = new Url(); try { if (!stristr($sUrl, '://') && is_file($sUrl) && is_readable($sUrl)) { $oUrl->setScheme('file'); $oUrl->setPath($sUrl); return $oUrl; } } catch (\Exception $e) { // possible open basedir restriction $oUrl->setScheme('file'); $oUrl->setPath($sUrl); return $oUrl; } try { if (!self::urlHasScheme($sUrl)) { $sUrl = (HttpRequestA::isSecure() ? 'https:' : 'http:') . $sUrl; } $aParsed = parse_url($sUrl); if (!is_array($aParsed)) { return null; } if (isset($aParsed['scheme'])) { $oUrl->setScheme($aParsed['scheme']); } if (isset($aParsed['host'])) { $oUrl->setHost($aParsed['host']); } if (isset($aParsed['port'])) { $oUrl->setPort($aParsed['port']); } if (isset($aParsed['path'])) { $oUrl->setPath($aParsed['path']); } if (isset($aParsed['query'])) { $oUrl->setRawQuery($aParsed['query']); } if (isset($aParsed['fragment'])) { $oUrl->setFragment($aParsed['fragment']); } return $oUrl; } catch (\Exception $e) { // failed php::parse_url } }