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 // the home_page_provders bit is an array
7 global $HOME_PAGE_PROVIDERS;
9 $MENU_ITEMS["00home"]["text"] = "Home";
10 $MENU_ITEMS["00home"]["link"] = "$BASE_URL";
14 function gwvp_goWebBegin()
16 global $CALL_ME_FUNCTIONS;
18 // first we determine if we have a valid setup and run the installer if not
24 // 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
25 // the functions return (i.e. if function returns false, its not it, otherwise it returns a function name we have to call)
26 // this is important for our plugin structure later on - the key on the array serves an an ordering method
27 ksort($CALL_ME_FUNCTIONS);
28 foreach($CALL_ME_FUNCTIONS as $key => $val) {
29 error_log("checking callmefunction $key as $val");
31 if($callme !== false) {
37 // we fell-thru to the main web page builder
41 function gwvp_SendMessage($messagetype, $message)
43 $_SESSION["messagetype"] = $messagetype;
44 $_SESSION["message"] = $message;
47 function gwvp_goMainPage($bodyFunction = null)
49 // the main page will look pretty simple, a title, a menu then a body
50 global $WEB_ROOT_FS, $BASE_URL;
52 // a simple web page layout that loads any css and js files that exist in the css and js directories
53 echo "<html><head><title>GWVP</title>";
56 if(file_exists("$WEB_ROOT_FS/css")) {
57 $dh = opendir("$WEB_ROOT_FS/css");
59 while(($file = readdir($dh))!==false) {
60 $mt = preg_match("/.*.css$/", $file);
62 error_log("loading css $file");
63 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$BASE_URL/css/$file\">";
64 //echo "required $basedir/$file\n";
71 if(file_exists("$WEB_ROOT_FS/js")) {
72 $dh = opendir("$WEB_ROOT_FS/js");
74 while(($file = readdir($dh))!==false) {
75 $mt = preg_match("/.*.js$/", $file);
77 error_log("loading js $file");
78 echo "<script type=\"text/javascript\" src=\"$BASE_URL/js/$file\"></script>";
79 //echo "required $basedir/$file\n";
89 echo "<h1>Git over Web Via PHP</h2>";
92 echo "<table width=\"100%\">";
94 if(isset($_SESSION["message"])) {
95 echo "<tr width=\"100%\"><td colspan=\"2\">";
96 gwvp_MessageBuilder();
100 echo "<tr width=\"100%\" bgcolor=\"#ddffdd\"><td>";
102 echo "</td><td align=\"right\">";
109 if($bodyFunction == null) {
112 if(function_exists($bodyFunction)) {
115 error_log("Got called with non-existant body function, $bodyFunction");
123 echo "</td></tr></table></body></html>";
128 // builds the message builder if its needed
129 function gwvp_MessageBuilder()
132 $messagetype = "info";
133 if(isset($_SESSION["message"])) $message = $_SESSION["message"];
134 if(isset($_SESSION["messagetype"])) $messagetype = $_SESSION["messagetype"];
137 switch($messagetype) {
139 echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#AAFFAA\">$message</td></tr></table>";
142 echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#FFAAAA\">$message</td></tr></table>";
145 unset($_SESSION["message"]);
146 if(isset($_SESSION["messagetype"])) unset($_SESSION["messagetype"]);
150 // builds the menu structure
151 function gwvp_MenuBuilder()
153 global $MENU_ITEMS, $BASE_URL;
158 echo "<table border=\"1\"><tr><td><b><i>Menu</i></b></td>";
159 foreach($MENU_ITEMS as $key => $val) {
160 $link = $val["link"];
161 $text = $val["text"];
163 // TODO: redo this bit with stristr to find urls - special case for home
165 if(isset($_REQUEST["q"])) {
166 $extlink = str_replace("$BASE_URL/", "", $link);
167 error_log("trying to do replace of $BASE_URL in $link, got $extlink for ".$_REQUEST["q"]);
168 if(stristr($_REQUEST["q"], $extlink)!==false) {
169 $menucolor = " bgcolor=\"#ffdddd\"";
173 // special case for home
174 if($link == $BASE_URL) $menucolor = " bgcolor=\"#ffdddd\"";
180 if(isset($val["userlevel"])) {
181 if(gwvp_CheckAuthLevel($val["userlevel"])) {
182 echo "<td$menucolor><a href=\"$link\">$text</a></td>";
186 echo "<td$menucolor><a href=\"$link\">$text</a></td>";
189 echo "</tr></table>";
194 function gwvp_LoginBuilder()
196 global $WEB_ROOT_FS, $BASE_URL;
199 $login = gwvp_IsLoggedIn();
200 if($login === false) {
201 gwvp_SingleLineLoginForm();
203 echo "Hello, ".gwvp_GetFullName($login)." <a href=\"$BASE_URL/logout\">logout</a>";
208 // builds the body structure
209 function gwvp_BodyBuilder()
211 global $HOME_PAGE_PROVIDERS;
213 echo "I AM THE MAIN BODY, FEAR ME!!!! - have no idea whats going to go here";
214 if(isset($HOME_PAGE_PROVIDERS)) {
215 ksort($HOME_PAGE_PROVIDERS);
216 foreach($HOME_PAGE_PROVIDERS as $provider) {
217 error_log("Loading home_page_provider, $provider");
223 // builds the tail structure
224 function gwvp_TailBuilder()
226 echo "<font size=\"-1\"><i>Copyright 2011, PJR - licensed under GPL</i></font>";
229 function gwvp_fourZeroThree()
231 error_log("403 called");
232 header("HTTP/1.0 403 Permission Denied");
235 function gwvp_fourZeroFour()
237 error_log("404 called");
238 header("HTTP/1.0 404 No Such Thing");