started work on the git backend bit
[gwvp.git] / gwvplib / gwvpgitcontrol.php
index d78fcde..978e3bf 100644 (file)
@@ -1,5 +1,53 @@
 <?php
 
+$CALL_ME_FUNCTIONS["repoadmin"] = "gwvp_gitControlCallMe";
+
+//$MENU_ITEMS["20repos"]["text"] = "Repo Admin";
+//$MENU_ITEMS["20repos"]["link"] = "$BASE_URL/admin/repos";
+
+function gwvp_gitControlCallMe()
+{
+       if(isset($_REQUEST["q"])) {
+               $query = $_REQUEST["q"];
+               $qspl = explode("/", $query);
+               if(isset($qspl[0])) {
+                       if($qspl[0] == "git") {
+                               return "gwvp_gitBackendInterface";
+                       }
+               } 
+               else return false;
+       }
+       
+       return false;
+       
+}
+
+function gwvp_gitBackendInterface()
+{
+       // we need to quite a bit of parsing in here. The "repo" will always be /git/repo.git
+       // but if we get here from a browser, we need to forward back to a normal repo viewer
+       // the only way i can think of doing this is to check the useragent for the word "git"
+       $agent = "git-unknown";
+       $isgitagent = false;
+       if(isset($_SERVER["HTTP_USER_AGENT"])) {
+               $agent = $_SERVER["HTTP_USER_AGENT"];
+               error_log("in git backend with user agent");
+               if(stristr($agent, "git")!==false) {
+                       $isgitagent = true;
+               }
+       }
+       
+       $repo = "";
+       if(isset($_REQUEST["q"])) {
+               $query = $_REQUEST["q"];
+               $qspl = explode("/", $query);
+               $repo = $qspl[1];
+       }
+               
+       if($isgitagent) echo "GIT: i am a git backened interface for a repo $repo, agent $agent";
+       else echo "NOT GIT: i am a git backened interface for a repo $repo, agent $agent";
+}
+
 function gwvp_repoExists($name)
 {
        global $repo_base;