PageRenderTime 39ms CodeModel.GetById 34ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/core/app/Globals.php

http://zoop.googlecode.com/
PHP | 79 lines | 49 code | 11 blank | 19 comment | 17 complexity | 55ec0c691d44daf3921dba9c8846065f MD5 | raw file
 1<?php
 2/**
 3 * app::config.php
 4 *
 5 * @author Rick Gigger
 6 * @version $Id$
 7 * @copyright __MyCompanyName__, 16 February, 2007
 8 * @package app
 9 **/
10
11//////////////////////////////////////////////
12//
13//	What we really want here is to define the following contants:
14//
15//	1) script_url		the url up to index.php or whatever the script name is
16//	2) virtual_path		the virtual path.  this comes directly after scriptname.php
17//	3) virtual_url		the url up through index.php and also the virtual path
18//
19//////////////////////////////////////////////
20// echo_r($_SERVER);
21if(php_sapi_name() != "cli")
22{
23	if( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' )
24		$protocol = 'https://';
25	else
26		$protocol = 'http://';
27	$sslProtocol = 'https://';
28	
29
30	$host = $_SERVER['HTTP_HOST'];
31	
32	$virtualPath = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (isset($_SERVER["ORIG_PATH_INFO"]) ? $_SERVER["ORIG_PATH_INFO"] : '');
33	//	what other situations besides mod_rewrite set this to 200?
34	if(isset($_SERVER['REDIRECT_STATUS']) && $_SERVER['REDIRECT_STATUS'] == 200)
35	{
36		$uri = $_SERVER['REQUEST_URI'];
37		if($pos = strpos($uri, '?'))
38			$uri = substr($uri, 0, $pos);
39		
40		if( $virtualPath && substr($uri, 0-strlen($virtualPath)) == $virtualPath )
41			$realPath = substr($uri, 0, strlen($uri) - strlen($virtualPath));
42		else
43			$realPath = $_SERVER['SCRIPT_NAME'];
44	}
45	else
46	{
47		$realPath = $_SERVER['SCRIPT_NAME'];
48	}
49	
50	define('root_url', $protocol . $host);
51	define('ssl_root_url', $sslProtocol . $host);
52	if(defined('script_url'))
53	{
54		define('back_script_url', root_url . $realPath);
55		define('back_virtual_url', back_script_url . $virtualPath);
56		define('back_pub_url', dirname(back_script_url) . '/public');
57	}
58	else
59	{
60		define('script_url', root_url . $realPath);
61		define('ssl_script_url', ssl_root_url . $realPath);
62	}
63	
64	define('app_url', dirname(script_url));
65	
66	if(isset($_SERVER['REDIRECT_STATUS']) && $_SERVER['REDIRECT_STATUS'] == 200)
67		define('base_url', script_url . '/');
68	else
69		define('base_url', script_url);
70	
71	define('virtual_path', $virtualPath);
72	define('virtual_url', script_url . virtual_path);
73	define('ssl_virtual_url', ssl_script_url . virtual_path);
74}
75
76if(!defined('E_DEPRECATED'))
77	define('E_DEPRECATED', 8192);
78
79define('version_53', version_compare(PHP_VERSION, '5.3.0') >= 0 ? true : false);