aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/PhpTemplate.php34
-rw-r--r--lib/helper.php28
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;
+}