X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=gwvpmini%2Fgwvpmini_web.php;h=71a931fa8f1108f4a174896e78db9eb9a1327f65;hb=90c1b8ddcf48b3f13f143954a81f231591955915;hp=f6b6665833691bfd2de4eca1ae2284dafeb68e47;hpb=abfd6ab968291688d09edfbefb38c88f1a33c919;p=gwvp-mini.git diff --git a/gwvpmini/gwvpmini_web.php b/gwvpmini/gwvpmini_web.php index f6b6665..71a931f 100644 --- a/gwvpmini/gwvpmini_web.php +++ b/gwvpmini/gwvpmini_web.php @@ -13,7 +13,7 @@ $MENU_ITEMS["00home"]["link"] = "$BASE_URL"; function gwvpmini_goWeb() { - global $CALL_ME_FUNCTIONS; + global $CALL_ME_FUNCTIONS, $force_ssl; // first we determine if we have a valid setup and run the installer if not /*if(!gwvpmini_issetup()) { @@ -24,9 +24,18 @@ function gwvpmini_goWeb() // 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 // the functions return (i.e. if function returns false, its not it, otherwise it returns a function name we have to call) // this is important for our plugin structure later on - the key on the array serves an an ordering method + + if($force_ssl) { + if(!isset($_SERVER['HTTPS'])) { + header("Location: https://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"], true); + return; + } + } + + 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(); @@ -50,7 +59,7 @@ function gwvpmini_goMainPage($bodyFunction = null) global $WEB_ROOT_FS, $BASE_URL; // a simple web page layout that loads any css and js files that exist in the css and js directories - echo "GWVP Mini"; + echo "GWVP"; // load css if(file_exists("$WEB_ROOT_FS/css")) { @@ -59,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 ""; //echo "required $basedir/$file\n"; } @@ -74,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 ""; //echo "required $basedir/$file\n"; } @@ -86,7 +95,7 @@ function gwvpmini_goMainPage($bodyFunction = null) // start body echo ""; - echo "

Git over Web Via PHP - Mini Version

"; + echo "

Git over Web Via PHP

"; echo ""; @@ -110,17 +119,30 @@ function gwvpmini_goMainPage($bodyFunction = null) echo ""; - echo ""; echo "
"; + echo "
"; + + echo ""; + + /* TODO: taking out chat for now + echo ""; */ + + echo "
"; 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 ""; + + gwvpmini_ChatBuilder(); + echo "
"; + echo "
"; @@ -152,6 +174,11 @@ function gwvpmini_MessageBuilder() } } +function gwvpmini_ChatBuilder() +{ + gwvpmini_DisplayChat(); +} + // builds the menu structure function gwvpmini_MenuBuilder() { @@ -168,7 +195,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\""; @@ -202,7 +229,7 @@ function gwvpmini_LoginBuilder() if($login === false) { gwvpmini_SingleLineLoginForm(); } else { - echo "Hello ".$_SESSION["fullname"]." logout"; + echo "Hello ".$_SESSION["fullname"]." logout"; } } @@ -211,11 +238,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(); } } @@ -224,34 +250,74 @@ function gwvpmini_BodyBuilder() // builds the tail structure function gwvpmini_TailBuilder() { - echo "Copyright 2011, PJR - licensed under GPL"; + echo "


GWVP - Copyright 2011, 2012 PJR - GPL"; } function gwvpmini_emailToUserLink($email) { global $BASE_URL; - $username = gwvpmini_GetUserNameFromEmail($username); + $username = gwvpmini_GetUserNameFromEmail($email); if($username !== false) { return "$username"; } else { - return "Uknown"; + return false; } } function gwvpmini_fourZeroThree() { - error_log("403 called"); - header("HTTP/1.0 403 Permission Denied"); + // error_log("403 called"); + header("HTTP/1.1 403 Permission Denied"); } function gwvpmini_fourZeroFour() { - error_log("404 called"); - header("HTTP/1.0 404 No Such Thing"); + // error_log("404 called"); + header("HTTP/1.1 404 No Such Thing"); } +/** + * Get either a Gravatar URL or complete image tag for a specified email address. + * + * @param string $email The email address + * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] + * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] + * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] + * @param boole $img True to return a complete IMG tag False for just the URL + * @param array $atts Optional, additional key/value attributes to include in the IMG tag + * @return String containing either just a URL or a complete image tag + * @source http://gravatar.com/site/implement/images/php/ + */ +function gwvpmini_HtmlGravatar($email, $size, $htmlappend="") +{ + + global $use_gravatar; + + if($use_gravatar) { + // error_log("call to gravatar with yes"); + } else { + // error_log("call to gravatar with no"); + } + + if($use_gravatar == false) return ""; + return get_gravatar( $email, $size, 'mm', 'g', true)."$htmlappend"; +} + +function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) { + $url = 'http://en.gravatar.com/avatar/'; + $url .= md5( strtolower( trim( $email ) ) ); + $url .= "?s=$s&d=$d&r=$r"; + if ( $img ) { + $url = ' $val ) + $url .= ' ' . $key . '="' . $val . '"'; + $url .= ' />'; + } + return $url; +} + ?> \ No newline at end of file