| 1 |
<?php |
<?php |
| 2 |
// $Id: multisite_manager.module,v 1.6 2007/09/04 20:24:16 schuyler1d Exp $ |
// $Id: multisite_manager.module,v 1.7 2008/02/08 20:25:25 schuyler1d Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* author: Schuyler Duveen |
* author: Schuyler Duveen |
| 319 |
|
|
| 320 |
$already_exists = db_result(@db_query("SELECT shortname FROM {drupal_site} WHERE shortname = '%s'",$node->shortname)); |
$already_exists = db_result(@db_query("SELECT shortname FROM {drupal_site} WHERE shortname = '%s'",$node->shortname)); |
| 321 |
if ($already_exists) { |
if ($already_exists) { |
| 322 |
form_set_error('shortname', t('The shortname you have entered, %shortname, is already taken. Please use a different one.', array('%shortname' => $node->shortname)), 'error'); |
form_set_error('shortname', t('The shortname you have entered, %shortname, is already taken. Please use a different one.', array('%shortname' => $node->shortname)), 'error'); |
| 323 |
} |
} |
| 324 |
if (_multisite_manager_dbexists($node)) { |
if (_multisite_manager_dbexists($node)) { |
| 325 |
form_set_error('shortname', t('The database location the site would be installed already exists. Please use a different shortname or database path and prefix.'), 'error'); |
form_set_error('shortname', t('The database location the site would be installed already exists. Please use a different shortname or database path and prefix.'), 'error'); |
| 326 |
} |
} |
| 327 |
} |
} |
| 328 |
|
|
| 469 |
case 'mysqli': |
case 'mysqli': |
| 470 |
$already_exists = db_result(@db_query("SHOW DATABASES LIKE '%s'", $new_db['path'])); |
$already_exists = db_result(@db_query("SHOW DATABASES LIKE '%s'", $new_db['path'])); |
| 471 |
if ($already_exists) { |
if ($already_exists) { |
| 472 |
$already_exists = db_result(@db_query("SHOW TABLES FROM %s LIKE '%s%%'", $new_db['path'], $new_db['prefix'])); |
$already_exists = db_result(@db_query("SHOW TABLES FROM %s LIKE '%s%%'", $new_db['path'], str_replace('_','\_',$new_db['prefix']))); |
| 473 |
if (!$already_exists && $db_prefix != $new_db['prefix']) { |
if (!$already_exists && $db_prefix != $new_db['prefix']) { |
| 474 |
///to avoid watchdog set_active_db() problems we install on the current prefix and then rename tables to the new one |
///to avoid watchdog set_active_db() problems we install on the current prefix and then rename tables to the new one |
| 475 |
///this needs to be doable, so we can't have tables hanging around that match the current prefix either |
///this needs to be doable, so we can't have tables hanging around that match the current prefix either |
| 476 |
///even (or especially!!!) if db_prefix == '' |
///even (or especially!!!) if db_prefix == '' |
| 477 |
$already_exists = db_result(@db_query("SHOW TABLES FROM %s LIKE '%s%%'", $new_db['path'], $new_db['prefix'])); |
$already_exists = db_result(@db_query("SHOW TABLES FROM %s LIKE '%s%%'", $new_db['path'], str_replace('_','\_',$new_db['prefix']))); |
| 478 |
} |
} |
| 479 |
} |
} |
| 480 |
break; |
break; |
| 485 |
$already_exists = db_result(@db_query("SELECT datname FROM pg_database WHERE datname = '%s'",$new_db['path'])); |
$already_exists = db_result(@db_query("SELECT datname FROM pg_database WHERE datname = '%s'",$new_db['path'])); |
| 486 |
} |
} |
| 487 |
elseif (!$new_db['new']) { |
elseif (!$new_db['new']) { |
| 488 |
$already_exists = db_result(db_query("SELECT relname FROM pg_stat_user_tables WHERE relname LIKE '%s%%'", $new_db['prefix'])); |
$already_exists = db_result(db_query("SELECT relname FROM pg_stat_user_tables WHERE relname LIKE '%s%%'", str_replace('_','\_',$new_db['prefix']))); |
| 489 |
} |
} |
| 490 |
break; |
break; |
| 491 |
} |
} |
| 716 |
switch ($GLOBALS['db_type']) { |
switch ($GLOBALS['db_type']) { |
| 717 |
case 'mysql': |
case 'mysql': |
| 718 |
case 'mysqli': |
case 'mysqli': |
| 719 |
$result = @db_query("SHOW TABLES LIKE '%s%%'", $prefix); |
$result = @db_query("SHOW TABLES LIKE '%s%%'", str_replace('_','\_',$prefix)); |
| 720 |
break; |
break; |
| 721 |
case 'pgsql': |
case 'pgsql': |
| 722 |
$result = @db_query("SELECT relname FROM pg_stat_user_tables WHERE relname LIKE '%s%%'", $prefix); |
$result = @db_query("SELECT relname FROM pg_stat_user_tables WHERE relname LIKE '%s%%'", str_replace('_','\_',$prefix)); |
| 723 |
break; |
break; |
| 724 |
} |
} |
| 725 |
return $result; |
return $result; |