some auth debugging nonsense
authorPaul J R <me@pjr.cc>
Fri, 21 Sep 2012 22:58:50 +0000 (08:58 +1000)
committerPaul J R <me@pjr.cc>
Fri, 21 Sep 2012 22:58:50 +0000 (08:58 +1000)
gwvpmini/gwvpmini_admin.php
gwvpmini/gwvpmini_auth.php
gwvpmini/gwvpmini_db.php
gwvpmini/gwvpmini_gitbackend.php
gwvpmini/gwvpmini_web.php
www/config.php
www/index.php

index 0b811eb..6b721c3 100644 (file)
@@ -11,7 +11,7 @@ if(gwvpmini_isLoggedIn()) if(gwvpmini_isUserAdmin()) {
 function gwvpmini_AdminCallMe()\r
 {\r
 \r
-       error_log("in admin callme");\r
+       //error_log("in admin callme");\r
        if(isset($_REQUEST["q"])) {\r
                $query = $_REQUEST["q"];\r
                $qspl = explode("/", $query);\r
index 4fd5894..89aec63 100644 (file)
@@ -7,7 +7,7 @@ $CALL_ME_FUNCTIONS["auth"] = "gwvpmini_AuthCallMe";
 function gwvpmini_AuthCallMe()\r
 {\r
 \r
-       error_log("in repoadmin callme");\r
+       //error_log("in repoadmin callme");\r
        if(isset($_REQUEST["q"])) {\r
                $query = $_REQUEST["q"];\r
                $qspl = explode("/", $query);\r
@@ -114,15 +114,18 @@ function gwvpmini_AskForBasicAuth()
 function gwvpmini_checkBasicAuthLogin()\r
 {\r
        $user = false;\r
-       $pass = false;\r
+       $pass = false;
+       
        if(isset($_SERVER["PHP_AUTH_USER"])) {\r
                $user = $_SERVER["PHP_AUTH_USER"];\r
        } else return false;\r
 \r
        if(isset($_SERVER["PHP_AUTH_PW"])) {\r
                $pass = $_SERVER["PHP_AUTH_PW"];\r
-       } else return false;\r
-\r
+       } else return false;
+       \r
+       error_log("IN CHECK FOR BASIC AUTH: $user");\r
+       \r
        error_log("passing basic auth for $user, $pass to backend");\r
        $auth = gwvpmini_authUserPass($user, $pass);\r
        if($auth !== false) {\r
index c3ac22b..b74a334 100644 (file)
@@ -6,7 +6,7 @@ $DB_CONNECTION = false;
 \r
 \r
 global $db_url, $db_type;\r
-error_log("in include for database, $db_type, $db_name");
+//error_log("in include for database, $db_type, $db_name");
 
 
 function gwvpmini_DBExists()
@@ -14,15 +14,15 @@ function gwvpmini_DBExists()
        global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name;
        
        // oh this isnt working. poo.
-       error_log("checking for $db_name, $db_type");
+       //error_log("checking for $db_name, $db_type");
        
        if($db_type == "sqlite") {
                if(file_exists($db_name)) {
-                       error_log("Exists");
+                       //error_log("Exists");
                        return true;
                }
                else {
-                       error_log("no exists");
+                       //error_log("no exists");
                        return false;
                }
        }
@@ -118,29 +118,48 @@ function gwvpmini_ChangeRepoPerm($rid, $uid, $acc)
        if($cperms_t === false) return false;
        
        $permsarray = array();
-       if($cperms_t == "") {
-               $permsarray[$uid] = $acc;
-       } else {
-               $permsarray = unserialize(base64_decode($cperms_t));
-               $permsarray[$uid] = $acc;
-               if($acc == 0) {
-                       error_log("PERMSUPDATE: REMOVE $uid");
-                       unset($permsarray[$uid]);
+       if($uid != "b") {
+               if($cperms_t == "") {
+                       $permsarray[$uid] = $acc;
+               } else {
+                       $permsarray = unserialize(base64_decode($cperms_t));
+                       $permsarray[$uid] = $acc;
+                       if($acc == 0) {
+                               error_log("PERMSUPDATE: REMOVE $uid");
+                               unset($permsarray[$uid]);
+                       }
                }
+       } else {
+               error_log("CHANGEREPOPERMS for b of $acc");
+               $permsarray["b"] = $acc;
        }
        
        // check if base is now r or a, we can drop any 1's
        if($permsarray["b"] == "a" || $permsarray["b"] == "r") {
                foreach($permsarray as $key => $val) {
                        if($val == 1) {
+                               error_log("CHANGEREPOPERMS removed $key $val for base perm change");
                                unset($permsarray[$key]);
                        }
                }
        }
        
+       if(is_array($permsarray)) {
+               if(!isset($permsarray["b"])) {
+                       // something went wrong, repalce b bit
+                       $permsarray["b"] = "a";
+               }
+       } else {
+               // something went even wronger
+               $permsarray["b"] = "a";
+       }
+       
+
        $encperms = base64_encode(serialize($permsarray));
        
        $sql = "update repos set repos_perms='$encperms' where repos_id='$rid'";\r
+
+       error_log("PERMSARRAYNOW $sql ".print_r($permsarray,true));\r
        
        $conn->query($sql);
        
@@ -283,14 +302,14 @@ function gwvpmini_ConnectDB()
        global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $DB_CONNECTION;\r
 \r
        // first check if $DB_CONNECTION IS live\r
-       error_log("in connection $db_type, $db_name");\r
+       //error_log("in connection $db_type, $db_name");\r
 \r
        if($DB_CONNECTION != false) return $DB_CONNECTION;\r
 \r
        if($db_type == "sqlite") {\r
                $db_url = $db_name;\r
                if(!file_exists($db_name)) {\r
-                       error_log("$db_name does not exist - problem");
+                       //error_log("$db_name does not exist - problem");
                        // TODO: NEED A SETUP AGENT!
                        gwvpmini_dbCreateSQLiteStructure($db_name);
                        gwvpmini_setConfigVal("repodir", "$data_directory/repos");\r
@@ -298,7 +317,7 @@ function gwvpmini_ConnectDB()
        }\r
 \r
        // and here we go with pdo.\r
-       error_log("attmpting to open db, $db_type:$db_url");\r
+       //error_log("attmpting to open db, $db_type:$db_url");\r
        try {\r
                $DB_CONNECTION = new PDO("$db_type:$db_url");\r
        } catch(PDOException $exep) {\r
index 192bb06..10bb77c 100644 (file)
@@ -31,6 +31,14 @@ function gwvpmini_gitBackendInterface()
        // and this is where i re-code the git backend interface from scratch
        global $BASE_URL;
        
+       header_remove("Pragma");\r
+       header_remove("Cache-Control");\r
+       header_remove("Set-Cookie");\r
+       header_remove("Expires");\r
+       header_remove("X-Powered-By");\r
+       header_remove("Vary");\r
+       
+       
        $repo_base = gwvpmini_getConfigVal("repodir");
        
        // TODO: we need to stop passing the repo name around as "repo.git", it needs to be just "repo"
@@ -146,7 +154,7 @@ function gwvpmini_gitBackendInterface()
                        echo fread($fh, 8192);
                }
        } else {
-               //echo "would ask $repo,$actual_repo_name for $repo/$newloc from $repo_base/$repo/$newloc, NE";
+               error_log("would ask $repo for $repo/$newloc from $repo_base/$repo/$newloc, NE");
                gwvpmini_fourZeroFour();
                return;
        }
index eb1a7c5..97afbaa 100644 (file)
@@ -26,7 +26,7 @@ function gwvpmini_goWeb()
        // this is important for our plugin structure later on - the key on the array serves an an ordering method
        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();
index cbdcdf4..3549c29 100644 (file)
@@ -12,5 +12,5 @@ $db_username = "";
 $db_password = "";
 
 
-error_log("included config file");
+//error_log("included config file");
 ?>
\ No newline at end of file
index 264e4e8..3765aca 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+error_log("INCALLSTART ".print_r($_COOKIE, true)." -------------------- ".print_r($_SERVER,true)." ---------- ".print_r($_REQUEST, true));
 $WEB_ROOT_FS = realpath(dirname(__FILE__));\r
 $BASE_URL = dirname($_SERVER["PHP_SELF"]);\r
 \r
@@ -27,6 +28,7 @@ if(!gwvpmini_DBExists($db_name)) {
        gwvpmini_setConfigVal("repodir", "$data_directory/repos");
 }
 
+error_log("REQUEST BEGIN");
 gwvpmini_goWeb();