| 1 | 
        
            2
         | 
        
            Manuela
         | 
        <?php
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        /**
  | 
      
      
        | 3 | 
        
         | 
        
         | 
         *
  | 
      
      
        | 4 | 
        
         | 
        
         | 
         * @category        admin
  | 
      
      
        | 5 | 
        
         | 
        
         | 
         * @package         languages
  | 
      
      
        | 6 | 
        
         | 
        
         | 
         * @author          WebsiteBaker Project
  | 
      
      
        | 7 | 
        
         | 
        
         | 
         * @copyright       Ryan Djurovich
  | 
      
      
        | 8 | 
        
         | 
        
         | 
         * @copyright       WebsiteBaker Org. e.V.
  | 
      
      
        | 9 | 
        
         | 
        
         | 
         * @link            http://websitebaker.org/
  | 
      
      
        | 10 | 
        
         | 
        
         | 
         * @license         http://www.gnu.org/licenses/gpl.html
  | 
      
      
        | 11 | 
        
         | 
        
         | 
         * @platform        WebsiteBaker 2.8.3
  | 
      
      
        | 12 | 
        
         | 
        
         | 
         * @requirements    PHP 5.3.6 and higher
  | 
      
      
        | 13 | 
        
         | 
        
         | 
         * @version         $Id$
  | 
      
      
        | 14 | 
        
         | 
        
         | 
         * @filesource      $HeadURL$
  | 
      
      
        | 15 | 
        
         | 
        
         | 
         * @lastmodified    $Date$
  | 
      
      
        | 16 | 
        
         | 
        
         | 
         * @description
  | 
      
      
        | 17 | 
        
         | 
        
         | 
         *
  | 
      
      
        | 18 | 
        
         | 
        
         | 
         */
  | 
      
      
        | 19 | 
        
         | 
        
         | 
        
  | 
      
      
        | 20 | 
        
         | 
        
         | 
        // Include config file and admin class file
  | 
      
      
        | 21 | 
        
         | 
        
         | 
        if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
 | 
      
      
        | 22 | 
        
         | 
        
         | 
        if ( !class_exists('admin', false) ) { require(WB_PATH.'/framework/class.admin.php'); }
 | 
      
      
        | 23 | 
        
         | 
        
         | 
        
  | 
      
      
        | 24 | 
        
         | 
        
         | 
        $admin = new admin('Addons', 'languages_uninstall', false);
 | 
      
      
        | 25 | 
        
         | 
        
         | 
        
  | 
      
      
        | 26 | 
        
         | 
        
         | 
        $js_back = ADMIN_URL.'/languages/index.php';
  | 
      
      
        | 27 | 
        
         | 
        
         | 
        
  | 
      
      
        | 28 | 
        
         | 
        
         | 
        if( !$admin->checkFTAN() )
  | 
      
      
        | 29 | 
        
         | 
        
         | 
        {
 | 
      
      
        | 30 | 
        
         | 
        
         | 
            $admin->print_header();
  | 
      
      
        | 31 | 
        
         | 
        
         | 
            $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back );
  | 
      
      
        | 32 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 33 | 
        
         | 
        
         | 
        // After check print the header
  | 
      
      
        | 34 | 
        
         | 
        
         | 
        $admin->print_header();
  | 
      
      
        | 35 | 
        
         | 
        
         | 
        
  | 
      
      
        | 36 | 
        
         | 
        
         | 
        // Get module name
  | 
      
      
        | 37 | 
        
         | 
        
         | 
            $code = '';
  | 
      
      
        | 38 | 
        
         | 
        
         | 
            if (!isset($_POST['code']) || $_POST['code'] == false) {
 | 
      
      
        | 39 | 
        
         | 
        
         | 
                $iAddonId = 0;
  | 
      
      
        | 40 | 
        
         | 
        
         | 
                $admin->print_error( $MESSAGE['GENERIC_FORGOT_OPTIONS'], $js_back );
  | 
      
      
        | 41 | 
        
         | 
        
         | 
            } else {
 | 
      
      
        | 42 | 
        
         | 
        
         | 
                $iAddonId = $admin->checkIDKEY('code',0);
 | 
      
      
        | 43 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 44 | 
        
         | 
        
         | 
            if ($iAddonId == 0){
 | 
      
      
        | 45 | 
        
         | 
        
         | 
                $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back );
  | 
      
      
        | 46 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 47 | 
        
         | 
        
         | 
        
  | 
      
      
        | 48 | 
        
         | 
        
         | 
        // Get module directory
  | 
      
      
        | 49 | 
        
         | 
        
         | 
            $sqlAddons = 'SELECT `directory` FROM `'.TABLE_PREFIX.'addons` '
  | 
      
      
        | 50 | 
        
         | 
        
         | 
                       . 'WHERE `addon_id`='.(int)$iAddonId.' '
  | 
      
      
        | 51 | 
        
         | 
        
         | 
                       . ''.'';
  | 
      
      
        | 52 | 
        
         | 
        
         | 
            if ($code = $database->get_one($sqlAddons)) {
 | 
      
      
        | 53 | 
        
         | 
        
         | 
                // fix secunia 2010-93-2
  | 
      
      
        | 54 | 
        
         | 
        
         | 
                if (!preg_match('/^[A-Z]{2}$/', $code) && $code!='' ) {
 | 
      
      
        | 55 | 
        
         | 
        
         | 
                    $admin->print_error( $MESSAGE['GENERIC_ERROR_OPENING_FILE'], $js_back );
  | 
      
      
        | 56 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 57 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 58 | 
        
         | 
        
         | 
        
  | 
      
      
        | 59 | 
        
         | 
        
         | 
        // Include the WB functions file
  | 
      
      
        | 60 | 
        
         | 
        
         | 
        require_once(WB_PATH.'/framework/functions.php');
  | 
      
      
        | 61 | 
        
         | 
        
         | 
        
  | 
      
      
        | 62 | 
        
         | 
        
         | 
        // Check if the language exists
  | 
      
      
        | 63 | 
        
         | 
        
         | 
        if(!file_exists(WB_PATH.'/languages/'.$code.'.php')) {
 | 
      
      
        | 64 | 
        
         | 
        
         | 
            $admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED'], $js_back );
  | 
      
      
        | 65 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 66 | 
        
         | 
        
         | 
        
  | 
      
      
        | 67 | 
        
         | 
        
         | 
        // Check if the language is in use
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        if($code == DEFAULT_LANGUAGE OR $code == LANGUAGE) {
 | 
      
      
        | 69 | 
        
         | 
        
         | 
            $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
  | 
      
      
        | 70 | 
        
         | 
        
         | 
        } else {
 | 
      
      
        | 71 | 
        
         | 
        
         | 
            $query_users = $database->query("SELECT `user_id` FROM `".TABLE_PREFIX."users` WHERE `language` = '".$code."' LIMIT 1");
 | 
      
      
        | 72 | 
        
         | 
        
         | 
            if($query_users->numRows() > 0) {
 | 
      
      
        | 73 | 
        
         | 
        
         | 
                $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE']);
  | 
      
      
        | 74 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 75 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 76 | 
        
         | 
        
         | 
        
  | 
      
      
        | 77 | 
        
         | 
        
         | 
        // Try to delete the language code
  | 
      
      
        | 78 | 
        
         | 
        
         | 
        if (!unlink(WB_PATH.'/languages/'.$code.'.php')) {
 | 
      
      
        | 79 | 
        
         | 
        
         | 
            $admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
  | 
      
      
        | 80 | 
        
         | 
        
         | 
        } else {
 | 
      
      
        | 81 | 
        
         | 
        
         | 
            // Remove entry from DB
  | 
      
      
        | 82 | 
        
         | 
        
         | 
            $sql  = 'DELETE FROM `'.TABLE_PREFIX.'addons` '
  | 
      
      
        | 83 | 
        
         | 
        
         | 
                  . 'WHERE `directory` = \''.$code.'\' '
  | 
      
      
        | 84 | 
        
         | 
        
         | 
                  .   'AND `type` = \'language\'';
  | 
      
      
        | 85 | 
        
         | 
        
         | 
            $database->query($sql);
  | 
      
      
        | 86 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 87 | 
        
         | 
        
         | 
        
  | 
      
      
        | 88 | 
        
         | 
        
         | 
        // Print success message
  | 
      
      
        | 89 | 
        
         | 
        
         | 
        $admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
  | 
      
      
        | 90 | 
        
         | 
        
         | 
        
  | 
      
      
        | 91 | 
        
         | 
        
         | 
        // Print admin footer
  | 
      
      
        | 92 | 
        
         | 
        
         | 
        $admin->print_footer();
  |