| 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 | 1457 | Luisehahne | // Setup admin object
 | 
      
        | 20 |  |  | require('../../config.php');
 | 
      
        | 21 |  |  | require_once(WB_PATH.'/framework/class.admin.php');
 | 
      
        | 22 |  |  | $admin = new admin('Addons', 'languages_uninstall', false);
 | 
      
        | 23 |  |  | if( !$admin->checkFTAN() )
 | 
      
        | 24 |  |  | {
 | 
      
        | 25 | 1467 | Luisehahne | 	$admin->print_header();
 | 
      
        | 26 | 1457 | Luisehahne | 	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
 | 
      
        | 27 |  |  | }
 | 
      
        | 28 |  |  | // After check print the header
 | 
      
        | 29 |  |  | $admin->print_header();
 | 
      
        | 30 |  |  | 
 | 
      
        | 31 | 1712 | Luisehahne | // Get language name
 | 
      
        | 32 |  |  | if(!isset($_POST['code']) OR $_POST['code'] == "") {
 | 
      
        | 33 |  |  | 	$code = '';
 | 
      
        | 34 |  |  | 	$file = '';
 | 
      
        | 35 |  |  | } else {
 | 
      
        | 36 |  |  | 	$code = $_POST['code'];
 | 
      
        | 37 |  |  | 	$file = $_POST['code'].'.php';
 | 
      
        | 38 |  |  | }
 | 
      
        | 39 |  |  | // fix secunia 2010-93-2
 | 
      
        | 40 |  |  | if (!preg_match('/^([A-Z]{2}.php)/', $file)) {
 | 
      
        | 41 |  |  | 	$admin->print_error($MESSAGE['GENERIC_FORGOT_OPTIONS']);
 | 
      
        | 42 |  |  | }
 | 
      
        | 43 |  |  | 
 | 
      
        | 44 |  |  | // Check if the template exists
 | 
      
        | 45 |  |  | if(!is_file(WB_PATH.'/languages/'.$file)) {
 | 
      
        | 46 |  |  | 	$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
 | 
      
        | 47 |  |  | }
 | 
      
        | 48 |  |  | 
 | 
      
        | 49 |  |  | // Check if the template exists
 | 
      
        | 50 |  |  | if(!is_readable(WB_PATH.'/languages/'.$file)) {
 | 
      
        | 51 |  |  | 	$admin->print_error($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']);
 | 
      
        | 52 |  |  | }
 | 
      
        | 53 |  |  | 
 | 
      
        | 54 |  |  | /*
 | 
      
        | 55 | 4 | ryan | // Check if user selected language
 | 
      
        | 56 |  |  | if(!isset($_POST['code']) OR $_POST['code'] == "") {
 | 
      
        | 57 |  |  | 	header("Location: index.php");
 | 
      
        | 58 | 286 | stefan | 	exit(0);
 | 
      
        | 59 | 4 | ryan | }
 | 
      
        | 60 |  |  | 
 | 
      
        | 61 | 268 | ryan | // Extra protection
 | 
      
        | 62 |  |  | if(trim($_POST['code']) == '') {
 | 
      
        | 63 |  |  | 	header("Location: index.php");
 | 
      
        | 64 | 286 | stefan | 	exit(0);
 | 
      
        | 65 | 268 | ryan | }
 | 
      
        | 66 |  |  | 
 | 
      
        | 67 | 4 | ryan | // Check if the language exists
 | 
      
        | 68 |  |  | if(!file_exists(WB_PATH.'/languages/'.$_POST['code'].'.php')) {
 | 
      
        | 69 | 1712 | Luisehahne | 	$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
 | 
      
        | 70 | 4 | ryan | }
 | 
      
        | 71 | 1712 | Luisehahne | */
 | 
      
        | 72 |  |  | // Include the WB functions file
 | 
      
        | 73 |  |  | require_once(WB_PATH.'/framework/functions.php');
 | 
      
        | 74 | 4 | ryan | 
 | 
      
        | 75 |  |  | // Check if the language is in use
 | 
      
        | 76 | 1712 | Luisehahne | if($code == DEFAULT_LANGUAGE OR $code == LANGUAGE) {
 | 
      
        | 77 |  |  | 	$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
 | 
      
        | 78 | 4 | ryan | } else {
 | 
      
        | 79 | 1712 | Luisehahne | 	$query_users = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE language = '".$admin->add_slashes($code)."' LIMIT 1");
 | 
      
        | 80 | 4 | ryan | 	if($query_users->numRows() > 0) {
 | 
      
        | 81 | 1712 | Luisehahne | 		$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
 | 
      
        | 82 | 4 | ryan | 	}
 | 
      
        | 83 |  |  | }
 | 
      
        | 84 |  |  | 
 | 
      
        | 85 |  |  | // Try to delete the language code
 | 
      
        | 86 | 1712 | Luisehahne | if(!unlink(WB_PATH.'/languages/'.$file)) {
 | 
      
        | 87 |  |  | 	$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
 | 
      
        | 88 | 170 | ryan | } else {
 | 
      
        | 89 |  |  | 	// Remove entry from DB
 | 
      
        | 90 | 1712 | Luisehahne | 	$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE directory = \'".$code."\' AND type = 'language'");
 | 
      
        | 91 | 4 | ryan | }
 | 
      
        | 92 |  |  | 
 | 
      
        | 93 |  |  | // Print success message
 | 
      
        | 94 | 1712 | Luisehahne | $admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
 | 
      
        | 95 | 4 | ryan | 
 | 
      
        | 96 |  |  | // Print admin footer
 | 
      
        | 97 |  |  | $admin->print_footer();
 |