2 $args = explode(";", $_SERVER["QUERY_STRING"]);
3 foreach($args as $arg) {
4 $arg = explode("=", $arg, 2);
5 $_GET[$arg[0]] = $arg[1];
8 function scandir_replace($folder,$arg){
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";
20 foreach($out as $id => $v) {
22 $maincode=file_get_contents($v);
23 $maincode = str_replace('$__GIT__', '"'.$arg.'"', $maincode); // replace $__GIT__ with the git version
25 fwrite($fp, $maincode);
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"');
35 echo "No Download available";
37 $name=substr($_GET["p"],0,strlen($_GET["p"])-4);
38 if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
39 echo "<a href='http://git.nexus-irc.de/dl/".$name."-".substr($hash, 0, -1).".tar.gz'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a>";
41 echo "No Download available (<a href='http://git.nexus-irc.de/git_download.php?build=".$_GET["p"]."'>Build snapshot</a>)";
45 echo "unknown project";
47 }elseif(isset($_GET['git'])){
48 if(file_exists("/home/git/".$_GET['git'])){
49 $hash = shell_exec("git --git-dir=/home/git/".$_GET["git"]." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
50 $con= shell_exec('git --git-dir=/home/git/'.$_GET["git"].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
52 echo "<p>".$_GET["git"].": No Download available</p>";
54 $name=substr($_GET["git"],0,strlen($_GET["git"])-4);
55 if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
56 echo "<p><a href='http://git.nexus-irc.de/dl/".$name."-".substr($hash, 0, -1).".tar.gz'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a></p>";
58 echo "<p>No Download available (<a href='http://git.nexus-irc.de/git_download.php?build=".$_GET["git"]."'>Build snapshot</a>)</p>";
62 echo "unknown project";
64 }elseif(isset($_GET['build'])){
65 if(file_exists("/home/git/".$_GET['build'])){
66 $hash = shell_exec("git --git-dir=/home/git/".$_GET['build']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
67 $con= shell_exec('git --git-dir=/home/git/'.$_GET['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
68 $name=substr($_GET['build'],0,strlen($_GET['build'])-4);
69 if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
70 echo '<meta http-equiv="refresh" content="0; URL='.$_SERVER['HTTP_REFERER'].'"> ';
72 $b = shell_exec("cd /usr/share/gitweb/dl; git clone git://git.nexus-irc.de/".$_GET['build']);
73 if($_GET['build'] != "gitweb.git") {
74 scandir_replace("/usr/share/gitweb/dl/".$name,"git-".substr($con, 0, -1)."-".substr($hash, 0, -1));
76 $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".substr($hash, 0, -1).".tar.gz ".$name);
77 $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
78 echo '<meta http-equiv="refresh" content="0; URL='.$_SERVER['HTTP_REFERER'].'"> ';
81 echo "unknown project";
83 }elseif(isset($_GET['build2']) && isset($_GET['h'])){
84 if(file_exists("/home/git/".$_GET['build2'])){
85 $name=substr($_GET['build2'],0,strlen($_GET['build2'])-4);
86 if(strtolower($_GET['h']) == "head") {
87 $hash = substr(shell_exec("git --git-dir=/home/git/".$_GET['build2']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"), 0, -1);
89 $hash = substr($_GET['h'], 0, 7);
91 if(file_exists("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz")) {
92 header("Content-Type: application/x-gzip");
93 header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz");
94 readfile("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz");
96 $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build2']);
97 $c = shell_exec("cd /usr/share/gitweb/dl/".$name."/; git reset ".$_GET['h']);
98 $con= shell_exec('git --git-dir=/home/git/'.$_GET['build2'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
99 if($_GET['build2'] != "gitweb.git") {
100 scandir_replace("/usr/share/gitweb/dl/".$name,"git-".substr($con, 0, -1)."-".$hash);
102 $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".$hash.".tar.gz ".$name);
103 $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name);
104 header("Content-Type: application/x-gzip");
105 header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz");
106 readfile("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz");
109 echo "unknown project";
112 $a = file_get_contents("http://git.nexus-irc.de/index.cgi?a=project_index2");
113 $b = explode("\n",$a);
114 foreach($b as $id => $v) {
116 $hash = shell_exec("git --git-dir=/home/git/".$v." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
117 $con= shell_exec('git --git-dir=/home/git/'.$v.' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
119 echo "<p>".$v.": No Download available</p>";
121 $name=substr($v,0,strlen($v)-4);
122 if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) {
123 echo "<p>".$v.": Download <a href='http://git.nexus-irc.de/dl/".$name."-".substr($hash, 0, -1).".tar.gz'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a></p>";
125 echo "<p>".$v.": No Download available (<a href='http://git.nexus-irc.de/git_download.php?build=".$v."'>Build snapshot</a>)</p>";