source: locker/sql/bin/get-next-database @ 382

Last change on this file since 382 was 382, checked in by presbrey, 15 years ago
new SQL signup and server
  • Property svn:executable set to *
File size: 453 bytes
Line 
1#!/usr/bin/php
2<?php
3
4list($h,$u,$p) = explode("\t",`/mit/scripts/sql/bin/get-password`);
5$newdb = str_replace($u.'+','',$argv[1]);
6$testdb = str_replace('.','',$u).'+'.$newdb;
7$dbs = explode("\n",file_get_contents('https://sql.mit.edu/tools/list_dbs.php?h=' . urlencode($h) . '&u=' . urlencode($u) . '&p=' . urlencode($p)));
8if (in_array($testdb,$dbs)) {
9        $i = 1;
10        while(in_array($testdb.$i,$dbs)) {
11                $i++;
12        }
13        echo $newdb.$i;
14} else echo $newdb;
15
16?>
Note: See TracBrowser for help on using the repository browser.