url manipulation
authorpaulr <me@pjr.cc>
Sun, 17 Apr 2011 18:03:48 +0000 (04:03 +1000)
committerpaulr <me@pjr.cc>
Sun, 17 Apr 2011 18:03:48 +0000 (04:03 +1000)
lib/config.php
lib/lib.php
lib/plugins/aptproxy.php
lib/plugins/install.php
lib/plugins/www.php
lib/plugins/yumproxy.php
www/index.php

index 8a98632..624cfe7 100644 (file)
@@ -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;
 }
index 13d5757..0b5c221 100644 (file)
@@ -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 "<br>checking $bases_cd for ".$bases["base"]." against \"".$urlcomps[0]."\"<br>";
+               if(strtolower($urlcomps[0]) == strtolower($bases["base"])) {
+                       //echo "match<br>";
+                       $func = $bases["function"];
+                       return $func();
+               }
+       }
+}
 ?>
\ No newline at end of file
index 15c5adc..65d0c0d 100644 (file)
@@ -1,3 +1,6 @@
 <?php
+global $BASE_URLS;
 
+$BASE_URLS["ap"]["base"] = "ap"; // ap for apt-proxy
+$BASE_URLS["ap"]["function"] = "ap_pageBuilder"; // the page builder function for us
 ?>
\ No newline at end of file
index 843dca0..865d1e9 100644 (file)
@@ -3,6 +3,7 @@ if(isset($agentInstall)) {
        if($agentInstall) goAgentInstall();
 }
 
+/*
 if(!isset($dataSource)) {
        goWebInstall();
 }
@@ -15,8 +16,6 @@ function goWebInstall()
 {
        echo "<html>install";
        echo "<pre>";
-       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
index 4ef4c99..7811bea 100644 (file)
 <?php
 
-global $preWebComponents, $webComponents, $postWebComponents;
+global $BASE_URLS;
 
+$BASE_URLS["wp"]["base"] = "";
+$BASE_URLS["wp"]["function"] = "wp_pageBuilder";
 
-function goWebProcessor()
+function goWebProcessor($calls)
 {
-       global $preWebComponents, $webComponents, $postWebComponents;
+       if(isset($calls["needs_base_page"])) {
+               if($calls["needs_base_page"] == true) {
+                       // build page
+                       echo "here base\n";
+                       www_basePage($calls);
+               } else {
+                       $func = $calls["page_builder"];
+                       $func();
+               }
+       } else {
+               echo "here base 2\n";
+               www_basePage($calls);
+       }
+}
+
+function www_basePage($calls)
+{
+               
+       // header
+       if(isset($calls["header_function"])) {
+               $func = $calls["header_function"];
+               $func();
+       } else {
+               www_header();
+       }
        
-       foreach($preWebComponents as $function) {
-               if(function_exists($function)) $function();
+       echo "<table><tr><td>";
+       
+       // top
+       if(isset($calls["top_function"])) {
+               $func = $calls["top_function"];
+               $func();
+       } else {
+               www_top();
        }
        
-       foreach($webComponents as $function) {
-               if(function_exists($function)) $function();
+       echo "</td></tr><tr><td>";
+       
+       // 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 "</td><td>";
+       
+       // contentpane
+       if(isset($calls["content_pane_function"])) {
+               $func = $calls["content_pane_function"];
+               $func();
+       } else {
+               www_contentpane();
        }
+       
+       echo "</td></tr><tr><td>";
+       
+       // footer
+       if(isset($calls["footer_function"])) {
+               $func = $calls["footer_function"];
+               $func();
+       } else {
+               www_footer();
+       }
+       
+       echo "</td></tr></table>";
+
+       // page end
+       if(isset($calls["page_end_function"])) {
+               $func = $calls["page_end_function"];
+               $func();
+       } else {
+               www_pageend();
+       }
+       
+}
+
+function www_header()
+{
+       echo "<html><head></head><body>";
+}
+
+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 "</body></html>";
 }
 ?>
\ No newline at end of file
index 15c5adc..cccb29d 100644 (file)
@@ -1,3 +1,20 @@
 <?php
+global $BASE_URLS;
 
+$BASE_URLS["yp"]["base"] = "yp"; // ap for apt-proxy
+$BASE_URLS["yp"]["function"] = "yp_contentUrls"; // the page builder function for us
+
+
+function yp_contentPane()
+{
+       echo "i am a yp content pane<br>";
+}
+
+function yp_contentUrls()
+{
+       $calls["needs_base_page"] = true;
+       $calls["content_pane_function"] = "yp_contentPane";
+       
+       return $calls;
+}
 ?>
\ No newline at end of file
index 4a873a4..d42091a 100644 (file)
@@ -2,8 +2,10 @@
 
 require_once("../lib/lib.php");
 
+
 if(function_exists("goWebProcessor")) {
-       goWebProcessor();
+       $calls = urlInterpretter();
+       goWebProcessor($calls);
        exit(0);
 }