From 8ed5cf0132d45b10a72923502677333626a359e5 Mon Sep 17 00:00:00 2001 From: Joe Presbrey Date: Wed, 30 Nov 2005 14:21:57 +0000 Subject: [PATCH] contact: page formatting global.act,mitsql.cfg,menu: offline aware offline: show message for maintenance time contrib: demo optional files security.lib: isOffline checkProcesses: only email if there are targets bin: hold some shell scripts git-svn-id: svn://presbrey.mit.edu/sql/mitsql@80 a142d4bd-2cfb-0310-9673-cb33a7e74f58 --- bin/updateMain.sh | 6 ++++ contact.php | 6 ++-- contrib/.forceauth | 1 + contrib/server.cfg.php | 34 +++++++++++++++++++ cron/checkProcesses.php | 3 +- global.act.php | 73 ++++++++++++++++++++++------------------- lib/security.lib.php | 8 +++++ mitsql.cfg.php | 14 ++++++-- offline.php | 13 ++++++++ tpl/contact.php | 6 +++- tpl/head.php | 16 ++++++++- tpl/index.php | 7 ---- tpl/main.php | 2 +- tpl/menu.php | 2 -- tpl/offline.php | 16 +++++++++ 15 files changed, 154 insertions(+), 53 deletions(-) create mode 100755 bin/updateMain.sh create mode 100755 contrib/.forceauth create mode 100755 contrib/server.cfg.php create mode 100755 offline.php create mode 100755 tpl/offline.php diff --git a/bin/updateMain.sh b/bin/updateMain.sh new file mode 100755 index 0000000..cb5d738 --- /dev/null +++ b/bin/updateMain.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +pushd ~/web_scripts/main/ >/dev/null +svn up +sh ../perm.sh +popd >/dev/null diff --git a/contact.php b/contact.php index 3e99683..68ecd24 100644 --- a/contact.php +++ b/contact.php @@ -3,9 +3,9 @@ require_once('mitsql.cfg.php'); require_once('mitsql.lib.php'); -$User = new User($Login->getUserID()); - -//redirect('main'); +if (isOnline()) { + $User = new User($Login->getUserID()); +} include 'tpl/contact.php'; diff --git a/contrib/.forceauth b/contrib/.forceauth new file mode 100755 index 0000000..25dc570 --- /dev/null +++ b/contrib/.forceauth @@ -0,0 +1 @@ +Test User|test@mit.edu diff --git a/contrib/server.cfg.php b/contrib/server.cfg.php new file mode 100755 index 0000000..00ac13c --- /dev/null +++ b/contrib/server.cfg.php @@ -0,0 +1,34 @@ +$networkAddress, + 'broadcastAddress'=>$broadcastAddress + ); +} + +$allowIP = array( + '204.9.221.18', + '18.237.0.77', + '18.237.0.90', + '18.237.0.225', + '18.237.0.227', + '18.237.0.228', + '18.239.1.6' + ); + +$IP = $_SERVER['REMOTE_ADDR']; + +if (!empty($IP) && !in_array($IP, $allowIP)) { +// header('Location: http://scripts.mit.edu/~sql/'); + header(''); + exit('403 Access denied'); +} diff --git a/cron/checkProcesses.php b/cron/checkProcesses.php index f04c5a5..a34d17b 100755 --- a/cron/checkProcesses.php +++ b/cron/checkProcesses.php @@ -21,7 +21,6 @@ foreach($bad as $badproc) { $baddb = mysql_escape_string($badproc['db']); $badtime = $badproc['Time']; $badquery = $badproc['Info']; - mysql_query('KILL '.$badproc['Id']); if (empty($baddb)) continue; $sql = "SELECT User.UserId,User.Name,User.Email FROM `User` @@ -33,6 +32,7 @@ foreach($bad as $badproc) { $mailtos[] = $addy['Email']; $mailnames[] = $addy['Name']; } + if (empty($mailtos)) continue; $mailto = implode(', ',$mailtos); $mailname = implode(', ',$mailnames); $mailsubj = "[sql] Slow Query on $baddb"; @@ -52,6 +52,7 @@ This SQL Service is available at sql.mit.edu. $badquery"; + mysql_query('KILL '.$badproc['Id']); mail($mailto,$mailsubj,$mailbody,"From: SQL Service \r\nBcc: sql@mit.edu\r\n"); } diff --git a/global.act.php b/global.act.php index 467282b..1a9b64d 100644 --- a/global.act.php +++ b/global.act.php @@ -3,20 +3,7 @@ require_once('mitsql.cfg.php'); require_once('mitsql.lib.php'); -if (isset($i_ssl)) { - if (isSSL() && $i_ssl==1) redirect(newQS('ssl')); - if (!isSSL() && $i_ssl==0) redirect(newQS('ssl')); - redirect2(flipSSL()); -} -if (isset($i_reset)) { session_destroy(); session_start(); redirect(newQS('reset')); } - -$msg = $err = array(); - -## SESSION VARS - -$timings = array(); -$UserId = sess('UserId'); -$Login = new Login($UserId); +$msg = $err = $timings = array(); ## PROCESS CERTIFICATE @@ -25,28 +12,46 @@ $SSLName = ''; $SSLEmail = ''; $SSLUsername = ''; -if (isSSL() || !isLoggedIn()) { - $SSLName = $SSLCred['Name']; - $SSLUsername = $SSLCred['Username']; - $SSLEmail = $SSLCred['Email']; +if (isOnline()) { + +## HANDLE SOME GLOBAL ACTIONS - /*$LoginSSL = sess('LoginSSL'); - if (!is_a($LoginSSL, 'Login')) { $LoginSSL = new Login($SSLUsername); }*/ - $LoginSSL = new Login($SSLUsername); - $LoginSSL->update($SSLCred['Name'],$SSLCred['Email']); + if (isset($i_ssl)) { + if (isSSL() && $i_ssl==1) redirect(newQS('ssl')); + if (!isSSL() && $i_ssl==0) redirect(newQS('ssl')); + redirect2(flipSSL()); + } + if (isset($i_reset)) { session_destroy(); session_start(); redirect(newQS('reset')); } + +## SETUP SESSION VARS + + $UserId = sess('UserId'); + $Login = new Login($UserId); + + if (isSSL() || !isLoggedIn()) { + $SSLName = $SSLCred['Name']; + $SSLUsername = $SSLCred['Username']; + $SSLEmail = $SSLCred['Email']; + + /*$LoginSSL = sess('LoginSSL'); + if (!is_a($LoginSSL, 'Login')) { $LoginSSL = new Login($SSLUsername); }*/ + $LoginSSL = new Login($SSLUsername); + $LoginSSL->update($SSLCred['Name'],$SSLCred['Email']); + + if (!isLoggedIn() && !$LoginSSL->exists()) { + if (!empty($SSLName)) + addUser($SSLCred); + $LoginSSL->refresh(); + } + } else { + unset($_SESSION['LoginSSL']); + } - if (!isLoggedIn() && !$LoginSSL->exists()) { - if (!empty($SSLName)) - addUser($SSLCred); - $LoginSSL->refresh(); + if (isPost() || isset($i_refresh)) { + checkQuotas($UserId); + isset($i_refresh) && redirect('main'); } -} else { - unset($_SESSION['LoginSSL']); -} - -if (isPost() || isset($i_refresh)) { - checkQuotas($UserId); - isset($i_refresh) && redirect('main'); -} + +} // isOnline() ?> diff --git a/lib/security.lib.php b/lib/security.lib.php index 2f72113..86676fb 100644 --- a/lib/security.lib.php +++ b/lib/security.lib.php @@ -237,6 +237,14 @@ function isImpersonating() { return isSess('_UserId') && isSess('UserId'); } +function isOffline() { + return (defined('OFFLINE') && OFFLINE); +} + +function isOnline() { + return !isOffline(); +} + function impersonate($userId=null) { $wasImpersonating = isImpersonating(); if ($wasImpersonating) { diff --git a/mitsql.cfg.php b/mitsql.cfg.php index 8702660..587f482 100755 --- a/mitsql.cfg.php +++ b/mitsql.cfg.php @@ -10,6 +10,7 @@ chdir(dirname(__FILE__)); file_exists('server.cfg.php') && require('server.cfg.php'); defined('DEBUG') || define('DEBUG', 0); defined('DEVEL') || define('DEVEL', 0); +defined('OFFLINE') || define('OFFLINE', 0); define('VER', '1.0'); if (DEVEL) { @@ -26,8 +27,12 @@ defined('ADMINPASS') || define('ADMINPASS', base64_decode('TXlCZWF0c1Bvc3RA')); defined('ADMINDB') || define('ADMINDB', 'mitsql'); $BASE_PATH = dirname(__FILE__).'/'; +define('BASE_PATH', $BASE_PATH); $URI = (isset($_SERVER["REDIRECT_URL"])?$_SERVER["REDIRECT_URL"]:''); $URI = ((empty($URI) && isset($_SERVER['REQUEST_URI']))?$_SERVER['REQUEST_URI']:$URI); +define('URI', $URI); +$THIS_PAGE = str_replace(BASE_URL, '', URI); +define('THIS_PAGE', $THIS_PAGE); set_time_limit(0); ignore_user_abort(1); @@ -38,9 +43,12 @@ set_include_path(get_include_path() . PATH_SEPARATOR . $BASE_PATH . 'lib/' . PAT require_once('defaults.cfg.php'); -$cxn = mysql_connect(DBHOST, ADMINUSER, ADMINPASS); -mysql_select_db(ADMINDB,$cxn); -if (mysql_error()) die(mysql_error()); +if (!OFFLINE) { + $cxn = mysql_connect(DBHOST, ADMINUSER, ADMINPASS); + mysql_select_db(ADMINDB,$cxn); + if (mysql_error()) die(mysql_error()); +} chdir($CWD); + ?> diff --git a/offline.php b/offline.php new file mode 100755 index 0000000..96e9641 --- /dev/null +++ b/offline.php @@ -0,0 +1,13 @@ + diff --git a/tpl/contact.php b/tpl/contact.php index a260bf9..70a721a 100755 --- a/tpl/contact.php +++ b/tpl/contact.php @@ -6,8 +6,12 @@ include 'head.php'; -We welcome questions, comments, and suggestions.
+

+We welcome all questions, comments, and suggestions.
+

+

Please direct inquiries to sql at mit.edu +

@@ -10,5 +24,5 @@
MIT SIPB MySQL ServiceContact/Help
- +
 
diff --git a/tpl/index.php b/tpl/index.php index c0acb32..ba88c0e 100644 --- a/tpl/index.php +++ b/tpl/index.php @@ -1,12 +1,5 @@ Important Notice:

This is a beta service and is not yet ready for use in data intensive applications. - -


- -
-*/ ?>

About

diff --git a/tpl/main.php b/tpl/main.php index 1929731..f6f12b9 100644 --- a/tpl/main.php +++ b/tpl/main.php @@ -59,7 +59,7 @@ if (isset($i_dropask)) {

Manage Data

-

One interface we recommend for managing SQL data is phpMyAdmin. Feel free to use it after you've created your databases.

+

One interface we recommend for managing SQL data is phpMyAdmin. Feel free to use it after you've created your databases.

Databases | @@ -26,4 +25,3 @@ Login via SQL Password or
  -
diff --git a/tpl/offline.php b/tpl/offline.php new file mode 100755 index 0000000..dffa7e0 --- /dev/null +++ b/tpl/offline.php @@ -0,0 +1,16 @@ + + +

System Maintenance

+ +

+The MySQL Service interface is temporarily offline while we perform system maintenance. +Please check back with us in a few minutes for interface access recommencement. +We apologize for the delay in service and inconvenience. +In the meantime, feel free to Contact Us. +

+ + -- 2.45.1