From: Joe Presbrey Date: Fri, 17 Aug 2007 07:44:46 +0000 (+0000) Subject: minor portability fixes X-Git-Url: http://andersk.mit.edu/gitweb/sql-web.git/commitdiff_plain/7654fe787e1be12afdaa8b5b5d866f9712b5e3fb minor portability fixes git-svn-id: svn://presbrey.mit.edu/sql/web/dev@136 a142d4bd-2cfb-0310-9673-cb33a7e74f58 --- diff --git a/index.php b/index.php index e825968..e8474a6 100755 --- a/index.php +++ b/index.php @@ -10,7 +10,7 @@ require_once('mitsql.cfg.php'); require_once('mitsql.lib.php'); isLoggedIn() && redirect('main'); -!DEBUG && $_SERVER['SERVER_NAME'] != 'sql.mit.edu' && redirect2('http://sql.mit.edu/'); +!DEVEL && $_SERVER['SERVER_NAME'] != 'sql.mit.edu' && redirect2('http://sql.mit.edu/'); //$LoginSSL->canSignup() && redirect('signup'); //redirect('login'); diff --git a/lib/security.lib.php b/lib/security.lib.php index ee5cf37..fbdea62 100644 --- a/lib/security.lib.php +++ b/lib/security.lib.php @@ -295,23 +295,21 @@ function getSSLCert() { ## 302 REDIRECTS function redirect($target=null,$secure=null) { - $base = (is_null($target)||substr($target,0,1)=='?')?$_SERVER['REDIRECT_URL']:(dirname($_SERVER['REDIRECT_URL']).'/'); + $base = (is_null($target)||substr($target,0,1)=='?')?URI:(dirname(URI).'/'); redirectFull(is_null($target)?$base:($base.$target),$secure); } function redirectStart() { redirectFull(BASE_URL,null); } function redirectFull($target,$secure) { - //redirect2((((isSSL()&&is_null($secure))||$secure==true)?'https://':'http://').$_SERVER['SERVER_NAME'].$target); - redirect2((((isSSL()&&is_null($secure))||$secure==true)?'https://scripts-cert.mit.edu':'http://scripts.mit.edu').$target); + redirect2((((isSSL()&&is_null($secure))||$secure==true)?BASE_HTTPS:BASE_HTTP).$target); } function redirect2($target) { header('Location: '.$target); exit; } function flipSSL() { - //return (isSSL()?'http://':'https://').$_SERVER['SERVER_NAME'].$_SERVER['REDIRECT_URL']; - return (isSSL()?'http://scripts.mit.edu':'https://scripts-cert.mit.edu').$_SERVER['REDIRECT_URL']; + return (isSSL()?BASE_HTTP:BASE_HTTPS).URI; } ## USER SCRIPTS diff --git a/mitsql.cfg.php b/mitsql.cfg.php index 6a5acfd..3f5ed9d 100755 --- a/mitsql.cfg.php +++ b/mitsql.cfg.php @@ -22,6 +22,8 @@ if (DEVEL) { define('VERSION', VER); defined('BASE_URL') || define('BASE_URL', '/~sql/main/'); } +defined('BASE_HTTP') || define('BASE_HTTP', 'http://sql.mit.edu'); +defined('BASE_HTTPS') || define('BASE_HTTPS', 'https://sql.mit.edu'); define('DELIMETER', '+'); defined('DBHOST') || define('DBHOST', 'sql.mit.edu'); @@ -31,8 +33,15 @@ defined('ADMINDB') || define('ADMINDB', 'mitsql'); $BASE_PATH = dirname(__FILE__).'/'; define('BASE_PATH', $BASE_PATH); +defined('TEMP_PATH') || define('TEMP_PATH', '/tmp'); $URI = (isset($_SERVER["REDIRECT_URL"])?$_SERVER["REDIRECT_URL"]:''); -$URI = ((empty($URI) && isset($_SERVER['REQUEST_URI']))?$_SERVER['REQUEST_URI']:$URI); +if (empty($URI) && isset($_SERVER['REQUEST_URI'])) { + if (empty($_SERVER['QUERY_STRING'])) { + $URI = $_SERVER['REQUEST_URI']; + } else { + $URI = substr($_SERVER['REQUEST_URI'], 0, -strlen($_SERVER['QUERY_STRING'])-1); + } +} define('URI', $URI); $THIS_PAGE = str_replace(BASE_URL, '', URI); define('THIS_PAGE', $THIS_PAGE); diff --git a/tpl/index.php b/tpl/index.php index 26ce4e8..e7cb30f 100644 --- a/tpl/index.php +++ b/tpl/index.php @@ -23,13 +23,13 @@ One nightly backup is available for your locker at /mit/sql/backup/LOCKER_