diff options
author | MaZderMind | 2014-10-01 10:33:00 +0200 |
---|---|---|
committer | MaZderMind | 2014-10-01 10:33:00 +0200 |
commit | bf4c140f5438101d87dcb0395c7c778585b7fe09 (patch) | |
tree | 6ebaf53ec3205222ca00796f9d880f719b2bb54a /lib |
31c3 php player site
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PhpTemplate.php | 34 | ||||
-rw-r--r-- | lib/helper.php | 28 |
2 files changed, 62 insertions, 0 deletions
diff --git a/lib/PhpTemplate.php b/lib/PhpTemplate.php new file mode 100644 index 0000000..8dd6f72 --- /dev/null +++ b/lib/PhpTemplate.php @@ -0,0 +1,34 @@ +<?php + +// Version 1.2 + +if(!function_exists('h')) +{ + function h($s) + { + return htmlspecialchars($s); + } +} + +class PhpTemplate +{ + public function __construct($file) + { + $this -> file = $file; + } + + public function render($___data = array()) + { + extract((array)$___data); + unset($___data); + + ob_start(); + include($this->file); + return ob_get_clean(); + } + + public function __tostring() + { + return $this->render(); + } +} diff --git a/lib/helper.php b/lib/helper.php new file mode 100644 index 0000000..3e5e8a6 --- /dev/null +++ b/lib/helper.php @@ -0,0 +1,28 @@ +<?php + +function link_index() +{ + return ''; +} + +function link_room($room) +{ + return rawurlencode($room).'/'; +} + +function link_player($room, $format, $translated = false) +{ + return rawurlencode($room).'/'.rawurlencode($format).($translated ? '/translated' : ''); +} + +function baseurl() +{ + if(isset($GLOBALS['CONFIG']['baseurl'])) + return $GLOBALS['CONFIG']['baseurl']; + + $base = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) ? 'https://' : 'http://'; + $base .= $_SERVER['HTTP_HOST']; + $base .= dirname($_SERVER['SCRIPT_NAME']).'/'; + + return $base; +} |