inst-resources/selfdestruct.php
changeset 10 014d58335b6d
parent 4 ea7b100e5de6
equal deleted inserted replaced
8:af10a4dbafb4 10:014d58335b6d
     3 // basically: self-destruct the database side of Enano.
     3 // basically: self-destruct the database side of Enano.
     4 
     4 
     5 $mydir = dirname(__FILE__);
     5 $mydir = dirname(__FILE__);
     6 require($mydir . '/../htdocs/includes/common.php');
     6 require($mydir . '/../htdocs/includes/common.php');
     7 if ( !defined('ENANO_CLI') )
     7 if ( !defined('ENANO_CLI') )
     8   die("Don't even try.");
     8 	die("Don't even try.");
     9 
     9 
    10 require(ENANO_ROOT . '/config.php');
    10 require(ENANO_ROOT . '/config.php');
    11 
    11 
    12 // one is mysql, one is postgresql
    12 if ( !in_array('--skip-revoke', $argv) )
    13 // too lazy to check right now
    13 {
    14 // FIXME this fails right now because we don't have root
    14 	$db->sql_query("DROP DATABASE `$dbname`;");
    15 $db->sql_query("DROP ROLE `$dbuser`;");
    15 	// one is mysql, one is postgresql
    16 $db->sql_query("REVOKE ALL PRIVILEGES ON `$dbname`.* FROM `$dbuser`@localhost;");
    16 	// too lazy to check right now
       
    17 	// FIXME this fails right now because we don't have root
       
    18 	$db->sql_query("DROP ROLE `$dbuser`;");
       
    19 	$db->sql_query("REVOKE ALL PRIVILEGES ON `$dbname`.* FROM `$dbuser`@localhost;");
       
    20 }
       
    21 else
       
    22 {
       
    23 	foreach ( $system_table_list as $table )
       
    24 	{
       
    25 		$q = "DROP TABLE `" . table_prefix . "$table`;";
       
    26 		echo "$q\n";
       
    27 		$db->sql_query($q);
       
    28 	}
       
    29 }
    17 
    30 
    18 $q = $db->sql_query("DROP DATABASE `$dbname`;");
    31 exit(0);
    19 if ( $q )
       
    20   exit(0);
       
    21 
    32 
    22 exit(1);
       
    23