Пример #1
0
    $access_denied = true;
} else {
    //	Тип активности (активно/неактивно).
    $folder = Text::get_get('folder');
    $query = 'CALL get_table_row_count(:table_name, :select_row, :select_value)';
    $params = array(':table_name' => PREF . 'modules', ':select_row' => 'folder', ':select_value' => $folder);
    $count = PdoWrap::selectRow($query, $params);
    //	Проверка существования записи.
    if ($count['count'] == 0) {
        $query = 'CALL get_max_position(:table_name, :table_column)';
        $params = array(':table_name' => PREF . 'modules', ':table_column' => 'position');
        $tmp = PdoWrap::selectRow($query, $params);
        $query = 'CALL modules_insert(:folder_field, :active_field, :position_field)';
        $params = array(':folder_field' => $folder, ':active_field' => 1, ':position_field' => $tmp['max'] + 1);
        //	Добавление записи в таблицу.
        PdoWrap::execute($query, $params);
    }
    /*
    // Подключение модуля
    if (is_file(DOC.'modules/'.$folder.'/'.$folder.'.class.php')) {
    
        require_once(DOC.'modules/'.$folder.'/'.$folder.'.class.php');
        if (class_exists($folder)) {
            $$folder = new $folder();
            $$folder->smarty = $smarty;
            $$folder->db = &$DB;
            $$folder->lang = $current_lang;
            $$folder->deflang = $default_lang;
            $$folder->langs = $langs;
    
            $$folder->createModuleTables();
Пример #2
0
//if ($_SERVER['REQUEST_URI'] == '') $re = '';
//if ($_SERVER['REQUEST_URI'] == '') $re = '';
if (preg_match('/^\\/novosti\\/(\\d+)-([^\\/]+)\\/$/i', $_SERVER['REQUEST_URI'], $alias)) {
    if (isset($alias[2])) {
        $re = '/novosti/' . $alias[2] . '/';
    }
}
if (strstr($_SERVER['REQUEST_URI'], '/kukhni/') || strstr($_SERVER['REQUEST_URI'], '/mebel/')) {
    $tmp = explode('/', $_SERVER['REQUEST_URI']);
    array_pop($tmp);
    $alias = end($tmp);
    $query = 'SELECT `to_url` FROM `' . PREF . 'redirect_urls` WHERE `from_url` = :url';
    $check_redirect = PdoWrap::selectCell($query, array(':url' => $_SERVER['REQUEST_URI']));
    if ($check_redirect != '') {
        $re = $check_redirect;
    } else {
        $query = 'SELECT CONCAT(`g`.`link`, `i`.`alias`, ".html") AS `link` FROM `cms_catalog_items` `i` INNER JOIN `cms_catalog_groups` `g` ON `g`.`id` = `i`.`group_id` INNER JOIN `zkymf_zoo_item` `z` ON `z`.`id` = `i`.`old_id` WHERE `z`.`alias` = :url';
        $params = array(':url' => $alias);
        $check = PdoWrap::selectCell($query, $params);
        if ($check != "" && $check != $_SERVER['REQUEST_URI']) {
            $query = 'INSERT INTO `' . PREF . 'redirect_urls` (`from_url`, `to_url`) VALUES (:from_url, :to_url)';
            PdoWrap::execute($query, array(':from_url' => $_SERVER['REQUEST_URI'], ':to_url' => $check));
            $re = $check;
        }
    }
}
if ($re != '') {
    header("HTTP/1.1 301 Moved Permanently");
    header('location: ' . $re);
    exit;
}
Пример #3
0
 /**
  * Транслитерация строк
  * @param string $str
  * @param int $db_flag
  * @return string
  */
 static function transliterate($str, $db_flag = 0)
 {
     // транслитерация корректно работает на страницах с любой кодировкой
     // (c)Imbolc http://php.imbolc.name
     static $tbl = array('а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ж' => 'g', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'ы' => 'i', 'э' => 'e', 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ж' => 'G', 'З' => 'Z', 'И' => 'I', 'Й' => 'Y', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Ы' => 'I', 'Э' => 'E', 'ё' => "yo", 'х' => "h", 'ц' => "ts", 'ч' => "ch", 'ш' => "sh", 'щ' => "shch", 'ъ' => "", 'ь' => "", 'ю' => "yu", 'я' => "ya", 'Ё' => "YO", 'Х' => "H", 'Ц' => "TS", 'Ч' => "CH", 'Ш' => "SH", 'Щ' => "SHCH", 'Ъ' => "", 'Ь' => "", 'Ю' => "YU", 'Я' => "YA");
     $data = strtr($str, $tbl);
     if ($db_flag == 1) {
         $data = preg_replace('/[[:punct:]]/', '', $data);
         $data = self::strtolow(preg_replace('/\\s+/', '_', $data));
         $query = 'CALL set_transliterate(:string_field, :value_field)';
         $params = array(':string_field' => $str, ':value_field' => $data);
         PdoWrap::execute($query, $params);
     }
     return $data;
 }
Пример #4
0
function clearCacheFiles(Smarty $smarty, $cache_id = 0, $table = '', $table_id = 0, $link = '')
{
    $cache_data = array();
    // Удаление файлов кэша по ID
    if ((int) $cache_id > 0) {
        $query = 'CALL get_table_row_by_id(:current_table, :id_value)';
        $params = array(':current_table' => PREF . 'cached_files', ':id_value' => $cache_id);
        $tmp = PdoWrap::select($query, $params);
        $cache_data = array_merge($cache_data, $tmp);
        $query = 'CALL delete_table_row_by_field(:current_table, :table_cell, :cell_value)';
        $params = array(':current_table' => PREF . 'cached_files', ':table_cell' => 'id', ':cell_value' => $cache_id);
        PdoWrap::execute($query, $params);
    }
    // Удаление файлов кэша по ID таблицы
    if (!empty($table) && (int) $table_id > 0) {
        $query = 'SELECT * FROM `' . PREF . 'cached_files` WHERE `table_name` = :table_name AND `table_id` = :table_id';
        $params = array(':table_name' => $table, ':table_id' => $table_id);
        $tmp = PdoWrap::select($query, $params);
        $cache_data = array_merge($cache_data, $tmp);
        $query = 'DELETE FROM `' . PREF . 'cached_files` WHERE `table_name` = :table_name AND `table_id` = :table_id';
        $params = array(':table_name' => $table, ':table_id' => $table_id);
        PdoWrap::execute($query, $params);
    }
    // Удаление файлов кэша по всей таблице
    if (!empty($table) && (int) $table_id == 0) {
        $query = 'SELECT * FROM `' . PREF . 'cached_files` WHERE `table_name` = :table_name';
        $params = array(':table_name' => $table);
        $tmp = PdoWrap::select($query, $params);
        $cache_data = array_merge($cache_data, $tmp);
        $query = 'DELETE FROM `' . PREF . 'cached_files` WHERE `table_name` = :table_name';
        $params = array(':table_name' => $table);
        PdoWrap::execute($query, $params);
    }
    // Удаление файлов кэша по ссылке
    if (!empty($link)) {
        $query = 'SELECT * FROM `' . PREF . 'cached_files` WHERE `link` LIKE :link';
        $params = array(':link' => '%' . $link . '%');
        $tmp = PdoWrap::select($query, $params);
        $cache_data = array_merge($cache_data, $tmp);
        $query = 'DELETE FROM `' . PREF . 'cached_files` WHERE `link` LIKE :link';
        $params = array(':link' => '%' . $link . '%');
        PdoWrap::execute($query, $params);
    }
    for ($i = 0; $i < count($cache_data); $i++) {
        $smarty->clearCache($cache_data[$i]['template'], $cache_data[$i]['id']);
    }
}
Пример #5
0
 /**
  * Редактирование данных в таблице
  * При успешном добавлении возвращает TRUE
  * При провале возвращает массив ошибок
  * @param string $table
  * @param int $id
  * @param array $data
  * @return mixed
  */
 public function editRow($table, $id, $data = array())
 {
     $error = array('all' => false);
     if (empty($data)) {
         $data = $this->base->postInputDataHandler($table);
         $error = $this->base->getErrors();
     }
     $parent = (int) Text::get_post('parent');
     $parent = $parent > 0 ? $parent : 1;
     $check_alias = $this->base->checkAlias($table, $id, $data['alias'], $parent, $data['type']);
     if ($check_alias == 1) {
         $error['all'] = $error['alias'] = true;
     } elseif ($check_alias == 2) {
         $error['all'] = $error['alias2'] = true;
     }
     if ($data['type'] == 3 && $data['url'] == '') {
         $data['url'] = $data['alias'];
     }
     // Обновление идентификатора пользователя, добавившего запись
     $data['user_edit'] = $this->getUid();
     if (!isset($error['all']) || $error['all'] === false) {
         $this->base->editTableRow($table, $data, $id, $parent);
         $query = 'CALL pages_update_links_after_update(:id)';
         $params = array(':id' => $id);
         PdoWrap::execute($query, $params);
         return true;
     }
     $this->setErrors($error);
     return false;
 }
Пример #6
0
 /**
  * Удаление записей из таблицы
  * @param string $table
  * @param int $id
  * @param array $files
  * @return mixed
  */
 public function deleteTableRow($table, $id, $files = array('image', 'icon', 'file'))
 {
     // Удаление файлов
     if (is_array($files) && !empty($files)) {
         $data = $this->getAllChildren($table, $id);
         for ($i = 0; $i < count($data); $i++) {
             foreach ($files as $value) {
                 if (isset($data[$i][$value]) && $data[$i][$value] != '') {
                     Files::deleteFile($data[$i][$value]);
                 }
             }
         }
     }
     // Получение ветвей дерева
     $tree_branches = $this->getNodeInfo($table, $id);
     $query = 'CALL delete_tree_table_rows(:current_table, :tree_left, :tree_right)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':tree_left' => $tree_branches['tree_left'], ':tree_right' => $tree_branches['tree_right']);
     PdoWrap::execute($query, $params);
     // Clearing blank spaces in a tree
     $query = 'CALL update_tree_branches_after_delete(:current_table, :tree_left, :tree_right)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':tree_left' => $tree_branches['tree_left'], ':tree_right' => $tree_branches['tree_right']);
     PdoWrap::execute($query, $params);
     // Логирование оперции
     $this->tableLog(PREF . $table, $id, "3");
 }
Пример #7
0
 /**
  * Удаление связей
  * @param string $table
  * @param string $col1
  * @param string $col2
  * @param int $val1
  * @param int $val2
  * @return bool
  */
 public function deleteRelations($table, $col1, $col2, $val1, $val2)
 {
     if ((int) $val1 > 0 && (int) $val2 > 0) {
         $query = 'CALL delete_relations(:table_name,:col1,:col2,:val1,:val2)';
         $params = array(':table_name' => $table, ':col1' => $col1, ':col2' => $col2, ':val1' => $val1, ':val2' => $val2);
         PdoWrap::execute($query, $params);
         return true;
     }
     return false;
 }
Пример #8
0
 /**
  *	Обязательная функция для компонента.
  *
  */
 public function start()
 {
     $this->setObject();
     // Определение полей формы
     $this->form = isset($this->params['form']) && (int) $this->params['form'] > 0 ? $this->params['form'] : "";
     $success = (int) Text::get_get('success');
     // Получение иформации формы
     $form = $this->__getFormInfo($this->form);
     // Получение полей формы
     $form_rows = $this->__getFormFields($this->form);
     if (Text::get_get('do') == 'ajaxUploadFile') {
         $file = load_file('Filedata', 'userfiles/', 1);
         echo $file['name'];
         exit;
     }
     if (Text::get_get('do') == 'ajaxDeleteFile') {
         $file = Text::get_get('file');
         if (file_exists(DOC . 'userfiles/' . $file)) {
             unlink(DOC . 'userfiles/' . $file);
         }
         exit;
     }
     $e = array('all' => false);
     if (Text::get_post('do') == 'send_order') {
         $ext = array('do', 'send');
         $values = array();
         foreach ($_POST as $key => $value) {
             if (!in_array($key, $ext)) {
                 if (!is_array($value)) {
                     $values[$key] = htmlspecialchars(stripcslashes(Text::get_post($key)));
                 } else {
                     $values[$key] = Text::get_post($key);
                 }
             }
         }
         foreach ($values as $k => $v) {
             for ($i = 0; $i < count($form_rows); $i++) {
                 if ($k == $form_rows[$i]['alias']) {
                     $form_rows[$i]['default'] = $v;
                     if ($form_rows[$i]['check'] == 1) {
                         if ($k == 'email') {
                             if (Text::check_mail($v) === false) {
                                 $e['all'] = $e[$k] = true;
                             }
                         } else {
                             if (empty($v)) {
                                 $e['all'] = $e[$k] = true;
                             }
                         }
                     }
                 }
             }
         }
         // Обработка изображений
         $files = array();
         if (isset($values['file'])) {
             foreach ($values['file'] as $v) {
                 $files[] = array('name' => $v, 'orig' => $v);
             }
         } else {
             foreach ($_FILES as $key => $value) {
                 if ($value['error'] == 0) {
                     $files[$key] = load_file($key);
                 }
             }
         }
         if ($e['all'] === false) {
             ob_start();
             $this->smarty->assign('data', $values);
             $this->smarty->assign('form_rows', $form_rows);
             $this->smarty->assign('options', getSiteOptions());
             $this->smarty->assign('site_url', 'http://' . $_SERVER['SERVER_NAME'] . '/');
             $this->smarty->display($this->doc . 'mail.tpl');
             $mail_body = ob_get_contents();
             ob_clean();
             $test = sendMail($form['email'], $form['subj'], $mail_body, '', $files);
             //sendMail($form['email'], $form['subj'], $mail_body, $files);
             if ($form['admin'] == 1) {
                 $v = array($form_rows, $values, $files);
                 $val = serialize($v);
                 $query = 'CALL form_orders_insert(:field_name, :field_value)';
                 $params = array(':field_name' => $form['name'], ':field_value' => $mail_body);
                 PdoWrap::execute($query, $params);
             }
             header("Location: " . $_SERVER['REQUEST_URI'] . (preg_match('/\\?/', $_SERVER['REQUEST_URI']) ? '&' : '?') . 'success=1');
             exit;
         }
     }
     $this->smarty->assign('e', $e);
     $this->smarty->assign('form', $form);
     $this->smarty->assign('form_rows', $form_rows);
     $this->smarty->assign('success', $success);
     return;
 }
Пример #9
0
 /**
  * Редкатирование ячейки
  * @param $table
  * @param $field
  * @param $value
  * @param $id
  */
 public function editCell($table, $field, $value, $id)
 {
     $query = 'CALL edit_cell(:current_table,:current_field,:field_value,:row_id)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':current_field' => $field, ':field_value' => $value, ':row_id' => $id);
     PdoWrap::execute($query, $params);
 }
Пример #10
0
 /**
  * Удаление записей из таблицы по названию поля
  * @param $table
  * @param $filed_name
  * @param $field_value
  * @return mixed
  */
 public function deleteTableRowByField($table, $filed_name, $field_value)
 {
     $query = 'CALL delete_table_row_by_field(:current_table, :table_cell, :cell_value)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':table_cell' => $filed_name, ':cell_value' => $field_value);
     PdoWrap::execute($query, $params);
 }
Пример #11
0
 /**
  * Обновление импортированных данных
  * @param XMLReader $reader
  * @return int
  */
 public function updateImportProduction(XMLReader $reader)
 {
     $count = 0;
     $tmp_data = $this->parseXML($reader, 'Предложения');
     if (is_array($tmp_data) && !empty($tmp_data)) {
         foreach ($tmp_data as $key => $item) {
             $xml_id = $item['Ид'];
             $data_item = $this->checkCatalogItem($xml_id);
             if ((int) $data_item > 0) {
                 $price = (double) $item['Цены']['Цена']['ЦенаЗаЕдиницу'];
                 $query = 'CALL catalog_item_update_price(:id, :price)';
                 $params = array(':id' => $data_item, ':price' => $price);
                 PdoWrap::execute($query, $params);
                 $count++;
             }
         }
     }
     return $count;
 }