]> andersk Git - sql-web.git/commitdiff
minor portability fixes
authorJoe Presbrey <presbrey@mit.edu>
Fri, 17 Aug 2007 07:44:46 +0000 (07:44 +0000)
committerJoe Presbrey <presbrey@mit.edu>
Fri, 17 Aug 2007 07:44:46 +0000 (07:44 +0000)
git-svn-id: svn://presbrey.mit.edu/sql/web/dev@136 a142d4bd-2cfb-0310-9673-cb33a7e74f58

index.php
lib/security.lib.php
mitsql.cfg.php
tpl/index.php

index e8259684d013d8a624e47e291c8f7ee75c40c599..e8474a6aa5a22460b2f9bf4819499dc460eb9d52 100755 (executable)
--- 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');
index ee5cf37fa0ccefddb7257956c1c08509c0832f3c..fbdea6274b6c8d1ed31b03b7d3c5539a5723ca94 100644 (file)
@@ -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
index 6a5acfda080832a5c119e6d8905b3129491fad0c..3f5ed9d9511321960dcaff3a50df3026ab3193f4 100755 (executable)
@@ -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);
index 26ce4e87b83f677f29dd5c699a36946b65b8c1c9..e7cb30f173e9bd23f601014f8dd55d1bcdc67b12 100644 (file)
@@ -23,13 +23,13 @@ One nightly backup is available for your locker at <code>/mit/sql/backup/LOCKER_
 
 <div style="text-align:center; font-style: italic;">
 <?php
-if (!file_exists('/mit/sql/web_tmp/stat') || filemtime('/mit/sql/web_tmp/stat')+3600<time()) {
+if (!file_exists(TEMP_PATH.'/stat') || filemtime(TEMP_PATH.'/stat')+3600<time()) {
        $x = fetchRows(DBSelect("SHOW STATUS WHERE Variable_name IN ('Questions','Uptime')"),'Variable_name');
        $v = $x['Questions']['Value'];
        $t = $x['Uptime']['Value'];
-       file_put_contents('/mit/sql/web_tmp/stat',implode("\n",array($v,$t)));
+       file_put_contents(TEMP_PATH.'/stat',implode("\n",array($v,$t)));
 } else {
-       $x = file_get_contents('/mit/sql/web_tmp/stat');
+       $x = file_get_contents(TEMP_PATH.'/stat');
        list($v, $t) = explode("\n", $x);
 }
 $qavg = $v/$t;
This page took 0.056679 seconds and 5 git commands to generate.