<?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 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
  
define('PAGE_PARSE_START_TIME', microtime()); 
# error_reporting(E_ALL);
# error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);

function isohtmlspecialchars($str) { 
	return htmlspecialchars($str, ENT_COMPAT, 'ISO-8859-1'); 
} 

if (file_exists(dirname(__FILE__) . '/load_bigware_15.php')){
	 if (filesize (dirname(__FILE__) . '/load_bigware_15.php') == 0){
	  	 header('Location: ../setup'); 
	 }
} 
require(dirname(__FILE__) . '/load_bigware_15.php'); 

$control_main = '1';
define('PROJECT_VERSION', 'Bigware Shop 2.3');

if (!ini_get('register_globals')){
	if(isset($_SESSION)) extract($_SESSION);
	if(isset($_COOKIE)) extract($_COOKIE);
	if(isset($_POST)) extract($_POST);
	if(isset($_GET)) extract($_GET);
} 

 $PHP_SELF = (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']); 
 define('LOCAL_EXE_GZIP', '/usr/bin/gzip');
 define('LOCAL_EXE_GUNZIP', '/usr/bin/gunzip');
 define('LOCAL_EXE_ZIP', '/usr/local/bin/zip');
 define('LOCAL_EXE_UNZIP', '/usr/local/bin/unzip'); 
 require(dirname(__FILE__) . '/load_bigware_13.php'); 
 require(dirname(__FILE__) . '/load_bigware_16.php'); 
 define('FRAME_WIDTH', 125); 
 define('CURRENCY_SERVER_PRIMARY', 'oanda');
 define('CURRENCY_SERVER_BACKUP', 'xe'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'func_bigware_2.php'); 
 go_db_connect() or die('Unable to connect to database server!'); 

 $set_it_up_query = go_db_query('select set_it_up_key as cfgKey, set_it_up_value as cfgValue, set_it_up_title as cfgTitle, set_it_up_description as cfgDescription from ' . DB_TBL_SET_IT_UP);
 while ($set_it_up = go_db_fetch_array($set_it_up_query)) {
	if (!defined($set_it_up['cfgKey'])) {
	 	define($set_it_up['cfgKey'], $set_it_up['cfgValue']);
	}
 } 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'func_bigware_9.php');
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'func_bigware_8.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'func_bigware_6.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_5.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_14.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'func_bigware_1.php'); 
 if (!function_exists('session_start')) {
 define('PHP_SESSION_NAME', 'bigWAdminID');
 define('PHP_SESSION_PATH', '/');
 define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);
 include(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'sessions.php');
 } 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'sessions.php');
 go_session_name('bigWAdminID'); 
 go_session_save_path(FOLDER_ABSOLUT_CATALOG . SESSION_WRITE_DIRECTORY); 
 if (function_exists('session_set_cookie_params')) {
 session_set_cookie_params(0, FOLDER_RELATIV_FORMER);
 } elseif (function_exists('ini_set')) {
 ini_set('session.cookie_lifetime', '0');
 ini_set('session.cookie_path', FOLDER_RELATIV_FORMER);
 } 
 go_session_start(); 
 if (!go_session_is_registered('language') || isset($_GET['language'])) {
 if (!go_session_is_registered('language')) {
 go_session_register('language');
 go_session_register('languages_id');
 }
 include(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_4.php');
 $lng = new language();
 if (isset($_GET['language']) && go_not_null($_GET['language'])) {
 $lng->set_language($_GET['language']);
 } else {
 $lng->get_browser_language();
 }
 $language = $lng->language['directory'];
 $languages_id = $lng->language['id'];
 } 
 global $translation;
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_LANGUAGES . $language . '.php');
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_LANGUAGES . $language . '/other/' . 'setitup.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_LANGUAGES . $language . '/other/' . 'setitup_group.php');
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_LANGUAGES . $language . '/other/' . 'db_other.php'); 
  
 $current_page = basename($PHP_SELF);
 if (file_exists(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_LANGUAGES . $language . '/' . $current_page)) {
 include(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_LANGUAGES . $language . '/' . $current_page);
 } 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'func_bigware_5.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'func_bigware_10.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_16.php');
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_3.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_6.php');
 $messageStack = new messageStack; 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_15.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_8.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_7.php');
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_2.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'class_bigware_17.php'); 
 require(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_CLASSES . 'box.php');
 if (isset($_GET['bigPfad'])) {
 $bigPfad = $_GET['bigPfad'];
 } else {
 $bigPfad = '';
 } 

 if (go_not_null($bigPfad)) {
 $bigPfad_array = go_analysis_category_path($bigPfad);
 $bigPfad = implode('_', $bigPfad_array);
 $current_category_id = $bigPfad_array[(sizeof($bigPfad_array)-1)];
 } else {
 $current_category_id = 0;
 } 
 if (!go_session_is_registered('selected_frame')) {
 go_session_register('selected_frame');
 $selected_frame = 'set_it_up';
 }
 if (isset($_GET['selected_frame'])) {
 $selected_frame = $_GET['selected_frame'];
 }
 $Selected_Box = $Sql_Data_Array; 
 $cache_blocks = array(array('title' => TEXT_CACHE_CATEGORIES, 'code' => 'categories', 'file' => 'categories_frame-language.cache', 'multiple' => true),
 array('title' => TEXT_CACHE_PRODUCERS, 'code' => 'producers', 'file' => 'producers_frame-language.cache', 'multiple' => true),
 array('title' => TEXT_CACHE_ALSO_PURCHASED, 'code' => 'also_purchased', 'file' => 'also_purchased-language.cache', 'multiple' => true)
 ); 
 if (!defined('DEFAULT_CURRENCY')) {
 $messageStack->add(ERROR_NO_DEFAULT_CURRENCY_DEFINED, 'error');
 } 
 if (!defined('DEFAULT_LANGUAGE')) {
 $messageStack->add(ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error');
 }
 if (function_exists('ini_get') && ((bool)ini_get('file_uploads') == false) ) {
 $messageStack->add(WARNING_FILE_UPLOADS_DISABLED, 'warning');
 }

     define('NAME_OF_FILE_SHIPPING', 'main_bigware_106.php');
     define('NAME_OF_FILE_CONDITIONS', 'main_bigware_20.php');
     define('NAME_OF_FILE_PRIVACY', 'main_bigware_100.php'); 
    include(FOLDER_ABSOLUT_FORMER . FOLDER_RELATIV_FUNCTIONS . 'func_bigware_11.php');
 if (basename($PHP_SELF) != NAME_OF_FILE_LOGIN && basename($PHP_SELF) != NAME_OF_FILE_PASSWORD_FORGOTTEN) {
 go_former_check_login();
 } 
define('DB_TBL_ITEMS_XSELL', 'items_xsell');
DEFINE('NAME_OF_FILE_GV_QUEUE', 'main_bigware_55.php');
DEFINE('NAME_OF_FILE_GV_MAIL', 'main_bigware_54.php');
DEFINE('NAME_OF_FILE_GV_SENT', 'main_bigware_56.php');
define('NAME_OF_FILE_COUPON_FORMER', 'main_bigware_21.php');
define('DB_TBL_COUPON_GV_QUEUE', 'coupon_gv_queue');
define('DB_TBL_COUPON_GV_ATTENDEE', 'coupon_gv_attendee');
define('DB_TBL_COUPON_EMAIL_TRACK', 'coupon_email_track');
define('DB_TBL_COUPON_REDEEM_TRACK', 'coupon_redeem_track');
define('DB_TBL_COUPONS', 'coupons');
define('DB_TBL_COUPONS_DESCRIPTION', 'coupons_description');    
define('SECURITY_CODE_LENGTH', '6');   
 function create_coupon_code($salt="secret", $length=SECURITY_CODE_LENGTH) {
 $ccid = md5(uniqid("","salt"));
 $ccid .= md5(uniqid("","salt"));
 $ccid .= md5(uniqid("","salt"));
 $ccid .= md5(uniqid("","salt"));
 srand((double)microtime()*1000000); 
 $random_start = @rand(0, (128-$length));
 $good_result = 0;
 while ($good_result == 0) {
 $id1=substr($ccid, $random_start,$length); 
 $query = go_db_query("select coupon_code from " . DB_TBL_COUPONS . " where coupon_code = '" . $id1 . "'"); 
 if (go_db_num_rows($query) == 0) $good_result = 1;
 }
 return $id1;
 } 
 function go_gv_member_update($attendee_id, $gv_id) {
 $attendee_gv_query = go_db_query("select amount from " . DB_TBL_COUPON_GV_ATTENDEE . " where attendee_id = '" . $attendee_id . "'");
 $coupon_gv_query = go_db_query("select coupon_amount from " . DB_TBL_COUPONS . " where coupon_id = '" . $gv_id . "'");
 $coupon_gv = go_db_fetch_array($coupon_gv_query);
 if (go_db_num_rows($attendee_gv_query) > 0) {
 $attendee_gv = go_db_fetch_array($attendee_gv_query);
 $new_gv_amount = $attendee_gv['amount'] + $coupon_gv['coupon_amount'];
 $gv_query = go_db_query("update " . DB_TBL_COUPON_GV_ATTENDEE . " set amount = '" . $new_gv_amount . "' where attendee_id = '" . $attendee_id . "'");
 } else {
 $gv_query = go_db_query("insert into " . DB_TBL_COUPON_GV_ATTENDEE . " (attendee_id, amount) values ('" . $attendee_id . "', '" . $coupon_gv['coupon_amount'] . "')");
 }
 } 
 function go_fetch_date_selector($prefix, $date='') {
 $month_array = array();
    $month_array[1] =_JANUARY;
    $month_array[2] =_FEBRUARY;
    $month_array[3] =_MARCH;
    $month_array[4] =_APRIL;
    $month_array[5] =_MAY;
    $month_array[6] =_JUNE;
    $month_array[7] =_JULY;
    $month_array[8] =_AUGUST;
    $month_array[9] =_SEPTEMBER;
    $month_array[10] =_OCTOBER;
    $month_array[11] =_NOVEMBER;
    $month_array[12] =_DECEMBER;
 $usedate = getdate($date);
 $day = $usedate['mday'];
 $month = $usedate['mon'];
 $year = $usedate['year']; 
 $date_selector = '<select name="'. $prefix .'_day">';
 for ($i=1;$i<32;$i++){
 $date_selector .= '<option value="' . $i . '"';
 if ($i==$day) $date_selector .= 'selected';
 $date_selector .= '>' . $i . '</option>';
 }
 $date_selector .= '</select>';
 $date_selector .= '<select name="'. $prefix .'_month">';
 for ($i=1;$i<13;$i++){
 $date_selector .= '<option value="' . $i . '"';
 if ($i==$month) $date_selector .= 'selected'; 
 $date_selector .= '>' . $month_array[$i] . '</option>';
 }
 $date_selector .= '</select>';
 $date_selector .= '<select name="'. $prefix .'_year">';
 for ($i=2001;$i<2019;$i++){
 $date_selector .= '<option value="' . $i . '"';
 if ($i==$year) $date_selector .= 'selected';
 $date_selector .= '>' . $i . '</option>';
 }
 $date_selector .= '</select>';
 return $date_selector;
 }
 if (go_session_is_registered('login_id')) {
	 if (file_exists(FOLDER_ABSOLUT_CATALOG . 'setup')) {
	 	$messageStack->add('<b>Hohes Risiko</b>: Bitte l&ouml;schen Sie den "setup" Ordner!  // <b>High risk</b> Please delete the folder "setup"!', 'error');
	 }
	if (is_writeable(FOLDER_ABSOLUT_CATALOG . 'load_this/' . 'load_this_bigware_15.php')) {
	 	$messageStack->add('<b>Hohes Risiko</b>: Die Datei ' . FOLDER_RELATIV_CATALOG . 'load_this/' . 'load_this_bigware_15.php muss auf 0444 gesetzt werden!  //  <b>High risk</b>: The file ' . FOLDER_RELATIV_CATALOG . 'load_this/' . 'load_this_bigware_15.php must be set on 0444!', 'error');
	}
	if (is_writeable(FOLDER_ABSOLUT_FORMER . 'load_this/' . 'load_bigware_15.php')) {
	 	$messageStack->add('<b>Hohes Risiko</b>: Die Datei ' . FOLDER_RELATIV_CATALOG . 'configmain/load_this/' . 'load_bigware_15.php muss auf 0644 bzw. 0444 gesetzt werden! // <b>High risk</b>: The file ' . FOLDER_RELATIV_CATALOG . 'configmain/load_this/' . 'load_bigware_15.php must be set on 0444!', 'error');
	}
	clearstatcache();
	function file_perms($file, $octal = false)
	{
	    if(!file_exists($file)) return false;
	
	    $perms = fileperms($file);
	
	    $cut = $octal ? -3 : -4;
	
	    return substr(decoct($perms), $cut);
	}
	if (file_perms(FOLDER_ABSOLUT_FORMER, true) > '755'){
	 	$messageStack->add('Der htaccess Passwortschutz ist angelegt worden. Bitte setzen Sie nun den Ordner ' . FOLDER_ABSOLUT_FORMER . ' mind. wieder zur&uuml;ck auf 0755! // The htaccess password protection is now enabled. Please set the folder ' . FOLDER_ABSOLUT_FORMER . ' at least with 0755!', 'error');		
	}
}
 require(dirname(__FILE__) . '/load_bigware_15_b.php');
?>
