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 echo "<a href='http://git.nexus-irc.de/git_download.php?build=".$_GET["p"]."'>".$name."-".substr($hash, 0, -1)." (tar.gz)</a>";
41 echo "unknown project";
43 }elseif(isset($_GET['build'])){
45 if(file_exists("/home/git/".$_GET['build'])){
46 $name=substr($_GET['build'],0,strlen($_GET['build'])-4);
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);
51 $hash = substr($_GET['h'], 0, 7);
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);
56 if(file_exists("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz")) {
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");
60 unlink("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz");
62 $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build']);
63 $c = shell_exec("cd /usr/share/gitweb/dl/".$name."/; git reset ".$_GET['h']);
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") {
66 scandir_replace("/usr/share/gitweb/dl/".$name,"git-".substr($con, 0, -1)."-".$hash);
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);
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");
73 unlink("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz");
76 echo "unknown project";
79 echo "<table class='project_list'>";
80 echo "<tr><th>Project</th><th>Download</th></tr>";
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) {
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"');
88 echo "<tr><td>".$v."</td><td>No Download available</td></tr>";
90 $name=substr($v,0,strlen($v)-4);
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>";