| 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 1712 2012-08-29 11:59:57Z Luisehahne $
 | 
  
    | 13 |  * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/languages/uninstall.php $
 | 
  
    | 14 |  * @lastmodified    $Date: 2012-08-29 13:59:57 +0200 (Wed, 29 Aug 2012) $
 | 
  
    | 15 |  * @description
 | 
  
    | 16 |  *
 | 
  
    | 17 |  */
 | 
  
    | 18 | 
 | 
  
    | 19 | // 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 | 	$admin->print_header();
 | 
  
    | 26 | 	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
 | 
  
    | 27 | }
 | 
  
    | 28 | // After check print the header
 | 
  
    | 29 | $admin->print_header();
 | 
  
    | 30 | 
 | 
  
    | 31 | // 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 | // Check if user selected language
 | 
  
    | 56 | if(!isset($_POST['code']) OR $_POST['code'] == "") {
 | 
  
    | 57 | 	header("Location: index.php");
 | 
  
    | 58 | 	exit(0);
 | 
  
    | 59 | }
 | 
  
    | 60 | 
 | 
  
    | 61 | // Extra protection
 | 
  
    | 62 | if(trim($_POST['code']) == '') {
 | 
  
    | 63 | 	header("Location: index.php");
 | 
  
    | 64 | 	exit(0);
 | 
  
    | 65 | }
 | 
  
    | 66 | 
 | 
  
    | 67 | // Check if the language exists
 | 
  
    | 68 | if(!file_exists(WB_PATH.'/languages/'.$_POST['code'].'.php')) {
 | 
  
    | 69 | 	$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
 | 
  
    | 70 | }
 | 
  
    | 71 | */
 | 
  
    | 72 | // Include the WB functions file
 | 
  
    | 73 | require_once(WB_PATH.'/framework/functions.php');
 | 
  
    | 74 | 
 | 
  
    | 75 | // Check if the language is in use
 | 
  
    | 76 | if($code == DEFAULT_LANGUAGE OR $code == LANGUAGE) {
 | 
  
    | 77 | 	$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
 | 
  
    | 78 | } else {
 | 
  
    | 79 | 	$query_users = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE language = '".$admin->add_slashes($code)."' LIMIT 1");
 | 
  
    | 80 | 	if($query_users->numRows() > 0) {
 | 
  
    | 81 | 		$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
 | 
  
    | 82 | 	}
 | 
  
    | 83 | }
 | 
  
    | 84 | 
 | 
  
    | 85 | // Try to delete the language code
 | 
  
    | 86 | if(!unlink(WB_PATH.'/languages/'.$file)) {
 | 
  
    | 87 | 	$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
 | 
  
    | 88 | } else {
 | 
  
    | 89 | 	// Remove entry from DB
 | 
  
    | 90 | 	$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE directory = \'".$code."\' AND type = 'language'");
 | 
  
    | 91 | }
 | 
  
    | 92 | 
 | 
  
    | 93 | // Print success message
 | 
  
    | 94 | $admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
 | 
  
    | 95 | 
 | 
  
    | 96 | // Print admin footer
 | 
  
    | 97 | $admin->print_footer();
 |