<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php 
if ($asfile != "sendit"){
  require('load_this/load_bigware_11.php'); 
  require(FOLDER_RELATIV_LANGUAGES . $language . '/' . NAME_OF_FILE_CHANGE_INVOICE); 
?> 
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html '<?php echo HTML_PARAMS; ?>'> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 
<title><?php echo TITLE; ?></title> 
<link rel="stylesheet" type="text/css" href="load_this/style.css"> 
<script language="javascript" src="load_this/menu.js"></script>
<script src="db_tools/libraries/functions.js" type="text/javascript" language="javascript"></script>
</head> 
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> 
<!-- header //--> 
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_9.php'); ?>
<!-- header_eof //--> 
<!-- body //--> 
<table border="0" width="100%" cellspacing="2" cellpadding="2"> 
<tr> 
  <td width="<?php echo FRAME_WIDTH; ?>" valign="top"> 
    
  </td> 
<!-- body_text //--> 
        
<?php
}
require_once('db_tools/libraries/grab_globals.lib.php');
require_once('db_tools/libraries/common.lib.php');
require_once('db_tools/libraries/zip.lib.php');
PMA_checkParameters(array('what')); 
if ($what == 'excel') {
    $type = 'csv';
} else {
    $type = $what;
} 
require('db_tools/libraries/export/' . PMA_securePath($type) . '.php'); 
if ($export_type == 'server') {
    $err_url = 'server_main_bigware_37.php?' . PMA_generate_common_url();
} elseif ($export_type == 'database') {
    $err_url = 'main_bigware_28.php?' . PMA_generate_common_url($db);
} else {
    $err_url = 'tbl_properties_main_bigware_37.php?' . PMA_generate_common_url($db, $table);
}
 @set_time_limit($cfg['ExecTimeLimit']); 
$dump_buffer = '';
$dump_buffer_len = 0; 
$time_start = time();
 function PMA_exportOutputHandler($line)
{
    global $time_start, $dump_buffer, $dump_buffer_len, $save_filename; 
    if ($GLOBALS['output_kanji_conversion']) {
        $line = PMA_kanji_str_conv($line, $GLOBALS['knjenc'], isset($GLOBALS['xkana']) ? $GLOBALS['xkana'] : '');
    } 
    if ($GLOBALS['buffer_needed']) {
        $dump_buffer .= $line;
        if ($GLOBALS['onfly_compression']) {
            $dump_buffer_len += strlen($line);
            if ($dump_buffer_len > $GLOBALS['memory_limit']) {
                if ($GLOBALS['output_charset_conversion']) {
                    $dump_buffer = PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $dump_buffer);
                } 
                if ($GLOBALS['compression'] == 'bzip'  && @function_exists('bzcompress')) {
                    $dump_buffer = bzcompress($dump_buffer);
                } 
                else if ($GLOBALS['compression'] == 'gzip' && @function_exists('gzencode')) { 
                    $dump_buffer = gzencode($dump_buffer);
                }
                if ($GLOBALS['save_on_server']) {
                    $write_result = @fwrite($GLOBALS['file_handle'], $dump_buffer);
                    if (!$write_result || ($write_result != strlen($dump_buffer))) {
                        $GLOBALS['message'] = sprintf($GLOBALS['strNoSpace'], isohtmlspecialchars($save_filename));
                        return FALSE;
                    }
                } else {
                    echo $dump_buffer;
                }
                $dump_buffer = '';
                $dump_buffer_len = 0;
            }
        } else {
            $time_now = time();
            if ($time_start >= $time_now + 30) {
                $time_start = $time_now;
                header('X-pmaPing: Pong');
            } 
        }
    } else {
        if ($GLOBALS['asfile']) {
            if ($GLOBALS['save_on_server']) {
                $write_result = @fwrite($GLOBALS['file_handle'], $line);
                if (!$write_result || ($write_result != strlen($line))) {
                    $GLOBALS['message'] = sprintf($GLOBALS['strNoSpace'], isohtmlspecialchars($save_filename));
                    return FALSE;
                }
                $time_now = time();
                if ($time_start >= $time_now + 30) {
                    $time_start = $time_now;
                    header('X-pmaPing: Pong');
                } 
            } else { 
                if ($GLOBALS['output_charset_conversion']) {
                    $line = PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $line);
                }
                echo $line;
            }
        } else { 
            echo isohtmlspecialchars($line);
        }
    }
    return TRUE;
}  
$save_on_server = isset($cfg['SaveDir']) && !empty($cfg['SaveDir']) && !empty($onserver); 
if (empty($asfile)) {
    if ($save_on_server) {
        $asfile = TRUE;
    } elseif (isset($compression) && ($compression == 'zip' | $compression == 'gzip' | $compression == 'bzip')) {
        $asfile = TRUE;
    } else {
        $asfile = FALSE;
    }
} else {
    $asfile = TRUE;
} 
$crlf = PMA_whichCrlf();
$output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls'; 
$output_charset_conversion = $asfile &&
    $cfg['AllowAnywhereRecoding'] && $allow_recoding
    && isset($charset_of_file) && $charset_of_file != $charset 
    && $type != 'xls'; 
$buffer_needed = isset($compression) && ($compression == 'zip' | $compression == 'gzip' | $compression == 'bzip'); 
$onfly_compression = $GLOBALS['cfg']['CompressOnFly'] && isset($compression) && ($compression == 'gzip' | $compression == 'bzip');
if ($onfly_compression) {
    $memory_limit = trim(@ini_get('memory_limit')); 
    if (empty($memory_limit)) $memory_limit = 2 * 1024 * 1024;
    if (strtolower(substr($memory_limit, -1)) == 'm') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
    elseif (strtolower(substr($memory_limit, -1)) == 'k') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
    elseif (strtolower(substr($memory_limit, -1)) == 'g') $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
    else $memory_limit = (int)$memory_limit;   
    if ($memory_limit > 1500000) $memory_limit -= 1500000; 
    $memory_limit *= 2/3;
} 
if ($asfile) {
    $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
    if ($export_type == 'server') {
        if (isset($remember_template)) {
            setcookie('pma_server_filename_template', $filename_template , 0,
                substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')),
                '', ($pma_uri_parts['scheme'] == 'https'));
        }
        $filename = str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template));
    } elseif ($export_type == 'database') {
        if (isset($remember_template)) {
            setcookie('pma_db_filename_template', $filename_template , 0,
                substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')),
                '', ($pma_uri_parts['scheme'] == 'https'));
        }
        $filename = str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template)));
    } else {
        if (isset($remember_template)) {
            setcookie('pma_table_filename_template', $filename_template , 0,
                substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/')),
                '', ($pma_uri_parts['scheme'] == 'https'));
        }
        $filename = str_replace('__DB_TBL__', $table, str_replace('__DB__', $db, str_replace('__SERVER__', $GLOBALS['cfg']['Server']['host'], strftime($filename_template))));
    } 
    if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
        $filename = PMA_convert_string($charset, 'iso-8859-1', $filename);
    } else {
        $filename = PMA_convert_string($convcharset, 'iso-8859-1', $filename);
    } 
    if ($type == 'csv') {
        $filename  .= '.csv';
        $mime_type = 'text/x-csv';
    } else if ($type == 'xls') {
        $filename  .= '.xls';
        $mime_type = 'application/excel';
    } else if ($type == 'xml') {
        $filename  .= '.xml';
        $mime_type = 'text/xml';
    } else if ($type == 'latex') {
        $filename  .= '.tex';
        $mime_type = 'application/x-tex';
    } else {
        $filename  .= '.sql';  
        $mime_type = (PMA_USR_BROWSER_AGENT == 'IE' || PMA_USR_BROWSER_AGENT == 'OPERA')
                   ? 'application/octetstream'
                   : 'application/octet-stream';
    }  
    if (isset($compression) && $compression == 'bzip') {
        $filename  .= '.bz2';
        $mime_type = 'application/x-bzip';
    } else if (isset($compression) && $compression == 'gzip') {
        $filename  .= '.gz';
        $mime_type = 'application/x-gzip';
    } else if (isset($compression) && $compression == 'zip') {
        $filename  .= '.zip';
        $mime_type = 'application/x-zip';
    }
} 
if ($save_on_server) {
    if (substr($cfg['SaveDir'], -1) != '/') {
        $cfg['SaveDir'] .= '/';
    }
    $save_filename = $cfg['SaveDir'] . preg_replace('@[/\\\\]@','_',$filename);
    unset($message);
    if (file_exists($save_filename) && empty($onserverover)) {
        $message = sprintf($strFileAlreadyExists, isohtmlspecialchars($save_filename));
    } else {
        if (is_file($save_filename) && !is_writable($save_filename)) {
            $message = sprintf($strNoPermission, isohtmlspecialchars($save_filename));
        } else {
            if (!$file_handle = @fopen($save_filename, 'w')) {
                $message = sprintf($strNoPermission, isohtmlspecialchars($save_filename));
            }
        }
    }
    if (isset($message)) {
        $js_to_run = 'functions.js';
        if ($export_type == 'server') {
            $active_page = 'server_main_bigware_37.php';
            require('db_tools/server_main_bigware_37.php');
        } elseif ($export_type == 'database') {
            $active_page = 'main_bigware_28.php';
            require('db_tools/main_bigware_28.php');
        } else {
            $active_page = 'tbl_properties_main_bigware_37.php';
            require('db_tools/tbl_properties_main_bigware_37.php');
        }
        exit();
    }
}
 if (!$save_on_server) {
    if ($asfile ) { 
        header('Content-Type: ' . $mime_type);
        header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
        if (PMA_USR_BROWSER_AGENT == 'IE') {
            header('Content-Disposition: inline; filename="' . $filename . '"');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
        } else {
            header('Content-Disposition: attachment; filename="' . $filename . '"');
            header('Pragma: no-cache');
        }
    } else { 
        $backup_cfgServer = $cfg['Server'];
        $cfg['Server'] = $backup_cfgServer;
        unset($backup_cfgServer); 
        echo '    <form name="nofunction">' . "\n"    
           . '        <textarea name="sqldump" cols="50" rows="30" id="textSQLDUMP" wrap="OFF">' . "\n";
    } 
} 
if ($export_type == 'database') {
    $tables     = PMA_DBI_get_tables($db);
    $num_tables = count($tables);
    if ($num_tables == 0) {
        $message = $strNoTablesFound;
        $js_to_run = 'functions.js';
        if ($export_type == 'server') {
            $active_page = 'server_main_bigware_37.php';
            require('db_tools/server_main_bigware_37.php');
        } elseif ($export_type == 'database') {
            $active_page = 'main_bigware_28.php';
            require('db_tools/main_bigware_28.php');
        } else {
            $active_page = 'tbl_properties_main_bigware_37.php';
            require('db_tools/tbl_properties_main_bigware_37.php');
        }
        exit();
    }
}  
do { 
if (!PMA_exportHeader()) break; 
$do_relation = isset($GLOBALS[$what . '_relation']);
$do_comments = isset($GLOBALS[$what . '_comments']);
$do_mime     = isset($GLOBALS[$what . '_mime']);
if ($do_relation || $do_comments || $do_mime) {
    require_once('db_tools/libraries/relation.lib.php');
    $cfgRelation = PMA_getRelationsParam();
}
if ($do_mime) {
    require_once('db_tools/libraries/transformations.lib.php');
} 
$do_dates   = isset($GLOBALS[$what . '_dates']);
  
if ($export_type == 'server') {
     if ($server > 0 && empty($dblist)) {
        PMA_availableDatabases();
    }
    if (isset($db_select)) {
        $tmp_select = implode($db_select, '|');
        $tmp_select = '|' . $tmp_select . '|';
    } 
    foreach ($dblist AS $current_db) {
        if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
            || !isset($tmp_select)) {
            if (!PMA_exportDBHeader($current_db)) 
                break 2;
            if (!PMA_exportDBCreate($current_db)) 
                break 2;
            $tables = PMA_DBI_get_tables($current_db);
            foreach ($tables as $table) {
                $local_query  = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
                if (isset($GLOBALS[$what . '_structure'])) {
                    if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates))
                        break 3;
                }
                if (isset($GLOBALS[$what . '_data'])) {
                    if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query))
                        break 3;
                }
            }
            if (!PMA_exportDBFooter($current_db)) 
                break 2;
        }
    }
} elseif ($export_type == 'database') {
    if (!PMA_exportDBHeader($db))
        break;
    if (isset($table_select)) {
        $tmp_select = implode($table_select, '|');
        $tmp_select = '|' . $tmp_select . '|';
    }
    $i = 0;
    foreach ($tables as $table) {
        $local_query  = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
        if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $table . '|'))
            || !isset($tmp_select)) {
            if (isset($GLOBALS[$what . '_structure'])) {
                if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates))
                    break 2;
            }
            if (isset($GLOBALS[$what . '_data'])) {
                if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query))
                    break 2;
            }
        }
    }
    if (!PMA_exportDBFooter($db)) 
        break;
} else {
    if (!PMA_exportDBHeader($db)) 
        break; 
    if ($limit_to > 0 && $limit_from >= 0) {
        $add_query  = ' LIMIT '
                    . (($limit_from > 0) ? $limit_from . ', ' : '')
                    . $limit_to;
    } else {
        $add_query  = '';
    }
    if (!empty($sql_query)) {
        $local_query = $sql_query . $add_query;
        PMA_DBI_select_db($db);
    } else {
        $local_query  = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query;
    }
    if (isset($GLOBALS[$what . '_structure'])) {
        if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates))
            break;
    }
    if (isset($GLOBALS[$what . '_data'])) {
        if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query))
            break;
    }
    if (!PMA_exportDBFooter($db))
        break;
}
if (!PMA_exportFooter()) break;
} while (FALSE); 
if ($save_on_server && isset($message)) {
    $js_to_run = 'functions.js';
    if ($export_type == 'server') {
        $active_page = 'server_main_bigware_37.php';
        require('db_tools/server_main_bigware_37.php');
    } elseif ($export_type == 'database') {
        $active_page = 'main_bigware_28.php';
        require('db_tools/main_bigware_28.php');
    } else {
        $active_page = 'tbl_properties_main_bigware_37.php';
        require('db_tools/tbl_properties_main_bigware_37.php');
    }
    exit();
}
 if (!empty($asfile)) { 
    if ($output_charset_conversion) {
        $dump_buffer = PMA_convert_string($GLOBALS['charset'], $GLOBALS['charset_of_file'], $dump_buffer);
    }  
    if (isset($compression) && $compression == 'zip') {
        if (@function_exists('gzcompress')) {
            $zipfile = new zipfile();
            $zipfile -> addFile($dump_buffer, substr($filename, 0, -4));
            $dump_buffer = $zipfile -> file();
        }
    } 
    else if (isset($compression) && $compression == 'bzip') {
        if (@function_exists('bzcompress')) {
            $dump_buffer = bzcompress($dump_buffer);
            if ($dump_buffer === -8) {
                echo sprintf($strBzError, '<a href="http://bugs.php.net/bug.php?id=17300" target="_blank">17300</a>');
                require_once('db_tools/footer.inc.php');
            }
        }
    } 
    else if (isset($compression) && $compression == 'gzip') {
        if (@function_exists('gzencode')) { 
            $dump_buffer = gzencode($dump_buffer);
        }
    }
     if ($save_on_server) {
        $write_result = @fwrite($file_handle, $dump_buffer);
        fclose($file_handle);
        if (strlen($dump_buffer) !=0 && (!$write_result || ($write_result != strlen($dump_buffer)))) {
            $message = sprintf($strNoSpace, isohtmlspecialchars($save_filename));
        } else {
            $message = sprintf($strDumpSaved, isohtmlspecialchars($save_filename));
        }
        $js_to_run = 'functions.js';
        if ($export_type == 'server') {
            $active_page = 'server_main_bigware_37.php';
            require_once('db_tools/server_main_bigware_37.php');
        } elseif ($export_type == 'database') {
            $active_page = 'main_bigware_28.php';
            require_once('db_tools/main_bigware_28.php');
        } else {
            $active_page = 'tbl_properties_main_bigware_37.php';
            require_once('db_tools/tbl_properties_main_bigware_37.php');
        }
        exit();
    } else {
        echo $dump_buffer;
    }
}
 else {
      
    echo '        </textarea>' . "\n"
       . '    </form>' . "\n";
    echo '</div>' . "\n";
    echo "\n";
?><script language="JavaScript" type="text/javascript">
<!--
    var bodyWidth=null; var bodyHeight=null;
    if (document.getElementById('textSQLDUMP')) {
        bodyWidth  = self.innerWidth;
        bodyHeight = self.innerHeight;
        if(!bodyWidth && !bodyHeight){
            if (document.compatMode && document.compatMode == "BackCompat") {
                bodyWidth  = document.body.clientWidth;
                bodyHeight = document.body.clientHeight;
            } else if (document.compatMode && document.compatMode == "CSS1Compat") {
                bodyWidth  = document.documentElement.clientWidth;
                bodyHeight = document.documentElement.clientHeight;
            }
        }
        document.getElementById('textSQLDUMP').style.width=(bodyWidth-50) + 'px';
        document.getElementById('textSQLDUMP').style.height=(bodyHeight-100) + 'px';
    }
//-->
</script>
<?php
} 
if ($asfile != "sendit"){
?>
<!-- body_text_eof //--> 
  </tr> 
</table> 
<!-- body_eof //--> 
<!-- footer //--> 
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?> 
<!-- footer_eof //--> 
<br> 
</body> 
</html> 
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_6.php'); 
}
?>
