Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         languages
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8
 * @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: uninstall.php 2098 2014-02-11 01:37:03Z darkviper $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/languages/uninstall.php $
14
 * @lastmodified    $Date: 2014-02-11 02:37:03 +0100 (Tue, 11 Feb 2014) $
15
 * @description
16
 *
17
 */
18

    
19
// 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
$admin = new admin('Addons', 'languages_uninstall', false);
29
if( !$admin->checkFTAN() )
30
{
31
	$admin->print_header();
32
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
33
}
34
// After check print the header
35
$admin->print_header();
36
$oLang = Translate::getInstance();
37
$oLang->enableAddon('admin\\languages');
38

    
39
// Get language name
40
if(!isset($_POST['code']) OR $_POST['code'] == "") {
41
	$code = '';
42
	$file = '';
43
} else {
44
	$code = $_POST['code'];
45
	$file = $_POST['code'].'.php';
46
}
47
// fix secunia 2010-93-2
48
if (!preg_match('/^([A-Z]{2}.php)/', $file)) {
49
	$admin->print_error($oLang->MESSAGE_GENERIC_FORGOT_OPTIONS);
50
}
51

    
52
// Check if the template exists
53
if(!is_file(WB_PATH.'/languages/'.$file)) {
54
	$admin->print_error($oLang->MESSAGE_GENERIC_NOT_INSTALLED);
55
}
56

    
57
// Check if the template exists
58
if(!is_readable(WB_PATH.'/languages/'.$file)) {
59
	$admin->print_error($oLang->MESSAGE_ADMIN_INSUFFICIENT_PRIVELLIGES);
60
}
61

    
62
// Include the WB functions file
63
require_once(WB_PATH.'/framework/functions.php');
64

    
65
// Check if the language is in use
66
if($code == DEFAULT_LANGUAGE OR $code == LANGUAGE) {
67
	$admin->print_error($oLang->MESSAGE_GENERIC_CANNOT_UNINSTALL_IN_USE);
68
} else {
69
	$sql  = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'users` ';
70
	$sql .= 'WHERE`language`=\''.$database->escapeString($code).'\'';
71
	if( $database->get_one($sql) ) {
72
		$admin->print_error($oLang->MESSAGE_GENERIC_CANNOT_UNINSTALL_IN_USE);
73
	}
74
}
75

    
76
// Try to delete the language code
77
if(!unlink(WB_PATH.'/languages/'.$file)) {
78
	$admin->print_error($oLang->MESSAGE_GENERIC_CANNOT_UNINSTALL);
79
} else {
80
	// Remove entry from DB
81
	$sql  = 'DELETE FROM `'.TABLE_PREFIX.'addons` ';
82
	$sql .= 'WHERE `directory`=\''.$database->escapeString($code).'\' ';
83
	$sql .=   'AND `type`=`type`=\'language\' ';
84
	if( $database->query($sql) ) {
85
        // Print success message
86
        $admin->print_success($oLang->MESSAGE_GENERIC_UNINSTALLED);
87
    } else {
88
    	$admin->print_error($oLang->MESSAGE_GENERIC_CANNOT_UNINSTALL.'<br />'.$database->get_error());
89
    }
90
}
91

    
92
// Print admin footer
93
$admin->print_footer();
(4-4/4)