Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor tweaks, Looks about the same, just starting out!

  • Loading branch information...
commit 3f491a6d6a6279c460cdb4993b017249ea848041 1 parent 39ba364
@xanmanning xanmanning authored
View
7 README.markdown
@@ -1,17 +1,18 @@
# Git-PHP
## Summary
-Git-PHP is a port of gitweb to PHP. It includes various functionality, such as submitting diffs, repository browsing, simple search, and diff highlighting. It is based upon Zack Bartel and Peeter Vois's original work, with updates to handle the latest git installs (1.6.4.4 as September 25, 2009), as well an update to the stylesheet to make it feel more like github.com. It definitely still needs tender love and care to make it more MVC like, but it'll get there. Please read the commit messages for more information on changes implemented.
+Git-PHP is a port of gitweb to PHP. It includes various functionality, such as submitting diffs, repository browsing, simple search, and diff highlighting. It is based upon Zack Bartel, Peeter Vois and Jose Diaz-Gonzalez' original work, with updates to handle the latest git installs (1.6.4.4 as September 25, 2009). It definitely still needs tender love and care to make it more MVC like, but it'll get there. Please read the commit messages for more information on changes implemented.
## Requirements
* git
* enscript
+* gd2
## Installation
1. edit config.php
2. In a terminal window, change directories to your git-php install directory and execute the following:
- * ``mkdir .temp/cache .temp/bundles .temp/secrets ; chmod -R 777 .cache .bundles .secrets``
+ * ``mkdir .temp/cache .temp/bundles .temp/secrets ; cd .temp ; chmod -R 0777 cache bundles secrets``
### Supposed directory structure:
git-php-\
@@ -46,4 +47,4 @@ Git-PHP is a port of gitweb to PHP. It includes various functionality, such as s
#### URL parameters:
p: $proj
- tr: any branch or tag or HEAD in a git-repo.
+ tr: any branch or tag or HEAD in a git-repo.
View
54 commit.php
@@ -21,20 +21,16 @@
// | Foundation, Inc., 59 Temple Place - Suite 330, |
// | Boston, MA 02111-1307, USA. |
// +------------------------------------------------------------------------+
- // | |
+ // | Author: Zack Bartel <zack@bartel.com> |
// | Author: Peeter Vois http://people.proekspert.ee/peeter/blog |
+ // | Author: Xan Manning http://knoxious.co.uk/ |
// +------------------------------------------------------------------------+
-global $title;
+global $CONFIG;
global $repos; // list of repositories
global $validargs; // list of allowed arguments
global $git_embed;
-global $git_css;
-global $git_logo;
-global $http_method_prefix; // prefix path for http clone method
-global $communication_link; // link for sending a message to owner
global $failedarg;
-global $cache_name;
global $tags;
global $branches;
global $nr_of_shortlog_lines;
@@ -53,7 +49,7 @@
require_once("html_helpers.php");
require_once("filestuff.php");
-if (!$git_commiting_active) {
+if (!$CONFIG['git_commiting_active']) {
die();
}
@@ -70,7 +66,7 @@
write_img_png($_GET['dl']);
} else if (in_array($_GET['dl'], $flagdesc, true)) {
write_img_png($_GET['dl']);
- } else if ($_GET['dl'] =="human_check") {
+ } else if ($_GET['dl'] == "human_check") {
draw_human_checker(create_secret());
}
}
@@ -100,7 +96,7 @@ function send_the_submit_form() {
echo "<table>\n";
echo "<tr><td class=\"descol\">Short MEANINGFUL description </td><td class=\"valcol\"><input type=\"text\" name=\"commiter name\" size=\"40\"></td></tr>\n";
echo "<tr><td class=\"descol\">Bundle file </td><td class=\"valcol\"><input type=\"file\" name=\"bundle_file\" size=\"40\"></td></tr>\n";
- echo "<tr><td class=\"descol\">enter the value <img src=\"".sanitized_url()."dl=human_check\"/> here </td><td class=\"valcol\"><input type=\"text\" name=\"check\" size=\"40\"></td></tr>\n";
+ echo "<tr><td class=\"descol\">enter the value <img src=\"" . sanitized_url() . "dl=human_check\"/> here </td><td class=\"valcol\"><input type=\"text\" name=\"check\" size=\"40\"></td></tr>\n";
echo "<tr><td class=\"descol\">Submit </td><td class=\"valcol\"><input type=\"submit\" name=\"action\" value=\"commit\" size=\"10\"></td></tr>\n";
echo "</table></div>\n";
echo "</form>\n";
@@ -121,7 +117,7 @@ function send_the_help_section_of_submit() {
}
function send_the_bundles_in_queue() {
- global $repo_directory, $bundle_name;
+ global $CONFIG;
$repo = $_GET['p'];
html_spacer();
html_title("BUNDLES IN QUEUE");
@@ -131,7 +127,7 @@ function send_the_bundles_in_queue() {
$nr = 0;
foreach ($bundles as $bdl) {
$nr++;
- echo "<tr><td>$nr</td><td><a href=\"".$bundle_name.$repo."/".$bdl['bdl']."\">".$bdl['bdl']."</a></td><td>".$bdl['name']."</td></tr>\n";
+ echo "<tr><td>$nr</td><td><a href=\"" . $CONFIG['bundle_name'] . $repo . "/" . $bdl['bdl'] . "\">" . $bdl['bdl'] . "</a></td><td>" . $bdl['name'] . "</td></tr>\n";
}
echo "</table>";
}
@@ -145,7 +141,7 @@ function send_the_main_page($subpage = 'submit') {
html_header();
html_style();
html_breadcrumbs();
- html_Title("COMMITTING TO {$_GET['p']}");
+ html_Title("COMMITTING TO " . $_GET['p']);
html_pages();
switch($subpage) {
case 'submit':
@@ -169,38 +165,38 @@ function send_the_main_page($subpage = 'submit') {
// **************************
function create_bundles_directory() {
- global $repo_directory, $bundle_name;
+ global $CONFIG;
$repo = $_GET['p'];
- $dname = $repo_directory.$bundle_name."/";
+ $dname = $CONFIG['repo_directory'] . $CONFIG['bundle_name'] . "/";
create_directory($dname);
- return create_directory("{$dname}{$repo}");
+ return create_directory($dname . $repo);
}
function load_bundles_in_directory() {
- global $repo_directory, $bundle_name;
+ global $CONFIG['repo_directory'], $CONFIG['bundle_name'];
$repo = $_GET['p'];
$bundles = array();
- $dname = "{$repo_directory}{$bundle_name}{$repo}/";
+ $dname = $CONFIG['repo_directory'] . $CONFIG['bundle_name'] . $repo . "/";
create_bundles_directory();
if ($handle = opendir($dname)) {
while (false !== ($fname = readdir($handle))) {
if (!is_numeric($fname)) {
continue;
}
- $fullpath = "{$dname}{$fname}";
+ $fullpath = $dname . $fname;
if (!is_file($fullpath)) {
continue;
}
- if (!is_file("{$fullpath}.txt")) {
+ if (!is_file($fullpath . ".txt")) {
// the description file must exist too
continue;
}
$record['bdl'] = $fname;
- $file = fopen("{$fullpath}.txt", "r");
+ $file = fopen($fullpath . ".txt", "r");
if (check_new_head_in_bundle($fullpath, $out)) {
$record['name'] = fgets($file);
} else {
- $record['name'] = "*** applied *** ".fgets($file);
+ $record['name'] = "*** applied *** " . fgets($file);
}
fclose($file);
$bundles[] = $record;
@@ -211,9 +207,9 @@ function load_bundles_in_directory() {
}
function save_bundle() {
- global $repo_directory, $bundle_name, $emailaddress;
+ global $CONFIG['repo_directory'], $CONFIG['bundle_name'], $CONFIG['email_address'];
$repo = $_GET['p'];
- $dname = "{$repo_directory}{$bundle_name}{$repo}/";
+ $dname = $CONFIG['repo_directory'] . $CONFIG['bundle_name'] . $repo . "/";
create_bundles_directory();
if ($_FILES['bundle_file']['error'] != UPLOAD_ERR_OK) {
return false;
@@ -233,10 +229,10 @@ function save_bundle() {
chmod("{$fullpath}.txt", 0666);
// send e-mail message about the commitment
$message = "{$_POST['commiter_name']}\n {$fullpath}\n";
- $headers = "From: {$emailaddress}\r\n" .
- "Reply-To: {$emailaddress}\r\n" .
+ $headers = "From: {$CONFIG['email_address']}\r\n" .
+ "Reply-To: {$CONFIG['email_address']}\r\n" .
'X-Mailer: PHP/' . phpversion();
- $ok = mail($emailaddress, "Bundle sent to {$repo}", $message, $headers);
+ $ok = mail($CONFIG['email_address'], "Bundle sent to {$repo}", $message, $headers);
if (!$ok) {
echo "Error sending email message\n";
}
@@ -245,12 +241,12 @@ function save_bundle() {
// check if a tag is in repository
function check_tag_in_repo($the_tag) {
- global $repo_directory;
+ global $CONFIG['repo_directory'];
$repo=$_GET['p'];
$out = array();
$nr=0;
do {
- $cmd="GIT_DIR=".escapeshellarg($repo_directory.$repo)." git rev-list --all --full-history --topo-order ";
+ $cmd="GIT_DIR=".escapeshellarg($CONFIG['repo_directory'].$repo)." git rev-list --all --full-history --topo-order ";
$cmd .= "--max-count=1000 --skip=" .escapeshellarg($nr) ." ";
$cmd .= "--pretty=format:\"";
$cmd .= "parents %P%n";
View
79 config.php
@@ -1,57 +1,78 @@
<?php
+
+ /* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
+ // +------------------------------------------------------------------------+
+ // | git-php - PHP front end to git repositories |
+ // +------------------------------------------------------------------------+
+ // | Copyright (c) 2006 Zack Bartel |
+ // +------------------------------------------------------------------------+
+ // | This program is free software; you can redistribute it and/or |
+ // | modify it under the terms of the GNU General Public License |
+ // | as published by the Free Software Foundation; either version 2 |
+ // | of the License, or (at your option) any later version. |
+ // | |
+ // | This program is distributed in the hope that it will be useful, |
+ // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+ // | GNU General Public License for more details. |
+ // | |
+ // | You should have received a copy of the GNU General Public License |
+ // | along with this program; if not, write to the Free Software |
+ // | Foundation, Inc., 59 Temple Place - Suite 330, |
+ // | Boston, MA 02111-1307, USA. |
+ // +------------------------------------------------------------------------+
+ // | Author: Zack Bartel <zack@bartel.com> |
+ // | Author: Peeter Vois http://people.proekspert.ee/peeter/blog |
+ // | Author: Xan Manning http://knoxious.co.uk/ |
+ // +------------------------------------------------------------------------+
+
/* git-php Configuration file */
/* Add the default css */
- $git_css = true;
+ $CONFIG['git_css'] = true;
/* Add the git logo in the footer */
- $git_logo = true;
-
-/* True if the voting mechanism with SMS is active */
- $git_sms_active = false;
+ $CONFIG['git_logo'] = true;
/* True if the bundle transfer is active */
- $git_bundle_active = true;
+ $CONFIG['git_bundle_active'] = true;
/* True if committing is active */
- $git_commiting_active = true;
+ $CONFIG['git_commiting_active'] = true;
/* Personal information */
- $emailaddress = "mail@example.com";
- $title = "Owner's public repository";
-
-/* Unused */
- $repo_index = "index.aux";
+ $CONFIG['email_address'] = "mail@example.com";
+ $CONFIG['repo_title'] = "My public repository";
-/* The directory where repo directories resist */
- $repo_directory = '/var/user/';
+/* The directory where repo directories reside */
+ $CONFIG['repo_directory'] = "/var/user/";
/* The suffix, that can be used for complementing the repo directory,
* useful when you are using nonbare repositories, then:
* $repo_suffix = "/.git/";
*/
- $repo_suffix = "/.git/";
+ $CONFIG['repo_suffix'] = "/.git/";
/* The date format to show the dates of commits */
- $git_date_format = 'd.m.Y (H:i)';
+ $CONFIG['git_date_format'] = "d.m.Y (H:i)";
- $cache_name = ".temp/cache/";
- $secret_name = ".temp/secrets/";
- $bundle_name = ".temp/bundles/";
- $cache_directory = dirname(__FILE__) . "/{$cache_name}";
+ $CONFIG['cache_name'] = ".temp/cache/";
+ $CONFIG['secret_name'] = ".temp/secrets/";
+ $CONFIG['bundle_name'] = ".temp/bundles/";
+ $CONFIG['cache_directory'] = dirname(__FILE__) . "/" . $CONFIG['cache_name'];
- $repo_http_relpath = "";
- $http_server_name = "http://localhost/";
- $http_method_prefix = "{$http_server_name}{$repo_http_relpath}";
- $communication_link = "http://mypersonalwebsite.com";
+ $CONFIG['repo_http_relpath'] = "";
+ $CONFIG['http_server_name'] = "http://localhost/";
+ $CONFIG['http_method_prefix'] = $CONFIG['http_server_name'] . $CONFIG['repo_http_relpath'];
+ $CONFIG['communication_link'] = "http://mypersonalwebsite.com";
/* if git is not installed into standard path, we need to set the path */
- $mypath= getenv("PATH");
- $addpath = "/usr/local/git/bin";
+ $mypath = getenv("PATH");
+ $addpath = "/usr/bin/git";
if (isset($mypath)) {
- $mypath .= ":$addpath";
+ $mypath .= ":" . $addpath;
} else {
$mypath = $addpath;
}
- putenv("PATH=$mypath");
-?>
+ putenv("PATH=" . $mypath);
+?>
View
3  filestuff.php
@@ -21,8 +21,9 @@
// | Foundation, Inc., 59 Temple Place - Suite 330, |
// | Boston, MA 02111-1307, USA. |
// +------------------------------------------------------------------------+
- // | |
+ // | Author: Zack Bartel <zack@bartel.com> |
// | Author: Peeter Vois http://people.proekspert.ee/peeter/blog |
+ // | Author: Xan Manning http://knoxious.co.uk/ |
// +------------------------------------------------------------------------+
function create_directory($fullpath) {
View
274 git.php
@@ -23,19 +23,14 @@
// +------------------------------------------------------------------------+
// | Author: Zack Bartel <zack@bartel.com> |
// | Author: Peeter Vois http://people.proekspert.ee/peeter/blog |
+ // | Author: Xan Manning http://knoxious.co.uk/ |
// +------------------------------------------------------------------------+
-global $title;
+global $CONFIG;
global $repos; // list of repositories
global $validargs; // list of allowed arguments
global $git_embed; // is git-php embedded in other scripts (true) or runs on it own (false)?
-global $git_css;
-global $git_logo;
-global $http_method_prefix; // prefix path for http clone method
-global $communication_link; // link for sending a message to owner
global $failedarg;
-global $cache_name;
-global $repo_http_relpath;
global $tags;
global $branches;
global $nr_of_shortlog_lines;
@@ -65,7 +60,7 @@
// increase statistic counters
if ($_GET['dl'] != 'rss2') {
// do not count the rss2 requests
- if ((floor(time()/15/60)-intval($_GET['tm'])) > 4) {
+ if ((floor(time() / 15 / 60) - intval($_GET['tm'])) > 4) {
// do not count the one hour session
if (((count($_GET) > 1) && isset($_GET['tm'])) || count($_GET) == 1) {
// prevent counting if no time set and more than one argument given
@@ -78,7 +73,7 @@
// add some keywords to valid array
$arrowdesc = array('none', 'up', 'down');
$validargs = array_merge($validargs,
- array("targz", "zip", "plain", "dlfile", "rss2","commitdiff", "jump_to_tag", "GO", "SET", "HEAD",),
+ array("targz", "zip", "plain", "dlfile", "rss2", "commitdiff", "jump_to_tag", "GO", "SET", "HEAD",),
$icondesc, $arrowdesc);
security_test_arg();
@@ -97,7 +92,7 @@
// modifying the number of shortlog lines
if (isset($_POST['nr_of_shortlog_lines'])) {
$nr_of_shortlog_lines = $_POST['nr_of_shortlog_lines'];
- setcookie('nr_of_shortlog_lines', "$nr_of_shortlog_lines", time()+3600*24*360);
+ setcookie('nr_of_shortlog_lines', $nr_of_shortlog_lines, time() + 3600 * 24 * 360);
} elseif (isset($_COOKIE['nr_of_shortlog_lines'])) {
$nr_of_shortlog_lines = $_COOKIE['nr_of_shortlog_lines'];
} else {
@@ -213,7 +208,7 @@
html_summary($_GET['p']);
html_spacer();
if ($_GET['a'] == "commitdiff") {
- html_title("diff --git {$_GET['p']} {$_GET['h']}");
+ html_title("diff --git " . $_GET['p'] . " " . $_GET['h']);
html_diff($_GET['p'], $_GET['h']);
} elseif (isset($_GET['tr'])) {
html_title("Files");
@@ -264,62 +259,61 @@ function html_browse($proj) {
}
function html_help($proj) {
- global $http_method_prefix;
- global $communication_link;
+ global $CONFIG;
echo "<div id=\"git-help\">\n";
echo "<table>\n";
echo "<tr><td>To clone: </td><td>git clone ";
- echo "{$http_method_prefix}";
- echo "{$proj} yourpath</td></tr>\n";
- echo "<tr><td>To communicate: </td><td><a href={$communication_link}>Visit this page</a></td></tr>";
+ echo $CONFIG['http_method_prefix'];
+ echo $proj . " yourpath</td></tr>\n";
+ echo "<tr><td>To communicate: </td><td><a href=\"" . $CONFIG['communication_link'] . "\">Visit this page</a></td></tr>";
echo "</table>\n";
echo "</div>\n";
}
function html_blob($proj, $blob) {
- global $extEnscript, $repo_suffix;
+ global $extEnscript, $CONFIG;
$repopath = get_repo_path($proj);
$out = array();
$name = $_GET['n'];
$plain = html_ahref(array('p' => $proj, 'dl' => "plain", 'h' => $blob, 'n' => $name)) . "plain</a>";
$ext =@ $extEnscript[strrchr($name,".")];
- echo "<div style=\"float:right;padding:7px;\">{$plain}</div>\n";
+ echo "<div style=\"float:right;padding:7px;\">" . $plain . "</div>\n";
//echo "$ext";
echo "<div class=\"gitcode\">\n";
if ($ext == "") {
//echo "nonhighlight!";
- $cmd = "GIT_DIR=" . escapeshellarg("{$repopath}{$repo_suffix}") . " git cat-file blob " . escapeshellarg($blob) . " 2>&1";
+ $cmd = "GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git cat-file blob " . escapeshellarg($blob) . " 2>&1";
exec($cmd, &$out);
- $out = "<PRE>" . htmlspecialchars(implode("\n",$out)) . "</PRE>";
+ $out = "<PRE>" . htmlspecialchars(implode("\n", $out)) . "</PRE>";
echo "$out";
//$out = highlight_string($out);
} elseif ($ext == "php") {
- $cmd = "GIT_DIR=" . escapeshellarg("{$repopath}{$repo_suffix}") . " git cat-file blob " . escapeshellarg($blob) . " 2>&1";
+ $cmd = "GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git cat-file blob " . escapeshellarg($blob) . " 2>&1";
exec($cmd, &$out);
//$out = "<PRE>".htmlspecialchars(implode("\n",$out))."</PRE>";
highlight_string(implode("\n",$out));
} else {
//echo "highlight";
$result = 0;
- $cmd = "GIT_DIR=" . escapeshellarg("{$repopath}{$repo_suffix}") . " git cat-file blob " . escapeshellarg($blob) .
+ $cmd = "GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git cat-file blob " . escapeshellarg($blob) .
" 2>&1 | enscript --language=html --color=1 --highlight=" . escapeshellarg($ext) . " -o - | sed -n \"/<PRE/,/<\\/PRE/p\" ";
- exec("$cmd", &$out);
- $out = implode("\n",$out);
- echo "$out";
+ exec($cmd, &$out);
+ $out = implode("\n", $out);
+ echo $out;
}
echo "</div>\n";
}
function html_diff($proj, $commit) {
- global $repo_suffix;
+ global $CONFIG;
$repopath = get_repo_path($proj);
//$c = git_commit($proj, $commit);
$c['parent'] = $_GET['hb'];
$out = array();
- exec("GIT_DIR=" . escapeshellarg("{$repopath}{$repo_suffix}") . " git diff " . escapeshellarg($c['parent']) . " " .
+ exec("GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git diff " . escapeshellarg($c['parent']) . " " .
escapeshellarg($commit) . " 2>&1 | enscript --language=html --color=1 --highlight=diffu -o - | sed -n \"/<PRE/,/<\\/PRE/p\" ", &$out);
echo "<div class=\"gitcode\">\n";
- echo implode("\n",$out);
+ echo implode("\n", $out);
echo "</div>\n";
}
@@ -344,19 +338,19 @@ function html_tree($proj, $tree) {
$objlink = html_ahref(array('p' => $proj, 'a' => "jump_to_tag", 'b' => $obj['hash'], 'n' => $obj['file']), "blob") . $obj['file'] . "</a>\n";
$ext=@$extEnscript[strrchr($obj['file'],".")];
if ($ext == "") {
- $icon = "<img src=\"".sanitized_url()."dl=icon_plain\" style=\"border-width: 0px;\"/>";
+ $icon = "<img src=\"" . sanitized_url() . "dl=icon_plain\" style=\"border-width: 0px;\"/>";
} else {
- $icon = "<img src=\"".sanitized_url()."dl=icon_color\" style=\"border-width: 0px;\"/>";
+ $icon = "<img src=\"" . sanitized_url() . "dl=icon_color\" style=\"border-width: 0px;\"/>";
}
}
- echo "<tr><td>$perm</td><td>$icon</td></td><td>$objlink</td><td>$plain$dlfile</td></tr>\n";
+ echo "<tr><td>" . $perm . "</td><td>" . $icon . "</td></td><td>" . $objlink . "</td><td>" . $plain$dlfile . "</td></tr>\n";
}
echo "</table>\n";
echo "</div>\n";
}
function html_shortlog($proj, $lines) {
- global $cache_name,$repo_http_relpath,$branches,$tags,$nr_of_shortlog_lines,$git_date_format;
+ global $CONFIG, $branches, $tags, $nr_of_shortlog_lines;
$page = 0;
$shortc["top"] = array();
$shortc["bot"] = array();
@@ -370,7 +364,7 @@ function html_shortlog($proj, $lines) {
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
switch($_GET['a']) {
case "commitdiff":
- $order = create_images_parents($proj,$page,$lines,$_GET['h'],$shortc);
+ $order = create_images_parents($proj, $page, $lines, $_GET['h'], $shortc);
break;
case "jump_to_tag":
if (isset($_POST['tag']) && $_POST['tag'] != "") {
@@ -383,11 +377,11 @@ function html_shortlog($proj, $lines) {
$start = "HEAD";
}
if ($start != "") {
- $order = create_images_starting($proj,$page,$lines,$start,$shortc);
+ $order = create_images_starting($proj, $page, $lines, $start, $shortc);
break;
}
default:
- $order = create_images($proj,$page,$lines,$shortc);
+ $order = create_images($proj, $page, $lines, $shortc);
break;
}
$treeid = "";
@@ -399,7 +393,7 @@ function html_shortlog($proj, $lines) {
echo "<tr class=\"inl\"><td></td><td>";
for ($i = 0; $i < count($shortc["top"]); $i++) {
if ($shortc["top"][$i] != ".") {
- echo html_ahref(array('p' => $_GET['p'], 'a' => "jump_to_tag", 'tag' => $shortc["top"][$i])) .html_ref(array('dl' => "up"), "<img src=\"")."</a>";
+ echo html_ahref(array('p' => $_GET['p'], 'a' => "jump_to_tag", 'tag' => $shortc["top"][$i])) . html_ref(array('dl' => "up"), "<img src=\"")."</a>";
} else {
echo html_ref(array('dl' => "none"), "<img src=\"");
}
@@ -408,7 +402,7 @@ function html_shortlog($proj, $lines) {
for ($i = 0; ($i < $lines) && ($order[$i]!= ""); $i++) {
$c = git_commit($proj, $order[$i]);
//var_dump($c);
- $date = date($git_date_format, (int)$c['date']);
+ $date = date($CONFIG['git_date_format'], (int)$c['date']);
$cid = $order[$i];
$pid = $c['parent'];
$mess = short_desc($c['message'], 40);
@@ -421,33 +415,33 @@ function html_shortlog($proj, $lines) {
} elseif ($_GET['hb'] == $cid) {
$diff = "pare";
} else {
- $diff = html_ahref(array('p' => $_GET['p'], 'a' => "commitdiff", 'h' => $order[0], 'hb' => $cid, 'pg' => "", 'tr' => "")) ."pare</a>";
+ $diff = html_ahref(array('p' => $_GET['p'], 'a' => "commitdiff", 'h' => $order[0], 'hb' => $cid, 'pg' => "", 'tr' => "")) . "pare</a>";
}
} elseif ($pid == "") {
$diff = "diff";
} else {
- $diff = html_ahref(array('p' => $_GET['p'], 'a' => "commitdiff", 'h' => $cid, 'hb' => $pid, 'pg' => "", 'tr' => "")) ."diff</a>";
+ $diff = html_ahref(array('p' => $_GET['p'], 'a' => "commitdiff", 'h' => $cid, 'hb' => $pid, 'pg' => "", 'tr' => "")) . "diff</a>";
}
// displaying tree
if ($tid == $treeid) {
$tree = "tree";
} else {
- $tree = html_ahref(array('p' => $_GET['p'], 'a' => "jump_to_tag", 'tag' => $cid, 'tr' => $tid, 't' => $tid, 'pg' => "")) ."tree</a>";
+ $tree = html_ahref(array('p' => $_GET['p'], 'a' => "jump_to_tag", 'tag' => $cid, 'tr' => $tid, 't' => $tid, 'pg' => "")) . "tree</a>";
}
echo "<tr><td>{$date}</td>";
- echo "<td>".html_ahref(array('p' => $_GET['p'], 'a' => "jump_to_tag", 'tag' => $cid))."<img src=\"" . $repo_http_relpath . $cache_name . $proj. "/graph-".$cid.".png\" /></a></td>";
+ echo "<td>" . html_ahref(array('p' => $_GET['p'], 'a' => "jump_to_tag", 'tag' => $cid)) . s"<img src=\"" . $CONFIG['repo_http_relpath'] . $CONFIG['cache_name'] . $proj . "/graph-" . $cid . ".png\" /></a></td>";
echo "<td>{$auth}</td><td>";
if (in_array($cid,$branches)) {
foreach($branches as $symbolic => $hashic) {
if ($hashic == $cid) {
- echo "<branches>{$symbolic}</branches> ";
+ echo "<branches>" . $symbolic . "</branches> ";
}
}
}
if (in_array($cid,$tags)) {
foreach($tags as $symbolic => $hashic) {
if ($hashic == $cid) {
- echo "<tags>".$symbolic."</tags> ";
+ echo "<tags>" . $symbolic . "</tags> ";
}
}
}
@@ -460,7 +454,7 @@ function html_shortlog($proj, $lines) {
echo "<tr class=\"inl\" ><td></td><td>";
for ($i = 0; $i < count($shortc["bot"]); $i++) {
if ($shortc["bot"][$i] != ".") {
- echo html_ahref(array('p' => $_GET['p'], 'a' => "jump_to_tag", 'tag' => $shortc["bot"][$i])) . html_ref(array('dl' => "down"), "<img src=\"")."</a>";
+ echo html_ahref(array('p' => $_GET['p'], 'a' => "jump_to_tag", 'tag' => $shortc["bot"][$i])) . html_ref(array('dl' => "down"), "<img src=\"") . "</a>";
} else {
echo html_ref(array('dl' => "none"), "<img src=\"");
}
@@ -506,15 +500,15 @@ function html_summary_title() {
echo "<select name=\"branch\">";
echo "<option selected value=\"\">select a branch</option>";
foreach(array_keys($branches) as $br) {
- echo "<option value=\"{$br}\">{$br}</option>";
+ echo "<option value=\"" . $br . "\">" . $br . "</option>";
}
echo "</select> or <select name=\"tag\">";
echo "<option selected value=\"\">select a tag</option>";
foreach(array_keys($tags) as $br) {
- echo "<option value=\"{$br}\">{$br}</option>";
+ echo "<option value=\"" . $br . "\">" . $br . "</option>";
}
echo "</select> and press <input type=\"submit\" name=\"branch_or_tag\" value=\"GO\">";
- echo " Lines to display <input type=\"text\" name=\"nr_of_shortlog_lines\" value=\"{$nr_of_shortlog_lines}\" size=\"3\"> <input type=\"submit\" name=\"branch_or_tag\" value=\"SET\"> \n";
+ echo " Lines to display <input type=\"text\" name=\"nr_of_shortlog_lines\" value=\"" . $nr_of_shortlog_lines . "\" size=\"3\"> <input type=\"submit\" name=\"branch_or_tag\" value=\"SET\"> \n";
echo "</div></form>";
} else {
echo "<div class=\"gittitle\">Summary</div>\n";
@@ -522,13 +516,13 @@ function html_summary_title() {
}
function git_parse($proj, $what) {
- global $repo_suffix;
- $cmd1 = "GIT_DIR=" . get_repo_path($proj) . $repo_suffix . " git rev-parse --symbolic --" . escapeshellarg($what) . " 2>&1";
+ global $CONFIG;
+ $cmd1 = "GIT_DIR=" . get_repo_path($proj) . $CONFIG['repo_suffix'] . " git rev-parse --symbolic --" . escapeshellarg($what) . " 2>&1";
$out1 = array();
$bran = array();
exec($cmd1, &$out1);
for($i = 0; $i < count($out1); $i++) {
- $cmd2="GIT_DIR=" . get_repo_path($proj) . "{$repo_suffix} git rev-list --max-count=1 " . escapeshellarg($out1[$i]) . " 2>&1";
+ $cmd2="GIT_DIR=" . get_repo_path($proj) . $CONFIG['repo_suffix'] . " git rev-list --max-count=1 " . escapeshellarg($out1[$i]) . " 2>&1";
$out2 = array();
exec($cmd2, &$out2);
$bran[$out1[$i]] = $out2[0];
@@ -538,21 +532,21 @@ function git_parse($proj, $what) {
}
function html_desc($repopath) {
- global $repo_suffix;
- $desc = file_get_contents("{$repopath}{$repo_suffix}/description");
+ global $CONFIG;
+ $desc = file_get_contents($repopath . $CONFIG['repo_suffix'] . "/description");
$owner = get_file_owner($repopath);
$last = get_last($repopath);
echo "<div id=\"git-description\">\n";
echo "<table>\n";
- echo "<tr><td>description</td><td>{$desc}</td></tr>\n";
- echo "<tr><td>owner</td><td>{$owner}</td></tr>\n";
- echo "<tr><td>last change</td><td>{$last}</td></tr>\n";
+ echo "<tr><td>description</td><td>" . $desc . "</td></tr>\n";
+ echo "<tr><td>owner</td><td>" . $owner . "</td></tr>\n";
+ echo "<tr><td>last change</td><td>" . $last . "</td></tr>\n";
echo "</table>\n";
echo "</div>\n";
}
function html_home() {
- global $repos, $repo_suffix;
+ global $repos, $CONFIG;
echo "<div class=\"git-home\">\n";
echo "<table>\n<tr>";
echo "<th>Project</th>";
@@ -564,22 +558,22 @@ function html_home() {
echo "</tr>\n";
foreach ($repos as $repo) {
$today = 0; $total = 0; stat_get_count($repo, $today, $total);
- $desc = short_desc(file_get_contents($repo.$repo_suffix."/description"));
+ $desc = short_desc(file_get_contents($repo . $CONFIG['repo_suffix'] . "/description"));
$owner = get_file_owner($repo);
$last = get_last($repo);
$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} | {$dlz}</td><td> ({$today} / {$total}) </td></tr>\n";
+ echo "<tr><td>" . $proj . "</td><td>" . $desc . "</td><td>" . $owner . "</td><td>" . $last . "</td><td>" . $dlt ." | " . $dlz . "</td><td> (" . $today . " / " . $total . ") </td></tr>\n";
}
echo "</table>";
echo "</div>\n";
}
function get_git($repo) {
- global $repo_suffix;
- if (file_exists("{$repo}{$repo_suffix}")) {
- $gitdir = "{$repo}{$repo_suffix}";
+ global $CONFIG;
+ if (file_exists($repo . $CONFIG['repo_suffix'])) {
+ $gitdir = $repo . $CONFIG['repo_suffix'];
} else {
$gitdir = $repo;
}
@@ -592,25 +586,25 @@ function get_file_owner($repopath) {
//$pw = posix_getpwuid($s['uid']);
//echo("owner1");
//return preg_replace("/[,;]/", "", $pw["gecos"]);
- global $repo_suffix;
+ global $CONFIG;
$out = array();
- $cmd = "GIT_DIR=" . escapeshellarg("{$repopath}{$repo_suffix}") . " git rev-list --header --max-count=1 HEAD 2>&1 | grep -a committer | cut -d' ' -f2-3";
+ $cmd = "GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git rev-list --header --max-count=1 HEAD 2>&1 | grep -a committer | cut -d' ' -f2-3";
$own = exec($cmd, &$out);
return $own;
}
function get_last($repopath) {
- global $git_date_format, $repo_suffix;
+ global $CONFIG;
$out = array();
- $cmd = "GIT_DIR=" . escapeshellarg("{$repopath}{$repo_suffix}") . " git rev-list --header --max-count=1 HEAD 2>&1 | grep -a committer | cut -d' ' -f5-6";
+ $cmd = "GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix'])) . " git rev-list --header --max-count=1 HEAD 2>&1 | grep -a committer | cut -d' ' -f5-6";
$date = exec($cmd, &$out);
- return date($git_date_format, (int)$date);
+ return date($CONFIG['git_date_format'], (int)$date);
}
function get_project_link($repo, $type = false, $tag="HEAD") {
$path = basename($repo);
if (!$type) {
- return "<a href=\"".sanitized_url()."p={$path}\">{$path}</a>";
+ return "<a href=\"" . sanitized_url() . "p=" . $path . "\">" . $path . "</a>";
} elseif ($type == "targz") {
return html_ahref(array('p' => $path, 'dl'=>'targz', 'h' => $tag)) . ".tar.gz</a>";
} elseif ($type == "zip") {
@@ -619,15 +613,15 @@ function get_project_link($repo, $type = false, $tag="HEAD") {
}
function git_commit($proj, $cid) {
- global $repo_directory, $repo_suffix;
+ global $CONFIG;
$out = array();
$commit = array();
if (strlen($cid) <= 0){
return 0;
}
- $cmd = "GIT_DIR=" . escapeshellarg("{$repo_directory}{$proj}{$repo_suffix}") . " git rev-list --max-count=1 --pretty=format:\"";
- $cmd .= "parents %P%ntree %T%nauthor %an%ndate %at%nmessage %s%nendrecord%n\" {$cid} 2>&1";
+ $cmd = "GIT_DIR=" . escapeshellarg($CONFIG['repo_directory'] . $proj . $CONFIG['repo_suffix']) . " git rev-list --max-count=1 --pretty=format:\"";
+ $cmd .= "parents %P%ntree %T%nauthor %an%ndate %at%nmessage %s%nendrecord%n\" " . $cid . " 2>&1";
exec($cmd, &$out);
@@ -664,12 +658,12 @@ function git_commit($proj, $cid) {
}
function git_ls_tree($repopath, $tree) {
- global $repo_suffix;
+ global $CONFIG;
$ary = array();
$out = array();
//Have to strip the \t between hash and file
- exec("GIT_DIR=" . escapeshellarg("{$repopath}{$repo_suffix}") . " git ls-tree " . escapeshellarg($tree) . " 2>&1 | sed -e 's/\t/ /g'", &$out);
+ exec("GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git ls-tree " . escapeshellarg($tree) . " 2>&1 | sed -e 's/\t/ /g'", &$out);
foreach ($out as $line) {
$entry = array();
@@ -684,34 +678,34 @@ function git_ls_tree($repopath, $tree) {
}
function write_plain() {
- global $repo_suffix;
+ global $CONFIG;
$repopath = get_repo_path($_GET['p']);
$name = $_GET['n'];
$hash = $_GET['h'];
$out = array();
- exec("GIT_DIR=".escapeshellarg("{$repopath}{$repo_suffix}") . " git cat-file blob " . escapeshellarg($hash) . " 2>&1", &$out);
+ exec("GIT_DIR=" . escapeshellarg($repopath . $CONFIG['repo_suffix']) . " git cat-file blob " . escapeshellarg($hash) . " 2>&1", &$out);
header("Content-Type: text/plain");
echo implode("\n",$out);
die();
}
function write_dlfile() {
- global $repo_suffix;
+ global $CONFIG;
$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}");
+ exec("GIT_DIR=" . escapeshellarg($repopath . $CONFIG['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}\";");
+ 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");
+ readfile("/tmp/" . $hash . "." . $name);
die();
}
@@ -724,58 +718,58 @@ function hash_to_tag($hash) {
}
function write_targz($repo) {
- global $repo_suffix;
+ global $CONFIG;
$p = basename($repo);
$head = hash_to_tag($_GET['h']);
$proj = explode(".", $p);
$proj = $proj[0];
exec("cd /tmp && git-clone " . escapeshellarg($repo) . " " . escapeshellarg($proj) . " && cd ".
escapeshellarg($proj) . " && git-checkout " . escapeshellarg($head).
- " && cd /tmp && rm -Rf " . escapeshellarg("/tmp/{$proj}/.git") . " && tar czvf " .
- escapeshellarg("{$proj}-{$head}.tar.gz") . " " . escapeshellarg($proj));
- exec("rm -Rf " . escapeshellarg("/tmp/$proj"));
+ " && cd /tmp && rm -Rf " . escapeshellarg("/tmp/ " . $proj . "/.git") . " && tar czvf " .
+ escapeshellarg($proj . "-" . $head . ".tar.gz") . " " . escapeshellarg($proj));
+ exec("rm -Rf " . escapeshellarg("/tmp/" . $proj));
- $filesize = filesize("/tmp/{$proj}-{$head}.tar.gz");
+ $filesize = filesize($proj . "-" . $head . ".tar.gz");
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=\"{$proj}-{$head}.tar.gz\";");
- readfile("/tmp/{$proj}-{$head}.tar.gz");
+ header("Content-Length: " . $filesize);
+ header("Content-Disposition: attachment; filename=\"" . $proj . "-" . $head . ".tar.gz\";");
+ readfile("/tmp/" . $proj . "-" . $head . ".tar.gz");
die();
}
function write_zip($repo) {
- global $repo_suffix;
+ global $CONFIG;
$p = basename($repo);
$head = hash_to_tag($_GET['h']);
$proj = explode(".", $p);
$proj = $proj[0];
exec("cd /tmp && git-clone " . escapeshellarg($repo) . " " . escapeshellarg($proj) . " && cd " .
- escapeshellarg($proj) . " && git-checkout " . escapeshellarg($head) . " && cd /tmp && rm -Rf " . escapeshellarg("/tmp/$proj/.git").
- " && zip -r " . escapeshellarg("$proj-$head.zip") . " " . escapeshellarg($proj));
- exec("rm -Rf " . escapeshellarg("/tmp/{$proj}"));
+ escapeshellarg($proj) . " && git-checkout " . escapeshellarg($head) . " && cd /tmp && rm -Rf " . escapeshellarg("/tmp/" . $proj . "/.git").
+ " && zip -r " . escapeshellarg($proj . "-" . $head . ".zip") . " " . escapeshellarg($proj));
+ exec("rm -Rf " . escapeshellarg("/tmp/" . $proj));
- $filesize = filesize("/tmp/{$proj}-{$head}.zip");
+ $filesize = filesize("/tmp/" . $proj . "-" . $head . ".zip");
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-zip");
- header("Content-Length: {$filesize}");
- header("Content-Disposition: attachment; filename=\"{$proj}-{$head}.zip\";");
- readfile("/tmp/{$proj}-{$head}.zip");
+ header("Content-Length: " . $filesize );
+ header("Content-Disposition: attachment; filename=\"" . $proj . "-" . $head . ".zip\";");
+ readfile("/tmp/" . $proj . "-" . $head . ".zip");
die();
}
function write_rss2() {
$proj = $_GET['p'];
//$repo = get_repo_path($proj);
- $link = "http://{$_SERVER['HTTP_HOST']}".sanitized_url()."p=$proj";
+ $link = "http://" . $_SERVER['HTTP_HOST'] . sanitized_url() . "p=" . $proj;
$c = git_commit($proj, "HEAD");
header("Content-type: text/xml", true);
@@ -793,9 +787,9 @@ function write_rss2() {
<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>
+ <generator>http://github.com/xanmanning/git-php</generator>
<language>en</language>
- <?php for ($i = 0; $i < 10 && $c; $i++): ?>
+ <?php for ($i = 0; $i < 10 && $c; $i++) { ?>
<item>
<title><?php echo $c['message'] ?></title>
<link><?php echo $link?></link>
@@ -806,8 +800,8 @@ function write_rss2() {
</item>
<?php
$c = git_commit($proj, $c['parent']);
- $link = "http://{$_SERVER['HTTP_HOST']}".sanitized_url()."p=$proj&amp;a=commitdiff&amp;h={$c['commit_id']}&amp;hb={$c['parent']}&amp;tm=0";
- endfor;
+ $link = "http://" . $_SERVER['HTTP_HOST'] . sanitized_url() . "p=" . $proj . "&amp;a=commitdiff&amp;h=" . $c['commit_id'] . "&amp;hb=" . $c['parent'] . "&amp;tm=0";
+ }
?>
</channel>
</rss>
@@ -837,7 +831,7 @@ function short_desc($desc, $size=25) {
$d = explode(" ", $desc);
foreach ($d as $str) {
if (strlen($short) < $size) {
- $short .= "$str ";
+ $short .= $str . " ";
} else {
$trunc = true;
break;
@@ -851,15 +845,15 @@ function short_desc($desc, $size=25) {
}
function zpr($arr) {
- print "<pre>" .print_r($arr, true). "</pre>";
+ print "<pre>" . print_r($arr, true) . "</pre>";
}
function highlight($code) {
- if (substr($code, 0,2) != '<?') {
- $code = "<?\n{$code}\n?>";
+ if (substr($code, 0, 2) != '<?') {
+ $code = "<?\n" . $code . "\n?>";
$add_tags = true;
}
- $code = highlight_string($code,1);
+ $code = highlight_string($code, 1);
if ($add_tags) {
//$code = substr($code, 0, 26).substr($code, 36, (strlen($code) - 74));
@@ -879,7 +873,7 @@ function highlight_code($code) {
// Check it if code starts with PHP tags, if not: add 'em.
if (substr($code, 0, 2) != '<?') {
- $code = "<?\n{$code}\n?>";
+ $code = "<?\n" . $code . "\n?>";
$add_tags = true;
}
@@ -896,11 +890,11 @@ function highlight_code($code) {
'</font>' => '</span>',
'color="' => 'style="color:',
'<br />' => '<br/>',
- '#000000">' => '#'.COLOR_DEFAULT.'">',
- '#0000BB">' => '#'.COLOR_FUNCTION.'">',
- '#007700">' => '#'.COLOR_KEYWORD.'">',
- '#FF8000">' => '#'.COLOR_COMMENT.'">',
- '#DD0000">' => '#'.COLOR_STRING.'">'
+ '#000000">' => '#' . COLOR_DEFAULT . '">',
+ '#0000BB">' => '#' . COLOR_FUNCTION . '">',
+ '#007700">' => '#' . COLOR_KEYWORD . '">',
+ '#FF8000">' => '#' . COLOR_COMMENT . '">',
+ '#DD0000">' => '#' . COLOR_STRING . '">'
);
// Replace "<font>" tags with "<span>" tags, to generate a valid XHTML code
@@ -918,9 +912,9 @@ function highlight_code($code) {
}
function git_number_of_commits($proj) {
- global $repo_directory, $repo_suffix;
+ global $CONFIG;
- $cmd = "GIT_DIR=" . escapeshellarg("{$repo_directory}{$proj}{$repo_suffix}") . " git rev-list --all --full-history 2>&1 | grep -c \"\" ";
+ $cmd = "GIT_DIR=" . escapeshellarg($CONFIG['repo_directory'] . $proj . $CONFIG['repo_suffix']) . " git rev-list --all --full-history 2>&1 | grep -c \"\" ";
unset($out);
$out = array();
//echo "$cmd\n";
@@ -932,17 +926,17 @@ function git_number_of_commits($proj) {
// Graph tree drawing section
//
function create_cache_directory($repo) {
- global $repo_directory, $cache_directory;
- $dirname = $cache_directory.$repo;
+ global $CONFIG;
+ $dirname = $CONFIG['cache_directory'].$repo;
create_directory($dirname);
}
function analyze_hierarchy(&$vin, &$pin, &$commit, &$coord, &$parents, &$nr, &$childs) {
// figure out the position of this node
- if (in_array($commit,$pin,true)) {
+ if (in_array($commit, $pin, true)) {
// take reserved coordinate
- $coord[$nr] = array_search($commit,$pin,true);
+ $coord[$nr] = array_search($commit, $pin, true);
// free the reserved coordinate
$pin[$coord[$nr]] = ".";
$childs[$coord[$nr]] = ".";
@@ -959,7 +953,7 @@ function analyze_hierarchy(&$vin, &$pin, &$commit, &$coord, &$parents, &$nr, &$c
// do not allocate this place in array as this is already freed place
}
//reserve place for parents
- $pc=0;
+ $pc = 0;
foreach($parents as $p) {
if (in_array($p, $pin, true)) {
// the parent alredy has place
@@ -1007,11 +1001,11 @@ function analyze_hierarchy(&$vin, &$pin, &$commit, &$coord, &$parents, &$nr, &$c
}
function create_images_starting($proj, &$retpage, $lines, $commit_name, &$shortc) {
- global $repo_directory, $cache_directory, $repo_suffix;
- $dirname=$cache_directory.$proj;
+ global $CONFIG;
+ $dirname = $CONFIG['cache_directory'] . $proj;
create_cache_directory($proj);
- $cmd = "GIT_DIR=" . escapeshellarg("{$repo_directory}{$proj}{$repo_suffix}") . " git rev-list --max-count=1 " . escapeshellarg($commit_name) . " 2>&1";
+ $cmd = "GIT_DIR=" . escapeshellarg($CONFIG['repo_directory'] . $proj . $CONFIG['repo_suffix']) . " git rev-list --max-count=1 " . escapeshellarg($commit_name) . " 2>&1";
unset($out);
$out = array();
@@ -1037,8 +1031,8 @@ function create_images_starting($proj, &$retpage, $lines, $commit_name, &$shortc
$childs = array("."); // sliding place for shortc[top]
do{
unset($cmd);
- $cmd="GIT_DIR=".escapeshellarg($repo_directory.$proj.$repo_suffix)." git rev-list --all --full-history --topo-order ";
- $cmd .= "--max-count=1000 --skip=" .escapeshellarg($nr) ." --pretty=format:\"parents %P%nendrecord%n\" 2>&1";
+ $cmd="GIT_DIR=" . escapeshellarg($CONFIG['repo_directory'] . $proj . $CONFIG['repo_suffix']) . " git rev-list --all --full-history --topo-order ";
+ $cmd .= "--max-count=1000 --skip=" . escapeshellarg($nr) . " --pretty=format:\"parents %P%nendrecord%n\" 2>&1";
unset($out);
$out = array();
@@ -1088,7 +1082,7 @@ function create_images_starting($proj, &$retpage, $lines, $commit_name, &$shortc
unset($descriptor);
unset($commit);
unset($parents);
- $parents=array();
+ $parents = array();
break;
}
}
@@ -1096,7 +1090,7 @@ function create_images_starting($proj, &$retpage, $lines, $commit_name, &$shortc
unset($out);
$rows = $nr;
$cols = count($pin);
- unset($pin,$nr);
+ unset($pin, $nr);
//echo "number of items ".$rows."\n";
//echo "width ".$cols."\n";
@@ -1104,8 +1098,8 @@ function create_images_starting($proj, &$retpage, $lines, $commit_name, &$shortc
}
function create_images_parents($proj, &$retpage, $lines, $commit, &$shortc) {
- global $repo_directory, $cache_directory, $repo_suffix;
- $dirname = "{$cache_directory}{$proj}";
+ global $CONFIG;
+ $dirname = $CONFIG['cache_directory'] . $proj;
create_cache_directory($proj);
$page = 0; // the counter of made lines
@@ -1126,7 +1120,7 @@ function create_images_parents($proj, &$retpage, $lines, $commit, &$shortc) {
$childs = array("."); // sliding place fore shortc[top]
do{
unset($cmd);
- $cmd = "GIT_DIR=" . escapeshellarg("{$repo_directory}{$proj}{$repo_suffix}") . " git rev-list --all --full-history --topo-order ";
+ $cmd = "GIT_DIR=" . escapeshellarg($CONFIG['repo_directory'] . $proj . $CONFIG['repo_suffix']) . " git rev-list --all --full-history --topo-order ";
$cmd .= "--max-count=1000 --skip=" . escapeshellarg($nr) . " --pretty=format:\"parents %P%nendrecord%n\" 2>&1";
unset($out);
$out = array();
@@ -1157,7 +1151,7 @@ function create_images_parents($proj, &$retpage, $lines, $commit, &$shortc) {
$parents=$d;
break;
case "endrecord":
- if (in_array($commit,$todo,true)) {
+ if (in_array($commit, $todo, true)) {
$order[$page] = $commit;
$todoc--;
if ($page==0) {
@@ -1169,7 +1163,7 @@ function create_images_parents($proj, &$retpage, $lines, $commit, &$shortc) {
}
$vin = $pin;
analyze_hierarchy($vin, $pin, $commit, $coord, $parents, $nr, $childs);
- if (in_array($commit,$todo,true)) {
+ if (in_array($commit, $todo, true)) {
draw_slice($dirname, $commit, $coord[$nr], $nr, $parents, $pin, $vin);
}
merge_slice($coord[$nr], $parents, $pin);
@@ -1195,8 +1189,8 @@ function create_images_parents($proj, &$retpage, $lines, $commit, &$shortc) {
}
function create_images($proj, $page, $lines, &$shortc) {
- global $repo_directory, $cache_directory, $repo_suffix;
- $dirname=$cache_directory.$proj;
+ global $CONFIG;
+ $dirname = $CONFIG['cache_directory'] . $proj;
create_cache_directory($proj);
$order = array(); // the commit sha-s
@@ -1213,8 +1207,8 @@ function create_images($proj, $page, $lines, &$shortc) {
$childs = array("."); // sliding place fore shortc[top]
do{
unset($cmd);
- $cmd = "GIT_DIR=" . escapeshellarg("{$repo_directory}{$proj}{$repo_suffix}") . " git rev-list --all --full-history --topo-order ";
- $cmd .= "--max-count=1000 --skip=" .escapeshellarg($nr) ." --pretty=format:\"parents %P%nendrecord%n\" 2>&1";
+ $cmd = "GIT_DIR=" . escapeshellarg($CONFIG['repo_directory'] . $proj . $CONFIG['repo_suffix']) . " git rev-list --all --full-history --topo-order ";
+ $cmd .= "--max-count=1000 --skip=" . escapeshellarg($nr) ." --pretty=format:\"parents %P%nendrecord%n\" 2>&1";
unset($out);
$out = array();
@@ -1224,7 +1218,7 @@ function create_images($proj, $page, $lines, &$shortc) {
// reading the commit tree
$descriptor = "";
- $commit ="";
+ $commit = "";
$parents = array();
foreach($out as $line) {
if ($nr >= $page + $lines -1) {
@@ -1333,7 +1327,7 @@ function draw_slice($dirname, $commit, $x, $y, $parents, $pin, $vin) {
}
if ($pin[$i] != ".") {
// we have a parent
- if (in_array($pin[$i],$parents,true)) {
+ if (in_array($pin[$i], $parents, true)) {
// the parent is our parent
// draw the horisontal for it
if ($pin[$i] == $parents[0]) {
@@ -1419,10 +1413,10 @@ function draw_slice($dirname, $commit, $x, $y, $parents, $pin, $vin) {
imagefilledellipse($im, $x * $w + $wo, $ho, $r, $r, $fillcolor);
imageellipse($im, $x * $w + $wo, $ho, $r, $r, $color);
- $filename = "{$dirname}/graph-{$commit}.png";
+ $filename = $dirname . "/ graph-" . $commit . ".png";
imagepng($im, $filename);
chmod($filename, 0777);
- //chgrp($filename, intval(filegroup($repo_directory)));
+ //chgrp($filename, intval(filegroup($CONFIG['repo_directory'])));
//echo "$filename\n";
}
@@ -1463,4 +1457,4 @@ function draw_arrow($type) {
imagepng($im);
die();
}
-?>
+?>
View
241 gitstyle.css
@@ -1,62 +1,179 @@
-/* Reset
-------------------------------------------------------------------------- */
-/* Based on http://meyerweb.com/eric/tools/css/reset/ */
-/* v1.0 | 20080212 */
-html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,
-blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,
-font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,
-u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,
-caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent;}
-ol,ul{list-style:none;}
-blockquote,q{quotes:none;}
-blockquote:before,blockquote:after,
-q:before,q:after{content:'';content:none;}
-:focus{outline:0;}
-ins{text-decoration:none;}
-del{text-decoration:line-through;}
-table{border-collapse:collapse;border-spacing:0;}
-a{outline:none;color: rgb(65, 131, 196);}
-
-body{font-family:"Monaco","Courier New",monospace;font-size:12px;margin:0;background-color:#fff;color:#000000;}
-.githead{background:#cfcfcf url(img/page_header.png) repeat-x 0 0;height:3.4em;line-height:3.4em;position:relative;padding:0 27px;margin-bottom:30px;}
-.githead a:link,.githead a:visited{color:#000;background:#eee;text-decoration:none;padding:3px;}
-.githead a:hover{background:#bbb;padding:3px;}
-.githead a:first-child{background:transparent;}
-.githead img.logo{float:right;padding:0.7em 1.0em;border:0;}
-.gitfooter{height:115px;line-height:115px;background:#4386ba url(img/page_footer.png) repeat-x 0 0;padding:0 30px;margin-top:15px;text-align:right;}
-.gitfooter a{padding-top:5em;}
-.gitfooter_text{color:#fff;display:inline;float:left;}
-
-/* Tables */
-table{border:1px solid #ccc;border-right:0;/*clear:both;*/color:#333;margin-bottom:10px;width:100%;}
-#gitbody th{background-color: rgb(234, 234, 234);font-weight: normal;padding: 0.5em 0.3em;text-align: left;border: 1px solid rgb(216, 216, 216);color: rgb(153, 153, 153);text-align:center;}
-#gitbody th a{background-color:#f2f2f2;display:block;padding:2px 4px;text-decoration:none;}
-#gitbody th a:hover{background-color:#ccc;color:#333;text-decoration:none;}
-#gitbody table tr td{background-color: rgb(248, 248, 248);padding: 0.5em 0.3em;border: 1px solid rgb(225, 225, 225);color: rgb(72, 72, 72);text-align:center;vertical-align:top;}
-#gitbody table tr.altrow td{background:#f4f4f4;}
-td.actions{text-align:center;white-space:nowrap;}
-td.actions a{margin:0px 6px;}
-
-.gittitle, center{margin: 0em 2em 0em 2em;padding:1em 1em 1em 1em;background-color: rgb(240, 240, 240);border:1px solid rgb(216, 216, 216); text-align:left;}
-#git-description, #git-submit{margin: 1em 2em 1em 2em;padding:1em 1em 1em 1em;background-color: rgb(234, 242, 245);border: 1px solid rgb(190, 220, 231);}
-#git-description table tbody tr td, #git-description table, #git-description table tbody, #git-description table tbody tr{background-color: rgb(234, 242, 245);border:none;}
-#git-submit table tbody tr td, #git-submit table, #git-submit table tbody, #git-submit table tbody tr{background-color: rgb(234, 242, 245);border:none;}
-#git-help{margin: 1em 2em 1em 2em;padding:1em 1em 1em 1em;background-color: rgb(248, 248, 248);border: 1px solid rgb(190, 220, 231);}
-#git-help table tbody tr td, #git-help table, #git-help table tbody, #git-help table tbody tr{border:none;}
-.git-home{margin: 1em 2em 1em 2em;}
-
-#git-submit table tbody tr:hover{border-width:1px;}
-#git-submit table tbody tr td.descol{text-align:right;width:30%;}
-#git-submit table tbody tr td.valcol{text-align:left;width:70%}
-
-tr:hover{background-color:#cdccc6;}
-.gitbrowse{margin: 1em 2em 1em 2em;}
-div.gitbrowse a.blob{text-decoration:none;color:#000000;}
-.gitcode{border: 1px solid rgb(216, 216, 216);margin: 1em 2em 1em 2em;padding:10px;}
-div.gitspacer{padding:1px 0px 0px 0px;background-color:#FFFFFF;}
-a.rss_logo{float:right;padding:3px;width:35px;line-height:10px;border:1px solid;border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;color:#ffffff;background-color:#ff6600;font-weight:bold;font-family:sans-serif;font-size:70%;text-align:center;text-decoration:none;margin-top:49px;margin-left:5px;}
-a.rss_logo:hover{background-color:#ee5500;}
-div.gitbrowse a.blob:hover{text-decoration:underline;}
-a.gitbrowse:hover{text-decoration:underline;color:#880000;}
-a.rss_logo{float:left;padding:3px 0px;width:35px;line-height:10px;margin:2px 5px 5px 5px;border:1px solid;border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;color:#ffffff;background-color:#ff6600;font-weight:bold;font-family:sans-serif;font-size:10px;text-align:center;text-decoration:none;}
-a.rss_logo:hover{background-color:#ee5500;}
+#gitbody
+{
+ margin: 10px 10px 10px 10px;
+ border-style: solid;
+ border-width: 1px;
+ border-color: gray;
+ font-family: sans-serif;
+ font-size: 12px;
+ }
+
+div.githead
+{
+ margin: 0px 0px 0px 0px;
+ padding: 10px 10px 10px 10px;
+ background-color: #d9d8d1;
+ font-weight: bold;
+ font-size: 18px;
+ }
+
+#gitbody th
+{
+ text-align: left;
+ padding: 0px 0px 0px 7px;
+ }
+
+#gitbody td
+{
+ padding: 0px 0px 0px 7px;
+ }
+
+div.optiontable table
+{
+ padding: 0px 7px 0px 7px;
+ border-width: 0px;
+ font-size: 12px;
+ table-layout: fixed;
+ padding: 5px;
+ line-height: 36px;
+ cellpadding: 5px;
+ border-spacing: 0px;
+ width: 100%;
+ vertical-align: middle;
+ }
+
+div.optiontable tr:hover
+{
+ border-width: 1px;
+ }
+
+div.optiontable .descol
+{
+ text-align: right;
+ width: 30%;
+ }
+
+div.optiontable .valcol
+{
+ text-align: left;
+ width: 70%
+ }
+
+div.optiontable img
+{
+ vertical-align: middle;
+ }
+
+div.imgtable table
+{
+ padding: 0px 0px 0px 7px;
+ border-width: 0px;
+ font-size: 1px;
+ table-layout: auto;
+ }
+
+div.imgtable tags
+{
+ color: #009900;
+ background-color: #FFFF00;
+ }
+
+div.imgtable branches
+{
+ color: #CC6600;
+ background-color: #99FF99;
+ }
+
+div.imgtable img
+{
+ border: 0px;
+ display: block;
+ }
+
+div.imgtable .inl img
+{
+ border: 0px;
+ display: inline;
+ }
+
+div.imgtable .inl td
+{
+ height: auto;
+ vertical-align: middle;
+ font-size: 2px;
+ line-height: 3px;
+ }
+
+div.imgtable tr
+{
+ height: auto;
+ vertical-align: middle;
+ font-size: 9px;
+/* line-height: 15px;*/
+ }
+
+tr:hover
+{
+ background-color:#cdccc6;
+ }
+
+div.gitbrowse a.blob
+{
+ text-decoration: none;
+ color: #000000;
+ }
+
+div.gitcode {
+ padding: 10px;
+ }
+
+div.gitspacer
+{
+ padding: 1px 0px 0px 0px;
+ background-color: #FFFFFF;
+ }
+
+div.gitfooter
+{
+ padding: 7px 2px 2px 2px;
+ background-color: #d9d8d1;
+ text-align: right;
+ }
+
+div.gittitle
+{
+ padding: 7px 7px 7px 7px;
+ background-color: #d9d8d1;
+ font-weight: bold;
+ }
+
+div.gitbrowse a.blob:hover
+{
+ text-decoration: underline;
+ }
+a.gitbrowse:hover
+{
+ text-decoration:underline;
+ color:#880000;
+ }
+a.rss_logo
+{
+ float:left;
+ padding:3px 0px;
+ width:35px;
+ line-height:10px;
+ margin: 2px 5px 5px 5px;
+ border:1px solid;
+ border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;
+ color:#ffffff;
+ background-color:#ff6600;
+ font-weight:bold;
+ font-family:sans-serif;
+ font-size:10px;
+ text-align:center;
+ text-decoration:none;
+ }
+a.rss_logo:hover
+{
+ background-color:#ee5500;
+ }
View
62 gitstyle_github.css
@@ -0,0 +1,62 @@
+/* Reset
+------------------------------------------------------------------------- */
+/* Based on http://meyerweb.com/eric/tools/css/reset/ */
+/* v1.0 | 20080212 */
+html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,
+blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,
+font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,
+u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,
+caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent;}
+ol,ul{list-style:none;}
+blockquote,q{quotes:none;}
+blockquote:before,blockquote:after,
+q:before,q:after{content:'';content:none;}
+:focus{outline:0;}
+ins{text-decoration:none;}
+del{text-decoration:line-through;}
+table{border-collapse:collapse;border-spacing:0;}
+a{outline:none;color: rgb(65, 131, 196);}
+
+body{font-family:"Monaco","Courier New",monospace;font-size:12px;margin:0;background-color:#fff;color:#000000;}
+.githead{background:#cfcfcf url(img/page_header.png) repeat-x 0 0;height:3.4em;line-height:3.4em;position:relative;padding:0 27px;margin-bottom:30px;}
+.githead a:link,.githead a:visited{color:#000;background:#eee;text-decoration:none;padding:3px;}
+.githead a:hover{background:#bbb;padding:3px;}
+.githead a:first-child{background:transparent;}
+.githead img.logo{float:right;padding:0.7em 1.0em;border:0;}
+.gitfooter{height:115px;line-height:115px;background:#4386ba url(img/page_footer.png) repeat-x 0 0;padding:0 30px;margin-top:15px;text-align:right;}
+.gitfooter a{padding-top:5em;}
+.gitfooter_text{color:#fff;display:inline;float:left;}
+
+/* Tables */
+table{border:1px solid #ccc;border-right:0;/*clear:both;*/color:#333;margin-bottom:10px;width:100%;}
+#gitbody th{background-color: rgb(234, 234, 234);font-weight: normal;padding: 0.5em 0.3em;text-align: left;border: 1px solid rgb(216, 216, 216);color: rgb(153, 153, 153);text-align:center;}
+#gitbody th a{background-color:#f2f2f2;display:block;padding:2px 4px;text-decoration:none;}
+#gitbody th a:hover{background-color:#ccc;color:#333;text-decoration:none;}
+#gitbody table tr td{background-color: rgb(248, 248, 248);padding: 0.5em 0.3em;border: 1px solid rgb(225, 225, 225);color: rgb(72, 72, 72);text-align:center;vertical-align:top;}
+#gitbody table tr.altrow td{background:#f4f4f4;}
+td.actions{text-align:center;white-space:nowrap;}
+td.actions a{margin:0px 6px;}
+
+.gittitle, center{margin: 0em 2em 0em 2em;padding:1em 1em 1em 1em;background-color: rgb(240, 240, 240);border:1px solid rgb(216, 216, 216); text-align:left;}
+#git-description, #git-submit{margin: 1em 2em 1em 2em;padding:1em 1em 1em 1em;background-color: rgb(234, 242, 245);border: 1px solid rgb(190, 220, 231);}
+#git-description table tbody tr td, #git-description table, #git-description table tbody, #git-description table tbody tr{background-color: rgb(234, 242, 245);border:none;}
+#git-submit table tbody tr td, #git-submit table, #git-submit table tbody, #git-submit table tbody tr{background-color: rgb(234, 242, 245);border:none;}
+#git-help{margin: 1em 2em 1em 2em;padding:1em 1em 1em 1em;background-color: rgb(248, 248, 248);border: 1px solid rgb(190, 220, 231);}
+#git-help table tbody tr td, #git-help table, #git-help table tbody, #git-help table tbody tr{border:none;}
+.git-home{margin: 1em 2em 1em 2em;}
+
+#git-submit table tbody tr:hover{border-width:1px;}
+#git-submit table tbody tr td.descol{text-align:right;width:30%;}
+#git-submit table tbody tr td.valcol{text-align:left;width:70%}
+
+tr:hover{background-color:#cdccc6;}
+.gitbrowse{margin: 1em 2em 1em 2em;}
+div.gitbrowse a.blob{text-decoration:none;color:#000000;}
+.gitcode{border: 1px solid rgb(216, 216, 216);margin: 1em 2em 1em 2em;padding:10px;}
+div.gitspacer{padding:1px 0px 0px 0px;background-color:#FFFFFF;}
+a.rss_logo{float:right;padding:3px;width:35px;line-height:10px;border:1px solid;border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;color:#ffffff;background-color:#ff6600;font-weight:bold;font-family:sans-serif;font-size:70%;text-align:center;text-decoration:none;margin-top:49px;margin-left:5px;}
+a.rss_logo:hover{background-color:#ee5500;}
+div.gitbrowse a.blob:hover{text-decoration:underline;}
+a.gitbrowse:hover{text-decoration:underline;color:#880000;}
+a.rss_logo{float:left;padding:3px 0px;width:35px;line-height:10px;margin:2px 5px 5px 5px;border:1px solid;border-color:#fcc7a5 #7d3302 #3e1a01 #ff954e;color:#ffffff;background-color:#ff6600;font-weight:bold;font-family:sans-serif;font-size:10px;text-align:center;text-decoration:none;}
+a.rss_logo:hover{background-color:#ee5500;}
View
19 html_helpers.php
@@ -23,6 +23,7 @@
// +------------------------------------------------------------------------+
// | Author: Zack Bartel <zack@bartel.com> |
// | Author: Peeter Vois http://people.proekspert.ee/peeter/blog |
+ // | Author: Xan Manning http://knoxious.co.uk/ |
// +------------------------------------------------------------------------+
// this functions existance starts from php5
@@ -81,14 +82,14 @@ function html_ref($arguments, $prefix) {
}
function html_header() {
- global $title;
+ global $CONFIG['repo_title'];
global $git_embed;
if (!$git_embed) {
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n";
echo "<head>\n";
- echo "\t<title>$title</title>\n";
+ echo "\t<title>$CONFIG['repo_title']</title>\n";
echo "\t<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>\n";
echo "\t<meta NAME=\"ROBOTS\" CONTENT=\"NOFOLLOW\" />\n";
echo "</head>\n";
@@ -123,13 +124,13 @@ function html_breadcrumbs() {
}
function html_pages() {
- global $git_bundle_active;
+ global $CONFIG['git_bundle_active'];
if(isset($_GET['p'])) {
html_spacer();
$now = floor(time()/15/60); // one hour
echo "<center>";
echo "<a href=\"git.php?p=".$_GET['p']."&tm=$now\">browse</a>";
- if($git_bundle_active) {
+ if($CONFIG['git_bundle_active']) {
echo " | <a href=\"commit.php?p={$_GET['p']}\">commit</a>";
}
echo "</center>";
@@ -138,14 +139,14 @@ function html_pages() {
function html_footer() {
global $git_embed;
- global $git_logo;
+ global $CONFIG['git_logo'];
echo "<div class=\"gitfooter\">\n";
if (isset($_GET['p'])) {
echo "<a class=\"rss_logo\" href=\"".sanitized_url()."p={$_GET['p']}&dl=rss2\" >RSS</a>\n";
}
- if ($git_logo) {
+ if ($CONFIG['git_logo']) {
echo "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\">" .
"<img src=\"".sanitized_url()."dl=git_logo\" style=\"border-width: 0px;\"/></a>\n";
}
@@ -193,12 +194,12 @@ function html_title($text = "&nbsp;") {
}
function html_style() {
- global $git_css;
+ global $CONFIG['git_css'];
if (file_exists("style.css")) {
echo "<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" />\n";
}
- if ($git_css) {
+ if ($CONFIG['git_css']) {
echo "<link rel=\"stylesheet\" href=\"gitstyle.css\" type=\"text/css\" />\n";
}
}
@@ -309,4 +310,4 @@ function write_img_png($imgptr) {
echo $img[$imgptr]['bin'];
die();
}
-?>
+?>
View
49 security.php
@@ -23,18 +23,19 @@
// +------------------------------------------------------------------------+
// | Author: Zack Bartel <zack@bartel.com> |
// | Author: Peeter Vois http://people.proekspert.ee/peeter/blog |
+ // | Author: Xan Manning http://knoxious.co.uk/ |
// +------------------------------------------------------------------------+
function security_load_repos() {
- global $repo_directory, $repo_suffix, $validargs, $repos;
+ global $CONFIG, $validargs, $repos;
- if (isset($repo_directory) && file_exists($repo_directory) && is_dir($repo_directory)) {
- if ($handle = opendir($repo_directory)) {
+ if (isset($CONFIG['repo_directory']) && file_exists($CONFIG['repo_directory']) && is_dir($CONFIG['repo_directory'])) {
+ if ($handle = opendir($CONFIG['repo_directory'])) {
while (false !== ($file = readdir($handle))) {
- $fullpath = $repo_directory . $file;
- //printf("%s,%d\n", $file, is_dir($repo_directory . "/" . $file));
+ $fullpath = $CONFIG['repo_directory'] . $file;
+ //printf("%s,%d\n", $file, is_dir($CONFIG['repo_directory'] . "/" . $file));
if ($file[0] != '.' && is_dir($fullpath)) {
- if (is_dir($fullpath . $repo_suffix)) {
+ if (is_dir($fullpath . $CONFIG['repo_suffix'])) {
/* TODO: Check for valid git repos */
// fill the security array.
$validargs[] = trim($file);
@@ -66,7 +67,7 @@ function security_test_repository_arg() {
}
function security_load_names() {
- global $validargs, $repo_direcotry, $repo_suffix, $branches, $tags;
+ global $validargs, $CONFIG, $branches, $tags;
if (isset($_GET['p'])) {
// now load the repository into validargs
@@ -86,7 +87,7 @@ function security_load_names() {
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'";
+ $cmd = "GIT_DIR=" . get_repo_path($proj) . $CONFIG['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);
@@ -190,7 +191,7 @@ function draw_human_checker($amessage) {
$ml = strlen($amessage);
$w = $ml * $fw +6;
- $h = $fh+6;
+ $h = $fh + 6;
$prob = 5;
$im = imagecreate($w, $h);
@@ -233,43 +234,43 @@ function draw_human_checker($amessage) {
}
function create_secrets_directory() {
- global $repo_directory, $secret_name;
+ global $CONFIG;
- $dname = $repo_directory.$secret_name;
+ $dname = $CONFIG['repo_directory'] . $CONFIG['secret_name'];
if (create_directory($dname) == false) return false;
/* TODO: This is Apache-specific. How to generalize? */
- $file = fopen($dname.".htaccess", "w");
+ $file = fopen($dname . ".htaccess", "w");
fwrite($file, "Deny from all\n");
fclose($file);
- $file = fopen($dname."index.html", "w");
+ $file = fopen($dname . "index.html", "w");
fwrite($file, "Access denied\n");
fclose($file);
return true;
}
function create_secret() {
- global $repo_directory, $secret_name;
+ global $CONFIG;
- $now = floor(time()/60/60); // number of hours since 1970
+ $now = floor(time() / 60 / 60); // number of hours since 1970
$secret = "";
create_secrets_directory();
- do{ $secret = create_random_message(9); }while (file_exists($repo_directory.$secret_name.$secret));
- $file = fopen($repo_directory.$secret_name.$secret, "w");
+ do{ $secret = create_random_message(9); }while (file_exists($CONFIG['repo_directory'] . $CONFIG['secret_name'] . $secret));
+ $file = fopen($CONFIG['repo_directory'] . $CONFIG['secret_name'] . $secret, "w");
fwrite($file, "$now");
fclose($file);
return $secret;
}
function clean_up_secrets() {
- global $repo_directory, $secret_name;
+ global $CONFIG;
$now = floor(time()/60/60); // number hours since 1970
create_secrets_directory();
- if ($handle = opendir($repo_directory.$secret_name)) {
+ if ($handle = opendir($CONFIG['repo_directory'] . $CONFIG['secret_name'])) {
while (false !== ($fname = readdir($handle))) {
if (!is_numeric($fname)) continue;
- $fullpath = $repo_directory.$secret_name.$fname;
- //printf("%s,%d\n", $file, is_dir($repo_directory . "/" . $file));
+ $fullpath = $CONFIG['repo_directory'] . $CONFIG['secret_name'] . $fname;
+ //printf("%s,%d\n", $file, is_dir($CONFIG['repo_directory'] . "/" . $file));
if (!is_file($fullpath)) continue;
$file = fopen($fullpath , "r");
$fd =