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()) {
// 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();
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 "<html><head><title>GWVP Mini</title>";
+ echo "<html><head><title>GWVP</title>";
// load css
if(file_exists("$WEB_ROOT_FS/css")) {
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";
}
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";
}
// start body
echo "</head><body>";
- echo "<h1>Git over Web Via PHP - Mini Version</h2>";
+ echo "<h1>Git over Web Via PHP</h1>";
echo "<table width=\"100%\">";
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>";
echo "</tr>";
- echo "<tr><td>";
+ 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>";
// 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":
}
}
+function gwvpmini_ChatBuilder()
+{
+ gwvpmini_DisplayChat();
+}
+
// builds the menu structure
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\"";
if($login === false) {
gwvpmini_SingleLineLoginForm();
} else {
- echo "Hello ".$_SESSION["fullname"]." <a href=\"$BASE_URL/logout\">logout</a>";
+ echo "Hello <a href=\"$BASE_URL/user/".$_SESSION["username"]."\">".$_SESSION["fullname"]."</a> <a href=\"$BASE_URL/logout\">logout</a>";
}
}
{
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();
}
}
// builds the tail structure
function gwvpmini_TailBuilder()
{
- echo "<font size=\"-1\"><i>Copyright 2011, PJR - licensed under GPL</i></font>";
+ echo "<br><br><hr><font size=\"-1\"><b><a href=\"http://github.com/takigama/GWVP\">GWVP</a></b> - <i>Copyright 2011, 2012 PJR - <a href=\"http://www.gnu.org/copyleft/gpl.html\">GPL</a></i></font>";
+}
+
+function gwvpmini_emailToUserLink($email)
+{
+ global $BASE_URL;
+
+ $username = gwvpmini_GetUserNameFromEmail($email);
+
+ if($username !== false) {
+ return "<a href=\"$BASE_URL/user/$username\">$username</a>";
+ } else {
+ 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");
}
+/**\r
+ * Get either a Gravatar URL or complete image tag for a specified email address.\r
+ *\r
+ * @param string $email The email address\r
+ * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]\r
+ * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]\r
+ * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]\r
+ * @param boole $img True to return a complete IMG tag False for just the URL\r
+ * @param array $atts Optional, additional key/value attributes to include in the IMG tag\r
+ * @return String containing either just a URL or a complete image tag\r
+ * @source http://gravatar.com/site/implement/images/php/\r
+ */
+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";
+}
+\r
+function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {\r
+ $url = 'http://en.gravatar.com/avatar/';\r
+ $url .= md5( strtolower( trim( $email ) ) );\r
+ $url .= "?s=$s&d=$d&r=$r";\r
+ if ( $img ) {\r
+ $url = '<img src="' . $url . '"';\r
+ foreach ( $atts as $key => $val )\r
+ $url .= ' ' . $key . '="' . $val . '"';\r
+ $url .= ' />';\r
+ }\r
+ return $url;\r
+}\r
+
?>
\ No newline at end of file