just trying to figure out how to get someone to auth at the gitbackend
[gwvp.git] / gwvplib / gwvpgitcontrol.php
1 <?php
2
3 $CALL_ME_FUNCTIONS["repoadmin"] = "gwvp_gitControlCallMe";
4
5 //$MENU_ITEMS["20repos"]["text"] = "Repo Admin";
6 //$MENU_ITEMS["20repos"]["link"] = "$BASE_URL/admin/repos";
7
8 function gwvp_gitControlCallMe()
9 {
10         if(isset($_REQUEST["q"])) {
11                 $query = $_REQUEST["q"];
12                 $qspl = explode("/", $query);
13                 if(isset($qspl[0])) {
14                         if($qspl[0] == "git") {
15                                 return "gwvp_gitBackendInterface";
16                         }
17                 } 
18                 else return false;
19         }
20         
21         return false;
22         
23 }
24
25 function gwvp_gitBackendInterface()
26 {
27         // we need to quite a bit of parsing in here. The "repo" will always be /git/repo.git
28         // but if we get here from a browser, we need to forward back to a normal repo viewer
29         // the only way i can think of doing this is to check the useragent for the word "git"
30         $agent = "git-unknown";
31         $isgitagent = false;
32         if(isset($_SERVER["HTTP_USER_AGENT"])) {
33                 $agent = $_SERVER["HTTP_USER_AGENT"];
34                 error_log("in git backend with user agent");
35                 if(stristr($agent, "git")!==false) {
36                         $isgitagent = true;
37                 }
38         }
39         
40         $repo = "";
41         if(isset($_REQUEST["q"])) {
42                 $query = $_REQUEST["q"];
43                 $qspl = explode("/", $query);
44                 $repo = $qspl[1];
45         }
46                 
47         if($isgitagent) echo "GIT: i am a git backened interface for a repo $repo, agent $agent";
48         else echo "NOT GIT: i am a git backened interface for a repo $repo, agent $agent";
49 }
50
51 function gwvp_repoExists($name)
52 {
53         global $repo_base;
54         
55         if(file_exists("$repo_base/$name.git")) return true;
56         else return false;
57 }
58
59 function gwvp_createGitRepo($name)
60 {
61         global $repo_base;
62         
63         error_log("would create $repo_base/$name.git");
64         
65         return true;
66 }
67 ?>