2006-10-19 16:55:07 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2011-01-05 23:44:23 +01:00
|
|
|
* @package Airtime
|
2010-07-24 05:03:53 +02:00
|
|
|
* @copyright 2010 Sourcefabric O.P.S.
|
2006-12-16 07:36:22 +01:00
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt
|
2006-10-19 16:55:07 +02:00
|
|
|
*/
|
|
|
|
|
2006-12-16 07:36:22 +01:00
|
|
|
// Do not allow remote execution.
|
2006-10-19 16:55:07 +02:00
|
|
|
$arr = array_diff_assoc($_SERVER, $_ENV);
|
2006-12-16 07:36:22 +01:00
|
|
|
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
2006-10-19 16:55:07 +02:00
|
|
|
header("HTTP/1.1 400");
|
|
|
|
header("Content-type: text/plain; charset=UTF-8");
|
2011-03-09 06:44:51 +01:00
|
|
|
echo "400 Not executable".PHP_EOL;
|
2006-10-19 16:55:07 +02:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2011-03-09 06:44:51 +01:00
|
|
|
require_once(dirname(__FILE__).'/../application/configs/conf.php');
|
|
|
|
require_once(dirname(__FILE__).'/installInit.php');
|
|
|
|
|
2011-01-20 16:56:07 +01:00
|
|
|
// Need to check that we are superuser before running this.
|
2011-03-09 06:44:51 +01:00
|
|
|
checkIfRoot();
|
2011-01-20 16:56:07 +01:00
|
|
|
|
2006-10-19 16:55:07 +02:00
|
|
|
|
2011-03-09 06:44:51 +01:00
|
|
|
echo "******************************* Uninstall Begin ********************************".PHP_EOL;
|
2010-10-11 17:22:04 +02:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Delete the database
|
2011-03-08 23:54:53 +01:00
|
|
|
// Note: Do not put a call to airtime_db_connect()
|
2010-10-11 17:22:04 +02:00
|
|
|
// before this function, even if you called $CC_DBC->disconnect(), there will
|
|
|
|
// still be a connection to the database and you wont be able to delete it.
|
|
|
|
//------------------------------------------------------------------------
|
2011-03-09 06:44:51 +01:00
|
|
|
echo " * Dropping the database '".$CC_CONFIG['dsn']['database']."'...".PHP_EOL;
|
2010-10-11 17:22:04 +02:00
|
|
|
$command = "sudo -u postgres dropdb {$CC_CONFIG['dsn']['database']} 2> /dev/null";
|
2010-10-18 12:12:23 +02:00
|
|
|
@exec($command, $output, $dbDeleteFailed);
|
2010-10-11 17:22:04 +02:00
|
|
|
|
2010-10-18 12:12:23 +02:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Delete DB tables
|
|
|
|
// We do this if dropping the database fails above.
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
if ($dbDeleteFailed) {
|
2011-03-09 06:44:51 +01:00
|
|
|
echo " * Couldn't delete the database, so deleting all the DB tables...".PHP_EOL;
|
2011-03-08 23:54:53 +01:00
|
|
|
airtime_db_connect(true);
|
2010-10-18 12:12:23 +02:00
|
|
|
|
2011-03-11 19:59:20 +01:00
|
|
|
if (!PEAR::isError($CC_DBC)) {
|
|
|
|
$sql = "select * from pg_tables where tableowner = 'airtime'";
|
|
|
|
$rows = airtime_get_query($sql);
|
|
|
|
|
|
|
|
foreach ($rows as $row){
|
|
|
|
$tablename = $row["tablename"];
|
|
|
|
echo " * Removing database table $tablename...";
|
|
|
|
|
|
|
|
if (airtime_db_table_exists($tablename)){
|
|
|
|
$sql = "DROP TABLE $tablename CASCADE";
|
|
|
|
airtime_install_query($sql, false);
|
|
|
|
|
|
|
|
$CC_DBC->dropSequence($tablename."_id");
|
|
|
|
}
|
2011-03-09 06:44:51 +01:00
|
|
|
echo "done.".PHP_EOL;
|
2010-10-18 12:12:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-10 20:37:02 +02:00
|
|
|
|
2010-10-11 17:22:04 +02:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Delete the user
|
|
|
|
//------------------------------------------------------------------------
|
2011-03-09 06:44:51 +01:00
|
|
|
echo " * Deleting database user '{$CC_CONFIG['dsn']['username']}'...".PHP_EOL;
|
2010-10-11 17:22:04 +02:00
|
|
|
$command = "sudo -u postgres psql postgres --command \"DROP USER {$CC_CONFIG['dsn']['username']}\" 2> /dev/null";
|
|
|
|
@exec($command, $output, $results);
|
|
|
|
if ($results == 0) {
|
2011-03-09 06:44:51 +01:00
|
|
|
echo " * User '{$CC_CONFIG['dsn']['username']}' deleted.".PHP_EOL;
|
2010-09-10 20:37:02 +02:00
|
|
|
} else {
|
2011-03-09 06:44:51 +01:00
|
|
|
echo " * Nothing to delete..".PHP_EOL;
|
2010-09-10 20:37:02 +02:00
|
|
|
}
|
|
|
|
|
2011-01-20 17:37:39 +01:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Delete files
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
airtime_uninstall_delete_files($CC_CONFIG['storageDir']);
|
|
|
|
|
|
|
|
|
2011-01-26 14:23:22 +01:00
|
|
|
$command = "python ".__DIR__."/../pypo/install/pypo-uninstall.py";
|
2011-01-28 06:23:39 +01:00
|
|
|
system($command);
|
2011-03-09 06:44:51 +01:00
|
|
|
echo "****************************** Uninstall Complete ******************************".PHP_EOL;
|
2011-02-22 18:22:31 +01:00
|
|
|
|