]> andersk Git - sql-web.git/commitdiff
contact: page formatting
authorJoe Presbrey <presbrey@mit.edu>
Wed, 30 Nov 2005 14:21:57 +0000 (14:21 +0000)
committerJoe Presbrey <presbrey@mit.edu>
Wed, 30 Nov 2005 14:21:57 +0000 (14:21 +0000)
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

15 files changed:
bin/updateMain.sh [new file with mode: 0755]
contact.php
contrib/.forceauth [new file with mode: 0755]
contrib/server.cfg.php [new file with mode: 0755]
cron/checkProcesses.php
global.act.php
lib/security.lib.php
mitsql.cfg.php
offline.php [new file with mode: 0755]
tpl/contact.php
tpl/head.php
tpl/index.php
tpl/main.php
tpl/menu.php
tpl/offline.php [new file with mode: 0755]

diff --git a/bin/updateMain.sh b/bin/updateMain.sh
new file mode 100755 (executable)
index 0000000..cb5d738
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+pushd ~/web_scripts/main/ >/dev/null
+svn up
+sh ../perm.sh
+popd >/dev/null
index 3e99683d70b988e4b1cec0b3a00caba8e3ce5e0f..68ecd241c02207268ea38dcdeeb6e0b853c8b1db 100644 (file)
@@ -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 (executable)
index 0000000..25dc570
--- /dev/null
@@ -0,0 +1 @@
+Test User|test@mit.edu
diff --git a/contrib/server.cfg.php b/contrib/server.cfg.php
new file mode 100755 (executable)
index 0000000..00ac13c
--- /dev/null
@@ -0,0 +1,34 @@
+<?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');
+}
index f04c5a5527d4e080dd3242904693c8c6faa9d644..a34d17bc58fa1551514a858a3a6ab5a9cfff3dd7 100755 (executable)
@@ -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 <sql@mit.edu>\r\nBcc: sql@mit.edu\r\n");
 }
 
index 467282be760f9ebf83b7803a5aea32db2fb090ed..1a9b64d6731d16c3454280a00d0fed254341f553 100644 (file)
@@ -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()
 
 ?>
index 2f7211330936a2390d8e902bc908047e39f7c842..86676fb38837b7ff89293e74f5fe6048d4e11b1d 100644 (file)
@@ -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) {
index 870266061d9042a4fdeda19106fdacf98a235d98..587f482e39f3509a0588203d2bb89eb12ca55451 100755 (executable)
@@ -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 (executable)
index 0000000..96e9641
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+/*
+       (c) 2005 Joe Presbrey
+*/
+
+require_once('mitsql.cfg.php');
+require_once('mitsql.lib.php');
+
+isOnline() && redirect('index');
+
+include 'tpl/offline.php';
+
+?>
index a260bf96101142b1a59484ba6f6da73af9d6727b..70a721ad1862782c5a9b4244c8fe385036516224 100755 (executable)
@@ -6,8 +6,12 @@ include 'head.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';
index 1389ff0fc027569413a9e4760b03fc991286eb66..6bcc7fd8a7e32f3e53e74869f32dc88aeb041531 100644 (file)
@@ -1,3 +1,17 @@
+<?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
@@ -10,5 +24,5 @@
 <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'); ?>&nbsp;</div>\r
 <div id="content2">\r
index c0acb320d85627d8564bca108f1cf1e82cc04b40..ba88c0eefe223af41e6130c114045dc8bbde560f 100644 (file)
@@ -1,12 +1,5 @@
 <?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>
 
index 1929731338d865a6ebce1904e2f06f84b115606f..f6f12b9c3ff8102dcbfba2ca3db12be858cf757c 100644 (file)
@@ -59,7 +59,7 @@ if (isset($i_dropask)) {
 </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
 
index 3060e24767d83491fef78535105c0a4e70128a8c..4ecb629a3d37faca9780218117ed5360a6cc75eb 100644 (file)
@@ -1,4 +1,3 @@
-<div id="content1">
 <?php if (isLoggedIn()): ?>
 <div style="float:left">
 <a href="do/main?refresh">Databases</a> |
@@ -26,4 +25,3 @@ Login via <a href="do/login?ssl=0">SQL Password</a> or <a href="do/login?ssl=1">
 </div>
 &nbsp;
 <?php endif; ?>
-</div>
diff --git a/tpl/offline.php b/tpl/offline.php
new file mode 100755 (executable)
index 0000000..dffa7e0
--- /dev/null
@@ -0,0 +1,16 @@
+<?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';
+?>
This page took 0.086243 seconds and 5 git commands to generate.