コード例 #1
0
ファイル: SessionRequestT.php プロジェクト: bogdananton/vsc
 /**
  * @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);
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: HttpResponseA.php プロジェクト: bogdananton/vsc
 /**
  * @return bool
  */
 public function outputHeaders()
 {
     if (vsc::isCli()) {
         return false;
     }
     if (headers_sent()) {
         header_remove();
     }
     if ($this->getStatus()) {
         header(self::getHttpStatusString($this->getServerProtocol(), $this->getStatus()));
     }
     $sLocation = $this->getLocation();
     if ($sLocation) {
         header('Location:' . $sLocation);
         return true;
         // end headers
     }
     $sContentType = $this->getContentType();
     if ($sContentType) {
         header('Content-Type: ' . $sContentType);
     }
     $sCacheControl = $this->getCacheControl();
     if ($sCacheControl) {
         header('Cache-Control: ' . $sCacheControl);
     }
     $sContentDisposition = $this->getContentDisposition();
     if ($sContentDisposition) {
         header('Content-Disposition: ' . $sContentDisposition);
     }
     $sContentEncoding = $this->getContentEncoding();
     if ($sContentEncoding) {
         header('Content-Encoding: ' . $sContentEncoding);
     }
     $sContentLanguage = $this->getContentLanguage();
     if ($sContentLanguage) {
         header('Content-Language: ' . $sContentLanguage);
     }
     $iContentLength = $this->getContentLength();
     if ($iContentLength !== null) {
         header('Content-Length: ' . $iContentLength);
     }
     $sContentLocation = $this->getContentLocation();
     if ($sContentLocation) {
         header('Content-Location: ' . $sContentLocation);
     }
     $sMd5 = $this->getContentMd5();
     if ($sMd5) {
         header('Content-MD5: ' . $sMd5);
     }
     $sDate = $this->getDate();
     if ($sDate) {
         header('Date: ' . $sDate);
     }
     $sETag = $this->getETag();
     if ($sETag) {
         header('ETag: "' . $sETag . '"');
         // the ETag is enclosed in quotes (i imagine it's because it might contain EOL's ?)
     }
     $sExpires = $this->getExpires();
     if ($sExpires) {
         header('Expires: ' . $sExpires);
     }
     $sLastModified = $this->getLastModified();
     if ($sLastModified) {
         header('Last-Modified: ' . $sLastModified);
     }
     if (is_array($this->aHeaders)) {
         foreach ($this->aHeaders as $sHeaderName => $sHeaderValue) {
             if (is_null($sHeaderValue)) {
                 header_remove($sHeaderName);
             } else {
                 header($sHeaderName . ': ' . $sHeaderValue);
             }
         }
     }
     return true;
 }
コード例 #3
0
ファイル: _isCliTest.php プロジェクト: bogdananton/vsc
 public function testNotIsCli()
 {
     $env = new vsc_underTest__isCli();
     vsc::setInstance($env);
     $this->assertFalse(vsc::isCli());
 }
コード例 #4
0
ファイル: functions.inc.php プロジェクト: bogdananton/vsc
/**
 * @param \Exception $e
 */
function _e($e)
{
    $aErrors = cleanBuffers();
    $sRet = '';
    if (!vsc::isCli()) {
        header('HTTP/1.1 500 Internal Server Error');
        echo getErrorHeaderOutput($e);
    }
    if (isDebug()) {
        echo $e instanceof \Exception ? $e->getTraceAsString() : '';
    }
    if (count($aErrors) > 0) {
        if (!vsc::isCli()) {
            echo '<h2>';
        }
        echo 'Previous Errors';
        if (!vsc::isCli()) {
            echo '</h2>';
        }
        if (!vsc::isCli()) {
            echo '<p>';
        }
        echo implode($aErrors, vsc::isCli() ? "\n" : '<br/>');
        if (!vsc::isCli()) {
            echo '</p>';
        }
    }
    if (!vsc::isCli()) {
        echo '</pre>';
        echo '</body>';
        echo '</html>';
    } else {
        if ($e instanceof \Exception) {
            $e->getMessage() . "\n";
            $sRet .= "\t" . $e->getFile() . ' at line ' . $e->getLine() . "\n";
        }
    }
    exit(0);
}