6 add switching of what owner to manage
7 - to support group sql "lockers"
10 require_once('mitsql.cfg.php');
11 require_once('mitsql.lib.php');
13 isLoggedIn() && redirect('main');
14 //$LoginSSL->canSignup() && redirect('signup');
18 include 'tpl/index.php';
22 if (isset($_SESSION['owner'])) {
23 $owner = $_SESSION['owner'];
24 $dbm = new DBManage($owner);
26 ?><p><h2>SQL Databases: <?php echo $owner; ?></h2><?php
27 if (isset($realuser)) {
28 ?><h4> [ <a href="?op=admin"><?php echo $realuser; ?></a> ]</h4><?php
32 $inputvars = array('initpw', 'op', 'name', 'owner');
37 if (isset($i_owner)) {
38 $_SESSION['owner'] = $i_owner;
39 $_SESSION['realuser'] = $_SESSION['owner'];
42 redirectLocal('/admin/');
45 if (strlen($i_initpw)<PASS_MIN_LEN) {
46 echo '<p class="err">',TEXT_REGPASSTOOSHORT,'</p>';
48 if (!$dbm->isInit()) {
49 $dbm->init($i_initpw);
52 echo '<p class="err">Your account is already initialized.</p>';
57 echo '<p>This operation will remove all the databases and accounts for: ',$owner,'. Are you sure?</p>';
58 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>';
66 if ($dbm->getNumDBs() < $dbm->getNumMaxDBs()) {
67 $dbm->addDB($owner.DELIMETER.$i_name);
70 echo '<p class="err">',TEXT_DBLIMIT,'</p>';
74 if ($dbm->isRegistered($i_name)) {
78 echo '<p class="err">',TEXT_NOTREG,'</p>';
82 if ($dbm->isRegistered($i_name)) {
83 $dbm->createDB($i_name);
86 echo '<p class="err">',TEXT_NOTREG,'</p>';
90 if ($dbm->isRegistered($i_name)) {
91 $dbm->dropDB($i_name);
94 echo '<p class="err">',TEXT_NOTREG,'</p>';
98 if ($dbm->isRegistered($i_name)) {
99 $dbm->grantDB($i_name);
102 echo '<p class="err">',TEXT_NOTREG,'</p>';
106 if ($dbm->isRegistered($i_name)) {
107 $dbm->revokeDB($i_name);
110 echo '<p class="err">',TEXT_NOTREG,'</p>';
115 $dbm = new DBManage($owner);
122 if ($dbm->getNumDBs()) {
124 $dbm->printOwnerDBs();
127 if ($dbm->isInit()) {
128 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>';
131 echo '<table width="100%" style="margin-top:20px;">';
132 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>';
134 echo '<h3>',TEXT_NOREG,'</h3>';
135 echo '<form method="',FORM_METHOD,'">';
137 echo '<tr><td>your SQL server:</td><td>',HOST,'</td></tr>';
138 echo '<tr><td>your SQL username:</td><td>',$owner,'</td></tr>';
139 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>';
140 echo '<table width="100%" style="margin-top:20px;">';
141 echo '<tr><td></td><td><input type="submit" value="Activate My Account"></td></form>';
143 echo '<form method=get><td><div align="right"><input type=hidden name="reset" value=""><input type="submit" value="Restart"></div></td></form></tr></table>';
153 <hr><div align="right">
155 <address>MIT SQL Service Management v<?php echo VERSION; ?><br />
156 Direct comments and bugs to: <a href="mailto:presbrey@mit.edu">presbrey@mit.edu</a></address></div>