1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | <?php /* * index.php * gitphp: A PHP git repository browser * Component: Index script * * Copyright (C) 2006 Christopher Han <xiphux@gmail.com> */ ob_start(); /* * Version */ include_once('include/version.php'); /* * Constants */ require_once('include/defs.constants.php'); /* * Configuration */ require_once('config/gitphp.conf.php'); /* * Instantiate Smarty */ require_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php"); $tpl =& new Smarty; if (isset($_GET['a']) && ($_GET['a'] != "commitdiff_plain") && ($_GET['a'] != "blob_plain") && ($_GET['a'] != "blobdiff_plain") && ($_GET['a'] != "opml")) { $tpl->load_filter('output','trimwhitespace'); } $rss_link = FALSE; $suppress_headers = FALSE; ob_start(); if (isset($_GET['a']) && $_GET['a'] == "opml") { $suppress_headers = TRUE; require_once('include/display.git_opml.php'); git_opml($gitphp_conf['projectroot'],$git_projects); } else if (isset($_GET['a']) && $_GET['a'] == "project_index") { $suppress_headers = TRUE; require_once('include/display.git_project_index.php'); git_project_index($gitphp_conf['projectroot'],$git_projects); } else if (isset($_GET['p'])) { if (!is_dir($gitphp_conf['projectroot'] . $_GET['p'])) echo "No such directory"; else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD")) echo "No such project"; else { $rss_link = TRUE; if (!isset($_GET['a'])) { require_once('include/display.git_summary.php'); git_summary($gitphp_conf['projectroot'],$_GET['p']); } else { switch ($_GET['a']) { case "summary": require_once('include/display.git_summary.php'); git_summary($gitphp_conf['projectroot'],$_GET['p']); break; case "tree": require_once('include/display.git_tree.php'); git_tree($gitphp_conf['projectroot'], $_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL)); break; case "shortlog": require_once('include/display.git_shortlog.php'); git_shortlog($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL)); break; case "log": require_once('include/display.git_log.php'); git_log($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL)); break; case "commit": require_once('include/display.git_commit.php'); git_commit($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']); break; case "commitdiff": require_once('include/display.git_commitdiff.php'); git_commitdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'], (isset($_GET['hp']) ? $_GET['hp'] : NULL)); break; case "commitdiff_plain": $suppress_headers = TRUE; require_once('include/display.git_commitdiff_plain.php'); git_commitdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['hp']) ? $_GET['hp'] : NULL)); break; case "heads": require_once('include/display.git_heads.php'); git_heads($gitphp_conf['projectroot'],$_GET['p']); break; case "tags": require_once('include/display.git_tags.php'); git_tags($gitphp_conf['projectroot'],$_GET['p']); break; case "rss": $suppress_headers = TRUE; require_once('include/display.git_rss.php'); git_rss($gitphp_conf['projectroot'],$_GET['p']); break; case "blob": require_once('include/display.git_blob.php'); git_blob($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL)); break; case "blob_plain": $suppress_headers = TRUE; require_once('include/display.git_blob_plain.php'); git_blob_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['f']) ? $_GET['f'] : NULL)); break; case "blobdiff": require_once('include/display.git_blobdiff.php'); git_blobdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],(isset($_GET['f']) ? $_GET['f'] : NULL)); break; case "blobdiff_plain": $suppress_headers = TRUE; require_once('include/display.git_blobdiff_plain.php'); git_blobdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'], (isset($_GET['f']) ? $_GET['f'] : NULL)); break; case "snapshot": $suppress_headers = TRUE; require_once('include/display.git_snapshot.php'); git_snapshot($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL)); break; case "history": require_once('include/display.git_history.php'); git_history($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL),$_GET['f']); break; case "search": if (isset($_GET['st']) && ($_GET['st'] == 'file')) { require_once('include/display.git_search_files.php'); git_search_files($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL),(isset($_GET['s']) ? $_GET['s'] : NULL),(isset($_GET['pg']) ? $_GET['pg'] : 0)); } else { require_once('include/display.git_search.php'); git_search($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL),(isset($_GET['s']) ? $_GET['s'] : NULL),(isset($_GET['st']) ? $_GET['st'] : "commit"),(isset($_GET['pg']) ? $_GET['pg'] : 0)); } break; case "tag": require_once('include/display.git_tag.php'); git_tag($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']); break; default: echo "Unknown action"; break; } } } } else { $tpl->display("hometext.tpl"); require_once('include/display.git_project_list.php'); git_project_list($gitphp_conf['projectroot'],$git_projects,(isset($_GET['o']) ? $_GET['o'] : "project")); } $main = ob_get_contents(); ob_end_clean(); if (!$suppress_headers) { $tpl->clear_all_assign(); $tpl->assign("stylesheet",$gitphp_conf['stylesheet']); $tpl->assign("version",$gitphp_version); $title = $gitphp_conf['title']; if ($rss_link) { $tpl->assign("rss_link",TRUE); $tpl->assign("project",$_GET['p']); $title .= " :: " . $_GET['p']; if (isset($_GET['a'])) { $tpl->assign("action",$_GET['a']); $title .= "/" . $_GET['a']; } } $tpl->assign("title",$title); if (isset($_GET['st'])) $tpl->assign("searchtype",$_GET['st']); else $tpl->assign("searchtype","commit"); if (isset($_GET['s'])) $tpl->assign("search",$_GET['s']); if (isset($_GET['hb'])) $tpl->assign("hash",$_GET['hb']); else if (isset($_GET['h'])) $tpl->assign("hash",$_GET['h']); if ($gitphp_conf['search']) $tpl->assign("enablesearch",TRUE); if ($gitphp_conf['filesearch']) $tpl->assign("filesearch",TRUE); $tpl->display("header.tpl"); } echo $main; if (!$suppress_headers) { if ($rss_link) { $tpl->assign("project",$_GET['p']); require_once('include/gitutil.git_project_descr.php'); $tpl->assign("descr",git_project_descr($gitphp_conf['projectroot'],$_GET['p'])); } $tpl->display("footer.tpl"); } ob_end_flush(); ?> |