1
|
<?php
|
2
|
|
3
|
// $Id: uninstall.php 1457 2011-06-25 17:18:50Z Luisehahne $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2009, 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
|
// Setup admin object
|
27
|
require('../../config.php');
|
28
|
require_once(WB_PATH.'/framework/class.admin.php');
|
29
|
$admin = new admin('Addons', 'languages_uninstall', false);
|
30
|
if( !$admin->checkFTAN() )
|
31
|
{
|
32
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
33
|
}
|
34
|
// After check print the header
|
35
|
$admin->print_header();
|
36
|
|
37
|
// Check if user selected language
|
38
|
if(!isset($_POST['code']) OR $_POST['code'] == "") {
|
39
|
header("Location: index.php");
|
40
|
exit(0);
|
41
|
}
|
42
|
|
43
|
// Extra protection
|
44
|
if(trim($_POST['code']) == '') {
|
45
|
header("Location: index.php");
|
46
|
exit(0);
|
47
|
}
|
48
|
|
49
|
// Include the WB functions file
|
50
|
require_once(WB_PATH.'/framework/functions.php');
|
51
|
|
52
|
// Check if the language exists
|
53
|
if(!file_exists(WB_PATH.'/languages/'.$_POST['code'].'.php')) {
|
54
|
$admin->print_error($MESSAGE['GENERIC']['NOT_INSTALLED']);
|
55
|
}
|
56
|
|
57
|
// Check if the language is in use
|
58
|
if($_POST['code'] == DEFAULT_LANGUAGE OR $_POST['code'] == LANGUAGE) {
|
59
|
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE']);
|
60
|
} else {
|
61
|
$query_users = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE language = '".$admin->add_slashes($_POST['code'])."' LIMIT 1");
|
62
|
if($query_users->numRows() > 0) {
|
63
|
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE']);
|
64
|
}
|
65
|
}
|
66
|
|
67
|
// Try to delete the language code
|
68
|
if(!unlink(WB_PATH.'/languages/'.$_POST['code'].'.php')) {
|
69
|
$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);
|
70
|
} else {
|
71
|
// Remove entry from DB
|
72
|
$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE directory = '".$_POST['code']."' AND type = 'language'");
|
73
|
}
|
74
|
|
75
|
// Print success message
|
76
|
$admin->print_success($MESSAGE['GENERIC']['UNINSTALLED']);
|
77
|
|
78
|
// Print admin footer
|
79
|
$admin->print_footer();
|
80
|
|
81
|
?>
|