wdjwxh/git-php

Disable download on gitphp

Opened this issue · 0 comments

Hi I add this little feature to git-php.
I know that probably this project is died but I like it powerful and easy
configuration.

Allow the end user to disable tar.zg/zip snapshot download.

diff --git a/config.php b/config.php
index 1bff39a..b167bfb 100644
--- a/config.php
+++ b/config.php
@@ -18,15 +18,18 @@

        /* True if committing is active */
        $git_commiting_active = true;
+
+       /* True if you like to allow tar.gz/zip download */
+       $git_download_active = true;

        /* E-mail address to notify about the bundles */
        $emailaddress = "Peeter.Vois@proekspert.ee";

diff --git a/git.php b/git.php
index ea83754..b69ab84 100644
--- a/git.php
+++ b/git.php
@@ -187,7 +187,7 @@ if (isset($_GET['dl']))
     write_plain();
   else if ( in_array( $_GET['dl'], $icondesc, true ) )
     write_img_png($_GET['dl']);
-  else if ($_GET['dl'] == 'dlfile' )
+  else if ($_GET['dl'] == 'dlfile' && $git_download_active)
     write_dlfile();
   else if ($_GET['dl'] == 'rss2')
     write_rss2();
@@ -529,7 +529,8 @@ function html_home()
   echo "<th>Description</th>";
   echo "<th>Owner</th>";
   echo "<th>Last Changed</th>";
-  echo "<th>Download</th>";
+  if ($git_download_active)
+      echo "<th>Download</th>";
   echo "<th>Hits</th>";
   echo "</tr>\n";
   foreach ($repos as $repo)   {
@@ -540,7 +541,10 @@ function html_home()
     $proj = get_project_link($repo);
     $dlt = get_project_link($repo, "targz");
     $dlz = get_project_link($repo, "zip");
-    echo
"<tr><td>$proj</td><td>$desc</td><td>$owner</td><td>$last</td><td>$dlt
+    echo "<tr><td>$proj</td><td>$desc</td><td>$owner</td><td>$last</td>";
+    if ($git_download_active) 
+        echo "<td>$dlt | $dlz</td>";
+    echo "<td> ( $today / $total ) </td></tr>\n";
   }
   echo "</table>";
 }
@@ -583,9 +587,9 @@ function get_project_link($repo, $type = false,
$tag="HEAD")
   $path = basename($repo);
   if (!$type)
     return "<a href=\"".sanitized_url()."p=$path\">$path</a>";
-  else if ($type == "targz")
+  else if ($type == "targz" && $git_download_active)
     return html_ahref( array( 'p'=>$path, 'dl'=>'targz', 'h'=>$tag )
).".tar.gz
-  else if ($type == "zip")
+  else if ($type == "zip" && $git_download_active)
     return html_ahref( array( 'p'=>$path, 'dl'=>'zip', 'h'=>$tag )
).".zip</a>"
 }


Original issue reported on code.google.com by claudyu...@gmail.com on 26 Apr 2010 at 11:34