From afe6e413d073cd29e366b0642ef0928db712c8e5 Mon Sep 17 00:00:00 2001 From: paulr Date: Mon, 18 Apr 2011 04:03:48 +1000 Subject: [PATCH] url manipulation --- lib/config.php | 4 +- lib/lib.php | 18 +++++++- lib/plugins/aptproxy.php | 3 + lib/plugins/install.php | 4 +- lib/plugins/www.php | 114 ++++++++++++++++++++++++++++++++++++++++++---- lib/plugins/yumproxy.php | 17 +++++++ www/index.php | 4 +- 7 files changed, 149 insertions(+), 15 deletions(-) diff --git a/lib/config.php b/lib/config.php index 8a98632..624cfe7 100644 --- a/lib/config.php +++ b/lib/config.php @@ -8,12 +8,12 @@ if(file_exists("../var/config.php")) { $configured = true; } -if(file_eixsts("/var/glcas/config.php")) { +if(file_exists("/var/glcas/config.php")) { require_once("/var/glcas/config.php"); $configured = true; } -if(file_eixsts("/etc/glcas/config.php")) { +if(file_exists("/etc/glcas/config.php")) { require_once("/etc/glcas/config.php"); $configured = true; } diff --git a/lib/lib.php b/lib/lib.php index 13d5757..0b5c221 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -20,5 +20,21 @@ if(is_dir("$basedir/plugins")) { echo "No plugins dir ($basedir/plugins), continuing without\n"; } - +function urlInterpretter() +{ + global $BASE_URLS; + + if(isset($_REQUEST["q"])) $qry = $_REQUEST["q"]; + else $qry = ""; + + $urlcomps = preg_split("/[,\/]/", $qry); + foreach($BASE_URLS as $bases_cd => $bases) { + //echo "
checking $bases_cd for ".$bases["base"]." against \"".$urlcomps[0]."\"
"; + if(strtolower($urlcomps[0]) == strtolower($bases["base"])) { + //echo "match
"; + $func = $bases["function"]; + return $func(); + } + } +} ?> \ No newline at end of file diff --git a/lib/plugins/aptproxy.php b/lib/plugins/aptproxy.php index 15c5adc..65d0c0d 100644 --- a/lib/plugins/aptproxy.php +++ b/lib/plugins/aptproxy.php @@ -1,3 +1,6 @@ \ No newline at end of file diff --git a/lib/plugins/install.php b/lib/plugins/install.php index 843dca0..865d1e9 100644 --- a/lib/plugins/install.php +++ b/lib/plugins/install.php @@ -3,6 +3,7 @@ if(isset($agentInstall)) { if($agentInstall) goAgentInstall(); } +/* if(!isset($dataSource)) { goWebInstall(); } @@ -15,8 +16,6 @@ function goWebInstall() { echo "install"; echo "
";
-	echo "globals\n";
-	print_r($_GLOBALS);
 	echo "servers\n";
 	print_r($_SERVER);
 	echo "request\n";
@@ -26,4 +25,5 @@ function goWebInstall()
 	exit(0);
 }
 
+*/
 ?>
\ No newline at end of file
diff --git a/lib/plugins/www.php b/lib/plugins/www.php
index 4ef4c99..7811bea 100644
--- a/lib/plugins/www.php
+++ b/lib/plugins/www.php
@@ -1,22 +1,118 @@
 ";
+	
+	// top
+	if(isset($calls["top_function"])) {
+		$func = $calls["top_function"];
+		$func();
+	} else {
+		www_top();
 	}
 	
-	foreach($webComponents as $function) {
-		if(function_exists($function)) $function();
+	echo "";
+	
+	// left menu
+	if(isset($calls["left_menu_function"])) {
+		$func = $calls["left_menu_function"];
+		$func();
+	} else {
+		www_leftmenu();
 	}
 	
-	foreach($postWebComponents as $function) {
-		if(function_exists($function)) $function();
+	echo "";
+	
+	// contentpane
+	if(isset($calls["content_pane_function"])) {
+		$func = $calls["content_pane_function"];
+		$func();
+	} else {
+		www_contentpane();
 	}
+	
+	echo "";
+	
+	// footer
+	if(isset($calls["footer_function"])) {
+		$func = $calls["footer_function"];
+		$func();
+	} else {
+		www_footer();
+	}
+	
+	echo "";
+
+	// page end
+	if(isset($calls["page_end_function"])) {
+		$func = $calls["page_end_function"];
+		$func();
+	} else {
+		www_pageend();
+	}
+	
+}
+
+function www_header()
+{
+	echo "";
+}
+
+function www_top()
+{
+	echo "i be a top, yar";
+}
+
+function www_leftmenu()
+{
+	echo "i be a menu, yar";
+}
+
+function www_contentpane()
+{
+	echo "i be a content pane, yar";
+}
+
+function www_footer()
+{
+	echo "i be a footer, yar";
+}	
+	
+	
+function www_pageend()
+{
+	echo "";
 }
 ?>
\ No newline at end of file
diff --git a/lib/plugins/yumproxy.php b/lib/plugins/yumproxy.php
index 15c5adc..cccb29d 100644
--- a/lib/plugins/yumproxy.php
+++ b/lib/plugins/yumproxy.php
@@ -1,3 +1,20 @@
 ";
+}
+
+function yp_contentUrls()
+{
+	$calls["needs_base_page"] = true;
+	$calls["content_pane_function"] = "yp_contentPane";
+	
+	return $calls;
+}
 ?>
\ No newline at end of file
diff --git a/www/index.php b/www/index.php
index 4a873a4..d42091a 100644
--- a/www/index.php
+++ b/www/index.php
@@ -2,8 +2,10 @@
 
 require_once("../lib/lib.php");
 
+
 if(function_exists("goWebProcessor")) {
-	goWebProcessor();
+	$calls = urlInterpretter();
+	goWebProcessor($calls);
 	exit(0);
 }
 
-- 
1.7.0.4