/**
 * @internal
 * Initialize URL routing
 */
function __route_init()
{
    if (!isset($_SERVER['HTTP_REFERER'])) {
        $_SERVER['HTTP_REFERER'] = '';
    }
    if (!isset($_SERVER['SERVER_PROTOCOL']) || $_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.0' && $_SERVER['SERVER_PROTOCOL'] != 'HTTP/1.1') {
        $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
    }
    if (isset($_SERVER['HTTP_HOST'])) {
        # As HTTP_HOST is user input, ensure it only contains characters allowed
        # in hostnames. See RFC 952 (and RFC 2181).
        # $_SERVER['HTTP_HOST'] is lowercased here per specifications.
        $_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']);
        if (!_validHost($_SERVER['HTTP_HOST'])) {
            # HTTP_HOST is invalid, e.g. if containing slashes it may be an attack.
            header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
            exit;
        }
    } else {
        # Some pre-HTTP/1.1 clients will not send a Host header. Ensure the key is
        # defined for E_ALL compliance.
        $_SERVER['HTTP_HOST'] = '';
    }
    # When clean URLs are enabled, emulate ?route=foo/bar using REQUEST_URI. It is
    # not possible to append the query string using mod_rewrite without the B
    # flag (this was added in Apache 2.2.8), because mod_rewrite unescapes the
    # path before passing it on to PHP. This is a problem when the path contains
    # e.g. "&" or "%" that have special meanings in URLs and must be encoded.
    $_GET[ROUTE] = route_request();
    _cfg('cleanRoute', $_GET[ROUTE]);
}
示例#2
0
function main()
{
    // создаем сессию
    session_start();
    // и выполняем маршрутизацию запроса
    route_request();
}
示例#3
0
			border-top: 6px solid transparent;
			border-left: 12px solid #B32900;
			border-bottom: 6px solid transparent;
			top: 3px;
		}
		body {
			background-color: black;
			font-family: "Helvetica", sans-serif;
			color: #CCC;
		}
		a {
			text-decoration: none;
		}
		a, a:active {
			color: #FF3B00;
		}
		a:visited {
			color: #B32900;
		}
		a:hover {
			color: #C06400;
		}
	</style>
</head>
<body>
<?php 
echo route_request($_REQUEST);
?>
</body>
</html>
示例#4
0
文件: index.php 项目: chinaares/nrdp
// Nagios Remote Data Processor (NRDP)
// Copyright (c) 2010 Nagios Enterprises, LLC.
//
// License: Nagios Open Software License <http://www.nagios.com/legal/licenses>
//
// $Id: index.php 12 2010-06-19 04:19:35Z egalstad $
require_once dirname(__FILE__) . '/config.inc.php';
require_once dirname(__FILE__) . '/includes/utils.inc.php';
// load plugins
load_plugins();
// grab GET or POST variables
grab_request_vars();
// check authorization
check_auth();
// handle the request
route_request();
function route_request()
{
    $cmd = strtolower(grab_request_var("cmd"));
    // token if required for most everyting
    if ($cmd != "" && $cmd != "hello") {
        check_token();
    }
    //echo "CMD='$cmd'<BR>";
    switch ($cmd) {
        // say hello
        case "hello":
            say_hello();
            break;
            // display a form for debugging/testing
        // display a form for debugging/testing
示例#5
0
         //$entries = array('southfields to east putney');
         //$entries = array('waterloo to paddington');
         $waypoints = array();
         $result = make_rail_waypoints($entries, $waypoints);
         if ($result['error'] == 200) {
             //qlog(__LINE__, $waypoints);
             $data = file_get_contents($p2p_path, FILE_BINARY);
             $links = clb_blob_dec($data);
             $prop = array();
             // 	$prop['units']  = 'km';
             $prop['opto'] = 'best';
             // 	$prop['opacity']  = 0.5;
             // 	$prop['color']  = '#880088';
             // 	$prop['getSteps']  = 1;
             // 	$prop['getPolyline']  = 1;
             $result = route_request($waypoints, $links, $prop);
         }
         qpre($result);
     }
     break;
 case 9:
     if (IS_CLI) {
         echo 'no function for mode 9';
     } else {
         //get array of pnum=>tubename
         $stops = do_query('SELECT pnum, name FROM places WHERE ptype in ("tube")', __FILE__, __LINE__, '*');
         $stops = array_combine($stops['pnum'], $stops['name']);
         //get array of links for tube and rail
         $sel = do_query('SELECT pnum, end1, end2 FROM links WHERE created>"2008-07-01" AND ptype in ("tube","rail")', __FILE__, __LINE__, '');
         //counts counts number of uses of each end point
         $counts = array();
$PATH = get_path();
#$CFG  = parse_ini_file($ROOT . 'etc/conf.ini', 1);
set_include_path(get_include_path() . PATH_SEPARATOR . $ROOT . PATH_SEPARATOR . $LIB);
#######################################################
# Common include files
#######################################################
include 'Smarty.class.php';
#######################################################
# Load and connect to database, if we need it.
#######################################################
if ($CFG['database']['use']) {
    require 'db.php';
    db_connect();
}
#$TMPL = template_path($ROOT);
$TMPL = route_request($PATH);
simple_tpl_display($TMPL);
#######################################################
# Helper functions
#######################################################
function route_request($path)
{
    #find the template to use or execute a PHP file
    $template = resolve_template($path);
    if ($template == NULL) {
        do_404($path);
        exit;
    }
    return $template;
}
function resolve_template($path)