1
|
<?php
|
2
|
|
3
|
// $Id: uninstall.php 114 2005-09-16 20:54:31Z stefan $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2005, Ryan Djurovich
|
9
|
|
10
|
Website Baker is free software; you can redistribute it and/or modify
|
11
|
it under the terms of the GNU General Public License as published by
|
12
|
the Free Software Foundation; either version 2 of the License, or
|
13
|
(at your option) any later version.
|
14
|
|
15
|
Website Baker is distributed in the hope that it will be useful,
|
16
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
GNU General Public License for more details.
|
19
|
|
20
|
You should have received a copy of the GNU General Public License
|
21
|
along with Website Baker; if not, write to the Free Software
|
22
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
|
24
|
*/
|
25
|
|
26
|
// Check if user selected module
|
27
|
if(!isset($_POST['file']) OR $_POST['file'] == "") {
|
28
|
header("Location: index.php");
|
29
|
} else {
|
30
|
$file = $_POST['file'];
|
31
|
}
|
32
|
|
33
|
// Setup admin object
|
34
|
require('../../config.php');
|
35
|
require_once(WB_PATH.'/framework/class.admin.php');
|
36
|
$admin = new admin('Addons', 'modules_uninstall');
|
37
|
|
38
|
// Include the WB functions file
|
39
|
require_once(WB_PATH.'/framework/functions.php');
|
40
|
|
41
|
// Check if the module exists
|
42
|
if(!is_dir(WB_PATH.'/modules/'.$file)) {
|
43
|
$admin->print_error($MESSAGE['MODULES']['NOT_INSTALLED']);
|
44
|
}
|
45
|
|
46
|
// Check if the module is in use
|
47
|
$query_modules = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE module = '".$admin->add_slashes($_POST['file'])."' LIMIT 1");
|
48
|
if($query_modules->numRows() > 0) {
|
49
|
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE']);
|
50
|
}
|
51
|
|
52
|
// Check if we have permissions on the directory
|
53
|
if(!is_writable(WB_PATH.'/modules/'.$file)) {
|
54
|
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);
|
55
|
}
|
56
|
|
57
|
$database->query("DELETE FROM ".TABLE_PREFIX."modules WHERE directory =
|
58
|
'$file'");
|
59
|
|
60
|
// Run the modules uninstall script if there is one
|
61
|
if(file_exists(WB_PATH.'/modules/'.$file.'/uninstall.php')) {
|
62
|
require(WB_PATH.'/modules/'.$file.'/uninstall.php');
|
63
|
}
|
64
|
|
65
|
// Try to delete the module dir
|
66
|
if(!rm_full_dir(WB_PATH.'/modules/'.$file)) {
|
67
|
$admin->print_error($MESSAGE['MODULES']['CANNOT_UNINSTALL']);
|
68
|
}
|
69
|
|
70
|
// Print success message
|
71
|
$admin->print_success($MESSAGE['GENERIC']['UNINSTALLED']);
|
72
|
|
73
|
// Print admin footer
|
74
|
$admin->print_footer();
|
75
|
|
76
|
?>
|