3 // this function is the initial insertion point for the web calls, here we need to determine where we go
4 global $CALL_ME_FUNCTIONS;
6 $MENU_ITEMS["00home"]["text"] = "Home";
7 $MENU_ITEMS["00home"]["link"] = "$BASE_URL";
11 function gwvp_goWebBegin()
13 global $CALL_ME_FUNCTIONS;
15 // first we determine if we have a valid setup and run the installer if not
21 // next, we go thru the CALL_ME_FUNCTIONS - the purpose of call_me_functions is to determine if a function should be called based on
22 // the functions return (i.e. if function returns false, its not it, otherwise it returns a function name we have to call)
23 // this is important for our plugin structure later on - the key on the array serves an an ordering method
24 ksort($CALL_ME_FUNCTIONS);
25 foreach($CALL_ME_FUNCTIONS as $key => $val) {
26 error_log("checking callmefunction $key as $val");
28 if($callme !== false) {
34 // we fell-thru to the main web page builder
38 function gwvp_SendMessage($messagetype, $message)
40 $_SESSION["messagetype"] = $messagetype;
41 $_SESSION["message"] = $message;
44 function gwvp_goMainPage($bodyFunction = null)
46 // the main page will look pretty simple, a title, a menu then a body
47 global $WEB_ROOT_FS, $BASE_URL;
49 // a simple web page layout that loads any css and js files that exist in the css and js directories
50 echo "<html><head><title>GWVP</title>";
53 if(file_exists("$WEB_ROOT_FS/css")) {
54 $dh = opendir("$WEB_ROOT_FS/css");
56 while(($file = readdir($dh))!==false) {
57 $mt = preg_match("/.*.css$/", $file);
59 error_log("loading css $file");
60 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$BASE_URL/css/$file\">";
61 //echo "required $basedir/$file\n";
68 if(file_exists("$WEB_ROOT_FS/js")) {
69 $dh = opendir("$WEB_ROOT_FS/js");
71 while(($file = readdir($dh))!==false) {
72 $mt = preg_match("/.*.js$/", $file);
74 error_log("loading js $file");
75 echo "<script type=\"text/javascript\" src=\"$BASE_URL/js/$file\"></script>";
76 //echo "required $basedir/$file\n";
86 echo "<h1>Git over Web Via PHP</h2>";
89 echo "<table width=\"100%\">";
91 if(isset($_SESSION["message"])) {
92 echo "<tr width=\"100%\"><td colspan=\"2\">";
93 gwvp_MessageBuilder();
97 echo "<tr width=\"100%\" bgcolor=\"#ddffdd\"><td>";
99 echo "</td><td align=\"right\">";
106 if($bodyFunction == null) {
109 if(function_exists($bodyFunction)) {
112 error_log("Got called with non-existant body function, $bodyFunction");
120 echo "</td></tr></table></body></html>";
125 // builds the message builder if its needed
126 function gwvp_MessageBuilder()
129 $messagetype = "info";
130 if(isset($_SESSION["message"])) $message = $_SESSION["message"];
131 if(isset($_SESSION["messagetype"])) $messagetype = $_SESSION["messagetype"];
134 switch($messagetype) {
136 echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#AAFFAA\">$message</td></tr></table>";
139 echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#FFAAAA\">$message</td></tr></table>";
142 unset($_SESSION["message"]);
143 if(isset($_SESSION["messagetype"])) unset($_SESSION["messagetype"]);
147 // builds the menu structure
148 function gwvp_MenuBuilder()
150 global $MENU_ITEMS, $BASE_URL;
154 echo "<table border=\"1\"><tr><td><b><i>Menu</i></b></td>";
155 foreach($MENU_ITEMS as $key => $val) {
156 $link = $val["link"];
157 $text = $val["text"];
159 // TODO: redo this bit with stristr to find urls - special case for home
161 if(isset($_REQUEST["q"])) {
162 $extlink = str_replace("$BASE_URL/", "", $link);
163 error_log("trying to do replace of $BASE_URL in $link, got $extlink for ".$_REQUEST["q"]);
164 if(stristr($_REQUEST["q"], $extlink)!==false) {
165 $menucolor = " bgcolor=\"#ffdddd\"";
169 // special case for home
170 if($link == $BASE_URL) $menucolor = " bgcolor=\"#ffdddd\"";
176 if(isset($val["userlevel"])) {
177 if(gwvp_CheckAuthLevel($val["userlevel"])) {
178 echo "<td$menucolor><a href=\"$link\">$text</a></td>";
182 echo "<td$menucolor><a href=\"$link\">$text</a></td>";
185 echo "</tr></table>";
189 function gwvp_LoginBuilder()
191 global $WEB_ROOT_FS, $BASE_URL;
193 $login = gwvp_IsLoggedIn();
194 if($login === false) {
195 gwvp_SingleLineLoginForm();
197 echo "Hello, ".gwvp_GetFullName($login)." <a href=\"$BASE_URL/logout\">logout</a>";
201 // builds the body structure
202 function gwvp_BodyBuilder()
204 echo "I AM THE MAIN BODY, FEAR ME!!!!";
207 // builds the tail structure
208 function gwvp_TailBuilder()
210 echo "<font size=\"-1\"><i>Copyright 2011, PJR - licensed under GPL</i></font>";