Esempio n. 1
0
 function setBannerSort()
 {
     $rows = (int) A_Session::get(STRUCTURE . "_rows", isset($_COOKIE[STRUCTURE . '_rows']) ? $_COOKIE[STRUCTURE . '_rows'] : 10);
     $page = !empty($_POST['page']) ? (int) $_POST['page'] : 0;
     $sort = !empty($_POST['sort']) ? explode(",", $_POST['sort']) : array();
     $i = $rows * $page + 1;
     foreach ($sort as $id) {
         A::$DB->Update(STRUCTURE, array('sort' => $i++), "id=" . (int) $id);
     }
 }
Esempio n. 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);
 }
Esempio n. 3
0
 /**
  * Обработчик действия: Отдает форму фильтров.
  */
 function getFilterForm()
 {
     $data = A_Session::get(SECTION . "_filter", array());
     $form = new A_Form("module_catalog_filter.tpl");
     $form->data['idcat'] = $_POST['idcat'];
     $form->data['name'] = $data['name'];
     $form->data['content'] = $data['content'];
     $form->data['date'] = $data['date'];
     $form->data['from'] = $data['date1'];
     $form->data['to'] = $data['date2'];
     $form->data['statuss'] = array(0 => "Не выбрано", "Y" => "Активные", "N" => "Неактивные");
     $form->data['status'] = $data['status'];
     $form->fieldseditor_filterprepare($data);
     $frame = new A_Frame("default_form.tpl", "Фильтр", $form);
     $this->RESULT['html'] = $frame->getContent();
 }
Esempio n. 4
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     $basket = A_Session::get("shoplite_basket", array());
     $all = array('count' => 0, 'oldsum' => 0, 'sum' => 0, 'discount' => 0);
     foreach ($basket as $i => $row) {
         $row['data']['basketblock'] = true;
         $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("basketlink", $this->sectionlink . "basket.html");
     $this->Assign('valute', $this->options['valute']);
 }
Esempio n. 5
0
 function getEditForm()
 {
     $idsec = (int) A_Session::get(STRUCTURE, 0);
     $form = new A_Form("plugin_fcategory_edit.tpl");
     $form->data = A::$DB->getRowById($_POST['id'], STRUCTURE);
     $form->data['vars'] = array();
     A::$DB->query("SELECT * FROM " . DOMAIN . "_structures ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $_item = DOMAIN . "_structure_" . $row['name'];
         if (function_exists($row['plugin'] . '_loadlist')) {
             $form->data['vars'][$_item] = $row['caption'];
         }
     }
     A::$DB->free();
     A::$DB->query("SELECT * FROM " . DOMAIN . "_sections WHERE id<>{$idsec} ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $_item = DOMAIN . "_" . $row['lang'] . "_" . $row['name'];
         if (function_exists($row['module'] . '_loadlist')) {
             $form->data['vars'][$_item] = $row['caption'];
         }
     }
     A::$DB->free();
     $this->RESULT['html'] = $form->getContent();
 }
Esempio n. 6
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     if (!A_Session::is_set(SECTION . "_filter")) {
         $this->unFilter();
     }
     $fields = A::$DB->getFields(SECTION . "_orders");
     if (!in_array('pay', $fields)) {
         A::$DB->execute("ALTER TABLE `" . SECTION . "_orders` ADD `pay` int(11) NOT NULL default '0'");
     }
     $categories = A::$DB->getAll("SELECT id,idker,name FROM " . SECTION . "_categories ORDER BY level,sort");
     $this->Assign("categories", $categories);
     if (!empty($_GET['idcat'])) {
         $this->Assign("category", A::$DB->getRowById($_GET['idcat'], SECTION . "_categories"));
         $idcat = (int) $_GET['idcat'];
         $childcats = array($idcat);
         getTreeSubItems(SECTION . "_categories", $idcat, $childcats);
         $where = "(c.idcat IN(" . implode(",", $childcats) . ") OR c.idcat1 IN(" . implode(",", $childcats) . ") OR c.idcat2 IN(" . implode(",", $childcats) . "))";
         $this->Assign("childcats", $childcats = count($childcats));
     } else {
         $where = "";
     }
     if ($filter = $this->getFilter()) {
         $where = !empty($where) ? "{$where} AND {$filter}" : $filter;
     }
     $this->Assign("treebox", new A_CategoriesTree("items"));
     $rows = A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 20);
     $sort = escape_order_string(A_Session::get(SECTION . "_sort", isset($_COOKIE[SECTION . '_sort']) ? $_COOKIE[SECTION . '_sort'] : A::$OPTIONS['sort']));
     $items = array();
     $pager = new A_Pager($rows);
     $pager->tab = "items";
     $pager->query("\r\r\n\tSELECT c.*,c.svote/c.cvote AS vote,cc.name AS category\r\r\n\tFROM " . SECTION . "_catalog AS c\r\r\n\tLEFT JOIN " . SECTION . "_categories AS cc ON cc.id=c.idcat\r\r\n\t" . (!empty($where) ? " WHERE {$where}" : "") . "\r\r\n\tORDER BY {$sort}");
     while ($row = $pager->fetchRow()) {
         $row['link'] = shoplite_createItemLink($row['id'], SECTION);
         $row['catpath'] = "";
         if (empty($_GET['idcat']) || $childcats > 1) {
             $row['catpath'] .= getTreePath(SECTION . "_categories", $row['idcat']);
         }
         if (!empty($row['idcat1'])) {
             $row['catpath'] .= '<br>' . getTreePath(SECTION . "_categories", $row['idcat1']);
         }
         if (!empty($row['idcat2'])) {
             $row['catpath'] .= '<br>' . getTreePath(SECTION . "_categories", $row['idcat2']);
         }
         $row['vote'] = round($row['vote'], 2);
         if (A::$OPTIONS['useimages']) {
             $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
         }
         if (A::$OPTIONS['usefiles']) {
             $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0;
         }
         $items[] = $row;
     }
     $pager->free();
     $this->Assign("items", $items);
     $this->Assign("items_pager", $pager);
     $this->Assign("rows", $rows);
     $this->Assign("sort", $sort);
     $this->Assign("filter", !empty($filter));
     if (A::$OPTIONS['usecomments']) {
         $this->Assign("commbox", new A_CommentsEditor(SECTION . "_catalog"));
     }
     $rows = (int) A_Session::get(SECTION . "_rows2", 20);
     $idpays = A::$DB->getCol("SELECT DISTINCT pay FROM " . SECTION . "_orders ORDER BY pay");
     $pays = array();
     foreach ($idpays as $idpay) {
         $pays[$idpay] = function_exists('pay_getname') ? pay_getname($idpay) : "Наличные";
     }
     $pays = array_unique($pays);
     $this->Assign("pays", $pays);
     $where = array();
     if (isset($_GET['date'])) {
         if (!empty($_GET['from'])) {
             $where[] = "date>=" . (int) $_GET['from'];
         }
         if (!empty($_GET['to'])) {
             $where[] = "date<=" . (int) $_GET['to'];
         }
     }
     if (!empty($_GET['sum1'])) {
         $where[] = "sum>=" . (int) $_GET['sum1'];
     }
     if (!empty($_GET['sum2'])) {
         $where[] = "sum<=" . (int) $_GET['sum2'];
     }
     if (isset($_GET['status']) && $_GET['status'] >= 0) {
         $where[] = "status=" . (int) $_GET['status'];
     }
     if (isset($_GET['pay']) && $_GET['pay'] >= 0) {
         $where[] = "pay=" . (int) $_GET['pay'];
     }
     $where = implode(" AND ", $where);
     $orders = array();
     $pager2 = new A_Pager($rows);
     $pager2->tab = "orders";
     $pager2->query("SELECT * FROM " . SECTION . "_orders " . ($where ? "WHERE {$where}" : "") . " ORDER BY status,date DESC");
     while ($row = $pager2->fetchRow()) {
         $row['pay'] = function_exists('pay_getname') ? pay_getname($row['pay']) : "Наличные";
         $row['sum'] = round($row['sum'], 2);
         $orders[] = $row;
     }
     $pager2->free();
     $this->Assign("orders", $orders);
     $this->Assign("orders_pager", $pager2);
     $this->Assign("rows2", $rows);
     $this->Assign("optbox1", new A_OptionsBox("Внешний вид на сайте:", array("idgroup" => 1)));
     $this->Assign("optbox2", new A_OptionsBox("Файлы:", array("idgroup" => 2)));
     $this->Assign("optbox3", new A_OptionsBox("Заказ:", array("idgroup" => 3)));
     $this->Assign("optbox4", new A_OptionsBox("Комментирование и голосование:", array("idgroup" => 4)));
     $this->Assign("optbox5", new A_OptionsBox("Дополнительно:", array("idgroup" => 5)));
     $this->Assign("fieldsbox", new A_FieldsEditor(SECTION . "_catalog", array('tab' => 'opt', 'tab_opt' => 'fields'), false, true));
     $types = array('string' => 'Строка', 'int' => 'Целое число', 'float' => 'Дробное число', 'bool' => 'Логический (Да/Нет)', 'text' => 'Текст', 'select' => 'Значение из списка', 'mselect' => 'Множество значений из списка', 'mprice' => 'Модификатор цены', 'image' => 'Изображение', 'file' => 'Файл');
     $nums = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
     $cols = array();
     A::$DB->query("SELECT * FROM " . SECTION . "_cols ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $row['num'] = array_shift($nums);
         $row['type'] = isset($types[$row['type']]) ? $types[$row['type']] : $row['type'];
         $cols[] = $row;
     }
     A::$DB->free();
     $this->Assign("cols", $cols);
 }
Esempio n. 7
0
<?php

include 'config.php';
include dirname(__FILE__) . '/../../A/autoload.php';
#include 'A/Session.php';
#include 'A/Rule/Captcha.php';
$session = new A_Session();
$session->start();
#echo "session_id=" . session_id() . '<br/>';
$captcha = new A_Rule_Captcha('captcha', 'CAPTCHA', null, $session, null);
$captcha->generateCode(5);
#dump($captcha);
#dump($session);
#echo "<br/>Code=" . $captcha->getCode();
#exit;
$image = new A_Rule_Captcha_Image($captcha);
#dump($session);
#echo "<br/>Code=" . $captcha->getCode();
#exit;
$image->out();
Esempio n. 8
0
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') {
    $session1->destroy();
}
Esempio n. 9
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);
 }
Esempio n. 10
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     $this->Assign("curdir", (int) A_Session::get(SECTION . "_cid", 0));
     if (!empty($_GET['page'])) {
         $this->AddJVar("cur_page", (int) $_GET['page']);
     }
     $this->Assign("fieldsbox", new A_FieldsEditor(SECTION, array('tab' => 'opt', 'tab_opt' => 'fields'), false, false));
     $this->Assign("optbox", new A_OptionsBox("", array("idgroup" => 1)));
     $this->Assign("rows", (int) A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 20));
 }
Esempio n. 11
0
 /**
  * Обработчик действия: Сортировка.
  */
 function setSort()
 {
     $sort = !empty($_POST['sort']) ? explode(",", $_POST['sort']) : array();
     $page = !empty($_POST['page']) ? (int) $_POST['page'] : 0;
     $rows = (int) A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 20);
     $i = $page * $rows + 1;
     foreach ($sort as $id) {
         A::$DB->Update(SECTION, array('sort' => $i++), "id=" . (int) $id);
     }
 }
Esempio n. 12
0
// basic config data
$ConfigArray = array('BASE' => 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . '/', 'PATH' => dirname($_SERVER['SCRIPT_FILENAME']) . '/', 'APP' => dirname($_SERVER['SCRIPT_FILENAME']) . '/application/', 'LIB' => dirname($_SERVER['SCRIPT_FILENAME']) . '/library', 'ERROR' => E_ALL | E_STRICT);
// Error reporting and include path
error_reporting($ConfigArray['ERROR']);
set_include_path($ConfigArray['LIB'] . PATH_SEPARATOR . get_include_path());
// init autoload
require dirname(__FILE__) . '/../../A/autoload.php';
$Locator = new A_Locator();
$Locator->autoload();
// create config object from array
$Config = new A_Collection($ConfigArray);
// create HTTP objects
$Request = new A_Http_Request();
$Response = new A_Http_Response();
// Start Sessions
$Session = new A_Session();
$Session->start();
$UserSession = new A_User_Session($Session);
// create registry/loader and add common objects
$Locator->set('Config', $Config);
$Locator->set('Request', $Request);
$Locator->set('Response', $Response);
$Locator->set('Session', $Session);
$Locator->set('UserSession', $UserSession);
// create router and have it modify request
$map = array('' => array(0 => array('name' => 'controller', 'default' => 'home'), 1 => array('name' => 'action', 'default' => 'index')));
$Pathinfo = new A_Http_Pathinfo($map, false);
$Pathinfo->run($Request);
// create mapper with base application path and default action
$Mapper = new A_Controller_Mapper($ConfigArray['APP'], array('', 'home', 'index'));
// create and run FC with error action
Esempio n. 13
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     if (!A_Session::is_set(SECTION . "_filter")) {
         $this->unFilter();
     }
     $categories = A::$DB->getAll("SELECT id,idker,name FROM " . SECTION . "_categories ORDER BY level,sort");
     $this->Assign("categories", $categories);
     if (!empty($_GET['idcat'])) {
         $this->Assign("category", A::$DB->getRowById($_GET['idcat'], SECTION . "_categories"));
         $idcat = (int) $_GET['idcat'];
         $childcats = array($idcat);
         getTreeSubItems(SECTION . "_categories", $idcat, $childcats);
         $where = "c.idcat IN(" . implode(",", $childcats) . ")";
         $this->Assign("childcats", $childcats = count($childcats));
     } else {
         $where = "";
     }
     if ($filter = $this->getFilter()) {
         $where = !empty($where) ? "{$where} AND {$filter}" : $filter;
     }
     $rows = (int) A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 10);
     $sort = escape_order_string(A_Session::get(SECTION . "_sort", isset($_COOKIE[SECTION . '_sort']) ? $_COOKIE[SECTION . '_sort'] : A::$OPTIONS['sort']));
     $items = array();
     $pager = new A_Pager($rows);
     $pager->tab = "items";
     $pager->query("\r\r\n\tSELECT c.*,c.svote/c.cvote AS vote,cc.name AS category\r\r\n\tFROM " . SECTION . "_catalog AS c\r\r\n\tLEFT JOIN " . SECTION . "_categories AS cc ON cc.id=c.idcat\r\r\n\t" . (!empty($where) ? " WHERE {$where}" : "") . "\r\r\n\tORDER BY {$sort}");
     while ($row = $pager->fetchRow()) {
         $row['link'] = catalog_createItemLink($row['id'], SECTION);
         $row['vote'] = round($row['vote'], 2);
         if (A::$OPTIONS['useimages']) {
             $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
         }
         if (A::$OPTIONS['usefiles']) {
             $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id']));
             $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0;
         }
         $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']);
         if (empty($_GET['idcat']) || $childcats > 1) {
             $row['catpath'] = getTreePath(SECTION . "_categories", $row['idcat']);
         }
         $items[] = $row;
     }
     $pager->free();
     $this->Assign("items", $items);
     $this->Assign("items_pager", $pager);
     $this->Assign("treebox", new A_CategoriesTree("items"));
     if (A::$OPTIONS['usecomments']) {
         $this->Assign("commbox", new A_CommentsEditor(SECTION . "_catalog"));
     }
     $this->Assign("optbox1", new A_OptionsBox("Внешний вид на сайте:", array('idgroup' => 1)));
     $this->Assign("optbox2", new A_OptionsBox("Файлы:", array('idgroup' => 2)));
     $this->Assign("optbox3", new A_OptionsBox("Комментирование и голосование:", array('idgroup' => 3)));
     $this->Assign("optbox4", new A_OptionsBox("Дополнительно:", array('idgroup' => 4)));
     $this->Assign("fieldsbox", new A_FieldsEditor(SECTION . "_catalog", array('tab' => 'opt', 'tab_opt' => 'fields'), false, true));
     $this->Assign("rows", $rows);
     $this->Assign("sort", $sort);
     $this->Assign("filter", !empty($filter));
 }
Esempio n. 14
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();
Esempio n. 15
0
 /**
  * Формирование данных доступных в шаблоне страницы сообщения.
  */
 function MessagePage()
 {
     $fields = array();
     if ($id = A_Session::get(SECTION . "_id", 0)) {
         if ($arch = A::$DB->getRowById($id, SECTION . "_arch")) {
             $fields = !empty($arch['data']) ? unserialize($arch['data']) : array();
         }
     }
     $this->Assign("fields", $fields);
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
 }
Esempio n. 16
0
function courier_SendOrder($template, $data)
{
    if (A_MODE == A_MODE_FRONT && MODULE == 'shoplite' && ($template == A::$OPTIONS['mail_toadmin'] || $template == A::$OPTIONS['mail_touser'])) {
        if (!($structure = getStructureByPlugin('courier'))) {
            return;
        }
        $all = $data['object']->get_template_vars('all');
        if (empty($all['count'])) {
            return;
        }
        $couriers = array();
        A::$DB->query("SELECT * FROM {$structure} ORDER BY sort");
        while ($row = A::$DB->fetchRow()) {
            $row['price'] = courier_getPrice($all['sum'], $row['data']);
            $row['fullname'] = $row['name'] . ' (' . ($row['price'] > 0 ? $row['price'] . " " . A::$OPTIONS['valute'] : "Бесплатно") . ')';
            $couriers[$row['id']] = $row;
        }
        A::$DB->free();
        if (empty($couriers)) {
            return;
        }
        $idcourier = A_Session::get(SECTION . '_courier', key($couriers));
        if (isset($couriers[$idcourier])) {
            if (!empty($couriers[$idcourier]['price'])) {
                $all['subcouriersum'] = $all['sum'];
                $all['sum'] += $couriers[$idcourier]['price'];
                $data['object']->Assign("all", $all);
            }
            $data['object']->Assign("courier", $couriers[$idcourier]);
        }
    }
}
Esempio n. 17
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'];
 }
Esempio n. 18
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'];
 }
Esempio n. 19
0
 /**
  * Обработчик действия: Отдает форму добавления столбца в структуру импорта.
  */
 function getAddColForm()
 {
     $form = new A_Form("module_shoplite_addcol.tpl");
     $cols = A::$DB->getCol("SELECT field FROM " . SECTION . "_cols");
     $form->data['fields'] = array();
     for ($i = 0; $i < 3; $i++) {
         if (!in_array('category' . $i, $cols)) {
             $form->data['fields'][] = array('field' => 'category' . $i, 'name' => 'Категория ур.' . ($i + 1), 'type' => 'string');
         }
     }
     if (!in_array('name', $cols)) {
         $form->data['fields'][] = array('field' => 'name', 'name' => 'Название', 'type' => 'string');
     }
     if (!in_array('content', $cols)) {
         $form->data['fields'][] = array('field' => 'content', 'name' => 'Описание', 'type' => 'text');
     }
     if (!in_array('description', $cols)) {
         $form->data['fields'][] = array('field' => 'description', 'name' => 'Аннотация', 'type' => 'text');
     }
     if (!in_array('art', $cols)) {
         $form->data['fields'][] = array('field' => 'art', 'name' => 'Артикул', 'type' => 'string');
     }
     if (A::$OPTIONS['modprices'] == 1 && !in_array('mprice', $cols)) {
         $form->data['fields'][] = array('field' => 'mprice', 'name' => 'Модификатор', 'type' => 'mprice');
     }
     if (!in_array('price', $cols)) {
         $form->data['fields'][] = array('field' => 'price', 'name' => 'Цена', 'type' => 'float');
     }
     if (!in_array('oldprice', $cols)) {
         $form->data['fields'][] = array('field' => 'oldprice', 'name' => 'Прошлая цена', 'type' => 'float');
     }
     if (A::$OPTIONS['onlyavailable'] == 1 && !in_array('iscount', $cols)) {
         $form->data['fields'][] = array('field' => 'iscount', 'name' => 'Количество', 'type' => 'int');
     }
     if (!in_array('active', $cols)) {
         $form->data['fields'][] = array('field' => 'active', 'name' => 'Активен', 'type' => 'bool');
     }
     if (!in_array('favorite', $cols)) {
         $form->data['fields'][] = array('field' => 'favorite', 'name' => 'Спецпредложение', 'type' => 'bool');
     }
     if (!in_array('new', $cols)) {
         $form->data['fields'][] = array('field' => 'new', 'name' => 'Новинка', 'type' => 'bool');
     }
     if (A::$OPTIONS['usetags'] == 1 && !in_array('tags', $cols)) {
         $form->data['fields'][] = array('field' => 'tags', 'name' => 'Теги', 'type' => 'string');
     }
     A::$DB->query("SELECT * FROM " . DOMAIN . "_fields WHERE item='" . SECTION . "' AND type<>'file' AND type<>'image' AND type<>'date' ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         if (!in_array($row['field'], $cols)) {
             if ($row['type'] == 'format') {
                 $row['type'] = 'text';
             }
             $form->data['fields'][] = array('field' => $row['field'], 'name' => $row['name_' . DEFAULTLANG], 'type' => $row['type']);
         }
     }
     A::$DB->free();
     if (A::$OPTIONS['useimages']) {
         for ($i = 0; $i < 3; $i++) {
             if (!in_array('idimg' . $i, $cols)) {
                 $form->data['fields'][] = array('field' => 'idimg' . $i, 'name' => 'Фото ' . ($i + 1), 'type' => 'image');
             }
         }
     }
     if (A::$OPTIONS['usefiles']) {
         for ($i = 0; $i < 3; $i++) {
             if (!in_array('idfile' . $i, $cols)) {
                 $form->data['fields'][] = array('field' => 'idfile' . $i, 'name' => 'Файл ' . ($i + 1), 'type' => 'file');
             }
         }
     }
     $sort = A_Session::get(SECTION . "_sort", isset($_COOKIE[SECTION . '_sort']) ? $_COOKIE[SECTION . '_sort'] : A::$OPTIONS['sort']);
     if ($sort == 'sort') {
         $form->data['fields'][] = array('field' => 'sort', 'name' => 'Порядок', 'type' => 'int');
     }
     if (count($form->data['fields']) > 0) {
         $this->RESULT['html'] = $form->getContent();
     } else {
         $this->RESULT['html'] = AddLabel("Все поля уже заданы!");
     }
 }
Esempio n. 20
0
 /**
  * Формирование данных доступных в шаблоне страницы сравнения.
  */
 function ComparePage()
 {
     $compare = A_Session::get(SECTION . "_compare", array());
     foreach ($compare as $id => $row) {
         $compare[$id]['deletelink'] = getSectionLink(SECTION) . "?action=delcompare&id={$id}";
     }
     $this->Assign('items', array_values($compare));
     $this->Assign('fields', getFields(SECTION));
     $this->prevc = false;
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
 }
Esempio n. 21
0
 function createData()
 {
     $categories = array();
     A::$DB->query("SELECT * FROM " . STRUCTURE . "_categories ORDER BY sort");
     while ($row = A::$DB->fetchRow()) {
         $row['count'] = A::$DB->getCount(STRUCTURE, "idcat=" . $row['id']);
         $row['selected'] = isset($_GET['idcat']) && $_GET['idcat'] == $row['id'];
         $categories[] = $row;
     }
     A::$DB->free();
     $this->Assign("categories", $categories);
     if (empty($_GET['tab']) && !empty($_COOKIE[STRUCTURE . '_idcat'])) {
         $_GET['idcat'] = (int) $_COOKIE[STRUCTURE . '_idcat'];
         $_REQUEST['tab'] = "banners";
     }
     if (!empty($_GET['idcat'])) {
         if ($row = A::$DB->getRowById($idcat = (int) $_GET['idcat'], STRUCTURE . "_categories")) {
             $this->Assign("category", $row);
             $rows = (int) A_Session::get(STRUCTURE . "_rows", isset($_COOKIE[STRUCTURE . '_rows']) ? $_COOKIE[STRUCTURE . '_rows'] : 10);
             $banners = array();
             $pager = new A_Pager($rows);
             $pager->tab = "banners";
             $pager->query("\r\r\n\t\tSELECT * FROM " . STRUCTURE . "\r\r\n\t\tWHERE idcat={$idcat}\r\r\n\t\tORDER BY " . A_Session::get(STRUCTURE . "_sort", isset($_COOKIE[STRUCTURE . '_sort']) ? A::$DB->real_escape_string($_COOKIE[STRUCTURE . '_sort']) : "sort"));
             while ($row = $pager->fetchRow()) {
                 $row['link'] = "http://" . DOMAINNAME . "/getfile/" . SNAME . "/click/?id=" . $row['id'];
                 $row['close'] = $row['active'] == 'N' || $row['date'] == 'Y' && !($row['date1'] < time() && time() < $row['date2']);
                 $banners[] = $row;
             }
             $pager->free();
             $this->Assign("banners", $banners);
             $this->Assign("banners_pager", $pager);
             setcookie(STRUCTURE . "_idcat", $idcat, time() + 31104000);
         } else {
             setcookie(STRUCTURE . "_idcat", 0, time() - 3600);
         }
     }
     $this->Assign("sort", A_Session::get(STRUCTURE . "_sort", isset($_COOKIE[STRUCTURE . '_sort']) ? A::$DB->real_escape_string($_COOKIE[STRUCTURE . '_sort']) : "sort"));
     $this->Assign("rows", A_Session::get(STRUCTURE . "_rows", isset($_COOKIE[STRUCTURE . '_rows']) ? $_COOKIE[STRUCTURE . '_rows'] : 10));
 }