--- /dev/null
+#!/bin/bash
+
+pushd ~/web_scripts/main/ >/dev/null
+svn up
+sh ../perm.sh
+popd >/dev/null
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';
--- /dev/null
+Test User|test@mit.edu
--- /dev/null
+<?php
+
+define('BASE_URL', '/~sql/dev/');
+define('DEVEL',1);
+define('DEBUG',0);
+
+function IPblockCalc($IP,$subnetMask) {
+ $IP = ip2long($IP);
+ $subnetMask = ip2long($subnetMask);
+ $revSub = ~$subnetMask;
+ $networkAddress = $IP & $subnetMask;
+ $broadcastAddress = $IP | $revSub;
+ return Array('networkAddress'=>$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');
+}
$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`
$mailtos[] = $addy['Email'];
$mailnames[] = $addy['Name'];
}
+ if (empty($mailtos)) continue;
$mailto = implode(', ',$mailtos);
$mailname = implode(', ',$mailnames);
$mailsubj = "[sql] Slow Query on $baddb";
$badquery";
+ mysql_query('KILL '.$badproc['Id']);
mail($mailto,$mailsubj,$mailbody,"From: SQL Service <sql@mit.edu>\r\nBcc: sql@mit.edu\r\n");
}
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
$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()
?>
return isSess('_UserId') && isSess('UserId');
}
+function isOffline() {
+ return (defined('OFFLINE') && OFFLINE);
+}
+
+function isOnline() {
+ return !isOffline();
+}
+
function impersonate($userId=null) {
$wasImpersonating = isImpersonating();
if ($wasImpersonating) {
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) {
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);
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);
+
?>
--- /dev/null
+<?php
+/*
+ (c) 2005 Joe Presbrey
+*/
+
+require_once('mitsql.cfg.php');
+require_once('mitsql.lib.php');
+
+isOnline() && redirect('index');
+
+include 'tpl/offline.php';
+
+?>
<?php printErrors($err); ?>
-We welcome questions, comments, and suggestions.<br>
+<p>
+We welcome all questions, comments, and suggestions.<br>
+</p>
+<p>
Please direct inquiries to <strong>sql at mit.edu</strong>
+</p>
<?php
include 'foot.php';
+<?php\r
+\r
+if (isOffline()) {\r
+ switch(THIS_PAGE) {\r
+ case 'do/contact':\r
+ case 'do/offline':\r
+ break;\r
+ default:\r
+ redirect('offline');\r
+ break;\r
+ }\r
+}\r
+\r
+?>\r
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\r
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
<html>\r
<body>\r
<div id="body">\r
<div id="content0"><span id="sitename">MIT SIPB MySQL Service</span><span id="contact"><a href="do/contact">Contact/Help</a></span></div>\r
-<?php include 'menu.php'; ?>\r
+<div id="content1"><?php isOnline() && include('menu.php'); ?> </div>\r
<div id="content2">\r
<?php
include 'head.php';
-/*
-<strong>Important Notice:</strong><p> This is a beta service and is not yet ready for use in data intensive applications.
-
-<hr />
-
-<br />
-*/
?>
<h2>About</h2>
</form>
<h2>Manage Data</h2>
-<p>One interface we recommend for managing SQL data is <a href="/~sql/phpMyAdmin/" target="_blank">phpMyAdmin</a>. Feel free to use it after you've created your databases.</p>
+<p>One interface we recommend for managing SQL data is <a href="/~tools/phpMyAdmin/" target="_blank">phpMyAdmin</a>. Feel free to use it after you've created your databases.</p>
<?php
-<div id="content1">
<?php if (isLoggedIn()): ?>
<div style="float:left">
<a href="do/main?refresh">Databases</a> |
</div>
<?php endif; ?>
-</div>
--- /dev/null
+<?php
+include 'head.php';
+?>
+
+<h2>System Maintenance</h2>
+
+<p>
+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 <a href="do/contact">Contact Us</a>.
+</p>
+
+<?php
+include 'foot.php';
+?>