From 5500a69581482640d2027546d6f353ad2410415b Mon Sep 17 00:00:00 2001 From: Stricted Date: Mon, 1 Oct 2012 14:32:34 +0200 Subject: [PATCH] change snapshot function --- git_download.php | 70 +++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 52 deletions(-) diff --git a/git_download.php b/git_download.php index 54a5061..697c587 100644 --- a/git_download.php +++ b/git_download.php @@ -35,68 +35,34 @@ if(isset($_GET['p'])){ echo "No Download available"; }else{ $name=substr($_GET["p"],0,strlen($_GET["p"])-4); - if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) { - echo "".$name."-".substr($hash, 0, -1)." (tar.gz)"; - } else { - echo "No Download available (Build snapshot)"; - } - } - }else{ - echo "unknown project"; - } -}elseif(isset($_GET['git'])){ - if(file_exists("/home/git/".$_GET['git'])){ - $hash = shell_exec("git --git-dir=/home/git/".$_GET["git"]." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"); - $con= shell_exec('git --git-dir=/home/git/'.$_GET["git"].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"'); - if(!$hash){ - echo "

".$_GET["git"].": No Download available

"; - }else{ - $name=substr($_GET["git"],0,strlen($_GET["git"])-4); - if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) { - echo "

".$name."-".substr($hash, 0, -1)." (tar.gz)

"; - } else { - echo "

No Download available (Build snapshot)

"; - } + echo "".$name."-".substr($hash, 0, -1)." (tar.gz)"; } }else{ echo "unknown project"; } }elseif(isset($_GET['build'])){ + if(file_exists("/home/git/".$_GET['build'])){ - $hash = shell_exec("git --git-dir=/home/git/".$_GET['build']." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"); - $con= shell_exec('git --git-dir=/home/git/'.$_GET['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"'); $name=substr($_GET['build'],0,strlen($_GET['build'])-4); - if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) { - echo ' '; - }else{ - $b = shell_exec("cd /usr/share/gitweb/dl; git clone git://git.nexus-irc.de/".$_GET['build']); - if($_GET['build'] != "gitweb.git") { - scandir_replace("/usr/share/gitweb/dl/".$name,"git-".substr($con, 0, -1)."-".substr($hash, 0, -1)); + if(isset($_GET['h'])){ + if(strtolower($_GET['h']) == "head") { + $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); + }else{ + $hash = substr($_GET['h'], 0, 7); } - $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".substr($hash, 0, -1).".tar.gz ".$name); - $d = shell_exec("rm -r /usr/share/gitweb/dl/".$name); - echo ' '; - } - }else{ - echo "unknown project"; - } -}elseif(isset($_GET['build2']) && isset($_GET['h'])){ - if(file_exists("/home/git/".$_GET['build2'])){ - $name=substr($_GET['build2'],0,strlen($_GET['build2'])-4); - if(strtolower($_GET['h']) == "head") { - $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); }else{ - $hash = substr($_GET['h'], 0, 7); + $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); } if(file_exists("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz")) { header("Content-Type: application/x-gzip"); header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz"); readfile("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz"); + unlink("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz"); }else{ - $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build2']); + $b = shell_exec("cd /usr/share/gitweb/dl/; git clone git://git.nexus-irc.de/".$_GET['build']); $c = shell_exec("cd /usr/share/gitweb/dl/".$name."/; git reset ".$_GET['h']); - $con= shell_exec('git --git-dir=/home/git/'.$_GET['build2'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"'); - if($_GET['build2'] != "gitweb.git") { + $con= shell_exec('git --git-dir=/home/git/'.$_GET['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"'); + if($_GET['build'] != "gitweb.git") { scandir_replace("/usr/share/gitweb/dl/".$name,"git-".substr($con, 0, -1)."-".$hash); } $c = shell_exec("cd /usr/share/gitweb/dl; tar czfv ".$name."-".$hash.".tar.gz ".$name); @@ -104,11 +70,14 @@ if(isset($_GET['p'])){ header("Content-Type: application/x-gzip"); header("Content-Disposition: attachment; filename=".$name."-".$hash.".tar.gz"); readfile("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz"); + unlink("/usr/share/gitweb/dl/".$name."-".$hash.".tar.gz"); } }else{ echo "unknown project"; } }else{ + echo ""; + echo ""; $a = file_get_contents("http://git.nexus-irc.de/index.cgi?a=project_index2"); $b = explode("\n",$a); foreach($b as $id => $v) { @@ -116,16 +85,13 @@ if(isset($_GET['p'])){ $hash = shell_exec("git --git-dir=/home/git/".$v." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'"); $con= shell_exec('git --git-dir=/home/git/'.$v.' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"'); if(!$hash){ - echo "

".$v.": No Download available

"; + echo ""; }else{ $name=substr($v,0,strlen($v)-4); - if(file_exists("/usr/share/gitweb/dl/".$name."-".substr($hash, 0, -1).".tar.gz")) { - echo "

".$v.": Download ".$name."-".substr($hash, 0, -1)." (tar.gz)

"; - } else { - echo "

".$v.": No Download available (Build snapshot)

"; - } + echo ""; } } } + echo "
ProjectDownload
".$v."No Download available
".$v."".$name."-".substr($hash, 0, -1)." (tar.gz)
"; } ?> \ No newline at end of file -- 2.20.1