From 1389493c540d4def6423bfb4ad05bf3dcc3e6156 Mon Sep 17 00:00:00 2001 From: Joe Presbrey Date: Mon, 18 Jul 2005 15:46:19 +0000 Subject: [PATCH] mitsql: contact page, signup fixes, main info on index git-svn-id: svn://presbrey.mit.edu/sql/mitsql@38 a142d4bd-2cfb-0310-9673-cb33a7e74f58 --- contact.php | 8 ++++++++ global.act.php | 13 +++++++++++-- global.done.php | 1 + index.php | 7 +++++-- lib/security.lib.php | 6 +++--- login.php | 6 ------ reset.sql | 10 ++++++++++ signup.php | 16 ++++++++-------- tpl/index.php | 43 +++++++++++++++++++++++++++++++++++++++++++ tpl/login.php | 4 ++-- tpl/main.php | 8 ++++++++ tpl/menu.php | 1 + tpl/signup.php | 9 +++------ 13 files changed, 103 insertions(+), 29 deletions(-) create mode 100644 contact.php create mode 100644 reset.sql diff --git a/contact.php b/contact.php new file mode 100644 index 0000000..23fc076 --- /dev/null +++ b/contact.php @@ -0,0 +1,8 @@ + diff --git a/global.act.php b/global.act.php index 21f9ad5..7563b61 100644 --- a/global.act.php +++ b/global.act.php @@ -21,9 +21,9 @@ $Name = ''; $Email = ''; $UL = 0; $Login = sess('Login'); +$LoginSSL = sess('LoginSSL'); -if (is_a($Login,'Login')) { -// $Login->refresh(); +if (is_a($Login, 'Login')) { $UserId = $Login->getUserId(); $Username = $Login->getUsername(); $Name = $Login->getName(); @@ -33,6 +33,8 @@ if (is_a($Login,'Login')) { $Login = new Login(''); } +## PROCESS CERTIFICATE + $SSLCred = getSSLCert(); $SSLName = ''; $SSLEmail = ''; @@ -43,5 +45,12 @@ if (isSSL()) { $SSLUsername = $SSLCred['Username']; $SSLEmail = $SSLCred['Email']; } +if (!is_a($LoginSSL, 'Login')) { + $LoginSSL = new Login($SSLUsername); +} +if (!isLoggedIn() && !$LoginSSL->exists()) { + addUser($SSLCred); + $LoginSSL->refresh(); +} ?> diff --git a/global.done.php b/global.done.php index 3e1c2c1..e02cc28 100644 --- a/global.done.php +++ b/global.done.php @@ -4,6 +4,7 @@ require_once('mitsql.cfg.php'); require_once('mitsql.lib.php'); sess('Login', $Login); +sess('LoginSSL', $LoginSSL); echo '
';
 print_r($_SESSION);
diff --git a/index.php b/index.php
index 9bdf89d..7ab6049 100755
--- a/index.php
+++ b/index.php
@@ -10,9 +10,12 @@
 require_once('mitsql.cfg.php');
 require_once('mitsql.lib.php');
 
-isLoggedIn() || redirect('login');
+isLoggedIn() && redirect('main');
+//$LoginSSL->canSignup() && redirect('signup');
 
-redirect('main');
+//redirect('login');
+
+include 'tpl/index.php';
 
 exit;
 
diff --git a/lib/security.lib.php b/lib/security.lib.php
index 8e7dcf3..44071d1 100644
--- a/lib/security.lib.php
+++ b/lib/security.lib.php
@@ -189,12 +189,12 @@ function getSSLCert() {
 
 ## 302 REDIRECTS
 
-function redirect($target=null,$secure=true) {
+function redirect($target=null,$secure=null) {
     $base = (is_null($target)||substr($target,0,1)=='?')?$_SERVER['REDIRECT_URL']:(dirname($_SERVER['REDIRECT_URL']).'/');
     redirectFull(is_null($target)?$base:($base.$target),$secure);
 }
 function redirectFull($target,$secure) {
-	redirect2((isSSL()&&$secure?'https://':'http://').$_SERVER['SERVER_NAME'].$target);
+	redirect2((((isSSL()&&is_null($secure))||$secure==true)?'https://':'http://').$_SERVER['SERVER_NAME'].$target);
 }
 function redirect2($target) {
 	header('Location: '.$target);
@@ -222,7 +222,7 @@ function addUser($sslCredentials) {
 
 	$arr = $_NEW_USERSTAT;
 	$arr['UserId'] = $UserId;
-    $sql = sprintf("INSERT INTO UserQuota %s",
+    $sql = sprintf("INSERT INTO UserStat %s",
                     buildSQLInsert($arr));
 	DBInsert($sql);
 
diff --git a/login.php b/login.php
index 18f7531..2d684fa 100644
--- a/login.php
+++ b/login.php
@@ -4,14 +4,8 @@ require_once('mitsql.cfg.php');
 require_once('mitsql.lib.php');
 
 if (isSSL()) {
-	$Login2 = new Login($SSLUsername);
 	if (is_null($SSLCred)) {
 		$err[] = 'Please install a valid certificate.';
-	} else {
-	    if (!(empty($SSLUsername) || $Login2->exists())) {
-	        addUser($SSLCred);
-	        $Login = new Login($SSLUsername);
-	    }
 	}
 }
 
diff --git a/reset.sql b/reset.sql
new file mode 100644
index 0000000..84c5573
--- /dev/null
+++ b/reset.sql
@@ -0,0 +1,10 @@
+TRUNCATE TABLE `DB`;
+TRUNCATE TABLE `DBOwner`;
+TRUNCATE TABLE `DBQuota`;
+TRUNCATE TABLE `Group`;
+TRUNCATE TABLE `GroupQuota`;
+TRUNCATE TABLE `GroupStat`;
+TRUNCATE TABLE `User`;
+TRUNCATE TABLE `UserGroup`;
+TRUNCATE TABLE `UserQuota`;
+TRUNCATE TABLE `UserStat`;
diff --git a/signup.php b/signup.php
index 0b52815..fa93c8b 100644
--- a/signup.php
+++ b/signup.php
@@ -4,7 +4,7 @@ require_once('mitsql.cfg.php');
 require_once('mitsql.lib.php');
 
 if (!isSSL())
-	redirect('index',false);
+	redirect('signup',true);
 
 if (isLoggedIn()) {
 
@@ -15,14 +15,14 @@ if (isLoggedIn()) {
 	if (is_null($SSLCred)) {
 		$err[] = 'Please install a valid certificate.';
 	} else {
-	$Login2 = new Login($SSLUsername);
-	if (isPost() && $Login2->canSignup()) {
-		$u = new User($Login2->getUserId());
-		$u->signup($i_p1);
-		$Login2->refresh();
+		if (isPost() && $LoginSSL->canSignup()) {
+			$u = new User($LoginSSL->getUserId());
+			$u->signup($i_p1);
+			$LoginSSL->refresh();
+			sess('Login', $LoginSSL);
+			redirect('login', true);
+		}
 	}
-	}
-
 }
 
 include 'tpl/signup.php';
diff --git a/tpl/index.php b/tpl/index.php
index 6f454e6..85b8d4d 100644
--- a/tpl/index.php
+++ b/tpl/index.php
@@ -1,7 +1,50 @@
 
+
+Important Notice:

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


+ +
+ +

About

+ +

+This service provides MySQL databases to Athena account holders. +You must choose a MySQL password (independent of your Athena account) when you Signup and then use this interface to create and drop your MySQL databases. +All subsequent SQL commands can be issued from any host, client, and/or script of your choosing. +

+ +

Backups

+

+As you work with your SQL data, it is automatically saved on an additional secondary SQL server for restoration in the event of a single server failure. +We strongly recommend you keep your own backups for your own independent use in all other cases. +Although we continually put forth our best efforts, we can make no guarantees on the reliability of the service and access to the data.

+

Quotas

+

+By default, new users can create up to 5 databases, consuming a total of 25 megabytes of SQL data. +The system will periodically check your database sizes and suspend creation of new data (INSERT statements) if your total usage exceeds your allotted quota. +

+ +

+This service is not designed to store gratuitous amounts of information in the BLOB or BINARY formats. Extra quota space will not be allotted to users for this type of data. +Users should instead store these types of data in AFS and use SQL tables only to catalogue it. +

+ +

Disclaimer

+ +

+We reserve the right to suspend or terminate your MySQL account at any time and for any or no reason. +

+ +

+We maintain general usage statistics of this service by the MIT community at large. +

+ + diff --git a/tpl/login.php b/tpl/login.php index 54abd2b..34dd8fe 100644 --- a/tpl/login.php +++ b/tpl/login.php @@ -19,13 +19,13 @@ $otherTxt = isSSL()?' without a Certificate':' with a Certificate';
-

You are identifed as:

+

You are identified as:

-canLogin()): ?> +canLogin()): ?>
diff --git a/tpl/main.php b/tpl/main.php index 717b51d..2f75713 100644 --- a/tpl/main.php +++ b/tpl/main.php @@ -4,6 +4,14 @@ include 'head.php'; ?>

Databases

+ +

+Thanks for signing up. This interface is nearly ready. We will e-mail you as soon as this portion of the site is ready. +
+
+- The MIT SQL Team +

+
+Main | Logout
  Logged in as on diff --git a/tpl/signup.php b/tpl/signup.php index f01aa18..5be6e87 100644 --- a/tpl/signup.php +++ b/tpl/signup.php @@ -8,13 +8,10 @@ $thisTxt = isSSL()?' with this Certificate':' via SQL'; -canLogin()): ?> +canSignup()): ?>

You are registering as:

- - -canSignup()): ?>

password:

@@ -22,9 +19,9 @@ $thisTxt = isSSL()?' with this Certificate':' via SQL';
-canLogin()): ?> +canLogin()): ?> -

Login. This account is signed up.

+

This account is signed up. Login.

-- 2.45.2