inst-resources/selfdestruct.php
author Dan Fuhry <dan@enanocms.org>
Sat, 21 Aug 2010 18:20:18 -0400
changeset 11 b62383876fdb
parent 10 014d58335b6d
permissions -rw-r--r--
Merged from accidental split
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
     1
<?php
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
     2
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
     3
// basically: self-destruct the database side of Enano.
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
     4
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
     5
$mydir = dirname(__FILE__);
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
     6
require($mydir . '/../htdocs/includes/common.php');
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
     7
if ( !defined('ENANO_CLI') )
10
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
     8
	die("Don't even try.");
4
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
     9
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
    10
require(ENANO_ROOT . '/config.php');
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
    11
10
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    12
if ( !in_array('--skip-revoke', $argv) )
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    13
{
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    14
	$db->sql_query("DROP DATABASE `$dbname`;");
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    15
	// one is mysql, one is postgresql
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    16
	// too lazy to check right now
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    17
	// FIXME this fails right now because we don't have root
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    18
	$db->sql_query("DROP ROLE `$dbuser`;");
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    19
	$db->sql_query("REVOKE ALL PRIVILEGES ON `$dbname`.* FROM `$dbuser`@localhost;");
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    20
}
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    21
else
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    22
{
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    23
	foreach ( $system_table_list as $table )
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    24
	{
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    25
		$q = "DROP TABLE `" . table_prefix . "$table`;";
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    26
		echo "$q\n";
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    27
		$db->sql_query($q);
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    28
	}
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    29
}
4
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
    30
10
014d58335b6d Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents: 4
diff changeset
    31
exit(0);
4
ea7b100e5de6 Got some basic uninstaller code in
Dan
parents:
diff changeset
    32