Beispiel #1
0
 function __construct()
 {
     global $AUTH_LOCK_PROJECT;
     $this->user = CUtils::_sessionVar('ukey');
     $this->operation = CUtils::_getVar('operation');
     $this->message = array('type' => '', 'text' => '');
     if (!empty($this->operation)) {
         switch ($this->operation) {
             case 'logout':
                 $this->logout();
                 break;
             case 'forgot':
                 $this->forgot();
                 break;
             case 'change_password':
                 $this->change_password();
                 break;
         }
     } else {
         if (empty($this->user)) {
             $this->checkUser();
         }
         if (($AUTH_LOCK_PROJECT == 'Y' || stristr($_SERVER['REQUEST_URI'], '/admin')) && empty($this->user)) {
             $this->authenticate();
         }
     }
 }
Beispiel #2
0
function getCartText()
{
    $sCartText = '';
    if (CUtils::_sessionVar('number', true, 0)) {
        $sCartText = '<span>' . CUtils::_sessionVar('number', true, 0) . '</span> товара(ов)<br> на сумму <span>' . CUtils::_sessionVar('summa') . '</span> руб.';
    }
    return $sCartText;
}
Beispiel #3
0
 public static function write($sMessage)
 {
     global $db;
     $sIPAddress = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'];
     $sUserName = CUtils::_sessionVar('user');
     $sQuery = "\r\n\t\t\t\tINSERT INTO\r\n\t\t\t\t\tsystem_log(credate, ip_address, user_name, description) \r\n\t\t\t\tVALUES\r\n\t\t\t\t\t(NOW(), '{$sIPAddress}','{$sUserName}', '{$sMessage}')\r\n\t\t\t";
     $db->execQuery('log', $sQuery);
 }
Beispiel #4
0
 public static function fdate($d, $format)
 {
     $dstr = date($format, mktime(substr($d, 11, 2), substr($d, 14, 2), substr($d, 17, 2), substr($d, 5, 2), substr($d, 8, 2), substr($d, 0, 4)));
     $lang = CUtils::_sessionVar('lang', false, 'ru');
     if ($lang != 'en') {
         $smonth = array('ru' => array('Jan' => 'января', 'Feb' => 'февраля', 'Mar' => 'марта', 'Apr' => 'апреля', 'May' => 'мая', 'Jun' => 'июня', 'Jul' => 'июля', 'Aug' => 'августа', 'Sep' => 'сентября', 'Oct' => 'октября', 'Nov' => 'ноября', 'Dec' => 'декабря'), 'fr' => array(), 'it' => array());
         $month = array('ru' => array('January' => 'января', 'February' => 'февраля', 'March' => 'марта', 'April' => 'апреля', 'May' => 'мая', 'June' => 'июня', 'July' => 'июля', 'August' => 'августа', 'September' => 'сентября', 'October' => 'октября', 'November' => 'ноября', 'December' => 'декабря'), 'fr' => array(), 'it' => array());
         $weekday = array('ru' => array('Monday' => 'понедельник', 'Tuesday' => 'вторник', 'Wednesday' => 'среда', 'Thursday' => 'четверг', 'Friday' => 'пятница', 'Saturday' => 'суббота', 'Sunday' => 'воскресенье'), 'fr' => array(), 'it' => array());
         $sweekday = array('ru' => array('Mon' => 'понедельник', 'Tue' => 'вторник', 'Wed' => 'среда', 'Thu' => 'четверг', 'Fri' => 'пятница', 'Sat' => 'суббота', 'Sun' => 'воскресенье'), 'fr' => array(), 'it' => array());
         $dstr = strtr($dstr, array_merge($smonth[$lang], $month[$lang], $sweekday[$lang], $weekday[$lang]));
     }
     return $dstr;
 }
Beispiel #5
0
 protected function setData()
 {
     if (!empty($GLOBALS['urlprops']['error'])) {
         header('HTTP/1.1 ' . $GLOBALS['urlprops']['error'] . ' Not Found');
         $this->smarty->assign('mainbody', $this->smarty->fetch('service/' . CUtils::_sessionVar('lang', false, 'ru') . '/errorpage.' . $GLOBALS['urlprops']['error'] . '.tpl'));
         $this->smarty->assign('title', 'Ошибка 404');
         $this->smarty->assign('h1', 'Ошибка 404');
     } elseif (is_object($this->unit)) {
         $this->smarty->assign('mainbody', $this->unit->getBody() . ' ');
         $this->smarty->assign('title', strip_tags($this->unit->getTitle()));
         if ($h1 = $this->unit->getH1()) {
             $this->smarty->assign('h1', $h1);
             $this->smarty->assign('h1_collage', $this->unit->props['node']['h1_img']);
             $this->smarty->assign('h1_collage_width', isset($this->unit->record['h1_img_width']) ? $this->unit->record['h1_img_width'] : '');
             $this->smarty->assign('h1_collage_height', isset($this->unit->record['h1_img_height']) ? $this->unit->record['h1_img_height'] : '');
         }
     }
 }
Beispiel #6
0
 private function processForm($frmObject, $tbl = '')
 {
     $ret = array('', '');
     if (CUtils::_postVar('submited')) {
         if ($frmObject->defense && CUtils::_sessionVar('c_sec_code') != md5(CUtils::_postVar('securecode') . __CAPTCHA_HASH)) {
             $ret[0] = 'error';
             $ret[1] = $this->dbparams['no_antispam'];
         } else {
             $ret = $frmObject->sendMail($this->dbparams);
             if (empty($ret[0])) {
                 $ret[0] = 'accept';
                 $ret[1] = $this->dbparams['text_inserted'];
                 if ($tbl) {
                     $GLOBALS['rtti']->addGlobalItem($tbl);
                 }
             }
         }
         unset($_SESSION['captcha_keystring']);
     }
     return $ret;
 }
Beispiel #7
0
 protected function setUnits()
 {
     global $PRJ_DIR, $THEME_REF;
     $components = $GLOBALS['rtti']->getComponents();
     if (sizeof($components) > 0) {
         foreach ($components as $u) {
             if ($u['name'] == $this->unit) {
                 $this->addUnit($u, array(CUtils::_sessionVar('user') => 1));
             }
         }
         switch ($this->state) {
             case 'content':
                 $stateLetter = 'C';
                 break;
             case 'settings':
                 $stateLetter = 'A';
                 break;
             case 'service':
                 $stateLetter = 'S';
                 break;
             default:
                 $stateLetter = 'N';
         }
         $units = array();
         foreach ($components as $u) {
             if ($u['ctype'] == $stateLetter) {
                 $basePath = $THEME_REF . '/img/module/';
                 $units[] = array('name' => $u['name'], 'title' => $u['title'], 'ref' => $this->getBaseRef($u['name']), 'icon' => (file_exists($PRJ_DIR . $basePath . $u['name'] . '.gif') ? $basePath . $u['name'] : $basePath . 'folder') . '.gif', 'tablelist' => $u['name'] == $this->unit ? $this->getUnit($u['name'])->getTableMenu() : '', 'current' => $u['name'] == $this->unit);
             }
         }
         $this->smarty->assign('units', $units);
     } else {
         unset($_SESSION['user']);
         unset($_SESSION['ukey']);
         session_destroy();
         header('/admin/?error=' . urlencode('Incorrect user settings. Check user rules.'));
     }
 }
Beispiel #8
0
 private function _processForgetForm()
 {
     $aMessages = array('info' => array(), 'errors' => array());
     $t = $GLOBALS['rtti']->getTable('auth_users');
     if (CUtils::_sessionVar('c_sec_code') != md5(CUtils::_postVar('captcha') . __CAPTCHA_HASH)) {
         $aMessages['errors'][] = $this->_aErrors['incorrect_securecode'];
     } else {
         $sLogin = CUtils::_postVar('login');
         if ($aUser = $GLOBALS['rtti']->getItem('auth_users', "email='{$sLogin}'")) {
             $sNewPassword = CUtils::genKey(6);
             $sUpdate = "password='******'";
             if ($t->update($sUpdate . ", change_date = NOW() WHERE email='" . $sLogin . "'")) {
                 $this->smarty->assign('Login', $sLogin);
                 $this->smarty->assign('NewPassword', $sNewPassword);
                 $this->_sendMail('Восстановление пароля в магазине Цвета жизни', $this->smarty->fetch('service/auth/' . $this->props['lang'] . '/forget.mail.tpl'), array($sLogin));
                 $aMessages['info'][] = $this->_aInfo['send_password'];
             }
         } else {
             $this->smarty->assign('login', $sLogin);
             $aMessages['errors'][] = $this->_aErrors['no_user'];
         }
     }
     return $aMessages;
 }
Beispiel #9
0
 function select($a = null)
 {
     global $db;
     if ($this->props['is_lang']) {
         $a['where'] = empty($a['where']) ? "lang='" . CUtils::_sessionVar('lang', false, 'ru') . "'" : $a['where'] . " AND lang='" . CUtils::_sessionVar('lang', false, 'ru') . "'";
     }
     return $db->execQuery($this->getDBTableName(), 'SELECT ' . (!empty($a['select']) ? $a['select'] : '*') . ' FROM ' . (!empty($a['from']) ? $a['from'] : $this->getDBTableName()) . (!empty($a['where']) ? ' WHERE ' . $a['where'] : '') . (!empty($a['order_by']) ? ' ORDER BY ' . $a['order_by'] : (!empty($this->props['order_by']) ? ' ORDER BY ' . $this->props['order_by'] : ' ORDER BY id')) . (!empty($a['limit']) ? ' LIMIT ' . $a['limit'] : ''));
 }
 function isAvailable()
 {
     return $GLOBALS['auth']->isSuperuser() || $this->users[CUtils::_sessionVar('user')] == 1;
 }
Beispiel #11
0
 private function _getConfirmPage()
 {
     if (count($_SESSION['cart']) && CUtils::_postVar('submited')) {
         $this->_addOrder();
         $_SESSION['cart'] = array();
         $_SESSION['number'] = 0;
         $_SESSION['summa'] = $this->getTotalPriceRus();
         unset($_SESSION['deliveryAddress']);
         unset($_SESSION['deliveryEmail']);
         unset($_SESSION['deliveryPhone']);
         unset($_SESSION['deliveryPhoneAdd']);
         unset($_SESSION['deliveryPerson']);
         return $this->getTpl('service/cart/' . $this->props['lang'] . '/message');
     } else {
         $aPayType = $GLOBALS['db']->getItem('pay', 'SELECT name FROM cart_pay_type WHERE id=' . CUtils::_sessionVar('payType'));
         $aDeliveryType = $GLOBALS['db']->getItem('delivery', 'SELECT name FROM cart_delivery_type WHERE id=' . CUtils::_sessionVar('deliveryType'));
         $this->smarty->assign('sPayType', $aPayType['name']);
         $this->smarty->assign('sDeliveryType', $aDeliveryType['name']);
         return $this->getList(false);
     }
 }
Beispiel #12
0
 public function getURLProps($url = '')
 {
     global $PRJ_REF;
     $uri = empty($url) ? $this->url : $url;
     $this->props['url'] = $uri;
     if (!stristr($uri, '/admin')) {
         $langs = $GLOBALS['db']->getItems('config_languages', 'SELECT * FROM config_languages');
         $findlang = false;
         foreach ($langs as $l) {
             if (stristr($uri, '/' . $l['name'] . '/') || CUtils::_getVar('lang') == $l['name']) {
                 $_SESSION['lang'] = $l['name'];
                 $uri = str_replace('/' . $l['name'] . '/', '/', $uri);
                 $findlang = true;
                 if (empty($uri)) {
                     $uri = '/';
                 }
             }
         }
         if (!$findlang) {
             $_SESSION['lang'] = 'ru';
         }
     }
     $this->parseVariables();
     $this->props['lang'] = CUtils::_sessionVar('lang', false, 'ru');
     $uri = str_replace(stristr($uri, '#'), '', $uri);
     $uri = str_replace('?' . $_SERVER['QUERY_STRING'], '', $uri);
     $clear_uri = $uri = str_replace($PRJ_REF . '/', '/', $uri);
     if ($this->checkURL($clear_uri)) {
         $url_parts = $GLOBALS['rtti']->parseURL($clear_uri);
         if (!$url_parts) {
             $this->props['error'] = '404';
         }
         $this->props['component'] = $url_parts['cname'];
         $this->props['method'] = $url_parts['mname'];
         $this->props['params'] = $url_parts['params'];
         $url_error = false;
         if ($clear_uri == '/') {
             //echo '1';
             $dir = $GLOBALS['rtti']->getItem('tree_tree', "name='/'");
             if (isset($dir['module_id_name'])) {
                 $this->props['component'] = $dir['module_id_name'];
             }
         } elseif ($clear_uri == '/' . $this->props['method'] . '.htm' && ($dir = $GLOBALS['rtti']->getItem('tree_tree', "name='" . $this->props['method'] . "'"))) {
             //echo '2';
             $this->props['params'] = array($this->props['method']);
             $this->props['method'] = 'index';
         } elseif (sizeof(explode('/', $clear_uri)) == 2) {
             //echo '2.2';
             $dir = $GLOBALS['rtti']->getItem('tree_tree', "name='/'");
             if (!isset($dir['module_id_name'])) {
                 $url_error = true;
             } else {
                 $this->props['component'] = $dir['module_id_name'];
             }
         } else {
             //echo '3';
             $dir = $GLOBALS['rtti']->getItem('tree_tree', "name='" . $this->props['component'] . "'");
             if (!isset($dir['module_id_name'])) {
                 $url_error = true;
             } else {
                 $this->props['component'] = $dir['module_id_name'];
             }
         }
         if (is_array($dir) && !$url_error) {
             $this->props['node'] = $dir;
             $this->props['dir_id'] = $dir['id'];
             $this->props['dir_uri'] = $this->props['uri'] = $dir['name'];
         } else {
             $this->props['error'] = '404';
         }
     } else {
         $this->props['uri'] = $clear_uri;
     }
     return $this->props;
 }
Beispiel #13
0
<?php

include_once CUtils::_sessionVar('lang') . '/stemming.php';
Beispiel #14
0
 function href($sComponentName = 'tree', $sMethodName = 'index', $aParams = array())
 {
     $sURL = CUtils::_sessionVar('lang', false, 'ru') != 'ru' ? '/' . CUtils::_sessionVar('lang', false, 'ru') : '';
     if ($sComponentName == 'tree') {
         $sURL .= '/';
     } else {
         $sURL .= '/' . $sComponentName . '/';
     }
     if ($aParams) {
         $sURL .= $sMethodName;
         foreach ($aParams as $mParam) {
             $sURL .= URL_PARAM_DELIMETER . $mParam;
         }
         $sURL .= '.htm';
     } else {
         if ($sMethodName != 'index') {
             $sURL .= $sMethodName . '.htm';
         }
     }
     return $sURL;
 }
Beispiel #15
0
function list_popup_show($f, $values)
{
    $ret = '';
    $lang_where = !empty($f['l_lang']) ? "lang='" . CUtils::_sessionVar('lang', false, 'ru') . "'" : '';
    if (!empty($f['query'])) {
        $lang_where .= ($lang_where ? ' AND ' : '') . '(' . $f['query'] . ')';
    }
    $f['l_sort'] = !empty($f['l_sort']) ? $f['l_sort'] : $f['l_field'];
    $items = $GLOBALS['rtti']->getItems($f["l_table"], $lang_where, $f["l_sort"]);
    $fields = explode(",", $f["l_field"]);
    foreach ($items as $a) {
        $vname = '';
        foreach ($fields as $fi) {
            if (isset($a[$fi])) {
                $vname .= ($vname ? ' ' : '') . $a[$fi];
            }
        }
        $ret .= list_popup_showItem($a['id'], $vname . ' [' . $a['id'] . ']', $f, $values);
    }
    return $ret;
}