1 |
4
|
ryan
|
<?php
|
2 |
1467
|
Luisehahne
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package languages
|
6 |
1712
|
Luisehahne
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7 |
|
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8 |
1467
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
9 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
|
|
* @platform WebsiteBaker 2.8.x
|
11 |
|
|
* @requirements PHP 5.2.2 and higher
|
12 |
|
|
* @version $Id$
|
13 |
|
|
* @filesource $HeadURL$
|
14 |
|
|
* @lastmodified $Date$
|
15 |
|
|
* @description
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
4
|
ryan
|
|
19 |
1785
|
Luisehahne
|
// Include config file
|
20 |
|
|
$config_file = realpath('../../config.php');
|
21 |
|
|
if(file_exists($config_file) && !defined('WB_URL'))
|
22 |
|
|
{
|
23 |
|
|
require($config_file);
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
|
27 |
|
|
|
28 |
1457
|
Luisehahne
|
$admin = new admin('Addons', 'languages_uninstall', false);
|
29 |
|
|
if( !$admin->checkFTAN() )
|
30 |
|
|
{
|
31 |
1467
|
Luisehahne
|
$admin->print_header();
|
32 |
1457
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
33 |
|
|
}
|
34 |
|
|
// After check print the header
|
35 |
|
|
$admin->print_header();
|
36 |
|
|
|
37 |
1712
|
Luisehahne
|
// Get language name
|
38 |
|
|
if(!isset($_POST['code']) OR $_POST['code'] == "") {
|
39 |
|
|
$code = '';
|
40 |
|
|
$file = '';
|
41 |
|
|
} else {
|
42 |
|
|
$code = $_POST['code'];
|
43 |
|
|
$file = $_POST['code'].'.php';
|
44 |
|
|
}
|
45 |
|
|
// fix secunia 2010-93-2
|
46 |
|
|
if (!preg_match('/^([A-Z]{2}.php)/', $file)) {
|
47 |
|
|
$admin->print_error($MESSAGE['GENERIC_FORGOT_OPTIONS']);
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
// Check if the template exists
|
51 |
|
|
if(!is_file(WB_PATH.'/languages/'.$file)) {
|
52 |
|
|
$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
// Check if the template exists
|
56 |
|
|
if(!is_readable(WB_PATH.'/languages/'.$file)) {
|
57 |
|
|
$admin->print_error($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']);
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
// Include the WB functions file
|
61 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
62 |
4
|
ryan
|
|
63 |
|
|
// Check if the language is in use
|
64 |
1712
|
Luisehahne
|
if($code == DEFAULT_LANGUAGE OR $code == LANGUAGE) {
|
65 |
|
|
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
|
66 |
4
|
ryan
|
} else {
|
67 |
1785
|
Luisehahne
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'users` ';
|
68 |
|
|
$sql .= 'WHERE`language`=\''.mysql_real_escape_string($code).'\'';
|
69 |
|
|
if( $database->get_one($sql) ) {
|
70 |
1712
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
|
71 |
4
|
ryan
|
}
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
// Try to delete the language code
|
75 |
1712
|
Luisehahne
|
if(!unlink(WB_PATH.'/languages/'.$file)) {
|
76 |
|
|
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
|
77 |
170
|
ryan
|
} else {
|
78 |
|
|
// Remove entry from DB
|
79 |
1785
|
Luisehahne
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'addons` ';
|
80 |
|
|
$sql .= 'WHERE `directory`=\''.mysql_real_escape_string($code).'\' ';
|
81 |
|
|
$sql .= 'AND `type`=`type`=\'language\' ';
|
82 |
|
|
if( $database->query($sql) ) {
|
83 |
|
|
// Print success message
|
84 |
|
|
$admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
|
85 |
|
|
} else {
|
86 |
|
|
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL'].'<br />'.$database->get_error());
|
87 |
|
|
}
|
88 |
4
|
ryan
|
}
|
89 |
|
|
|
90 |
|
|
// Print admin footer
|
91 |
|
|
$admin->print_footer();
|