<?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"
+
+ /*
+ * here we need to
+ * 1) figure out the repo its acessing
+ * 2) figure out the perms on the repo
+ * 3) determine if its a pull or a push
+ * - if its a pull, we just serve straight from the fs
+ * - if its a push, we go thru git-http-backend
+ * 4) if it requiers auth, we push to auth
+ *
+ */
+ $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;
+
+ if(file_exists("$repo_base/$name.git")) return true;
+ else return false;
+}
+
function gwvp_createGitRepo($name)
{
global $repo_base;