dwing
changeset 153:f4f258c4de48
get rid of and also make Core:: work with https and non-standard ports
| author | Arpad Borsos <arpad.borsos@googlemail.com> |
|---|---|
| date | Sat Jul 18 15:46:52 2009 +0200 (2009-07-18) |
| parents | 26eeeb47a559 |
| children | 69ae49dca9b6 |
| files | .htaccess TODO inc/rest.class.php inc/user.class.php index.php tpl/default/atom.tpl.php tpl/default/header.tpl.php tpl/default/rdf.tpl.php tpl/default/rss.tpl.php |
line diff
1.1 --- a/.htaccess Sat Jul 18 08:51:11 2009 +0200 1.2 +++ b/.htaccess Sat Jul 18 15:46:52 2009 +0200 1.3 @@ -3,4 +3,4 @@ 1.4 RewriteCond %{REQUEST_FILENAME} !-d 1.5 RewriteCond %{REQUEST_FILENAME} !-f 1.6 1.7 -RewriteRule ^(.*)$ /index.php/$1 [L] 1.8 +RewriteRule ^(.*)$ ./index.php/$1 [L]
2.1 --- a/TODO Sat Jul 18 08:51:11 2009 +0200 2.2 +++ b/TODO Sat Jul 18 15:46:52 2009 +0200 2.3 @@ -13,7 +13,6 @@ 2.4 - start using John Resigs JS templates 2.5 - start using TextPrefill 2.6 - maybe use jQuery ajax methods inside REST functions? 2.7 -- make all GLOBALS static Core:: members 2.8 - maybe do all stuff that's inside index.php in Core::_construct()? 2.9 - Make Rating and Tags into ActiveRecord-like classes 2.10 - Make ContentItem __get() automatically fetch related ContentListeners
3.1 --- a/inc/rest.class.php Sat Jul 18 08:51:11 2009 +0200 3.2 +++ b/inc/rest.class.php Sat Jul 18 15:46:52 2009 +0200 3.3 @@ -79,10 +79,14 @@ 3.4 3.5 public function __construct() 3.6 { 3.7 - $webRoot = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']); 3.8 - if($webRoot{strlen($webRoot)-1} != '/') 3.9 + $isHttps = !empty($_SERVER['HTTPS']); 3.10 + $port = ($isHttps && $_SERVER['SERVER_PORT'] == 443 ? '' : ( 3.11 + !$isHttps && $_SERVER['SERVER_PORT'] == 80 ? '' : 3.12 + ':'.$_SERVER['SERVER_PORT'])); 3.13 + $webRoot = ($isHttps ? 'https' : 'http').'://'.$_SERVER['SERVER_NAME'].$port.dirname($_SERVER['SCRIPT_NAME']); 3.14 + if($webRoot[strlen($webRoot)-1] != '/') 3.15 $webRoot.= '/'; 3.16 - $GLOBALS['webRoot'] = $webRoot; 3.17 + Core::$webRoot = $webRoot; 3.18 3.19 $url = !empty($_SERVER['PATH_INFO']) ? trim($_SERVER['PATH_INFO'], '/') : ''; 3.20
4.1 --- a/inc/user.class.php Sat Jul 18 08:51:11 2009 +0200 4.2 +++ b/inc/user.class.php Sat Jul 18 15:46:52 2009 +0200 4.3 @@ -285,7 +285,7 @@ 4.4 if(empty($_SESSION['returnto'])) 4.5 $_SESSION['returnto'] = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; 4.6 4.7 - $webroot = $GLOBALS['webRoot']; 4.8 + $webroot = Core::$webRoot; 4.9 header("Location: ".$authRequest->redirectURL( 4.10 $webroot, 4.11 $webroot.'login?completelogin=1', 4.12 @@ -313,7 +313,7 @@ 4.13 $store = new Auth_OpenID_MySQLStore(Core::$db); 4.14 $store->createTables(); 4.15 $consumer = new Auth_OpenID_Consumer($store); 4.16 - $returnUrl = $GLOBALS['webRoot'].'login?completelogin=1'; 4.17 + $returnUrl = Core::$webRoot.'login?completelogin=1'; 4.18 $response = $consumer->complete($returnUrl); 4.19 Core::$db->setAttribute(PDO::ATTR_AUTOCOMMIT, true); 4.20 if(!$response)
5.1 --- a/index.php Sat Jul 18 08:51:11 2009 +0200 5.2 +++ b/index.php Sat Jul 18 15:46:52 2009 +0200 5.3 @@ -35,6 +35,7 @@ 5.4 public static $user; 5.5 public static $config; 5.6 public static $tpl; 5.7 + public static $webRoot; 5.8 } 5.9 5.10 // start session management
6.1 --- a/tpl/default/atom.tpl.php Sat Jul 18 08:51:11 2009 +0200 6.2 +++ b/tpl/default/atom.tpl.php Sat Jul 18 15:46:52 2009 +0200 6.3 @@ -1,7 +1,7 @@ 6.4 <?php 6.5 header('Content-Type: application/atom+xml'); 6.6 echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; 6.7 -$webroot = $GLOBALS['webRoot']; 6.8 +$webroot = Core::$webRoot; 6.9 $newsall = new NewsRange(); 6.10 ?> 6.11 <feed xmlns="http://www.w3.org/2005/Atom">
7.1 --- a/tpl/default/header.tpl.php Sat Jul 18 08:51:11 2009 +0200 7.2 +++ b/tpl/default/header.tpl.php Sat Jul 18 15:46:52 2009 +0200 7.3 @@ -1,5 +1,5 @@ 7.4 <?php 7.5 -$webroot = $GLOBALS['webRoot']; 7.6 +$webroot = Core::$webRoot; 7.7 7.8 // do User sign in only in the templates that need the user to be signed in 7.9 try
8.1 --- a/tpl/default/rdf.tpl.php Sat Jul 18 08:51:11 2009 +0200 8.2 +++ b/tpl/default/rdf.tpl.php Sat Jul 18 15:46:52 2009 +0200 8.3 @@ -1,7 +1,7 @@ 8.4 <?php 8.5 header('Content-Type: application/xml'); 8.6 echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; 8.7 -$webroot = $GLOBALS['webRoot']; 8.8 +$webroot = Core::$webRoot; 8.9 $newsall = new NewsRange(); 8.10 ?> 8.11 <rdf:RDF
9.1 --- a/tpl/default/rss.tpl.php Sat Jul 18 08:51:11 2009 +0200 9.2 +++ b/tpl/default/rss.tpl.php Sat Jul 18 15:46:52 2009 +0200 9.3 @@ -1,7 +1,7 @@ 9.4 <?php 9.5 header('Content-Type: application/rss+xml'); 9.6 echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; 9.7 -$webroot = $GLOBALS['webRoot']; 9.8 +$webroot = Core::$webRoot; 9.9 $newsall = new NewsRange(); 9.10 ?> 9.11 <rss version="2.0">
