PHPDoc + coding conventions

This commit is contained in:
Will Rossiter 2013-05-10 21:59:20 +12:00
parent d47b202697
commit 07b9bd8527
1 changed files with 23 additions and 3 deletions

View File

@ -1,4 +1,5 @@
<?php
/**
* A class with HTTP-related helpers.
* Like Debug, this is more a bundle of methods than a class ;-)
@ -8,17 +9,30 @@
*/
class HTTP {
/**
* @var int $cache_age
*/
protected static $cache_age = 0;
/**
* @var timestamp $modification_date
*/
protected static $modification_date = null;
/**
* @var string $etag
*/
protected static $etag = null;
/**
* Turns a local system filename into a URL by comparing it to the script filename
* Turns a local system filename into a URL by comparing it to the script
* filename.
*
* @param string
*/
public static function filename2url($filename) {
$slashPos = -1;
while(($slashPos = strpos($filename, "/", $slashPos+1)) !== false) {
if(substr($filename, 0, $slashPos) == substr($_SERVER['SCRIPT_FILENAME'],0,$slashPos)) {
$commonLength = $slashPos;
@ -27,13 +41,19 @@ class HTTP {
}
}
$urlBase = substr($_SERVER['PHP_SELF'], 0, -(strlen($_SERVER['SCRIPT_FILENAME']) - $commonLength));
$urlBase = substr(
$_SERVER['PHP_SELF'],
0,
-(strlen($_SERVER['SCRIPT_FILENAME']) - $commonLength)
);
$url = $urlBase . substr($filename, $commonLength);
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? "https" : "http";
return "$protocol://". $_SERVER['HTTP_HOST'] . $url;
// Count the number of extra folders the script is in.
// $prefix = str_repeat("../", substr_count(substr($_SERVER[SCRIPT_FILENAME],$commonBaseLength)));
return "$protocol://". $_SERVER['HTTP_HOST'] . $url;
}
/**