function security_load_names() { global $validargs, $repo_direcotry, $repo_suffix, $branches, $tags; if (isset($_GET['p'])) { // now load the repository into validargs $proj = $_GET['p']; $out = array(); $branches = git_parse($proj, "branches"); foreach (array_keys($branches) as $tg) { $validargs[] = $tg; } $tags = git_parse($proj, "tags"); foreach (array_keys($tags) as $tg) { $validargs[] = $tg; } // add files unset($out); $head = "HEAD"; if (isset($_GET['tr']) && is_valid($_GET['tr'])) { $head = $_GET['tr']; } $cmd = "GIT_DIR=" . get_repo_path($proj) . $repo_suffix . " git ls-tree -r -t " . escapeshellarg($head) . " 2>&1 | sed -e 's/\t/ /g'"; exec($cmd, &$out); foreach ($out as $line) { $arr = explode(" ", $line); //$validargs[] = $arr[2]; // add the hash to valid array $validargs[] = basename($arr[3]); // add the file name to valid array } } }
function write_dlfile() { global $repo_suffix; $repopath = get_repo_path($_GET['p']); $name = $_GET['n']; $hash = $_GET['h']; exec("GIT_DIR=" . escapeshellarg("{$repopath}{$repo_suffix}") . " git cat-file blob " . escapeshellarg($hash) . " 2>&1 > " . escapeshellarg("/tmp/{$hash}.{$name}")); $filesize = filesize("/tmp/{$hash}.{$name}"); header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // required for certain browsers header("Content-Transfer-Encoding: binary"); //header("Content-Type: application/x-tar-gz"); header("Content-Length: {$filesize}"); header("Content-Disposition: attachment; filename=\"{$name}\";"); //$str = system("GIT_DIR=$repo git-cat-file blob $hash 2>/dev/null"); readfile("/tmp/{$hash}.{$name}"); die; }
function write_rss2() { $proj = $_GET['p']; $repo = get_repo_path($proj); $link = "http://{$_SERVER['HTTP_HOST']}" . sanitized_url() . "p={$proj}"; $c = git_commit($repo, "HEAD"); header("Content-type: text/xml", true); echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" > <channel> <title><?php echo $proj; ?> </title> <link><?php echo $link; ?> </link> <description><?php echo $proj; ?> </description> <pubDate><?php echo date('D, d M Y G:i:s', $c['date']); ?> </pubDate> <generator>http://code.google.com/p/git-php/</generator> <language>en</language> <?php for ($i = 0; $i < 10 && $c; $i++) { ?> <item> <title><?php echo $c['message']; ?> </title> <link><?php echo $link; ?> </link> <pubDate><?php echo date('D, d M Y G:i:s', $c['date']); ?> </pubDate> <guid isPermaLink="false"><?php echo $link; ?> </guid> <description><?php echo $c['message']; ?> </description> <content><?php echo $c['message']; ?> </content> </item> <?php $c = git_commit($repo, $c['parent']); $link = "http://{$_SERVER['HTTP_HOST']}" . sanitized_url() . "p={$proj}&a=commitdiff&c={$c['commit_id']}&hb={$c['parent']}"; } ?> </channel> </rss> <?php die; }
function check_new_head_in_bundle($what, &$out1) { $repo = $_GET['p']; $cmd1 = "GIT_DIR=" . get_repo_path(basename($repo)) . " git bundle verify " . escapeshellarg($what) . " 2>&1 "; //echo $cmd1; $out1 = array(); $status = 1; exec($cmd1, &$out1, &$status); if ($status == 0) { foreach ($out1 as $line) { unset($d); $d = explode(" ", $line); if (is_sha1($d[0])) { if (!check_tag_in_repo($d[0])) { return true; } } } } $out1[] = "*** Error *** No new tag found in bundle!"; return false; }