6 add switching of what owner to manage
7 - to support group sql "lockers"
10 if (file_exists('/mit/presbrey/web_tmp'))
11 ini_set('session.save_path','/mit/presbrey/web_tmp');
12 ini_set('display_errors', 1);
14 error_reporting(E_ALL);
17 if (isset($_GET['reset'])) { session_destroy(); session_start(); }
18 require_once('mitsql.lib.php');
20 if (!isset($_SESSION['owner'])) {
21 if (isset($_GET['owner'])) {
22 $_SESSION['owner'] = $_GET['owner'];
25 if (isset($_POST['owner'])) {
26 $_SESSION['owner'] = $_POST['owner'];
29 if (is_null(getSSLIdent())) {
30 redirect('https://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']);
31 echo '<p class="err">Your SSL certificate could not be verified, please authenticate manually below.</p>';
32 // echo '<form method="',FORM_METHOD,'"><input type="text" name="owner" value="',$_SESSION['owner'],'"><input type=submit value="owner"></form>';
33 echo '<p>(This will be fixed when I do group locker SQL support)</p>';
35 $_SESSION['owner'] = getSSLIdent();
38 if (isset($_SESSION['realuser'])) {
39 $realuser = $_SESSION['realuser'];
40 } else $realuser = null;
45 if (isset($_SESSION['owner'])) {
46 $owner = $_SESSION['owner'];
47 $dbm = new DBManage($owner);
50 ?><p><h2>SQL Databases: <?php echo $owner; ?></h2><?php
51 if (isset($realuser)) {
52 ?><h4> [ <a href="?op=admin"><?php echo $realuser; ?></a> ]</h4><?php
56 $inputvars = array('initpw', 'op', 'name', 'owner');
57 foreach($inputvars as $i) {
59 $$newvar = isset($_GET[$i]) ? $_GET[$i] : null;
65 if (isset($i_owner)) {
66 $_SESSION['owner'] = $i_owner;
67 $_SESSION['realuser'] = $_SESSION['owner'];
70 redirectLocal('/admin/');
73 if (strlen($i_initpw)<PASS_MIN_LEN) {
74 echo '<p class="err">',TEXT_REGPASSTOOSHORT,'</p>';
76 if (!$dbm->isInit()) {
77 $dbm->init($i_initpw);
80 echo '<p class="err">Your account is already initialized.</p>';
85 echo '<p>This operation will remove all the databases and accounts for: ',$owner,'. Are you sure?</p>';
86 echo '<form method="',FORM_METHOD,'"><tr><td><div align="left"><input type=hidden name="op" value="uninit2"><input type="submit" value="Remove My Account"></div></td></form>';
94 if ($dbm->getNumDBs() < $dbm->getNumMaxDBs()) {
95 $dbm->addDB($owner.DELIMETER.$i_name);
98 echo '<p class="err">',TEXT_DBLIMIT,'</p>';
102 if ($dbm->isRegistered($i_name)) {
103 $dbm->delDB($i_name);
106 echo '<p class="err">',TEXT_NOTREG,'</p>';
110 if ($dbm->isRegistered($i_name)) {
111 $dbm->createDB($i_name);
114 echo '<p class="err">',TEXT_NOTREG,'</p>';
118 if ($dbm->isRegistered($i_name)) {
119 $dbm->dropDB($i_name);
122 echo '<p class="err">',TEXT_NOTREG,'</p>';
126 if ($dbm->isRegistered($i_name)) {
127 $dbm->grantDB($i_name);
130 echo '<p class="err">',TEXT_NOTREG,'</p>';
134 if ($dbm->isRegistered($i_name)) {
135 $dbm->revokeDB($i_name);
138 echo '<p class="err">',TEXT_NOTREG,'</p>';
143 $dbm = new DBManage($owner);
150 if ($dbm->getNumDBs()) {
152 $dbm->printOwnerDBs();
155 if ($dbm->isInit()) {
156 echo '<form method="',FORM_METHOD,'"><input type=text readonly value="',$owner.DELIMETER,'" style="text-align:right"><input type=text name="name"><input type=hidden name="op" value="adddb"><input type=submit value="Add Database"></form>';
159 echo '<table width="100%" style="margin-top:20px;">';
160 echo '<form method="',FORM_METHOD,'"><tr><td><div align="left"><input type=hidden name="op" value="uninit"><input type="submit" value="Remove My Account"></div></td></form>';
162 echo '<h3>',TEXT_NOREG,'</h3>';
163 echo '<form method="',FORM_METHOD,'">';
165 echo '<tr><td>your SQL server:</td><td>',HOST,'</td></tr>';
166 echo '<tr><td>your SQL username:</td><td>',$owner,'</td></tr>';
167 echo '<tr><td>choose a SQL password:</td><td><input type=hidden name="op" value="init"><input type="password" name="initpw" value=""></td></tr></table>';
168 echo '<table width="100%" style="margin-top:20px;">';
169 echo '<tr><td></td><td><input type="submit" value="Activate My Account"></td></form>';
171 echo '<form method=get><td><div align="right"><input type=hidden name="reset" value=""><input type="submit" value="Restart"></div></td></form></tr></table>';
181 <hr><div align="right">
183 <address>MIT SQL Service Management v<?php echo VERSION; ?><br />
184 Direct comments and bugs to: <a href="mailto:presbrey@mit.edu">presbrey@mit.edu</a></address></div>