/* GIT configuration */
class GitConfig {
- /* PHPGitWeb Title / Name */
+ /* PHPGitWeb Title / Name */
const GITWEB_TITLE = "PHPGitWeb";
- /* path to git projects (<project>.git) */
- const PROJECT_ROOT = "/srv/gitosis/repositories/";
-
- /* Point to projects.list file generated by gitosis. */
- //const PROJECT_LIST = NULL;
- const PROJECT_LIST = "/srv/gitosis/gitosis/projects.list";
-
- /* Only allow Projects from PROJECT_LIST being viewed */
- const STRICT_EXPORT = true;
-
- /* Only allow Projects with this file within their PROJECT_ROOT being viewed */
- //const EXPORT_FILE = "export-ok";
- const EXPORT_FILE = NULL;
+ /* path to git projects (<project>.git) */
+ const PROJECT_ROOT = "/srv/gitosis/repositories/";
+
+ /* Point to projects.list file generated by gitosis. */
+ //const PROJECT_LIST = NULL;
+ const PROJECT_LIST = "/srv/gitosis/gitosis/projects.list";
+
+ /* Only allow Projects from PROJECT_LIST being viewed */
+ const STRICT_EXPORT = true;
+
+ /* Only allow Projects with this file within their PROJECT_ROOT being viewed */
+ //const EXPORT_FILE = "export-ok";
+ const EXPORT_FILE = NULL;
/* Override Project Owner to this one */
const PROJECT_OWNER = NULL;
*/
class ContentProvider {
- private static $template_cache = array();
+ private static $template_cache = array();
private static $overall_content = array();
private $template, $subtemplate;
private $content = array();
- public function __construct($template, $subtemplate, $content = null) {
+ public function __construct($template, $subtemplate, $content = null) {
$this->template = $template;
$this->subtemplate = $subtemplate;
$this->content = $content;
}
}
-
+
public function set($name, $value) {
$this->content[strtolower($name)] = $value;
}
require_once("lib/graph.class.php");
class PHPGitWeb {
- private $page, $rendertime;
+ private $page, $rendertime;
private $project, $project_loader, $project_header;
- public function __construct() {
+ public function __construct() {
$this->rendertime = microtime(true);
session_start();
$this->page = new ContentProvider('main', 'main');
} else
$this->page->append('content', file_get_contents('pages/404.html'));
if($this->project_header) {
- $this->project_header->set('nav_summary', new ContentProvider('main', ($page == 'summary' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "summary", 'link' => "summary", 'link_add' => "")));
+ $this->project_header->set('nav_summary', new ContentProvider('main', ($page == 'summary' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "summary", 'link' => "summary", 'link_add' => "")));
$this->project_header->set('nav_shortlog', new ContentProvider('main', ($page == 'shortlog' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "shortlog", 'link' => "shortlog", 'link_add' => "&h=%commit_base_id%")));
- $this->project_header->set('nav_log', new ContentProvider('main', ($page == 'log' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "log", 'link' => "log", 'link_add' => "&h=%commit_base_id%")));
- $this->project_header->set('nav_commit', new ContentProvider('main', ($page == 'commit' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commit", 'link' => "commit", 'link_add' => "&h=%commit_id%")));
+ $this->project_header->set('nav_log', new ContentProvider('main', ($page == 'log' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "log", 'link' => "log", 'link_add' => "&h=%commit_base_id%")));
+ $this->project_header->set('nav_commit', new ContentProvider('main', ($page == 'commit' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commit", 'link' => "commit", 'link_add' => "&h=%commit_id%")));
$this->project_header->set('nav_commitdiff', new ContentProvider('main', ($page == 'commitdiff' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commitdiff", 'link' => "commitdiff", 'link_add' => "&h=%commit_id%")));
- $this->project_header->set('nav_tree', new ContentProvider('main', ($page == 'tree' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "tree", 'link' => "tree", 'link_add' => "&h=%commit_id%")));
+ $this->project_header->set('nav_tree', new ContentProvider('main', ($page == 'tree' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "tree", 'link' => "tree", 'link_add' => "&h=%commit_id%")));
}
}
$html = str_replace(array("%rendertime%"), array($rendertime), $html);
return $html;
}
-
+
public function error_handler($errno, $errstr, $errfile, $errline) {
$error = new ContentProvider('main', 'error');
$etype = "";
*/
class ProjectLoader {
- private $projects = NULL;
-
- private function loadProjects($load_details = true) {
- $this->projects = array();
- if(GitConfig::PROJECT_LIST) {
- foreach(file(GitConfig::PROJECT_LIST) as $entry) {
- $entry = explode(" ", $entry);
-
- if($load_details) {
- //check if project really exists
- $project = $this->loadProject($entry[0], false);
+ private $projects = NULL;
+
+ private function loadProjects($load_details = true) {
+ $this->projects = array();
+ if(GitConfig::PROJECT_LIST) {
+ foreach(file(GitConfig::PROJECT_LIST) as $entry) {
+ $entry = explode(" ", $entry);
+
+ if($load_details) {
+ //check if project really exists
+ $project = $this->loadProject($entry[0], false);
if($project === NULL)
continue;
- } else
+ } else
$project['name'] = $entry[0];
-
- $project['owner'] = $entry[1];
- $this->projects[] = $project;
- }
- } else {
- //walk through PROJECT_ROOT
-
- }
- }
-
- private function loadProject($name, $check_strict_export = true) {
- $project = array();
+
+ $project['owner'] = $entry[1];
+ $this->projects[] = $project;
+ }
+ } else {
+ //walk through PROJECT_ROOT
+
+ }
+ }
+
+ private function loadProject($name, $check_strict_export = true) {
+ $project = array();
$project['name'] = $name;
-
- $dir_seperator = (substr(GitConfig::PROJECT_ROOT, -1) == '/' ? '' : '/');
+
+ $dir_seperator = (substr(GitConfig::PROJECT_ROOT, -1) == '/' ? '' : '/');
if(!Validation::validate_path($name))
return NULL;
- if(is_dir(GitConfig::PROJECT_ROOT.$dir_seperator.$name))
- $project['path'] = GitConfig::PROJECT_ROOT.$dir_seperator.$name;
- else if(is_dir(GitConfig::PROJECT_ROOT.$dir_seperator.$name.".git"))
- $project['path'] = GitConfig::PROJECT_ROOT.$dir_seperator.$name.".git";
- else
- return NULL;
+ if(is_dir(GitConfig::PROJECT_ROOT.$dir_seperator.$name))
+ $project['path'] = GitConfig::PROJECT_ROOT.$dir_seperator.$name;
+ else if(is_dir(GitConfig::PROJECT_ROOT.$dir_seperator.$name.".git"))
+ $project['path'] = GitConfig::PROJECT_ROOT.$dir_seperator.$name.".git";
+ else
+ return NULL;
if(is_dir($project['path'].'/.git'))
$project['path'] .= '/.git';
- if(GitConfig::EXPORT_FILE && !file_exists($project['path'].'/'.GitConfig::EXPORT_FILE))
- return NULL;
-
- if(GitConfig::STRICT_EXPORT && $check_strict_export) {
- if($this->projects === NULL)
- $this->loadProjects(false);
- $found = false;
- foreach($this->projects as $p) {
- if(strtolower($p['name']) == strtolower($name)) {
- $found = true;
+ if(GitConfig::EXPORT_FILE && !file_exists($project['path'].'/'.GitConfig::EXPORT_FILE))
+ return NULL;
+
+ if(GitConfig::STRICT_EXPORT && $check_strict_export) {
+ if($this->projects === NULL)
+ $this->loadProjects(false);
+ $found = false;
+ foreach($this->projects as $p) {
+ if(strtolower($p['name']) == strtolower($name)) {
+ $found = true;
$project['name'] = $p['name'];
$project['owner'] = $p['owner'];
- break;
- }
- }
- if(!$found)
- return NULL;
- }
-
+ break;
+ }
+ }
+ if(!$found)
+ return NULL;
+ }
+
if(file_exists($project['path'].'/description'))
$project['description'] = file_get_contents($project['path'].'/description');
else
}
}
- return $project;
- }
-
- public function getProjectList() {
+ return $project;
+ }
+
+ public function getProjectList() {
$this->loadProjects();
- return $this->projects;
- }
-
- public function getProject($name) {
- return $this->loadProject($name);
- }
+ return $this->projects;
+ }
+
+ public function getProject($name) {
+ return $this->loadProject($name);
+ }
public function getLastChange($project) {
if(!array_key_exists('last_activity', $project)) {
}
}
return $project['refs'];
- }
+ }
}
?>
\ No newline at end of file
*/
class page_commit {
- private $page, $phpgitweb;
+ private $page, $phpgitweb;
- public function main($phpgitweb, $project) {
+ public function main($phpgitweb, $project) {
$this->phpgitweb = $phpgitweb;
if(!$project)
return new ContentProvider('main', 'err400');
*/
class page_commitdiff {
- private $page, $phpgitweb;
+ private $page, $phpgitweb;
- public function main($phpgitweb, $project) {
+ public function main($phpgitweb, $project) {
$this->phpgitweb = $phpgitweb;
if(!$project)
return new ContentProvider('main', 'err400');
*/
class page_projects {
- private $page, $phpgitweb;
+ private $page, $phpgitweb;
- public function main($phpgitweb, $project) {
+ public function main($phpgitweb, $project) {
$this->phpgitweb = $phpgitweb;
$this->page = new ContentProvider('projects', 'main');
else
$order = 'project';
- $this->page->set('header_project', new ContentProvider('projects', ($order == 'project' ? 'head_order_active' : 'head_order_link'), array('name' => "Project", 'tag' => "project")));
+ $this->page->set('header_project', new ContentProvider('projects', ($order == 'project' ? 'head_order_active' : 'head_order_link'), array('name' => "Project", 'tag' => "project")));
$this->page->set('header_description', new ContentProvider('projects', ($order == 'descr' ? 'head_order_active' : 'head_order_link'), array('name' => "Description", 'tag' => "descr")));
- $this->page->set('header_owner', new ContentProvider('projects', ($order == 'owner' ? 'head_order_active' : 'head_order_link'), array('name' => "Owner", 'tag' => "owner")));
+ $this->page->set('header_owner', new ContentProvider('projects', ($order == 'owner' ? 'head_order_active' : 'head_order_link'), array('name' => "Owner", 'tag' => "owner")));
$this->page->set('header_age', new ContentProvider('projects', ($order == 'age' ? 'head_order_active' : 'head_order_link'), array('name' => "Last Change", 'tag' => "age")));
switch($order) {
$ret = strcmp($a['name'], $b['name']);
return $ret;
}
-
+
private function project($class, $project) {
$entry = new ContentProvider('projects', 'project');
$entry->set('class', $class);
*/
class page_shortlog {
- private $page, $phpgitweb;
+ private $page, $phpgitweb;
- public function main($phpgitweb, $project) {
+ public function main($phpgitweb, $project) {
$this->phpgitweb = $phpgitweb;
$this->project = $project;
if(!$this->project)
require_once('pages/shortlog.class.php');
class page_summary {
- private $page, $phpgitweb;
+ private $page, $phpgitweb;
- public function main($phpgitweb, $project) {
+ public function main($phpgitweb, $project) {
$this->phpgitweb = $phpgitweb;
if(!$project)
return new ContentProvider('main', 'err400');