} else { return ""; } } } if (empty($dbh)) { $options = array('persistent' => false, 'portability' => DB_PORTABILITY_ALL); $GLOBALS['_NODB'] = true; $dbh =& DB::connect(PEAR_DATABASE_DSN, $options); $GLOBALS['_NODB'] = false; } if (!isset($pear_rest)) { if (!DEVBOX) { $pear_rest = new pear_rest(PEAR_REST_DIR); } else { $pear_rest = new pear_rest(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'public_html' . DIRECTORY_SEPARATOR . 'rest'); } } $tmp = filectime($_SERVER['SCRIPT_FILENAME']); $LAST_UPDATED = date('D M d H:i:s Y', $tmp - date('Z', $tmp)) . ' UTC'; // set the session cookie lifetime to 2038 (this is the old behaviour, maybe we should change it to something shorter :)) if (!empty($_COOKIE['REMEMBER_ME'])) { call_user_func_array('session_set_cookie_params', array_merge(session_get_cookie_params(), array('lifetime' => time() + 86400))); } else { call_user_func_array('session_set_cookie_params', array_merge(session_get_cookie_params(), array('lifetime' => null))); } session_start(); init_auth_user(); if (!empty($_GET['logout']) && $_GET['logout'] === '1') { auth_logout(); }
function response_header($title = 'The PHP Extension Community Library', $style = false) { global $_style, $_header_done, $SIDEBAR_DATA, $extra_styles, $auth_user; if ($_header_done) { return; } $_header_done = true; $_style = $style; $rts = rtrim($SIDEBAR_DATA); if (substr($rts, -1) == '-') { $SIDEBAR_DATA = substr($rts, 0, -1); } else { global $main_menu, $docu_menu, $downloads_menu; $SIDEBAR_DATA .= draw_navigation($main_menu); $SIDEBAR_DATA .= draw_navigation($docu_menu, 'Documentation:'); $SIDEBAR_DATA .= draw_navigation($downloads_menu, 'Downloads:'); if (!$GLOBALS['_NODB']) { init_auth_user(); } else { $auth_user = null; } if (is_logged_in()) { global $developer_menu; $SIDEBAR_DATA .= draw_navigation($developer_menu, 'Developers:'); if (auth_check(true)) { global $admin_menu; $SIDEBAR_DATA .= draw_navigation($admin_menu, 'Administrators:'); } } } echo '<?xml version="1.0" encoding="ISO-8859-1" ?>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>PECL :: <?php echo $title; ?> </title> <link rel="shortcut icon" href="/gifs/pecl-favicon.ico" /> <link rel="stylesheet" href="/css/style.css" /> <?php foreach ($extra_styles as $style_file) { echo ' <link rel="stylesheet" href="' . $style_file . "\" />\n"; } ?> <link rel="alternate" type="application/rss+xml" title="RSS feed" href="http://<?php echo $_SERVER['HTTP_HOST']; ?> /feeds/latest.rss" /> </head> <body <?php if (!empty($GLOBALS['ONLOAD'])) { print "onload=\"" . $GLOBALS['ONLOAD'] . "\""; } ?> > <div> <a id="TOP"></a> </div> <!-- START HEADER --> <table class="head" cellspacing="0" cellpadding="0" width="100%"> <tr> <td class="head-logo"> <?php print_link('/', make_image('peclsmall.gif', 'PECL :: The PHP Extension Community Library', false, false, false, false, 'margin: 5px;')); ?> <br /> </td> <td class="head-menu"> <?php if (empty($auth_user)) { print_link('/login.php', 'Login', false, 'class="menuBlack"'); } else { print '<small class="menuWhite">'; print 'Logged in as ' . strtoupper($auth_user->handle) . ' ('; print '<a class="menuWhite" href="/user/' . $auth_user->handle . '">Info</a> | '; print '<a class="menuWhite" href="/account-edit.php?handle=' . $auth_user->handle . '">Profile</a> | '; print '<a class="menuWhite" href="https://bugs.php.net/search.php?cmd=display&status=Open&assign=' . $auth_user->handle . '">Bugs</a>'; print ")</small><br />\n"; print_link('/?logout=1', 'Logout', false, 'class="menuBlack"'); } echo delim(); print_link('/packages.php', 'Packages', false, 'class="menuBlack"'); echo delim(); print_link('/support.php', 'Support', false, 'class="menuBlack"'); echo delim(); print_link('/bugs/', 'Bugs', false, 'class="menuBlack"'); ?> <br /> <?php spacer(2, 2); ?> <br /> </td> </tr> <tr> <td class="head-search" colspan="2"> <form method="post" action="/search.php"> <p class="head-search"><span class="accesskey">S</span>earch for <input class="small" type="text" name="search_string" value="" size="20" accesskey="s" /> in the <select name="search_in" class="small"> <option value="packages">Packages</option> <option value="site">This site (using Google)</option> <option value="developers">Developers</option> <option value="pecl-dev">Developer mailing list</option> <option value="pecl-cvs">SVN commits mailing list</option> </select> <input type="image" src="/gifs/small_submit_white.gif" alt="search" style="vertical-align: middle;" /> <br /> </p> </form> </td> </tr> </table> <!-- END HEADER --> <!-- START MIDDLE --> <table class="middle" cellspacing="0" cellpadding="0"> <tr> <?php if (isset($SIDEBAR_DATA)) { ?> <!-- START LEFT SIDEBAR --> <td class="sidebar_left"> <?php echo $SIDEBAR_DATA; ?> </td> <!-- END LEFT SIDEBAR --> <?php } ?> <!-- START MAIN CONTENT --> <td class="content"> <?php }
function draw_navigation() { global $auth_user; // SELF doesn't cut it here, using REQUEST URI instead $self = strip_tags(htmlspecialchars(@$_SERVER['REQUEST_URI'], ENT_QUOTES, 'iso-8859-1')); if ($self === '/') { $self = '/index.php'; } include_once 'pear-auth.php'; init_auth_user(); $main_order = $main = $data = $sub = $rel = array(); $main_order[1] = '/index.php'; $main['/index.php'] = 'Main'; $sub['/index.php'] = array(); $sub['/index.php']['/index.php'] = 'Home'; $sub['/index.php']['/news/'] = 'News'; $sub['/index.php']['/qa/'] = 'Quality Assurance'; $sub['/index.php']['/group/'] = 'The PEAR Group'; $sub['/index.php']['/mirrors.php'] = 'Mirrors'; $main_order[2] = '/support/'; $main['/support/'] = 'Support'; $sub['/support/'] = array(); $sub['/support/']['/support/'] = 'Overview'; $sub['/support/']['/support/lists.php'] = 'Mailing Lists'; $sub['/support/']['/support/books.php'] = 'Books'; $sub['/support/']['/support/tutorials.php'] = 'Tutorials'; $sub['/support/']['/support/slides.php'] = 'Presentation Slides'; $sub['/support/']['/support/icons.php'] = 'Icons'; $sub['/support/']['/support/forums.php'] = 'Forums'; $main_order[3] = '/manual/'; $main['/manual/'] = 'Documentation'; $sub['/manual/'] = array(); $sub['/manual/']['/manual/en/about-pear.php'] = 'About PEAR'; $sub['/manual/']['/manual/'] = 'Manual'; $sub['/manual/']['/manual/en/faq.php'] = 'FAQ'; $main_order[4] = '/packages.php'; $main['/packages.php'] = 'Packages'; $sub['/packages.php'] = array(); if (!empty($auth_user) && !empty($auth_user->registered) && auth_check('pear.dev')) { $sub['/packages.php']['/package-new.php'] = 'New Package'; $sub['/packages.php']['/release-upload.php'] = 'Upload Release'; } $sub['/packages.php']['/packages.php'] = 'List Packages'; $sub['/packages.php']['/search.php'] = 'Search Packages'; $sub['/packages.php']['/package-stats.php'] = 'Statistics'; $sub['/packages.php']['/channels/'] = 'Channels'; $main_order[6] = '/accounts.php'; $main['/accounts.php'] = 'Developers'; $sub['/accounts.php'] = array(); $sub['/accounts.php']['/map/'] = 'Find a Developer'; $sub['/accounts.php']['/accounts.php'] = 'List Accounts'; $sub['/accounts.php']['/bugs/stats_dev.php'] = 'Developers Bug Statistics'; if (!empty($auth_user) && !empty($auth_user->registered) && auth_check('pear.dev')) { $sub['/accounts.php']['/release-upload.php'] = 'Upload Release'; $sub['/accounts.php']['/package-new.php'] = 'New Package'; $sub['/accounts.php']['/notes/admin/'] = 'Manage User Notes'; $sub['/accounts.php']['/election/'] = 'View Elections'; } $main_order[5] = '/pepr/'; $main['/pepr/'] = 'Package Proposals'; $sub['/pepr/'] = array(); $sub['/pepr/']['/pepr/'] = 'Browse Proposals'; $sub['/pepr/']['/pepr/pepr-proposal-edit.php'] = 'New Proposal'; $main_order[7] = '/bugs/'; $main['/bugs/'] = 'Bugs'; $sub['/bugs/'] = array(); $sub['/bugs/']['/bugs/search.php'] = 'Search for bugs'; $sub['/bugs/']['/bugs/stats.php'] = 'Package Bug Statistics'; if (!empty($auth_user) && $auth_user->isAdmin()) { $main_order[8] = '/admin/'; $main['/admin/'] = 'Administrators'; $sub['/admin/'] = array(); $sub['/admin/']['/admin/'] = 'Overview'; $sub['/admin/']['/admin/package-approval.php'] = 'Package approvals'; $sub['/admin/']['/admin/category-manager.php'] = 'Manage categories'; $sub['/admin/']['/tags/admin.php'] = 'Manage tags'; $sub['/admin/']['/admin/karma.php'] = 'Karma'; $sub['/admin/']['/admin/apidoc-log.php'] = 'APIdoc log'; } // Orders the main items in the proper order according to $main_order ksort($main_order); foreach ($main_order as $mo) { if (isset($main[$mo])) { $data[$mo] = $main[$mo]; } } // Relationship linker foreach (array_keys($sub) as $path) { $keys = array_keys($sub[$path]); $temp = array_fill_keys($keys, $path); $rel += $temp; } // Can't find a match, lets cut pieces of the url // lets first try sub dir + a php file if (!isset($rel[$self]) || $rel[$self] === null) { $pos = strpos($self, '.php'); $self = $pos !== false ? substr($self, 0, $pos + 4) : $self; } // Can't find a match, lets cut pieces of the url if ((!isset($rel[$self]) || $rel[$self] === null) && strlen($self) > 0) { $pos = strpos($self, '/', 1); $self = $pos !== false ? substr($self, 0, $pos + 1) : $self; } /* Check if it's a top level item. * There are cases were we don't want to put fake second level * menu item, like Bugs -> Index, the top level link serves as Index */ if (isset($data[$self])) { $rel += array($self => $self); } // avoid a notice if the array key isn't set if (!array_key_exists($self, $rel)) { $rel[$self] = null; } // Not really menu items but required so the correct // sub menu item gets selected $fake = array('/developers/' => '/accounts.php', '/user/' => '/accounts.php', '/package/' => '/packages.php', '/package-edit.php' => '/packages.php', '/package-delete.php' => '/packages.php'); if (isset($fake[$self])) { $self = $fake[$self]; } // Still no luck, lets fallback on index.php if ($rel[$self] === null) { $self = '/index.php'; } $menu = array(); $menu['main'] = make_menu($data, 'menu', $rel[$self]); $menu['sub'] = make_menu($sub[$rel[$self]], 'submenu', $self); return $menu; }