| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  *
 | 
  
    | 4 |  * @category        admin
 | 
  
    | 5 |  * @package         languages
 | 
  
    | 6 |  * @author          WebsiteBaker Project
 | 
  
    | 7 |  * @copyright       2004-2009, Ryan Djurovich
 | 
  
    | 8 |  * @copyright       2009-2011, Website Baker Org. e.V.
 | 
  
    | 9 |  * @link            http://www.websitebaker2.org/
 | 
  
    | 10 |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
  
    | 11 |  * @platform        WebsiteBaker 2.8.x
 | 
  
    | 12 |  * @requirements    PHP 5.2.2 and higher
 | 
  
    | 13 |  * @version         $Id: uninstall.php 1467 2011-07-02 00:06:53Z Luisehahne $
 | 
  
    | 14 |  * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/languages/uninstall.php $
 | 
  
    | 15 |  * @lastmodified    $Date: 2011-07-02 02:06:53 +0200 (Sat, 02 Jul 2011) $
 | 
  
    | 16 |  * @description
 | 
  
    | 17 |  *
 | 
  
    | 18 |  */
 | 
  
    | 19 | 
 | 
  
    | 20 | // Setup admin object
 | 
  
    | 21 | require('../../config.php');
 | 
  
    | 22 | require_once(WB_PATH.'/framework/class.admin.php');
 | 
  
    | 23 | $admin = new admin('Addons', 'languages_uninstall', false);
 | 
  
    | 24 | if( !$admin->checkFTAN() )
 | 
  
    | 25 | {
 | 
  
    | 26 | 	$admin->print_header();
 | 
  
    | 27 | 	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
 | 
  
    | 28 | }
 | 
  
    | 29 | // After check print the header
 | 
  
    | 30 | $admin->print_header();
 | 
  
    | 31 | 
 | 
  
    | 32 | // Check if user selected language
 | 
  
    | 33 | if(!isset($_POST['code']) OR $_POST['code'] == "") {
 | 
  
    | 34 | 	header("Location: index.php");
 | 
  
    | 35 | 	exit(0);
 | 
  
    | 36 | }
 | 
  
    | 37 | 
 | 
  
    | 38 | // Extra protection
 | 
  
    | 39 | if(trim($_POST['code']) == '') {
 | 
  
    | 40 | 	header("Location: index.php");
 | 
  
    | 41 | 	exit(0);
 | 
  
    | 42 | }
 | 
  
    | 43 | 
 | 
  
    | 44 | // Include the WB functions file
 | 
  
    | 45 | require_once(WB_PATH.'/framework/functions.php');
 | 
  
    | 46 | 
 | 
  
    | 47 | // Check if the language exists
 | 
  
    | 48 | if(!file_exists(WB_PATH.'/languages/'.$_POST['code'].'.php')) {
 | 
  
    | 49 | 	$admin->print_error($MESSAGE['GENERIC']['NOT_INSTALLED']);
 | 
  
    | 50 | }
 | 
  
    | 51 | 
 | 
  
    | 52 | // Check if the language is in use
 | 
  
    | 53 | if($_POST['code'] == DEFAULT_LANGUAGE OR $_POST['code'] == LANGUAGE) {
 | 
  
    | 54 | 	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE']);
 | 
  
    | 55 | } else {
 | 
  
    | 56 | 	$query_users = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE language = '".$admin->add_slashes($_POST['code'])."' LIMIT 1");
 | 
  
    | 57 | 	if($query_users->numRows() > 0) {
 | 
  
    | 58 | 		$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE']);
 | 
  
    | 59 | 	}
 | 
  
    | 60 | }
 | 
  
    | 61 | 
 | 
  
    | 62 | // Try to delete the language code
 | 
  
    | 63 | if(!unlink(WB_PATH.'/languages/'.$_POST['code'].'.php')) {
 | 
  
    | 64 | 	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);
 | 
  
    | 65 | } else {
 | 
  
    | 66 | 	// Remove entry from DB
 | 
  
    | 67 | 	$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE directory = '".$_POST['code']."' AND type = 'language'");
 | 
  
    | 68 | }
 | 
  
    | 69 | 
 | 
  
    | 70 | // Print success message
 | 
  
    | 71 | $admin->print_success($MESSAGE['GENERIC']['UNINSTALLED']);
 | 
  
    | 72 | 
 | 
  
    | 73 | // Print admin footer
 | 
  
    | 74 | $admin->print_footer();
 | 
  
    | 75 | 
 | 
  
    | 76 | ?>
 |