source: trunk/locker/sql/bin/get-next-database @ 1217

Last change on this file since 1217 was 465, checked in by andersk, 17 years ago
Sync svn with locker.
  • Property svn:executable set to *
File size: 449 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?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.