PHP Classes
elePHPant
Icontem

File: source/server.php

Recommend this page to a friend!
  Classes of Wolfy-J  >  spiral  >  source/server.php  >  Download  
File: source/server.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: spiral
Modular Web application development framework
Author: By
Last change:
Date: 10 months ago
Size: 750 bytes
 

Contents

Class file image Download
<?php
/**
 * Spiral Framework.
 *
 * @license MIT
 * @author Anton Titov (Wolfy-J)
 */
date_default_timezone_set('UTC');

$requestURI = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$out = fopen('php://stdout', 'w');

if (
$_SERVER['REQUEST_METHOD'] == 'GET') {
   
$logMessage = '[' . date('M d, Y H:i:s') . '] GET ';
} else {
   
$logMessage = '[' . date('M d, Y H:i:s') . '] <fg=cyan>' . $_SERVER['REQUEST_METHOD'] . '</fg=cyan>';
}

if (
$requestURI !== '/' && file_exists(getcwd() . $requestURI)) {
   
//CLI-Server will handle resources by itself.
   
fwrite($out, 'R ' . $logMessage . ' ' . $requestURI);

    return
false;
}

fwrite($out, 'S ' . $logMessage . ' <info>' . $_SERVER['REQUEST_URI'] . '</info>');
require_once
'index.php';