add gen_id function and fixed link fails
authorStricted <Stricted@nexus-irc.de>
Tue, 2 Oct 2012 15:31:04 +0000 (17:31 +0200)
committerStricted <Stricted@nexus-irc.de>
Tue, 2 Oct 2012 15:31:04 +0000 (17:31 +0200)
git_download.php
index.cgi

index 74d3851115615c93d322a102c0ec265fc9b54733..33fbd7828e7f7eaa0cbc054f37ddd7c2eece75ba 100644 (file)
@@ -26,7 +26,14 @@ function scandir_replace($folder,$arg){
                fclose($fp);
        }
 }
-
+function gen_id($len = 6)
+{
+    $r = '';
+    for($i=0; $i<$len; $i++) {
+        $r .= chr(rand(0, 25) + ord('a'));
+       }
+    return $r;
+}
 if(isset($_GET['p'])){
        if(file_exists("/home/git/".$_GET['p'])){
                $hash = shell_exec("git --git-dir=/home/git/".$_GET["p"]." rev-list -n 1 --pretty='format:%h' --header master | grep '^[0-9a-f]*$'");
@@ -53,7 +60,7 @@ if(isset($_GET['p'])){
                }else{
                        $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);
                }
-               $id = sha1(time());
+               $id = sha1(gen_id());
                $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['build'].' rev-list --oneline --header master | wc -l | sed "s/[ \t]//g"');
index 55ca54e197493f22950ad8b0a77080179d73602e..e16fcbe6bb4177ec3b684a8da4c1d489737b17fb 100644 (file)
--- a/index.cgi
+++ b/index.cgi
@@ -4832,7 +4832,7 @@ sub git_shortlog_body {
                      $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
                      $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . " | " .
                      $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree"). " | " .
-                     "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build2=".$project.";h=".$commit."'>snapshot</a>";
+                     "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build=".$project.";h=".$commit."'>snapshot</a>";
 
                print "</td>\n" .
                      "</tr>\n";
@@ -5796,7 +5796,7 @@ sub git_tree {
                my $snapshot_links = "1";
                if (defined $snapshot_links) {
                        # FIXME: Should be available when we have no hash base as well.
-                       push @views_nav, "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build2=".$project.";h=".$hash."'>snapshot</a>";
+                       push @views_nav, "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build=".$project.";h=".$hash."'>snapshot</a>";
                }
                git_print_page_nav('tree','', $hash_base, undef, undef,
                                   join(' | ', @views_nav));
@@ -6114,7 +6114,7 @@ sub git_commit {
                      "tree");
        my $snapshot_links = "1";
        if (defined $snapshot_links) {
-               print " | " . "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build2=".$project.";h=".$hash."'>snapshot</a>";
+               print " | " . "<a title='in format: tar.gz' href='http://git.nexus-irc.de/git_download.php?build=".$project.";h=".$hash."'>snapshot</a>";
        }
        print "</td>" .
              "</tr>\n";