Permalink
Browse files

Large update, removed .zip, added GeSHi support, Repository verification

  • Loading branch information...
1 parent 3da2486 commit de59dcceaeb271c758314f4b623a44046f17e53a @xanmanning xanmanning committed Jun 28, 2010
Showing with 470 additions and 222 deletions.
  1. +3 −1 README.markdown
  2. +16 −3 commit.php
  3. +29 −5 config.php
  4. +2 −2 filestuff.php
  5. +56 −0 geshifunc.php
  6. +150 −124 git.php
  7. +171 −69 html_helpers.php
  8. +25 −15 security.php
  9. +18 −3 statis.php
View
@@ -3,9 +3,11 @@
## 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, 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.
+Icons now included from http://www.famfamfam.com/lab/icons/silk/
+
## Requirements
* git
-* enscript
+* GeSHi
* gd2
View
@@ -170,16 +170,29 @@ function send_the_main_page($subpage = 'submit') {
function create_bundles_directory() {
global $CONFIG;
$repo = $_GET['p'];
- $dname = $CONFIG['repo_directory'] . $CONFIG['bundle_name'] . "/";
+ $dname = $CONFIG['bundle_directory'] . "/";
create_directory($dname);
return create_directory($dname . $repo);
}
+function get_file_owner($repopath) {
+ //$s = stat($path);
+ //print_r($s);
+ //$pw = posix_getpwuid($s['uid']);
+ //echo("owner1");
+ //return preg_replace("/[,;]/", "", $pw["gecos"]);
+ global $CONFIG;
+ $out = array();
+ $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 load_bundles_in_directory() {
global $CONFIG;
$repo = $_GET['p'];
$bundles = array();
- $dname = $CONFIG['repo_directory'] . $CONFIG['bundle_name'] . $repo . "/";
+ $dname = $CONFIG['bundle_directory'] . $repo . "/";
create_bundles_directory();
if ($handle = opendir($dname)) {
while (false !== ($fname = readdir($handle))) {
@@ -212,7 +225,7 @@ function load_bundles_in_directory() {
function save_bundle() {
global $CONFIG;
$repo = $_GET['p'];
- $dname = $CONFIG['repo_directory'] . $CONFIG['bundle_name'] . $repo . "/";
+ $dname = $CONFIG['bundle_directory'] . $repo . "/";
create_bundles_directory();
if ($_FILES['bundle_file']['error'] != UPLOAD_ERR_OK) {
return false;
View
@@ -49,9 +49,18 @@
/* The suffix, that can be used for complementing the repo directory,
* useful when you are using nonbare repositories, then:
- * $repo_suffix = "/.git/";
+ * $CONFIG['repo_suffix'] = "/.git/";
+ * Bare repositories should be set to NULL;
*/
- $CONFIG['repo_suffix'] = "/.git/";
+ $CONFIG['repo_suffix'] = "/.git/";
+ # $CONFIG['repo_suffix'] = NULL; // Bare Repository!
+
+/* The path to GeSHi (geshi.php). Can be relative. */
+ $CONFIG['geshi_directory'] = "/path/to/geshi.php";
+
+/* GeSHi line styles. (Produces tiger striping) */
+ $CONFIG['geshi_linea_style'] = 'background: #FFFFFF;';
+ $CONFIG['geshi_lineb_style'] = 'background: #F5F5F5; font-weight: normal;';
/* The date format to show the dates of commits */
$CONFIG['git_date_format'] = "d.m.Y (H:i)";
@@ -60,10 +69,25 @@
$CONFIG['secret_name'] = ".temp/secrets/";
$CONFIG['bundle_name'] = ".temp/bundles/";
$CONFIG['cache_directory'] = dirname(__FILE__) . "/" . $CONFIG['cache_name'];
+ $CONFIG['bundle_directory'] = dirname(__FILE__) . "/" . $CONFIG['bundle_name'];
+ $CONFIG['secret_directory'] = dirname(__FILE__) . "/" . $CONFIG['secret_name'];
+
+/* There has been a major change here, sometimes the preferred method for
+ * cloning is via git:// or ssh:// protocol. The option to change how a repository
+ * is cloned has been added to this release.
+ *
+ * Example usage. /home/git/project.git/ can be accessed with git://[SERVER_ADDRESS]/project.git (Git Protocol)
+ * $CONFIG['git_server_method'] = "git://[SERVER_ADDRESS]/";
+ *
+ * Let's say /home/git/user_folder/project.git/ wants to be accessed with SSH. [USER]@[SERVER_ADDRESS]:user_folder/project.git
+ * and this repository is for one user only...
+ * $CONFIG['git_server_method'] = "[USER]@SERVER_ADDRESS]:";
+ * $CONFIG['repo_relpath'] = "user_folder/";
+ */
- $CONFIG['repo_http_relpath'] = "";
- $CONFIG['http_server_name'] = "http://localhost/";
- $CONFIG['http_method_prefix'] = $CONFIG['http_server_name'] . $CONFIG['repo_http_relpath'];
+ $CONFIG['repo_relpath'] = "";
+ $CONFIG['git_server_method'] = "http://localhost/";
+ $CONFIG['git_method_prefix'] = $CONFIG['git_server_method'] . $CONFIG['repo_relpath'];
$CONFIG['communication_link'] = "http://mypersonalwebsite.com";
/* if git is not installed into standard path, we need to set the path */
View
@@ -31,8 +31,8 @@ function create_directory($fullpath) {
echo "Wrong path name " . $fullpath . "\n";
die();
}
- if( ! is_dir($fullpath) ){
- if( ! mkdir($fullpath) ){
+ if( !is_dir($fullpath) ){
+ if(!mkdir($fullpath) ){
echo "Error by making directory " . $fullpath . "\n";
die();
}
View
@@ -0,0 +1,56 @@
+<?php
+
+ /* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
+ // +------------------------------------------------------------------------+
+ // | git-php - PHP front end to git repositories [GeSHi Patch] |
+ // +------------------------------------------------------------------------+
+ // | 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: Xan Manning http://knoxious.co.uk/ |
+ // +------------------------------------------------------------------------+
+
+include_once($CONFIG['geshi_directory']);
+
+function geshi_init()
+ {
+ global $geshi;
+ global $CONFIG;
+ $geshi = new GeSHi('<!-- Unavailable -->', 'html4strict');
+ $geshi->enable_classes();
+ $geshi->set_header_type(GESHI_HEADER_PRE_VALID);
+ $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
+ $geshi->set_line_style($CONFIG['geshi_linea_style'], $CONFIG['geshi_lineb_style'], TRUE);
+ }
+
+function geshi_highlight($code, $language)
+ {
+ global $geshi;
+ $geshi->set_language($language);
+ $geshi->set_source($code);
+ $geshiCode = $geshi->parse_code();
+ return $geshiCode;
+ }
+
+function geshi_style()
+ {
+ global $geshi;
+ $geshiStyle = "<style type=\"text/css\">" . $geshi->get_stylesheet() . "</style>";
+ return $geshiStyle;
+ }
+
+?>
Oops, something went wrong.

0 comments on commit de59dcc

Please sign in to comment.