summaryrefslogtreecommitdiff
path: root/httpdocs/index.php
blob: 4f11f49daab76e7add12a36aea4fab4752c4d798 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

if (isset($_GET['r'])) {

  if (base64_decode($_GET['r'],true)===false)
    die('Invalid base64');

  if (!is_dir('../work/repositories/' . $_GET['r'])) {
    $wish_list = fopen('../work/wish-list','a');
    if ($wish_list === false)
      die('Cannot open wish-list');
    fwrite($wish_list, $_GET['r'] . "\n");
    fclose($wish_list);
    die('I put repository on wish-list');
  }

  if (isset($_GET['tag'])) {
    if (base64_decode($_GET['tag'],true)===false)
      $_GET['tag'] = base64_encode($_GET['tag']);

    $handle = popen(
      'git -C "../work/repositories/' . $_GET['r'] . '" archive "$(' .
        'echo "' . $_GET['tag'] . '" | ' .
          'base64 -d' .
      ')" | ' .
      'gzip -nc',
      'r'
    );
    if ($handle === false)
      die('Unable to create archive');
    header('Content-type: application/x-gzip');
    header('Content-Disposition: attachment; filename="archive.tar.gz"');
    fpassthru($handle);
    pclose($handle);
    die();
  }

  die('errrm, this is not yet implemented');

}