Commit | Line | Data |
---|---|---|
8a1b4b56 | 1 | <?php |
9086c806 S |
2 | $args = explode(";", $_SERVER["QUERY_STRING"]); |
3 | foreach($args as $arg) { | |
4 | $arg = explode("=", $arg, 2); | |
5 | $_GET[$arg[0]] = $arg[1]; | |
6 | } | |
7b5266f1 S |
7 | |
8 | function scandir_replace($folder,$arg){ | |
9 | $out = array(); | |
10 | if($content = opendir($folder)){ | |
11 | while(false !== ($file = readdir($content))){ | |
12 | if(is_dir("$folder/$file") && $file != "." && $file != ".." && $file != ".git"){ | |
13 | scandir_replace("$folder/$file",$arg); | |
14 | } elseif($file != "." && $file != ".." && $file != ".git"){ | |
15 | $out[] = "$folder/$file"; | |
16 | } | |
17 | } | |
18 | closedir($content); | |
19 | } | |
20 | foreach($out as $id => $v) { | |
21 | chmod($v,0777); | |
22 | $maincode=file_get_contents($v); | |
23 | $maincode = str_replace('$__GIT__', '"'.$arg.'"', $maincode); // replace $__GIT__ with the git version | |
24 | $fp = fopen($v, 'w'); | |
25 | fwrite($fp, $maincode); | |
26 | fclose($fp); | |
27 | } | |
28 | } | |
29 | ||
8a1b4b56 S |
30 | if(isset($_GET['p'])){ |
31 | if(file_exists("/home/git/".$_GET['p'])){ | |
32 | $hash = shell_exec("git --git-dir=/home/git/".$_GET["p"]." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"); | |
33 | $con= shell_exec('git --git-dir=/home/git/'.$_GET["p"].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"'); | |
34 | if(!$hash){ | |
0c0738da | 35 | echo "No Download available"; |
8a1b4b56 S |
36 | }else{ |
37 | $name=substr($_GET["p"],0,strlen($_GET["p"])-4); | |
5500a695 | 38 | echo "<a href='http://git.nexus-irc.de/git_download.php?build=".$_GET["p"]."'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a>"; |
8a1b4b56 S |
39 | } |
40 | }else{ | |
41 | echo "unknown project"; | |
42 | } | |
43 | }elseif(isset($_GET['build'])){ | |
5500a695 | 44 | |
8a1b4b56 S |
45 | if(file_exists("/home/git/".$_GET['build'])){ |
46 | $name=substr($_GET['build'],0,strlen($_GET['build'])-4); | |
5500a695 S |
47 | if(isset($_GET['h'])){ |
48 | if(strtolower($_GET['h']) == "head") { | |
49 | $hash = substr(shell_exec("git --git-dir=/home/git/".$_GET['build']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"), 0, -1); | |
50 | }else{ | |
51 | $hash = substr($_GET['h'], 0, 7); | |
feacd354 | 52 | } |
9086c806 | 53 | }else{ |
5500a695 | 54 | $hash = substr(shell_exec("git --git-dir=/home/git/".$_GET['build']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"), 0, 7); |
9086c806 S |
55 | } |
56 | if(file_exists("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz")) { | |
7e90fff2 S |
57 | header("Content-Type: application/x-gzip"); |
58 | header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz"); | |
59 | readfile("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz"); | |
5500a695 | 60 | unlink("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz"); |
9086c806 | 61 | }else{ |
5500a695 | 62 | $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build']); |
9086c806 | 63 | $c = shell_exec("cd /usr/share/gitweb/dl/".$name."/; git reset ".$_GET['h']); |
5500a695 S |
64 | $con= shell_exec('git --git-dir=/home/git/'.$_GET['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"'); |
65 | if($_GET['build'] != "gitweb.git") { | |
feacd354 S |
66 | scandir_replace("/usr/share/gitweb/dl/".$name,"git-".substr($con, 0, -1)."-".$hash); |
67 | } | |
9086c806 S |
68 | $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".$hash.".tar.gz ".$name); |
69 | $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name); | |
7e90fff2 S |
70 | header("Content-Type: application/x-gzip"); |
71 | header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz"); | |
72 | readfile("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz"); | |
5500a695 | 73 | unlink("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz"); |
8a1b4b56 S |
74 | } |
75 | }else{ | |
76 | echo "unknown project"; | |
77 | } | |
78 | }else{ | |
5500a695 S |
79 | echo "<table class='project_list'>"; |
80 | echo "<tr><th>Project</th><th>Download</th></tr>"; | |
8a1b4b56 S |
81 | $a = file_get_contents("http://git.nexus-irc.de/index.cgi?a=project_index2"); |
82 | $b = explode("\n",$a); | |
83 | foreach($b as $id => $v) { | |
84 | if($v == ""){ }else{ | |
85 | $hash = shell_exec("git --git-dir=/home/git/".$v." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"); | |
86 | $con= shell_exec('git --git-dir=/home/git/'.$v.' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"'); | |
87 | if(!$hash){ | |
5500a695 | 88 | echo "<tr><td>".$v."</td><td>No Download available</td></tr>"; |
8a1b4b56 S |
89 | }else{ |
90 | $name=substr($v,0,strlen($v)-4); | |
5500a695 | 91 | echo "<tr><td>".$v."</td><td><a href='http://git.nexus-irc.de/git_download.php?build=".$v."'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a></td></tr>"; |
8a1b4b56 S |
92 | } |
93 | } | |
94 | } | |
5500a695 | 95 | echo "</table>"; |
8a1b4b56 S |
96 | } |
97 | ?> |