replacing the cli cmds with variables and configuration in config.php
[gwvp-mini.git] / gwvpmini / gwvpmini_web.php
index 0613c05..92005b3 100644 (file)
@@ -35,7 +35,7 @@ function gwvpmini_goWeb()
        
        ksort($CALL_ME_FUNCTIONS);
        foreach($CALL_ME_FUNCTIONS as $key => $val) {
-               //error_log("checking callmefunction $key as $val");
+               //// error_log("checking callmefunction $key as $val");
                $callme = $val();
                if($callme !== false) {
                        $callme();
@@ -68,7 +68,7 @@ function gwvpmini_goMainPage($bodyFunction = null)
                        while(($file = readdir($dh))!==false) {
                                $mt = preg_match("/.*.css$/", $file);
                                if($mt > 0) {
-                                       error_log("loading css $file");
+                                       // error_log("loading css $file");
                                        echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$BASE_URL/css/$file\">";
                                        //echo "required $basedir/$file\n";
                                }
@@ -83,7 +83,7 @@ function gwvpmini_goMainPage($bodyFunction = null)
                        while(($file = readdir($dh))!==false) {
                                $mt = preg_match("/.*.js$/", $file);
                                if($mt > 0) {
-                                       error_log("loading js $file");
+                                       // error_log("loading js $file");
                                        echo "<script type=\"text/javascript\" src=\"$BASE_URL/js/$file\"></script>";
                                        //echo "required $basedir/$file\n";
                                }
@@ -104,8 +104,11 @@ function gwvpmini_goMainPage($bodyFunction = null)
        gwvpmini_SearchBuilder();
        echo "</td></tr>";\r
        
-
-       if(isset($_SESSION["message"])) {
+       $havemessage = false;
+       if(isset($_SESSION["message"])) $havemessage = true;
+       if(isset($_SESSION["id"])) if(gwvpmini_GetMessagesForId($_SESSION["id"]) !== 0) $havemessage = true;
+       
+       if($havemessage) {
                echo "<tr width=\"100%\"><td colspan=\"2\">";
                gwvpmini_MessageBuilder();
                echo "</td></tr>";
@@ -119,17 +122,30 @@ function gwvpmini_goMainPage($bodyFunction = null)
        
        echo "</tr>";
        
-       echo "<tr><td colspan=\"2\">";
+       echo "<tr width=\"100%\"><td colspan=\"3\">";
+       
+       echo "<table width=\"100%\"><tr width=\"100%\" valign=\"top\"><td>";
        if($bodyFunction == null) {
                gwvpmini_BodyBuilder();
        } else {
                if(function_exists($bodyFunction)) {
                        $bodyFunction();
                } else {
-                       error_log("Got called with non-existant body function, $bodyFunction");
+                       // error_log("Got called with non-existant body function, $bodyFunction");
                        gwvpmini_BodyBuilder();
                }
        }
+       
+       echo "</td>";
+       
+       /* TODO: taking out chat for now
+       echo "<td align=\"right\">";
+       
+       gwvpmini_ChatBuilder();
+       echo "</td>"; */
+       
+       echo "</tr></table>";\r
+       
        echo "</td></tr>";
        
        echo "<tr><td>";
@@ -142,11 +158,30 @@ function gwvpmini_goMainPage($bodyFunction = null)
 // builds the message builder if its needed
 function gwvpmini_MessageBuilder()
 {
+       
+       error_log("begin message building?");
        $message = "";
        $messagetype = "info";
        if(isset($_SESSION["message"])) $message = $_SESSION["message"];
        if(isset($_SESSION["messagetype"])) $messagetype = $_SESSION["messagetype"];
+       if(isset($_SESSION["id"])) $dbmsgs = gwvpmini_GetMessagesForId($_SESSION["id"]);
        
+       error_log("dbmsgs was 0 - ".print_r($_SESSION,true));
+       
+       if($dbmsgs !== 0) {
+               foreach($dbmsgs as $mgkey => $mgval) {
+                       $data = $mgval["data"];
+                       switch($mgval["type"]) {\r
+                               case "info":\r
+                                       echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#AAFFAA\">$data</td></tr></table>";\r
+                                       break;\r
+                               case "error":\r
+                                       echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#FFAAAA\">$data</td></tr></table>";\r
+                                       break;\r
+                       }
+                       gwvpmini_DeleteMessagesById($mgval["id"]);
+               }
+       } 
        if($message != "") {
                switch($messagetype) {
                        case "info":
@@ -161,6 +196,11 @@ function gwvpmini_MessageBuilder()
        }
 }
 
+function gwvpmini_ChatBuilder()
+{
+       gwvpmini_DisplayChat();
+}
+
 // builds the menu structure
 function gwvpmini_MenuBuilder()
 {
@@ -177,7 +217,7 @@ function gwvpmini_MenuBuilder()
                $menucolor = "";
                if(isset($_REQUEST["q"])) {
                        $extlink = str_replace("$BASE_URL/", "", $link);
-                       error_log("trying to do replace of $BASE_URL in $link, got $extlink for ".$_REQUEST["q"]);
+                       // error_log("trying to do replace of $BASE_URL in $link, got $extlink for ".$_REQUEST["q"]);
                        if(stristr($_REQUEST["q"], $extlink)!==false) {
                                $menucolor = " bgcolor=\"#ffdddd\"";
                                
@@ -220,11 +260,10 @@ function gwvpmini_BodyBuilder()
 {
        global $HOME_PAGE_PROVIDERS;
        
-       echo "I AM THE MAIN BODY, FEAR ME!!!! - have no idea whats going to go here";
        if(isset($HOME_PAGE_PROVIDERS)) {
                ksort($HOME_PAGE_PROVIDERS);
                foreach($HOME_PAGE_PROVIDERS as $provider) {
-                       error_log("Loading home_page_provider, $provider");
+                       // error_log("Loading home_page_provider, $provider");
                        $provider();
                }
        }
@@ -251,13 +290,13 @@ function gwvpmini_emailToUserLink($email)
 
 function gwvpmini_fourZeroThree()
 {
-       error_log("403 called");
+       // error_log("403 called");
        header("HTTP/1.1 403 Permission Denied");
 }
 
 function gwvpmini_fourZeroFour()
 {
-       error_log("404 called");
+       // error_log("404 called");
        header("HTTP/1.1 404 No Such Thing");
 }
 
@@ -280,9 +319,9 @@ function gwvpmini_HtmlGravatar($email, $size, $htmlappend="")
        global $use_gravatar;
        
        if($use_gravatar) {
-               error_log("call to gravatar with yes");
+               // error_log("call to gravatar with yes");
        } else {
-               error_log("call to gravatar with no");
+               // error_log("call to gravatar with no");
        }
        
        if($use_gravatar == false) return "";