Fix undefined order warning
[gitphp.git] / index.php
blob:a/index.php -> blob:b/index.php
<?php <?php
  error_reporting(E_ALL | E_STRICT);
/* /*
* index.php * index.php
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Index script * Component: Index script
* *
* Copyright (C) 2006 Christopher Han <xiphux@gmail.com> * Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
*/ */
ob_start(); ob_start();
   
/* /*
* Version * Version
*/ */
include_once('include/version.php'); include_once('include/version.php');
   
/* /*
* Configuration * Configuration
*/ */
include_once('config/gitphp.conf.php'); include_once('config/gitphp.conf.php');
   
/* /*
* Instantiate Smarty * Instantiate Smarty
*/ */
include_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php"); include_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php");
$tpl =& new Smarty; $tpl =& new Smarty;
$tpl->load_filter('output','trimwhitespace'); $tpl->load_filter('output','trimwhitespace');
   
$rss_link = FALSE; $rss_link = FALSE;
$suppress_headers = FALSE; $suppress_headers = FALSE;
   
ob_start(); ob_start();
if (isset($_GET['a']) && $_GET['a'] == "opml") { if (isset($_GET['a']) && $_GET['a'] == "opml") {
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_opml.php'); include_once('include/display.git_opml.php');
git_opml($gitphp_conf['projectroot'],$git_projects); git_opml($gitphp_conf['projectroot'],$git_projects);
} else if (isset($_GET['a']) && $_GET['a'] == "project_index") { } else if (isset($_GET['a']) && $_GET['a'] == "project_index") {
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_project_index.php'); include_once('include/display.git_project_index.php');
git_project_index($gitphp_conf['projectroot'],$git_projects); git_project_index($gitphp_conf['projectroot'],$git_projects);
} else if (isset($_GET['p'])) { } else if (isset($_GET['p'])) {
if (!is_dir($gitphp_conf['projectroot'] . $_GET['p'])) if (!is_dir($gitphp_conf['projectroot'] . $_GET['p']))
echo "No such directory"; echo "No such directory";
else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD")) else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD"))
echo "No such project"; echo "No such project";
else { else {
$rss_link = TRUE; $rss_link = TRUE;
if (!isset($_GET['a'])) { if (!isset($_GET['a'])) {
include_once('include/display.git_summary.php'); include_once('include/display.git_summary.php');
git_summary($gitphp_conf['projectroot'],$_GET['p']); git_summary($gitphp_conf['projectroot'],$_GET['p']);
} else { } else {
switch ($_GET['a']) { switch ($_GET['a']) {
case "summary": case "summary":
include_once('include/display.git_summary.php'); include_once('include/display.git_summary.php');
git_summary($gitphp_conf['projectroot'],$_GET['p']); git_summary($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "tree": case "tree":
include_once('include/display.git_tree.php'); include_once('include/display.git_tree.php');
git_tree($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f'],$_GET['hb']); git_tree($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f'],$_GET['hb']);
break; break;
case "shortlog": case "shortlog":
include_once('include/display.git_shortlog.php'); include_once('include/display.git_shortlog.php');
git_shortlog($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']); git_shortlog($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']);
break; break;
case "log": case "log":
include_once('include/display.git_log.php'); include_once('include/display.git_log.php');
git_log($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']); git_log($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']);
break; break;
case "commit": case "commit":
include_once('include/display.git_commit.php'); include_once('include/display.git_commit.php');
git_commit($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']); git_commit($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']);
break; break;
case "commitdiff": case "commitdiff":
include_once('include/display.git_commitdiff.php'); include_once('include/display.git_commitdiff.php');
git_commitdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hp']); git_commitdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hp']);
break; break;
case "commitdiff_plain": case "commitdiff_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_commitdiff_plain.php'); include_once('include/display.git_commitdiff_plain.php');
git_commitdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hp']); git_commitdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hp']);
break; break;
case "heads": case "heads":
include_once('include/display.git_heads.php'); include_once('include/display.git_heads.php');
git_heads($gitphp_conf['projectroot'],$_GET['p']); git_heads($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "tags": case "tags":
include_once('include/display.git_tags.php'); include_once('include/display.git_tags.php');
git_tags($gitphp_conf['projectroot'],$_GET['p']); git_tags($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "rss": case "rss":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_rss.php'); include_once('include/display.git_rss.php');
git_rss($gitphp_conf['projectroot'],$_GET['p']); git_rss($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "blob": case "blob":
include_once('include/display.git_blob.php'); include_once('include/display.git_blob.php');
git_blob($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f'],$_GET['hb']); git_blob($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f'],$_GET['hb']);
break; break;
case "blob_plain": case "blob_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_blob_plain.php'); include_once('include/display.git_blob_plain.php');
git_blob_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f']); git_blob_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f']);
break; break;
case "blobdiff": case "blobdiff":
include_once('include/display.git_blobdiff.php'); include_once('include/display.git_blobdiff.php');
git_blobdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],$_GET['f']); git_blobdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],$_GET['f']);
break; break;
case "blobdiff_plain": case "blobdiff_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_blobdiff_plain.php'); include_once('include/display.git_blobdiff_plain.php');
git_blobdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],$_GET['f']); git_blobdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],$_GET['f']);
break; break;
case "snapshot": case "snapshot":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_snapshot.php'); include_once('include/display.git_snapshot.php');
git_snapshot($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']); git_snapshot($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']);
break; break;
case "history": case "history":
include_once('include/display.git_history.php'); include_once('include/display.git_history.php');
git_history($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f']); git_history($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f']);
break; break;
default: default:
echo "Unknown action"; echo "Unknown action";
break; break;
} }
} }
} }
} else { } else {
$tpl->display("hometext.tpl"); $tpl->display("hometext.tpl");
include_once('include/display.git_project_list.php'); include_once('include/display.git_project_list.php');
git_project_list($gitphp_conf['projectroot'],$git_projects,$_GET['o']); git_project_list($gitphp_conf['projectroot'],$git_projects,(isset($_GET['o']) ? $_GET['o'] : "project"));
} }
$main = ob_get_contents(); $main = ob_get_contents();
ob_end_clean(); ob_end_clean();
   
if (!$suppress_headers) { if (!$suppress_headers) {
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("stylesheet",$gitphp_conf['stylesheet']); $tpl->assign("stylesheet",$gitphp_conf['stylesheet']);
$tpl->assign("version",$gitphp_version); $tpl->assign("version",$gitphp_version);
$title = $gitphp_conf['title']; $title = $gitphp_conf['title'];
if ($rss_link) { if ($rss_link) {
$tpl->assign("rss_link",TRUE); $tpl->assign("rss_link",TRUE);
$tpl->assign("project",$_GET['p']); $tpl->assign("project",$_GET['p']);
$title .= " :: " . $_GET['p']; $title .= " :: " . $_GET['p'];
if (isset($_GET['a'])) { if (isset($_GET['a'])) {
$tpl->assign("action",$_GET['a']); $tpl->assign("action",$_GET['a']);
$title .= "/" . $_GET['a']; $title .= "/" . $_GET['a'];
} }
} }
$tpl->assign("title",$title); $tpl->assign("title",$title);
$tpl->display("header.tpl"); $tpl->display("header.tpl");
} }
   
echo $main; echo $main;
   
if (!$suppress_headers) { if (!$suppress_headers) {
if ($rss_link) { if ($rss_link) {
$tpl->assign("project",$_GET['p']); $tpl->assign("project",$_GET['p']);
include_once('include/gitutil.git_project_descr.php'); include_once('include/gitutil.git_project_descr.php');
$tpl->assign("descr",git_project_descr($gitphp_conf['projectroot'],$_GET['p'])); $tpl->assign("descr",git_project_descr($gitphp_conf['projectroot'],$_GET['p']));
} }
$tpl->display("footer.tpl"); $tpl->display("footer.tpl");
} }
   
ob_end_flush(); ob_end_flush();
   
?> ?>
   
comments