예제 #1
0
function courier_RecalcBasket($action)
{
    if (A_MODE == A_MODE_FRONT && MODULE == 'shoplite' && $action == 'recalcbasket') {
        if (!empty($_REQUEST['courier'])) {
            A_Session::set(SECTION . '_courier', (int) $_REQUEST['courier']);
        }
    }
}
예제 #2
0
 function createData()
 {
     $sections = array();
     A::$DB->query("SELECT * FROM " . DOMAIN . "_sections WHERE module='shoplite' OR module='catalog' ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $_section = DOMAIN . "_" . $row['lang'] . "_" . $row['name'];
         if (getFields($_section)) {
             $sections[$_section] = $row['caption'];
         }
     }
     A::$DB->free();
     $this->Assign("sections", $sections);
     if (!empty($_GET['section'])) {
         $_section = preg_replace("/[^a-zA-Z0-9_-]/i", "", $_GET['section']);
         if (isset($sections[$_section])) {
             $section = $_section;
             setcookie(STRUCTURE, $_GET['section'], time() + 31104000);
         }
     }
     if (empty($section)) {
         $section = preg_replace("/[^a-zA-Z0-9_-]/i", "", A_Session::get(STRUCTURE, isset($_COOKIE[STRUCTURE]) ? $_COOKIE[STRUCTURE] : key($sections)));
     }
     A_Session::set(STRUCTURE, $section);
     $this->Assign("section", $section);
     if (empty($section)) {
         return;
     }
     $categories = A::$DB->getAll("SELECT id,idker,name FROM {$section}_categories ORDER BY level,sort");
     $this->Assign("categories", $categories);
     $idcat = !empty($_GET['idcat']) ? (int) $_GET['idcat'] : 0;
     $_cfields = getTextOption(STRUCTURE, 'cfields');
     $_cfields = !empty($_cfields) ? unserialize($_cfields) : array();
     if (!isset($_cfields[$section])) {
         $_cfields[$section] = $_cfields;
     }
     $_cfields = !empty($_cfields[$section][$idcat]) ? $_cfields[$section][$idcat] : array();
     $cfields = cfields_getfields($idcat, $section);
     foreach ($cfields as $field => $value) {
         if (in_array($field, $_cfields)) {
             unset($cfields[$field]);
         }
     }
     $fields = array();
     A::$DB->query("SELECT * FROM " . DOMAIN . "_fields WHERE item='{$section}' ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $row['disabled'] = isset($cfields[$row['field']]);
         $row['checked'] = in_array($row['field'], $_cfields) || $row['disabled'];
         $row['caption'] = $row['name_' . LANG];
         $fields[] = $row;
     }
     A::$DB->free();
     $this->Assign("fields", $fields);
 }
예제 #3
0
 /**
  * Формирование данных доступных в шаблоне страницы заказа.
  */
 function OrderPage()
 {
     if (empty(A::$OPTIONS['useorder'])) {
         A::goUrl(getSectionLink(SECTION));
     }
     $basket = A_Session::get("shoplite_basket", array());
     $all = array('count' => 0, 'oldsum' => 0, 'sum' => 0, 'discount' => 0);
     foreach ($basket as $i => $row) {
         $basket[$i]['data'] = $row['data'] = A::$OBSERVER->Modifier('shoplite_prepareValues', $row['section'], $row['data']);
         $basket[$i]['id'] = $i;
         $basket[$i]['oldsum'] = $row['oldsum'] = $row['data']['oldprice'] * $row['count'];
         $basket[$i]['sum'] = $row['sum'] = $row['data']['price'] * $row['count'];
         $basket[$i]['discount'] = $row['discount'] = !empty($row['data']['discount']) ? $row['data']['discount'] * $row['count'] : 0;
         $all['count'] += $row['count'];
         $all['oldsum'] += $row['oldsum'];
         $all['sum'] += $row['sum'];
         $all['discount'] += $row['discount'];
     }
     $this->Assign('basket', $basket);
     $this->Assign('all', $all);
     $this->Assign("form", !empty($_POST) ? $_POST : (A::$AUTH->isLogin() ? A::$AUTH->data : array()));
     $this->Assign("captcha", $captcha = substr(time(), rand(0, 6), 4));
     A_Session::set("captcha", md5($captcha));
     $this->prevc = false;
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
 }
예제 #4
0
 /**
  * Формирование данных доступных в шаблоне страницы альбома.
  */
 function AlbumPage()
 {
     $this->supportCached();
     $this->addCacheParam_Get('page');
     if ($this->idcat > 0) {
         $this->category['link'] = gallery_createCategoryLink($this->category['id'], SECTION);
         if (A::$OPTIONS['usetags']) {
             $this->category['tags'] = A_SearchEngine::getInstance()->convertTags($this->category['tags']);
         }
         $this->Assign("category", $this->category);
     }
     $album = $this->album;
     $album['vote'] = $album['cvote'] > 0 ? round($album['svote'] / $album['cvote'], 2) : 0;
     $album['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $album['id']));
     if (A::$OPTIONS['usetags']) {
         $album['tags'] = A_SearchEngine::getInstance()->convertTags($album['tags']);
     }
     prepareValues(SECTION, $album);
     $album = A::$OBSERVER->Modifier('gallery_prepareValues', SECTION, $album);
     $this->Assign("album", $album);
     $irows = (int) (!empty($_GET['irows'])) ? (int) $_GET['irows'] : A::$OPTIONS['irows'];
     $this->Assign("irows", $irows);
     $pager = new A_Pager($irows);
     $images = $pager->setItems($album['images']);
     $this->Assign("images", $images);
     $this->Assign("images_pager", $pager);
     $sort = escape_order_string(!empty(A::$OPTIONS['mysort']) ? A::$OPTIONS['mysort'] : A::$OPTIONS['sort']);
     $albums = A::$DB->getCol("\r\r\n\tSELECT id FROM " . SECTION . "_albums\r\r\n\tWHERE active='Y' AND idcat={$album['idcat']} ORDER BY {$sort}");
     $i = array_search($album['id'], $albums);
     if ($i !== false) {
         $previd = isset($albums[$i - 1]) ? $albums[$i - 1] : 0;
         $nextid = isset($albums[$i + 1]) ? $albums[$i + 1] : 0;
         if ($previd) {
             $this->Assign("prevalbum", gallery_createItemLink($previd, SECTION));
         }
         if ($nextid) {
             $this->Assign("nextalbum", gallery_createItemLink($nextid, SECTION));
         }
     }
     if (A::$OPTIONS['usecomments']) {
         $comments = array();
         A::$DB->query("SELECT * FROM " . DOMAIN . "_comments WHERE idsec=" . SECTION_ID . " AND iditem={$this->idalb} AND active='Y' ORDER BY date");
         while ($row = A::$DB->fetchRow()) {
             if ($row['iduser'] > 0 && A::$AUTH->section) {
                 if ($row['user'] = A::$DB->getRowById($row['iduser'], A::$AUTH->section)) {
                     prepareValues(A::$AUTH->section, $row['user']);
                 }
             }
             $comments[] = $row;
         }
         A::$DB->free();
         $this->Assign("comments", $comments);
         $form = array();
         $form['name'] = !empty($_REQUEST['name']) ? $_REQUEST['name'] : (A::$AUTH->isLogin() ? A::$AUTH->data['name'] : "");
         $form['message'] = !empty($_REQUEST['message']) ? $_REQUEST['message'] : "";
         $this->Assign("form", $form);
         $this->Assign("captcha", $captcha = substr(time(), rand(0, 6), 4));
         A_Session::set("captcha", md5($captcha));
     }
     if (A::$OPTIONS['usevote']) {
         $this->Assign("isvote", A_Session::get(SECTION . "_vote_" . $this->idalb, false));
         $this->addCacheParam_Session(SECTION . "_vote_" . $this->idalb);
     }
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
     if (isset($this->category)) {
         $this->AddNavCategories($this->category['id']);
     }
     $this->title = $this->album['name'] . (!empty($this->title) ? " - " . $this->title : "");
     $this->description = $this->album['description'];
 }
예제 #5
0
 /**
  * Формирование данных доступных в шаблоне главной страницы раздела.
  */
 function MainPage()
 {
     $this->Assign("form", $_REQUEST);
     $this->prepareAddForm();
     $this->Assign("content", getTextOption(SECTION, 'content'));
     $this->Assign("captcha", $captcha = substr(time(), rand(0, 6), 4));
     A_Session::set("captcha", md5($captcha));
     $this->AddNavigation(SECTION_NAME);
 }
예제 #6
0
<?php

error_reporting(E_ALL);
require_once 'config.php';
require_once 'A/Session.php';
$session1 = new A_Session();
$counter = $session1->get('counter', 9);
$session1->set('counter', ++$counter);
?>
<html>
<body>
<?php 
echo "Start counter with a default of 10, counter={$counter}<br/>";
$session1->set('one.two', 'hi1');
$session1->set('one.three.six', 'hi2');
$session1->set('one.three.four', 'hi3');
$session1->set('one.five', 'hi4');
$session2 = new A_Session();
$counter = $session2->get('counter');
echo "Is Singleton? Second session object counter={$counter}<br/>";
if ($session1 !== $session2) {
    echo "session1 !== session2<br/>";
}
if ($session1 == $session2) {
    echo "session1 == session2<br/>";
}
?>
<p><a href="?destroy=">refresh</a> <a href="?destroy=yes">destroy</a></p>
<?php 
echo '<pre>' . print_r($_SESSION, true) . '</pre>';
if (isset($_REQUEST['destroy']) && $_REQUEST['destroy'] == 'yes') {
예제 #7
0
 /**
  * Обработчик действия: Установка количества строк в таблице заказов.
  */
 function setRows2()
 {
     A_Session::set(SECTION . "_rows2", $_REQUEST['rows']);
     return true;
 }
예제 #8
0
 /**
  * Формирование данных доступных в шаблоне детальной страницы материала.
  */
 function ItemPage()
 {
     $this->supportCached();
     if ($this->idcat > 0) {
         $this->category['link'] = catalog_createCategoryLink($this->category['id'], SECTION);
         if (A::$OPTIONS['usetags']) {
             $this->category['tags'] = A_SearchEngine::getInstance()->convertTags($this->category['tags']);
         }
         $this->category = A::$OBSERVER->Modifier('fcategory_prepareValues', SECTION, $this->category);
         $this->Assign("category", $this->category);
     }
     $itemdata = $this->itemdata;
     $itemdata['vote'] = $itemdata['cvote'] > 0 ? round($itemdata['svote'] / $itemdata['cvote'], 2) : 0;
     if (A::$OPTIONS['useimages']) {
         $itemdata['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $itemdata['id']));
         $itemdata['idimg'] = isset($itemdata['images'][0]['id']) ? $itemdata['images'][0]['id'] : 0;
     }
     if (A::$OPTIONS['usefiles']) {
         $itemdata['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $this->iditem));
         foreach ($itemdata['files'] as $i => $data) {
             $itemdata['files'][$i]['link'] = (LANG == DEFAULTLANG ? "" : "/" . LANG) . "/getfile/" . $data['id'] . "/" . $data['name'];
             $itemdata['files'][$i]['size'] = sizestring($data['size']);
         }
         $itemdata['idfile'] = isset($itemdata['files'][0]['id']) ? $itemdata['files'][0]['id'] : 0;
     }
     if (A::$OPTIONS['usetags']) {
         $itemdata['tags'] = A_SearchEngine::getInstance()->convertTags($itemdata['tags']);
     }
     prepareValues(SECTION, $itemdata);
     $itemdata = A::$OBSERVER->Modifier('catalog_prepareValues', SECTION, $itemdata);
     $this->Assign("item", $itemdata);
     if (A::$OPTIONS['usecomments']) {
         $comments = array();
         A::$DB->query("SELECT * FROM " . DOMAIN . "_comments WHERE idsec=" . SECTION_ID . " AND iditem={$this->iditem} AND active='Y' ORDER BY date");
         while ($row = A::$DB->fetchRow()) {
             if ($row['iduser'] > 0 && A::$AUTH->section) {
                 if ($row['user'] = A::$DB->getRowById($row['iduser'], A::$AUTH->section)) {
                     prepareValues(A::$AUTH->section, $row['user']);
                 }
             }
             $comments[] = $row;
         }
         A::$DB->free();
         $this->Assign("comments", $comments);
         $form = array();
         $form['name'] = !empty($_REQUEST['name']) ? $_REQUEST['name'] : (A::$AUTH->isLogin() ? A::$AUTH->data['name'] : "");
         $form['message'] = !empty($_REQUEST['message']) ? $_REQUEST['message'] : "";
         $this->Assign("form", $form);
         $this->Assign("captcha", $captcha = substr(time(), rand(0, 6), 4));
         A_Session::set("captcha", md5($captcha));
     }
     if (A::$OPTIONS['usevote']) {
         $this->Assign("isvote", A_Session::get(SECTION . "_vote_" . $this->iditem, false));
         $this->addCacheParam_Session(SECTION . "_vote_" . $this->iditem);
     }
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
     if (isset($this->category)) {
         $this->AddNavCategories($this->category['id']);
     }
     $this->title = $this->itemdata['name'] . (!empty($this->title) ? " - " . $this->title : "");
     if (!empty($this->itemdata['keywords'])) {
         $this->keywords = $this->itemdata['keywords'];
     }
     $this->description = $this->itemdata['description'];
 }
예제 #9
0
 function setRows()
 {
     A_Session::set(STRUCTURE . "_rows", (int) $_REQUEST['rows']);
     setcookie(STRUCTURE . "_rows", (int) $_REQUEST['rows'], time() + 31104000);
     return true;
 }
예제 #10
0
 /**
  * Обработчик действия: Количество строк на странице.
  */
 function SetRows()
 {
     A_Session::set(SECTION . "_rows", $_REQUEST['rows']);
     setcookie(SECTION . "_rows", $_REQUEST['rows'], time() + 31104000);
     return true;
 }
예제 #11
0
 /**
  * Обработчик действия: Переход в подраздел.
  */
 function InDir()
 {
     A_Session::set(SECTION . "_cid", (int) $_POST['id']);
     $this->getGrid();
 }
예제 #12
0
 /**
  * Обработчик действия: Сброс фильтра.
  */
 function unFilter()
 {
     $data = array("active" => false, "name" => "", "content" => "", "date" => false, "status" => 0);
     $date1 = A::$DB->getOne("SELECT MIN(date) FROM " . SECTION . "_catalog");
     $data['date1'] = $date1 > 0 ? $date1 : time();
     $data['date2'] = time();
     $this->fieldseditor_unfilter($data);
     A_Session::set(SECTION . "_filter", $data);
     return true;
 }
예제 #13
0
<?php

error_reporting(E_ALL);
require_once 'config.php';
require_once 'A/Session.php';
$test = preg_replace('/[^a-zA-Z0-9\\ ]/', '', isset($_REQUEST['test']) ? $_REQUEST['test'] : null);
$expire = intval(isset($_REQUEST['expire']) ? $_REQUEST['expire'] : 0);
$session = new A_Session();
if ($test && $expire) {
    $session->set('test', $test, $expire);
}
if ($expire) {
    $counter = 0;
} else {
    $counter = $session->get('counter', 0);
}
$session->set('counter', ++$counter);
?>
<html>
<body>
<p>Submit form to set value with expiration count, then click refresh to expure.</p>
<form action="" method="post">
<input type="hidden" name="destroy" value=""/>
<p>Set value to <input type="text" name="test" value="foo"/></p>
<p>To expire in <input type="text" name="expire" value="5"/> requests. </p>
<p><input type="submit" name="set" value="set"/></p>
<p><a href="?destroy=">refresh</a> <a href="?destroy=yes">destroy</a></p>
<?php 
echo '<pre>' . print_r($_SESSION, true) . '</pre>';
if (isset($_REQUEST['destroy']) && $_REQUEST['destroy'] == 'yes') {
    $session->destroy();
예제 #14
0
 function createData()
 {
     $sections = array();
     A::$DB->query("SELECT * FROM " . DOMAIN . "_sections WHERE module='shoplite' OR module='catalog' ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         if ($row['module'] == 'shoplite' || getOption(DOMAIN . "_" . $row['lang'] . "_" . $row['name'], 'usecats')) {
             $sections[$row['id']] = $row['caption'];
         }
     }
     A::$DB->free();
     $this->Assign("sections", $sections);
     if (!empty($_GET['idsec'])) {
         $idsec = (int) $_GET['idsec'];
         if (isset($sections[$idsec])) {
             setcookie(STRUCTURE, $idsec, time() + 31104000);
         }
     }
     if (empty($idsec)) {
         $idsec = A_Session::get(STRUCTURE, isset($_COOKIE[STRUCTURE]) ? $_COOKIE[STRUCTURE] : key($sections));
     }
     if (isset($sections[$idsec])) {
         A_Session::set(STRUCTURE, $idsec);
         $this->Assign("idsec", $idsec);
     } elseif ($sections) {
         A_Session::set(STRUCTURE, $idsec = key($sections));
         $this->Assign("idsec", $idsec);
     } else {
         return;
     }
     $types = array('string' => 'Строка', 'int' => 'Целое число', 'float' => 'Дробное число', 'bool' => 'Логический (Да/Нет)', 'date' => 'Дата', 'text' => 'Текст', 'format' => 'Форматированный текст', 'select' => 'Значение из списка', 'mselect' => 'Множество значений из списка', 'image' => 'Изображение', 'file' => 'Файл');
     $fields = array();
     A::$DB->query("SELECT * FROM " . STRUCTURE . " WHERE idsec={$idsec} ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $row['type'] = isset($types[$row['type']]) ? $types[$row['type']] : "";
         $fields[] = $row;
     }
     $this->Assign("fields", $fields);
 }