diff index.php @ 8:19dfa6f3e2be

Support for scripts.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Sun, 12 Jun 2011 14:15:00 +0200
parents 350a8c63bd14
children a20bb1b51aad 91ee5f49907e
line wrap: on
line diff
--- a/index.php	Fri May 20 23:34:33 2011 +0200
+++ b/index.php	Sun Jun 12 14:15:00 2011 +0200
@@ -128,8 +128,25 @@
 }
 
 foreach ($files as $file) {
-	$src=$file->getAttribute("src");
-	$file_content=loadFile("${lang}/${src}");
+	$script=$file->getAttribute("script");
+	if ($script) {
+	  $src="";
+	  $cwd=getcwd();
+
+	  $matches=array();
+	  preg_match('/(.*\/)/', $script, $matches);
+	  $dirname=$matches[0];
+	  preg_match('/([^\/]*)$/', $script, $matches);
+	  $filename=$matches[0];
+	  chdir("${lang}/${dirname}");
+	  $pipe=popen("php ${filename}","r");
+	  $file_content = stream_get_contents($pipe);
+	  chdir("${cwd}");
+	}
+	else {
+		$src=$file->getAttribute("src");
+		$file_content=loadFile("${lang}/${src}");
+	}
 	if(floatval($file_content)<0) {
 	  errorPage("Resource not found '${lang}/${src}'");
 	}