$value) {
if (isset($data[$i])) {
$return_vars[$name] = $data[$i];
$i++;
} else {
$return_vars[$name] = $value;
}
}
return $return_vars;
}
/* Pathinfo retrieval minus starting slash */
function mtrack_get_pathinfo($no_strip = false) {
$pi = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : NULL;
if ($pi !== NULL && strlen($pi) && $no_strip == false) {
$pi = substr($pi, 1);
}
return $pi;
}
function mtrack_calc_root()
{
/* ABSWEB: the absolute URL to the base of the web app */
global $ABSWEB;
/* if they have one, use the weburl config value for this */
$ABSWEB = MTrackConfig::get('core', 'weburl');
if (strlen($ABSWEB)) {
return;
}
/* otherwise, determine the root of the app.
* This is complicated because the DOCUMENT_ROOT may refer to an area that
* is completely unrelated to the actual root of the web application, for
* instance, in the case that the user has a public_html dir where they
* are running mtrack */
/* determine the root of the app */
$sdir = dirname($_SERVER['SCRIPT_FILENAME']);
$idir = dirname(dirname(__FILE__)) . '/web';
$diff = substr($sdir, strlen($idir)+1);
$rel = preg_replace('@[^/]+@', '..', $diff);
if (strlen($rel)) {
$rel .= '/';
}
/* $rel is now the relative path to the root of the web app, from the current
* page */
if (isset($_SERVER['HTTP_HOST'])) {
$ABSWEB = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ?
'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
} else {
$ABSWEB = 'http://localhost';
}
$bits = explode('/', $rel);
$base = $_SERVER['SCRIPT_NAME'];
foreach ($bits as $b) {
$base = dirname($base);
}
if ($base == '/') {
$ABSWEB .= '/';
} else {
$ABSWEB .= $base . '/';
}
}
mtrack_calc_root();
function mtrack_head($title, $navbar = true)
{
global $ABSWEB;
static $mtrack_did_head;
$whoami = mtrack_username(MTrackAuth::whoami(),
array(
'no_image' => true
)
);
if ($mtrack_did_head) {
return;
}
$mtrack_did_head = true;
$projectname = htmlentities(MTrackConfig::get('core', 'projectname'),
ENT_QUOTES, 'utf-8');
$logo = MTrackConfig::get('core', 'projectlogo');
if (strlen($logo)) {
$projectname = "";
}
$fav = MTrackConfig::get('core', 'favicon');
if (strlen($fav)) {
$fav = <<
HTML;
echo <<
HTML;
$nav = array();
if (MTrackAuth::whoami() !== 'anonymous') {
// $nav['/'] = 'Today';
}
$navcandidates = array(
"/Browse.php" => array("Browse", 'read', 'Browser'),
// "/wiki.php" => array("Wiki", 'read', 'Wiki'),
"/timeline.php" => array("Timeline", 'read', 'Timeline'),
// "/roadmap.php" => array("Roadmap", 'read', 'Roadmap'),
"/report.php/1" => array("Active Tickets", 'read', 'Reports'),
"/report.php/3" => array("Pending Review", 'read', 'Reports'),
"/Ticket.php/new" => array("New Ticket", 'create', 'Tickets'),
// "/snippet.php" => array("Snippets", 'read', 'Snippets'),
"/admin/" => array("Administration", 'modify', 'Enumerations', 'Components', 'Projects', 'Browser'),
);
foreach ($navcandidates as $url => $data) {
$label = array_shift($data);
$right = array_shift($data);
$ok = false;
foreach ($data as $object) {
if (MTrackACL::hasAllRights($object, $right)) {
$ok = true;
break;
}
}
if ($ok) {
$nav[$url] = $label;
}
}
echo mtrack_nav('mainnav', $nav);
echo <<
HTML;
}
if (MTrackConfig::get('core', 'admin_party') == 1 &&
MTrackAuth::whoami() == 'adminparty' &&
($_SERVER['REMOTE_ADDR'] == '127.0.0.1' ||
$_SERVER['REMOTE_ADDR'] == '::1')) {
echo <<
Welcome to the admin party! Authentication is not yet configured;
while it is in this state, any user connecting from the localhost
address is treated as having admin rights (that includes you, and this
is why you are seeing this message). All other users are treated
as anonymous users. Click here to Configure Authentication
HTML;
} elseif (!MTrackAuth::isAuthConfigured() &&
MTrackConfig::get('core', 'admin_party') == 1)
{
$localaddr = preg_replace('@^(https?://)([^/]+)/(.*)$@',
"\\1localhost/\\3", $ABSWEB);
echo <<
Authentication is not yet configured. If you are the admin,
you should use the localhost address
to reach the system and configure it.
HTML;
} elseif (!MTrackAuth::isAuthConfigured()) {
echo <<
Authentication is not yet configured. If you are the admin,
you will need to edit the config.ini file to configure authentication.
HTML;
}
if (ini_get('magic_quotes_gpc') === true ||
!strcasecmp(ini_get('magic_quotes_gpc'), 'on')) {
echo <<
magic_quotes_gpc is enabled. This causes mtrack not to work.
Please disable this setting in your server configuration.
HTML;
}
echo <<
HTML;
}
function mtrack_foot($visible_markup = true)
{
echo <<
HTML;
if ($visible_markup) {
echo <<