From c88f8e79670d909c0e6bc3d40920077956d92dac Mon Sep 17 00:00:00 2001 From: Gilbert Pellegrom Date: Fri, 26 Apr 2013 17:38:10 +0100 Subject: [PATCH] v0.2 Added some inline docs. --- index.php | 4 ---- lib/pico.php | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 1b278a6..fcd6c79 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,5 @@ base_url(), $content); @@ -59,6 +77,12 @@ class Pico { return $content; } + /** + * Parses the file meta from the txt file header + * + * @param string $content the raw txt content + * @return array $headers an array of meta values + */ function read_file_meta($content) { $headers = array( @@ -78,6 +102,11 @@ class Pico { return $headers; } + /** + * Loads the config + * + * @return array $defaults an array of config values + */ function get_config() { global $config; @@ -96,6 +125,11 @@ class Pico { return $defaults; } + /** + * Helper function to work out the base URL + * + * @return string the base url + */ function base_url() { global $config; @@ -110,6 +144,11 @@ class Pico { return rtrim(str_replace($url, '', $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), '/'); } + /** + * Tries to guess the server protocol. Used in base_url() + * + * @return string the current protocol + */ function get_protocol() { preg_match("|^HTTP[S]?|is",$_SERVER['SERVER_PROTOCOL'],$m);