force ssl, change to /gwvp url
authorPaul J R <me@pjr.cc>
Thu, 27 Sep 2012 21:51:44 +0000 (07:51 +1000)
committerPaul J R <me@pjr.cc>
Thu, 27 Sep 2012 21:51:44 +0000 (07:51 +1000)
gwvpmini/gwvpmini_admin.php
gwvpmini/gwvpmini_user.php
gwvpmini/gwvpmini_web.php
www/.htaccess

index af007c1..e19a268 100644 (file)
@@ -54,6 +54,9 @@ function gwvpmini_AdminCallMe()
                                        if($qspl[1] == "changegravs") {
                                                return "gwvpmini_SwitchGravatars";
                                        }
+                                       if($qspl[1] == "changessl") {
+                                               return "gwvpmini_SwitchForceSSL";
+                                       }
                                } else {\r
                                        error_log("i got here, where next?");\r
                                        return "gwvpmini_AdminMainPage";\r
@@ -87,7 +90,7 @@ function gwvpmini_AdminMainPage()
 function gwvpmini_AdminMainPageBody()
 {
        global $BASE_URL;
-       global $can_register, $reg_reqs_confirm, $confirm_from_address, $use_gravatar;
+       global $can_register, $reg_reqs_confirm, $confirm_from_address, $use_gravatar, $force_ssl;
        
        if($can_register) {
                $register = "Registration Enabled (<a href=\"$BASE_URL/admin/changereg\">Disable</a>)";
@@ -107,10 +110,17 @@ function gwvpmini_AdminMainPageBody()
                $usegrav = "Gravatars are disabled (<a href=\"$BASE_URL/admin/changegravs\">Enable</a>)";
        }
        
+       if($force_ssl) {\r
+               $forcessl = "Force SSL is enabled (<a href=\"$BASE_URL/admin/changessl\">Disable</a>)";\r
+       } else {\r
+               $forcessl = "Force SSL is disabled (<a href=\"$BASE_URL/admin/changessl\">Enable</a>)";\r
+       }\r
+       
+       
        $totalusers = gwvpmini_GetNUsers();
        echo "<table><tr valign=\"top\"><td>";
        echo "<h2>Users - $totalusers</h2>";
-       echo "$register<br>$regconfirm<br>$usegrav<br>";
+       echo "$register<br>$regconfirm<br>$usegrav<br>$forcessl<br>";
        echo "<form method=\"post\" action=\"$BASE_URL/admin/changefromemail\">";
        echo "Address emails are sent from <input type=\"text\" name=\"fromemail\" value=\"$confirm_from_address\"><input type=\"submit\" name=\"Update\" value=\"Update\"><br>";
        echo "</form>"; 
@@ -502,4 +512,23 @@ function gwvpmini_SwitchGravatars()
        \r
        header("Location: $BASE_URL/admin");
 }
+
+function gwvpmini_SwitchForceSSL()
+{
+       global $BASE_URL, $force_ssl;\r
+       \r
+       if($newst == 1) $stat = "disabled";\r
+       else $stat = "enabled";\r
+       \r
+       if($force_ssl) {\r
+               gwvpmini_setConfigVal("forcessl", "0");\r
+       } else {\r
+               gwvpmini_setConfigVal("forcessl", "1");\r
+       }\r
+       \r
+       gwvpmini_SendMessage("info", "forcessl $stat");\r
+       \r
+       header("Location: $BASE_URL/admin");\r
+       
+}
 ?>
\ No newline at end of file
index c495552..f2efe02 100644 (file)
@@ -15,6 +15,21 @@ if($IS_WEB_REQUEST) {
        }\r
        \r
        global $use_gravatar;
+       
+       $reg = gwvpmini_getConfigVal("forcessl");\r
+\r
+       $force_ssl = false;\r
+       if($reg == null) {\r
+               // dont force ssl by default\r
+               gwvpmini_setConfigVal("forcessl", "0");\r
+       } else if($reg == 1) {\r
+               $force_ssl = true;\r
+       } else {\r
+               $force_ssl = false;\r
+       }\r
+\r
+       global $force_ssl;\r
+       
 }\r
 
 
index 4f83206..e7e0e54 100644 (file)
@@ -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,6 +24,15 @@ 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");
index 9f3570d..6805308 100644 (file)
@@ -1,5 +1,5 @@
 RewriteEngine on
-RewriteBase /src/local/eclipse-workspace/gwvp-mini/www/ 
+RewriteBase /gwvp 
 RewriteRule ^index\.php.* - [L,B]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d