<?php
// czy dostęp do strony odbywa się poprzez połączenie HTTPS?
$is_https = false;
else
$is_https = true;
// czy odwiedzamy stronę z poufnymi informacjami?
if (isset($_GET['RegisterCustomer']) || isset($_GET['ChangeDetails']) || isset($_GET['AddOrChangeAddress']) || isset($_GET['AddOrChangeCreditCard']) || $is_sensitive_page = true;
else
$is_sensitive_page = false;
// gdy odwiedzasz strony z poufnymi informacjami, korzystaj z HTTPS
if ($is_sensitive_page && $is_https==false)
{
header ('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
// nie korzystaj z HTTPS jeśli łączysz się ze zwykłymi stronami
if (!$is_sensitive_page && $is_https == true)
{
header ('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
// Załadowanie biblioteki Smarty i plików konfiguracyjnych
require_once 'include/app_top.php';
/* jeśli nie jest przeglądana strona produktu, odsyłacz do bieżacej strony
zostanie zapisany w zmiennej sesji PageLink; zostanie on wykorzystany do
utworzenia łacza Kontynuacja zakupów, umieszczanego na stronach
przedstawiających szczegółowe informacje o produktach */
if (!isset($_GET['ProductID']) && !isset($_GET['CartAction'])) $_SESSION['PageLink'] = "http://" . $_SERVER['SERVER_NAME'] .
":" . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
// Załadowanie kodu warstwy logiki
require_once SITE_ROOT.'/business_objects/bo_catalog.php';
require_once SITE_ROOT.'/business_objects/bo_shopping_cart.php';
require_once SITE_ROOT.'/business_objects/bo_customer.php';
// Załadowanie pliku szablonu Smarty
$page = new Page();
$pageContentsCell = "first_page_contents.tpl";
$categoriesCell = "blank.tpl";
// jeśli jest przeglądany dział, trzeba pobrać szczegółowe informacje na jego tema
t
if (isset($_GET['DepartmentID'])) {
$pageContentsCell = "department.tpl";
$categoriesCell = "categories_list.tpl";
}
if (isset($_GET['Search'])) $pageContentsCell="search_results.tpl";
if (isset($_GET['ProductID'])) $pageContentsCell = "product.tpl";
if (isset($_GET['CartAction'])) {
$pageContentsCell = "shopping_cart.tpl";
$cartSummaryCell = "blank.tpl";
}
else
$cartSummaryCell="cart_summary.tpl";
// funkcjonalność związana z kontami użytkowników
$bo_customer = new BoCustomer();
if ($bo_customer->IsAuthenticated())
$customerLoginOrLogged="customer_logged.tpl";
else
$customerLoginOrLogged="customer_login.tpl";
if (isset($_GET['RegisterCustomer']) || isset($_GET['ChangeDetails'])) $pageContentsCell="customer_details.tpl";
if (isset($_GET['AddOrChangeAddress'])) $pageContentsCell="customer_address.tpl";
if (isset($_GET['AddOrChangeCreditCard'])) $pageContentsCell="customer_credit_card.tpl";
$page->assign("customerLoginOrLogged",$customerLoginOrLogged);
$page->assign("cartSummaryCell",$cartSummaryCell);
$page->assign("pageContentsCell", $pageContentsCell);
$page->assign("categoriesCell", $categoriesCell);
$page->display('index.tpl');
// Załadowanie kodu app_bottom odpowiedzialnego za zakończenie połączenia z bazą d
anych
require_once 'include/app_bottom.php';
?>