| 
      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 1785 2012-10-12 14:08:01Z Luisehahne $
 
     | 
  
  
    | 
      13
     | 
    
       * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/languages/uninstall.php $
 
     | 
  
  
    | 
      14
     | 
    
       * @lastmodified    $Date: 2012-10-12 16:08:01 +0200 (Fri, 12 Oct 2012) $
 
     | 
  
  
    | 
      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
     | 
    
      
 
     | 
  
  
    | 
      37
     | 
    
      // 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
     | 
    
      
 
     | 
  
  
    | 
      63
     | 
    
      // Check if the language is in use
 
     | 
  
  
    | 
      64
     | 
    
      if($code == DEFAULT_LANGUAGE OR $code == LANGUAGE) {
     | 
  
  
    | 
      65
     | 
    
      	$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
 
     | 
  
  
    | 
      66
     | 
    
      } else {
     | 
  
  
    | 
      67
     | 
    
      	$sql  = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'users` ';
 
     | 
  
  
    | 
      68
     | 
    
      	$sql .= 'WHERE`language`=\''.mysql_real_escape_string($code).'\'';
 
     | 
  
  
    | 
      69
     | 
    
      	if( $database->get_one($sql) ) {
     | 
  
  
    | 
      70
     | 
    
      		$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
 
     | 
  
  
    | 
      71
     | 
    
      	}
 
     | 
  
  
    | 
      72
     | 
    
      }
 
     | 
  
  
    | 
      73
     | 
    
      
 
     | 
  
  
    | 
      74
     | 
    
      // Try to delete the language code
 
     | 
  
  
    | 
      75
     | 
    
      if(!unlink(WB_PATH.'/languages/'.$file)) {
     | 
  
  
    | 
      76
     | 
    
      	$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
 
     | 
  
  
    | 
      77
     | 
    
      } else {
     | 
  
  
    | 
      78
     | 
    
      	// Remove entry from DB
 
     | 
  
  
    | 
      79
     | 
    
      	$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
     | 
    
      }
 
     | 
  
  
    | 
      89
     | 
    
      
 
     | 
  
  
    | 
      90
     | 
    
      // Print admin footer
 
     | 
  
  
    | 
      91
     | 
    
      $admin->print_footer();
 
     |