protected function __construct($controller) { parent::__construct($controller); if (Router::getDefaultModule() == 'Page') { if (Page_Handler::getPageID()) { $this->show->merge(Page_Handler::getPage(), true); $this->show->breadcrumbs = Page_Handler::getPage()->getParents(); } $oPage = new Page(); list($full, $current) = $oPage->getMenuList(); if (is_array($full) && count($full)) { foreach ($full as $menu) { if (isset($menu["Children0"])) { $this->show->{'MENU_' . $menu["StaticPath"]} = $menu["Children0"]; } } } } // i.kiz для интернет магазина // $trash = NULL; // $this->show->basketList = NULL; if ($this->show->itemID) { $this->show->staticPath = $this->show->itemID; } else { if (!empty($this->data[0])) { $this->show->staticPath = $this->data[0]; } else { $this->show->staticPath = 0; } } $this->oCatalogCategory = new Catalog_Category(); $this->oCatalogBrand = new Catalog_Brand(); $this->show->catalogBrand = $this->oCatalogBrand->getList(); // menu $i = 0; $this->show->catalogMenu = array(); foreach ($this->show->catalogBrand as $br) { $this->show->catalogMenu['Brand'][$i] = $br['Title']; $cats = $this->oCatalogCategory->getList($br['BrandID']); $j = 0; foreach ($cats as $cat) { $this->show->catalogMenu['Category'][$i][$j] = $cat['Title']; $this->show->catalogMenu['CategoryID'][$i][$j] = $cat['CategoryID']; $j++; } $i++; } // корзина $this->session = MySession::getInstance(); $trash = $this->session->get('trash'); if (isset($trash)) { $this->show->trash = $trash; } else { $this->show->trash = array(); } }
} } if (check_ver() == 'True') { setcookie("ie", "yes", time() + 60 * 60 * 24 * 360); header("Location: /ie6/ie6.html"); } date_default_timezone_set('Asia/Novosibirsk'); define('START_TIME', microtime(true)); ob_start(); error_reporting(E_ALL | E_STRICT); ini_set('register_globals', 0); ini_set('display_errors', 1); mb_internal_encoding('utf-8'); define('DOC_ROOT', realpath(dirname(__FILE__)) . "/"); define('CORE_ROOT', DOC_ROOT . 'core/'); include CORE_ROOT . 'error_handlers.php'; include CORE_ROOT . 'config.php'; include CORE_ROOT . 'functions.php'; if (get_magic_quotes_gpc()) { $_POST = RemoveQuotes($_POST); $_GET = RemoveQuotes($_GET); $_COOKIE = RemoveQuotes($_COOKIE); $_REQUEST = RemoveQuotes($_REQUEST); } Router::init(); MySQL::getInstance(); Config::init(); MySession::getInstance(); File::init(); Controller::getInstance()->run(); die;
/** * Log a user out. * * @param boolean $destroy completely destroy the session * @return boolean */ public function logout($destroy = FALSE) { if (!$this->loggedIn()) { return FALSE; } $user = $this->getUser(); if (intval($user->UserID) !== 0) { $token = new User_Token($this->config['cookie_key']); $token->delete($user->UserID); } if ($destroy === TRUE) { MySession::getInstance()->destroy(); } else { $this->session->delete($this->config['session_key']); $this->session->regenerate(); } Cookie::delete($this->config['cookie_key']); // Double check return !$this->loggedIn(); }
public function index() { $this->show['Title'] = 'Оформление заказа'; $this->session = MySession::getInstance(); $trash = $this->session->get('trash'); if (sizeof($trash) < 1) { $this->show['Title'] = 'Ваша корзина пуста...'; } else { $this->show->basketList = array(); $catalog = new Catalog(); foreach ($trash as $i => $item) { $str = $catalog->getById($item['id']); $str['col'] = $item['col']; $this->show->basketList[$i] = $str; $this->show->basketList[$i]['col'] = $item['col']; } } if (isset($_POST['mode']) && $_POST['mode'] == 'send') { $db = MySQL::getInstance(); $db->query('SELECT FieldName, FieldValue FROM `config` WHERE FieldName="Title"'); $str = $db->fetchRow(); $sitename = $str['FieldValue']; if (substr(PHP_OS, 0, 3) == "WIN") { $n = "\r\n"; } else { $n = "\n"; } $mail = htmlspecialchars(stripslashes(trim($_POST['mail']))); $name = htmlspecialchars(stripslashes(trim($_POST['name']))); $phone = htmlspecialchars(stripslashes(trim($_POST['phone']))); $description = htmlspecialchars(stripslashes(trim($_POST['description']))); $body = 'Заказ с сайта ' . $sitename . $n; $body .= 'тел:' . $phone . ' ' . $name . $n . $n; $w = array('n' => 4, 'cod' => 15, 'name' => 30, 'x' => 20); $row = 1; $total = 0; foreach ($this->show->basketList as $key => $val) { $body .= str_pad($row, $w['n'], " ", STR_PAD_RIGHT); $body .= str_pad($val['Code'], $w['cod'], " ", STR_PAD_RIGHT); $body .= str_pad($val['Title'], $w['name'], " ", STR_PAD_RIGHT) . $n . $n; $body .= str_pad(' ', $w['n'], " ", STR_PAD_RIGHT); $body .= str_pad('Цена ', $w['x'], " ", STR_PAD_RIGHT) . $val['Price'] . " руб." . $n; $body .= str_pad(' ', $w['n'], " ", STR_PAD_RIGHT); $body .= str_pad('Кол-во ', $w['x'], " ", STR_PAD_RIGHT) . $val['col'] . ' ' . $val['Ed'] . $n; $body .= str_pad(' ', $w['n'], " ", STR_PAD_RIGHT); $body .= str_pad('Сумма ', $w['x'], " ", STR_PAD_RIGHT) . $val['col'] * $val['Price'] . ' руб.' . $n; $total += $val['col'] * $val['Price']; $row++; $body .= $n . str_pad('_', 60, "_", STR_PAD_RIGHT) . $n; } $body .= $n . ' ИТОГО на сумму: ' . $total . ' руб.' . $n . $n . $n; $body .= $description; $to = [$this->show->Email]; $subject = 'Заказ с сайта ' . $sitename . '--' . $mail; $transport = Swift_SmtpTransport::newInstance($this->show->Smtp, $this->show->Port, "ssl")->setUsername($this->show->Login)->setPassword($this->show->Password); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance($subject)->setFrom(array($this->show->Email))->setTo($to)->setBody($body); $result = $mailer->send($message); if ($result == 1) { $trash = null; $this->session->delete('trash'); $this->show->basketList = null; exit('ok'); } exit('error'); } }