sBENCHMARK = $sSystem->sStartBenchmark("Begin benchmarking"); // Database-Connection-Settings $sSystem->sDB_CONNECTOR = $DB_CONNECTOR; $sSystem->sDB_USER = $DB_USER; $sSystem->sDB_PASSWORD = $DB_PASSWORD; $sSystem->sDB_HOST = $DB_HOST; $sSystem->sDB_DATABASE = $DB_DATABASE; $sSystem->sInitAdo(); // Init database $sSystem->sLoadHookPoints(); // Load Hook-Points $sSystem->sInitConfig(); // Load configuration $sSystem->sInitFactory(); // Load classes eval($sSystem->sCallHookPoint("shopware.php_start")); // Setting unique-visitors-id if (!$_COOKIE["sUniqueID"]){ setcookie("sUniqueID", md5(uniqid(rand())),Time()+(86400*360)); } // ================================================================================================ // Some basic checks // ================================================================================================ // Secure user-input if (empty($_SERVER['PATH_INFO'])) $_SERVER["PATH_INFO"] = ""; $_GET = $sSystem->sSerialize_GET($_SERVER['PATH_INFO']); $_POST = $sSystem->sSerialize_POST($_POST); $sSystem->_COOKIE = $sSystem->sSerialize_COOKIE($_COOKIE); // ================================================================================================ // Session-Security // ================================================================================================ if (!empty($_GET["sCoreId"])){ $sSystem->sSESSION_ID = $_GET["sCoreId"]; }elseif (!empty($_POST["sCoreId"])){ $sSystem->sSESSION_ID = $_POST["sCoreId"]; } $sSystem->sInitSession(); // Init session $www = $_SERVER["SERVER_NAME"]; // Load suitable domain configuration $queryDomainConfigurations = $sSystem->sDB_CONNECTION->GetAll(" SELECT * FROM s_core_multilanguage "); $sSystem->sSubShops = $queryDomainConfigurations; foreach ($queryDomainConfigurations as $domainConfiguration){ if ($domainConfiguration["default"]){ $wwwHost[$sSystem->sCONFIG["sHOST"]] = $domainConfiguration; } $aliase = explode("\n",$domainConfiguration["domainaliase"]); if (count($aliase)){ $domainConfiguration["domainaliase"] = $aliase; foreach ($aliase as $alias){ if (!empty($alias)) $wwwHost[trim($alias)] = $domainConfiguration; } } } $sSystem->sCONFIG["sHOSTORIGINAL"] = false; if (!empty($wwwHost[$www])){ // Host found in subshop-config / Load configuration // Set Host to first-alias entry if (!empty($wwwHost[$www]["domainaliase"][0])){ if(trim($wwwHost[$www]["domainaliase"][0])!=$sSystem->sCONFIG["sHOST"]){ // Saving original (licensed) host - to go through license check $sSystem->sCONFIG["sHOSTORIGINAL"] = $sSystem->sCONFIG["sHOST"]; // Query License-Key $getLicenseKey = $sSystem->sDB_CONNECTION->CacheGetRow(86400," SELECT hash FROM s_core_licences WHERE module LIKE '%sLANGUAGEPACK%' "); if (!$sSystem->sCheckLicense("","",$getLicenseKey["hash"])){ die("

Keine gültige Subshop-Lizenz gefunden

"); } // Modify host to rewrite urls $sSystem->sCONFIG['sBASEPATH'] = str_replace($sSystem->sCONFIG["sHOSTORIGINAL"],trim($wwwHost[$www]["domainaliase"][0]),$sSystem->sCONFIG['sBASEPATH']); }else { $sSystem->sCONFIG["sHOSTORIGINAL"] = $sSystem->sCONFIG["sHOST"]; } $sSystem->sCONFIG["sHOST"] = trim($wwwHost[$www]["domainaliase"][0]); } if (empty($_POST["sLanguage"]) && empty($_SESSION["sLanguage"])){ $_POST["sLanguage"] = $wwwHost[$www]["id"]; } if (empty($_POST["sCurrency"]) && empty($_SESSION["sCurrency"])){ $_POST["sCurrency"] = $wwwHost[$www]["defaultcurrency"]; } $sSystem->sCONFIG["sDefaultCustomerGroup"] = $wwwHost[$www]["defaultcustomergroup"]; $sSystem->sCONFIG["sTEMPLATEPATH"] = $wwwHost[$www]["template"]; $sSystem->sSubShop = $wwwHost[$www]; }else { // Load default configuration $domainConfig = $sSystem->sDB_CONNECTION->GetRow(" SELECT * FROM s_core_multilanguage WHERE `default`=1 "); $sSystem->sSubShop = $domainConfig; // 18.10.2008 STH $sSystem->sCONFIG["sDefaultCustomerGroup"] = "EK"; // parentID // isocode // defaultcustomergroup // template // defaultcurrency } if (!$sSystem->sCheckLicense("","",$sSystem->sLicenseData["sCORE"])){ die("

Keine gültige Lizenz gefunden

"); } eval($sSystem->sCallHookPoint("shopware.php_licenseCheckAfter")); // Check if host matches if (!preg_match("/".$sSystem->sCONFIG["sHOST"]."/",$_SERVER['SERVER_NAME'])){ $redirectURL = "http://".$sSystem->sCONFIG["sHOST"].$_SERVER["SCRIPT_NAME"]; header("Location: ".$redirectURL); if (!empty($_SERVER['HTTP_REFERER'])){ if (!preg_match("/".$sSystem->sCONFIG["sHOST"]."/",$_SERVER['HTTP_REFERER'])){ $_SESSION["sReferer"] = $_SERVER['HTTP_REFERER']; } } exit; } // Fix Referer-Bug for prepend session-hijacking if (empty($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] = $sSystem->sCONFIG["sHOST"]; if (!preg_match("/".$sSystem->sCONFIG["sHOST"]."/",$_SERVER['HTTP_REFERER']) && !$_GET["sRefererAllowed"]){ unset($sSystem->sSESSION_ID); unset($_GET["sCoreId"]); unset($_POST["sCoreId"]); unset($PHPSESSID); unset($_COOKIE); } // Preprocess Routines // Init Language / Currency etc. $sSystem->sPreProcess(); if (!empty($_GET["sTpl"])){ if ($_GET["sTpl"]==-1) $_GET["sTpl"] = 0; $_SESSION["sTpl"] = $_GET["sTpl"]; } if (!empty($_SESSION["sTpl"])) $sSystem->sCONFIG['sTEMPLATEPATH'] = "templates/".intval($_SESSION["sTpl"]); $sSystem->sInitSmarty(dirname(__FILE__)."/".$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]."/html/"); // Init smarty $sSystem->sBENCHMARK = $sSystem->sNextBenchmark($sSystem->sBENCHMARK,"After Loading-Classes"); // ================================================================================================ if (empty($_COOKIE["SHOPWARESID"])){ $sSystem->sSMARTY->assign("sCoreId",$sSystem->sSESSION_ID); } // Start Benchmarking (if debug is active) // ================================================================================================ if ($sSystem->sCONFIG["sDEBUG"]){ $sSystem->sBENCHMARK = $sSystem->sNextBenchmark($sSystem->sBENCHMARK,"After Loading-Classes"); } // ================================================================================================ // Serialize-Partner-ID // ================================================================================================ if (!empty($_GET["sMerchandise"])){ $_SESSION["sMerchandise"] = $_GET["sMerchandise"]; unset($_GET["sMerchandise"]); } if (!empty($_SERVER['HTTP_REFERER'])){ if (!preg_match("/".$sSystem->sCONFIG["sHOST"]."/",$_SERVER['HTTP_REFERER'])){ $_SESSION["sReferer"] = $_SERVER['HTTP_REFERER']; } } if (empty($sSystem->sCONFIG["sBOTBLACKLIST"])) die("Bot-Blacklist missing (ADD sBOTBLACKLIST TO s_core_config)"); $botSession = false; $check = preg_replace("/[^A-Za-z]/", "", $_SERVER['HTTP_USER_AGENT']); $checkBots = explode(";",$sSystem->sCONFIG["sBOTBLACKLIST"]); foreach ($checkBots as $bot){ if (preg_match("/".strtolower($bot)."/",strtolower($check)) && !empty($bot)){ $botSession = true; break; } } eval($sSystem->sCallHookPoint("shopware.php_botCheckAfter")); /* Building captchas to secure user-submitted-data */ if ($sSystem->sSESSION_ID && isset($_GET["sCaptcha"]) && empty($botSession)){ $captcha = $sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]."/media/img/default/captcha.jpg"; if (is_file($captcha)){ $im = imagecreatefromjpeg($captcha); $black = ImageColorAllocate ($im, 255, 0, 0); for ($i=1;$i<=5;$i++){ $string .= rand(0,9)." "; } $_SESSION["sCaptcha"] = $string; for ($i=0;$i<=strlen($string);$i++){ imagettftext($im,20,rand(0,45),($i+1)*15,50,$black,$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]."/media/img/default/font.ttf",substr($string,$i,1)); } header('Content-Type: image/jpeg'); imagejpeg( $im, "", 90 ); imagedestroy($im); exit; } } // ================================================================================================ // Statistics // ================================================================================================ if (!empty($_GET["sPartner"])){ $_SERVER['HTTP_REFERER'] = $_SERVER['HTTP_REFERER']."$".$_GET["sPartner"]; } if (empty($botSession)){ $sSystem->sRefreshLog($_SERVER['REMOTE_ADDR']); $sSystem->sRefreshReferer($_SERVER['HTTP_REFERER']); // Clear-Up-Statistics if ((rand()%10) == 0) $sSystem->sDB_CONNECTION->execute("DELETE FROM s_statistics_currentusers WHERE time<(now()-180)"); // Current active user if (empty($_SESSION["sUserId"])) $_SESSION["sUserId"] = 0; $sSystem->sDB_CONNECTION->execute("INSERT INTO s_statistics_currentusers VALUES ('','".$_SERVER['REMOTE_ADDR']."','{$_SERVER['PHP_SELF']}',now(),'".$_SESSION["sUserId"]."')"); } // Benchmark Statistics if ($sSystem->sCONFIG["sDEBUG"])$sSystem->sBENCHMARK = $sSystem->sNextBenchmark($sSystem->sBENCHMARK,"Writing logs"); // ================================================================================================ // Loading Error-Codes / Templates for current language // 2DO // ================================================================================================ // Benchmark Loading Error-Codes if ($sSystem->sCONFIG["sDEBUG"])$sSystem->sBENCHMARK = $sSystem->sNextBenchmark($sSystem->sBENCHMARK,"Load Error-Codes"); // ================================================================================================ // Get current user-group // ================================================================================================ if (!empty($_SESSION["sUserGroup"])){ // Setting specific usergroup $sSystem->sUSERGROUP = $_SESSION["sUserGroup"]; $sSystem->sUSERGROUPDATA = $_SESSION["sUserGroupData"]; $sSystem->sSMARTY->assign("sUserGroup",$_SESSION["sUserGroup"]); }else { // Default - Usergroup $sSystem->sUSERGROUP = $sSystem->sCONFIG["sDefaultCustomerGroup"]; // Get Tax-Configuration $getTax = $sSystem->sDB_CONNECTION->CacheGetRow(3600,"SELECT * FROM s_core_customergroups WHERE groupkey='".$sSystem->sCONFIG["sDefaultCustomerGroup"]."' "); $sSystem->sUSERGROUPDATA = $getTax; } eval($sSystem->sCallHookPoint("shopware.php_assignPathBefore")); // ================================================================================================ // HTTPS-Socket Support // 2DO // ================================================================================================ if (preg_match("/443/",$_SERVER['SERVER_PORT'])){ $sSystem->sPathMedia = "https://".$sSystem->sCONFIG["sBASEPATH"]."/".$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]."/html/dummy/"; $sSystem->sPathArticleImg = "https://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG["sARTICLEIMAGES"]."/"; $sSystem->sPathBanner = "https://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG["sBANNER"]."/"; $sSystem->sPathSupplierImg = "https://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG["sSUPPLIERIMAGES"]."/"; $sSystem->sPathStart = "https://".$sSystem->sCONFIG["sBASEPATH"]."/".$sSystem->sCONFIG['sBASEFILE']; $sSystem->sPathArticleFiles = "https://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG['sARTICLEFILES']; }else { $sSystem->sPathMedia = "http://".$sSystem->sCONFIG["sBASEPATH"]."/".$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]."/html/dummy/"; $sSystem->sPathArticleImg = "http://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG["sARTICLEIMAGES"]."/"; $sSystem->sPathBanner = "http://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG["sBANNER"]."/"; $sSystem->sPathSupplierImg = "http://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG["sSUPPLIERIMAGES"]."/"; $sSystem->sPathCmsImg = "http://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG["sCMSIMAGES"]."/"; $sSystem->sPathStart = "http://".$sSystem->sCONFIG["sBASEPATH"]."/".$sSystem->sCONFIG['sBASEFILE']; $sSystem->sPathArticleFiles = "http://".$sSystem->sCONFIG["sBASEPATH"].$sSystem->sCONFIG['sARTICLEFILES']; } $sSystem->sBasefile = $sSystem->sCONFIG['sBASEFILE']; // ================================================================================================ // Load Viewport for this command // ================================================================================================ eval($sSystem->sCallHookPoint("shopware.php_viewportBefore")); // Support viewport from _POST if (!empty($_POST['sViewport'])) $_GET["sViewport"] = $_POST["sViewport"]; // Assign _GET/_POST Variables to System $sSystem->_GET = $_GET; $sSystem->_POST = $_POST; $sSystem->_SESSION = &$_SESSION; /* Shopware 3 - Experimental static cache */ $refreshcache = true; if (!empty($sSystem->sCONFIG["sHIGHPERFCACHE"])){ if (in_array($_GET["sViewport"],explode("|",$sSystem->sCONFIG["sHIGHPERFCACHEVIEWPORTS"])) || empty($_GET["sViewport"])){ // If this viewport should be cached $hash = $sSystem->sMODULES["sCore"]->sCache()."_".date("Ymd_H"); // Building unique hash (Viewports, _GET,_POST) if (file_exists(dirname(__FILE__)."/"."cache/highperfcache/$hash")){ // If cached file exists, continue $refreshcache = false; }else { $refreshcache = $hash; // Refresh cache } } } //$refreshcache = "1234"; // Temporary disable static cache // Register Smarty filters $sSystem->sSMARTY->register_prefilter(array($sSystem->sMODULES['sCore'],"prefilter")); $sSystem->sSMARTY->register_outputfilter(array($sSystem->sMODULES['sCore'],"postfilter")); eval($sSystem->sCallHookPoint("shopware.php_registerSmartyFilter")); // Loading viewport (or homepage for default) if (!empty($refreshcache)){ if (isset($_GET["sViewport"]) && isset($sSystem->sCONFIG['sViewports'][$_GET["sViewport"]]["file"])){ // Core-Viewport || Custom-Viewport include("engine/core/class/viewports/".$sSystem->sCONFIG['sViewports'][$_GET["sViewport"]]["file"]); $classname = "sViewport".ucfirst($_GET["sViewport"]); $sViewport = new $classname($sSystem); $sViewport->sSYSTEM = &$sSystem; $sSystem->sRenderViewport($sViewport->sRender(),dirname(__FILE__),$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]); }else { // Homepage $sSystem->sRenderViewport($sSystem->sMODULES['sCore']->sStart(),dirname(__FILE__),$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]); } } eval($sSystem->sCallHookPoint("shopware.php_viewportAfter")); // Benchmark Render Viewport if ($sSystem->sCONFIG["sDEBUG"])$sSystem->sBENCHMARK = $sSystem->sNextBenchmark($sSystem->sBENCHMARK,"Loading Viewport"); // ================================================================================================ // Prepare index template, rewrite links and add variables // ================================================================================================ $sSystem->sSMARTY->assign("sViewport",$_SERVER['PHP_SELF']); // Includes the index-template if (empty($sSystem->sCONFIG["sUSEDEFAULTTEMPLATES"])){ $filename = dirname(__FILE__)."/".$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]."/html/index/index.tpl"; }else { if (!is_file(dirname(__FILE__)."/".$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]."/html/index/index.tpl")){ $getTemplates = $sSystem->sCONFIG["sUSEDEFAULTTEMPLATES"]; $filename = dirname(__FILE__)."/templates/$getTemplates/html/index/index.tpl"; }else { $filename = dirname(__FILE__)."/".$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]."/html/index/index.tpl"; } } $checkFolder = dirname(__FILE__)."/".$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]; eval($sSystem->sCallHookPoint("shopware.php_defineTemplatePathAfter")); if (!is_dir($checkFolder)){ die("Folder ".dirname(__FILE__)."/".$sSystem->sCONFIG["sTEMPLATEPATH"]."/".$sSystem->sLanguageData[$sSystem->sLanguage]["isocode"]." missing"); } if (!empty($refreshcache)){ // Pass caching variables $sSystem->sCache["sHash"] = $hash; $sSystem->sCache["sHashFile"] = dirname(__FILE__)."/"."cache/highperfcache/$hash"; $sSystem->sCache["sRefreshCache"] = $refreshcache; $sViewport = $sSystem->sSMARTY->fetch($filename); $sSystem->sMODULES["sCore"]->sBuildCache(); } /* Export variables / messages in json */ if (!empty($_SESSION["sDump"]) && $sSystem->_GET["sDump"] && !empty($sSystem->sCONFIG["sTEMPLATEDEBUG"])){ echo json_encode($_SESSION["sDump"]); exit; } /* Starting content buffering */ if (empty($sSystem->sCONFIG["sDONTGZIP"])){ ob_clean(); ob_start("ob_gzhandler"); } /* Template/Firebug Handler */ if (!empty($sSystem->sCONFIG["sTEMPLATEDEBUG"])){ $_SESSION["sDump"] = array("sBenchmark"=>$sSystem->sBENCHRESULTS,"toSmarty"=>$sSystem->sRenderVariables); echo "
sPathStart."?sDump=true', {method: 'post', async: true, onComplete: function(ret){ret = Json.evaluate(ret);console.log(ret);}}).request();\">
"; } /* Push content */ eval($sSystem->sCallHookPoint("shopware.php_pushContentBefore")); if (empty($sViewport) && !empty($hash)){ //echo "Using cache $hash"; // Open static cache $sViewport = file_get_contents(dirname(__FILE__)."/"."cache/highperfcache/$hash"); // Rewrite Links / Add Session etc. // $sRender = $sSystem->sMODULES['sCore']->sCustomRenderer(array(),"",""); $sViewport = $sSystem->sMODULES["sCore"]->postfilter($sViewport); } eval($sSystem->sCallHookPoint("shopware.php_pushContentAfter")); echo ($sViewport); if (empty($sSystem->sCONFIG["sDONTGZIP"])) ob_end_flush(); ?>