Exemplo n.º 1
0
 /**
  * Получение пунктов меню
  * @param $parent
  * @param $group_id
  * @return array
  */
 public function getMenuElements($parent, $group_id)
 {
     $query = 'CALL get_menu_elements(:parent_id, :group_id)';
     $params = array(':parent_id' => $parent, ':group_id' => $group_id);
     $data = PdoWrap::select($query, $params);
     return $data;
 }
Exemplo n.º 2
0
 /**
  * Получение массива дочерних элементов для панели администрирования
  * @param $table
  * @param $parent
  * @param int $page_num
  * @param string $sort
  * @param string $sort_type
  * @return array
  */
 public function getAdminChildren($table, $parent = 0, $page_num = 1, $sort = '', $sort_type = 'ASC')
 {
     $count = '';
     $query = 'CALL get_tree_table_children_rows_group_names(:current_table, :group_table, :parent_id, :group_id, :sort, :sort_type, :limit_field, :page_num, :active_field)';
     $params = array(':current_table' => $this->__getPrefixTableName($table), ':group_table' => $this->__getPrefixTableName($this->getTableGroupName()), ':parent_id' => (int) $parent, ':group_id' => (int) $this->getGroup(), ':sort' => $sort, ':sort_type' => $sort_type, ':limit_field' => $this->getLimit(), ':page_num' => $page_num, ':active_field' => 2);
     // Получение массива данных
     $data = PdoWrap::select($query, $params);
     // Получение общего количества записей
     $count = PdoWrap::selectCell('SELECT @count AS `count`');
     $this->setCount($count);
     return $data;
 }
Exemplo n.º 3
0
 public function start()
 {
     $this->setObject();
     $group_id = isset($this->params['gid']) && (int) $this->params['gid'] > 0 ? (int) $this->params['gid'] : 0;
     $parent = isset($this->params['parent']) && (int) $this->params['parent'] > 0 ? (int) $this->params['parent'] : 0;
     $query = 'CALL get_menu_elements(:parent_id, :group_id)';
     $params = array(':parent_id' => $parent, ':group_id' => $group_id);
     $data = PdoWrap::select($query, $params);
     $this->smarty->assign('__lang', $this->getLocalization());
     $this->smarty->assign('current_link', $this->getUrl());
     $this->smarty->assign('data', $data);
     $this->smarty->assign('page', $this->page_info);
 }
Exemplo n.º 4
0
 /**
  * Получение массива дочерних элементов для панели администрирования
  * @param string $table
  * @param int $parent
  * @param int $page_num
  * @param string $sort
  * @param int $sort_type
  * @return array
  */
 public function getAdminChildren($table, $parent = 0, $page_num = 1, $sort = '', $sort_type = 0)
 {
     $count = '';
     if ((int) $parent == 0) {
         $query = 'CALL get_table_all_rows_with_group(:current_table, :group_table, :sort, :sort_type, :table_limit, :page_num, :active_field)';
         $params = array(':current_table' => $this->__getPrefixTableName($table), ':group_table' => $this->__getPrefixTableName($this->getTableGroupName()), ':sort' => $sort, ':sort_type' => $sort_type, ':table_limit' => $this->getLimit(), ':page_num' => $page_num, ':active_field' => 2);
         // Получение массива данных
         $data = PdoWrap::select($query, $params);
         // Получение общего количества записей
         $count = PdoWrap::selectCell('SELECT @count AS `count`');
         $this->setCount($count);
         return $data;
     } else {
         return $this->getRows($table, 'group_id', $parent, $sort, $sort_type, $page_num, $this->getLimit(), 2);
     }
 }
Exemplo n.º 5
0
    public function search_data($search_query)
    {
        $data = array();
        if ($search_query != '') {
            $tmp = preg_split('/\\s/', $search_query);
            $count = count($tmp);
            $query = '
				(
				SELECT
					`p`.`name`,
					`p`.`link`,
					`p`.`text`,
					CONCAT_WS(" ", `p`.`name`, `p`.`h1`, `p`.`text`, `p`.`head_title`, `p`.`meta_description`, `p`.`meta_keywords`) AS `search_string`
				FROM
					`' . PREF . 'pages` `p`
				WHERE
					`p`.`type` != 3
				HAVING
					`search_string` LIKE "%' . mysql_real_escape_string($count > 1 ? $search_query : $this->stemmer->stem_word($search_query)) . '%"
			';
            if ($count > 1) {
                $query .= '
						OR
					(
				';
                for ($i = 0; $i < $count; $i++) {
                    if ($i != 0) {
                        $query .= '
							OR
						';
                    }
                    $query .= '
						`search_string` LIKE "%' . mysql_real_escape_string($this->stemmer->stem_word($tmp[$i])) . '%"
					';
                }
                $query .= '
						)
				';
            }
            $query .= '
					)
			';
            $data = PdoWrap::select($query);
        }
        return $data;
    }
Exemplo n.º 6
0
 private function showList()
 {
     //	Лимит записей на страницу.
     $limit = isset($this->params['limit']) && (int) $this->params['limit'] > 0 ? (int) $this->params['limit'] : System_Settings::getLimit();
     //	Группа новостей.
     $group_id = isset($this->params['gid']) && (int) $this->params['gid'] > 0 ? (int) $this->params['gid'] : 0;
     //	Выводить на главной.
     $main_page = isset($this->params['main_page']) && (int) $this->params['main_page'] > 0 ? (int) $this->params['main_page'] : 0;
     // Получение номера страницы
     $page_num = $this->getPageNum();
     $data = $this->getList($group_id, $page_num, $limit);
     if ($main_page == 1) {
         $query = '
             SELECT
                 `i`.*,
                 CONCAT(`c`.`link`, `i`.`alias`, ".html") AS `link`,
                 `c`.`link` AS `group_link`,
                 `c`.`name` AS `group_name`,
                 (SELECT `image` FROM `cms_catalog_images` `im` WHERE `im`.`item_id` = `i`.`id` ORDER BY `im`.`position` DESC LIMIT 1) AS `image`
             FROM
                 `' . PREF . 'catalog_items` `i`
             INNER JOIN
                 `' . PREF . 'catalog_groups` `c` ON `c`.`id` = `i`.`group_id`
             INNER JOIN
                 `' . PREF . 'catalog_groups` `p` ON `c`.`tree_left` >= `p`.`tree_left` AND `c`.`tree_right` <= `p`.`tree_right`
             WHERE
                 `p`.`id` = ?
             AND
                 `i`.`active` = "1"
             AND
                 `i`.`main_page` = "1"
             ORDER BY `i`.`position` ASC
             LIMIT ' . (int) $limit . '
         ';
         $data = PdoWrap::select($query, array($group_id));
     }
     // Вывод информации о постраничной навигации
     $this->smarty->assign('pagination', $this->object->getPagination($page_num));
     $this->smarty->assign('current_link', $this->getUrl());
     // Вывод информации в шаблон
     $this->smarty->assign('data', $data);
     $this->smarty->assign('page', $this->page_info);
 }
Exemplo n.º 7
0
 /**
  * Получение информации о каталоге
  * @return array
  */
 public function getCatalogInfo($group_id = 1)
 {
     $query = 'CALL catalog_info(:group_id)';
     $param = array('group_id' => $group_id);
     return PdoWrap::selectRow($query, $param);
 }
Exemplo n.º 8
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");
 }
Exemplo n.º 9
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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 11
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']);
    }
}
Exemplo n.º 12
0
 function __construct(&$smarty, $preload_m = null, $conf = array(), $rights = array(), $localize = array())
 {
     self::setCurrentLang($conf['curlang']);
     self::setDefaultLang($conf['deflang']);
     self::setAString($conf['aStrings']);
     self::setLocalize($localize);
     if (is_array($conf) && count($conf) > 0) {
         foreach ($conf as $var => $value) {
             $this->setConf($var, $value);
         }
     }
     self::setFinalPath($this->getConf('final_path'));
     self::setLimit($this->getConf('limit'));
     //	Подключение данных для ремаппинга.
     $__remap = array();
     if (is_file(System_Settings::getPathRoot() . '/remap.php')) {
         require System_Settings::getPathRoot() . '/remap.php';
     }
     $show_page_text = 1;
     $current_lang = self::getCurrentLang();
     // Подключение файлов основного модуля
     include System_Settings::getPathRoot() . '/modules/pages/class.pages.php';
     include System_Settings::getPathRoot() . '/modules/pages/controller.php';
     // Выгрузка файла локализации
     $__lang = self::getLocalize();
     // Получаем информацию об корневой странице модуля
     $page = array();
     $bread_crumbs = array();
     $page_title = '';
     $tpl = 'index';
     self::setModuleAString(self::$aString);
     if (class_exists('Pages')) {
         // Объекст класса для работы с деревьями
         $base = new TreeTable(DOC, $current_lang, PREF);
         $pages = new Pages($base, $__lang);
         // Для показа статических страниц нужно разобрать URL
         $aStrings = self::getModuleAString();
         // Получение информации о корневой странице
         $page = $pages->showBasePage($aStrings);
         if (isset($page['type']) && $page['type'] == 1 && $page['tree_level'] > 0 && !preg_match('/\\.html$/i', $_SERVER['REDIRECT_URL'])) {
             $page = array();
         } elseif (isset($page['tree_level']) && $page['tree_level'] == 0 && count($aStrings) > 1) {
             $page = array();
         }
         if (isset($page['id'])) {
             // Получение хлебных крошек
             $bread_crumbs = $pages->getBreadCrumbsByID($page['id']);
             /*		Шаблон страницы.	*/
             $tpl = !isset($page['template']) || empty($page['template']) ? 'index' : is_file(System_Settings::getSmarty_template() . $page['template'] . '.tpl') ? $page['template'] : 'index2';
         }
     }
     if (count(self::$aString) > 1) {
         if (isset($__remap[self::$aString[1]])) {
             // Если Страница является модулем, то отьрасывыем остальную часть УРЛ
             // Разбор остальной части будет производиться в модуле
             $root_aString = array();
             $module_aString = array();
             $count_aString = count(self::$aString);
             for ($i = 0; $i < $count_aString; $i++) {
                 if ($i <= 1) {
                     $root_aString[] = self::$aString[$i];
                 } else {
                     $module_aString[] = self::$aString[$i];
                 }
             }
             if ($count_aString != count($root_aString)) {
                 $show_page_text = 0;
             }
             self::setAString($root_aString);
             self::setModuleAString($module_aString);
             $module_name = $__remap[self::$aString[1]]['module'];
         } elseif (isset($page['type']) && $page['type'] == 2) {
             $module_name = $page['alias'];
             // TODO: Проверить работу модулей
             // Проверяем является ли страница модулем
             if ($this->checkModule($module_name)) {
                 // Если Страница является модулем, то отьрасывыем остальную часть УРЛ
                 // Разбор остальной части будет производиться в модуле
                 $root_aString = array();
                 $module_aString = array();
                 $count_aString = count(self::$aString);
                 for ($i = 0; $i < $count_aString; $i++) {
                     if ($i <= 1) {
                         $root_aString[] = self::$aString[$i];
                     } else {
                         $module_aString[] = self::$aString[$i];
                     }
                 }
                 if ($count_aString != count($root_aString)) {
                     $show_page_text = 0;
                 }
                 self::setAString($root_aString);
                 self::setModuleAString($module_aString);
                 $module_name = self::$aString[1];
             } else {
                 $module_name = 'pages';
             }
         }
     }
     // Имя запрашиваемого пользователем модуля
     $modules = !empty($module_name) ? $module_name : 'pages';
     // Модули загружаемые до загрузки основного модуля
     if ($preload_m != null) {
         foreach ($preload_m as $key => $value) {
             $this->setRequestModule($key);
             $this->AddModule($key, $value);
         }
     }
     if ($modules != 'pages') {
         // Проверить существует ли запрошенный модуль
         if ($this->checkModule($modules)) {
             // Получение прав пользователей
             $query = 'CALL get_user_rights(:user_level)';
             $params = array(':user_level' => isset($_SESSION['siteuser']['group_id']) ? (int) $_SESSION['siteuser']['group_id'] : 0);
             $rights = PdoWrap::select($query, $params);
             $access = 1;
             foreach ($rights as $values) {
                 if ($modules == $values['folder'] && $values['read'] == 1) {
                     $access++;
                 }
             }
             $action = 'index';
             if ($access > 0) {
                 // Установить имя запрошенного модуля
                 $this->setRequestModule($modules);
                 // Проверить вызываемые дейтсвия для модуля
                 if ($this->checkAction($action)) {
                     // Установить имя запрошенного модуля
                     $this->setRequestAction($action);
                     if (isset($__remap[$this->getRequestModule()])) {
                         // Все параметры для вызова основного модуля готовы, вызываем модуль
                         $module = $__remap[$this->getRequestModule()]['module'];
                         if ($this->checkLang()) {
                             include System_Settings::getPathRoot() . '/modules/' . $module . '/langs/' . self::getCurrentLang() . '.lang.php';
                         }
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/class.' . $module . '.php';
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/controller.php';
                         include System_Settings::getPathRoot() . '/modules/' . $module . '/index.action.php';
                     } else {
                         // Все параметры для вызова основного модуля готовы, вызываем модуль
                         if ($this->checkLang()) {
                             $__lang = '';
                             require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/langs/' . self::getCurrentLang() . '.lang.php';
                             self::setLocalize($__lang);
                         }
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/class.' . $this->getRequestModule() . '.php';
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/controller.php';
                         // и действие для данного модуля
                         require_once System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/' . self::getRequestAction() . '.action.php';
                         // Проверяем существование модульного шаблона
                         if (file_exists(System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/templates/' . $tpl . '.tpl')) {
                             $tpl = System_Settings::getPathRoot() . 'modules/' . $this->getRequestModule() . '/templates/' . $tpl;
                         }
                     }
                     // В случае ошибки - вывести сообщение и остановить работу скрипта
                 } else {
                     require_once DOC . '/error404.php';
                 }
             } else {
                 echo 'access denied';
                 exit;
             }
         } else {
             require_once DOC . '/error404.php';
             exit;
         }
     } else {
         // Подключение управляющего файла модуля
         include System_Settings::getPathRoot() . '/modules/pages/index.action.php';
     }
     // Установка шаблона
     self::setTpl($tpl);
     // Получение заголовка
     $page_title = $pages->getPageTitle($page['head_title'], self::getPageNum(), $page['show_navigation']);
     // Выгрузка переменных в шаблон
     $smarty->assign(array('page' => $page, 'breadcrumbs' => $bread_crumbs, 'page_title' => $page_title, 'show_page_text' => $show_page_text));
 }
Exemplo n.º 13
0
 /**
  * Проверяем зарегистрирован ли пользоватль через соц сеть
  * @param int $social
  * 0 - Регистрация на сайте
  * 1 - Регистрация через VK
  * 2 - Регистрация через facebook
  * 3 - Регистрация через LinkedIn
  * @param int $social_id - Идентификатор в соц сети
  * @return array
  */
 public function getUserBySocial($social = 0, $social_id = 0)
 {
     $query = 'CALL get_user_by_social(:social,:social_id)';
     $params = array(':social' => (int) $social, ':social_id' => (int) $social_id);
     $data = PdoWrap::selectRow($query, $params);
     return $data;
 }
Exemplo n.º 14
0
 /**
  * Получение массива дочерних альбомов
  * @param $parent
  * @param int $page_num
  * @param string $sort
  * @param string $sort_type
  * @return array
  */
 public function getChildrenAlbums($parent, $page_num = 1, $sort = '', $sort_type = 'ASC')
 {
     $count = '';
     $query = 'CALL get_gallery_children_albums(:parent_id, :sort, :sort_type, :limit_field, :page_num)';
     $params = array(':parent_id' => (int) $parent, ':sort' => $sort, ':sort_type' => $sort_type, ':limit_field' => $this->base->getLimit(), ':page_num' => $page_num);
     // Получение массива данных
     $data = PdoWrap::select($query, $params);
     // Получение общего количества записей
     $count = PdoWrap::selectCell('SELECT @count AS `count`');
     $this->base->setCount($count);
     return $data;
 }
Exemplo n.º 15
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;
 }
Exemplo n.º 16
0
/**
 * Получение собственных заметок пользователя
 * @param $param
 * @param $smarty
 */
function smarty_function_getUserNotes($param, &$smarty)
{
    $data = array();
    //	Переменная, в которую все вернется.
    $assign = 'data';
    if (isset($param['assign']) && preg_match('/^[a-z0-9_]+?$/', $param['assign'])) {
        $assign = $param['assign'];
    }
    if (isset($_SESSION['siteuser']['id'])) {
        $query = 'CALL get_user_notes(:user_id,:status,:table_limit,:table_page,:sort_field,:sort_type)';
        $params = array('user_id' => $_SESSION['siteuser']['id'], 'status' => 1, 'table_limit' => 5, 'table_page' => 1, 'sort_field' => '', 'sort_type' => '');
        $data = PdoWrap::select($query, $params);
    }
    // Выгрузка в шпблон
    $smarty->assign($assign, $data);
}
Exemplo n.º 17
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;
 }
Exemplo n.º 18
0
 /**
  * Очищаем экземпляр класса
  */
 public static function close()
 {
     self::$db = NULL;
 }
Exemplo n.º 19
0
 /**
  * Поиск по любым таблицам
  * @param $table
  * @param $search
  * @param $parent
  * @param int $page_num
  * @param string $sort
  * @param string $sort_type
  * @param int $active
  * @return array
  */
 public function searchAllTables($table, $search, $parent, $page_num = 1, $sort = '', $sort_type = '', $active = 2)
 {
     // Название процедуры для поиска
     $proc_name = 'search_by_' . $table;
     // Проверяем существование процедуры поиска по таблице
     if (!$this->__storedProcedureCheck($proc_name)) {
         // Генерация процедуры для поиска
         $this->__generateSearchStoredProc($table);
     }
     $query = 'CALL `' . $proc_name . '`(:group_id,:sort,:sort_type,:table_limit,:page_num,:search_query,:active_field);';
     $params = array(':group_id' => (int) $parent, ':sort' => $sort, ':sort_type' => $sort_type, ':table_limit' => $this->getLimit(), ':page_num' => $page_num, ':search_query' => '%' . $search . '%', ':active_field' => $active);
     $data = PdoWrap::select($query, $params);
     $count = PdoWrap::selectCell('SELECT @count');
     $this->setCount($count);
     return $data;
 }
Exemplo n.º 20
0
Arquivo: list.php Projeto: klimjr/cms
<?php

//	Запрет на обращение к файлу.
if (realpath($_SERVER['SCRIPT_FILENAME']) == realpath(__FILE__)) {
    header('Location: /');
    exit;
}
/**
 * Получение установленных модулей.
 */
//	Получение записей.
$tmp = PdoWrap::select('CALL get_installed_modules()');
//	Подсчет полученных записей.
$count = count($tmp);
$data = array();
$data['notinstalled'] = array();
for ($i = 0; $i < $count; $i++) {
    if (is_file(DOC . 'admin/~' . $tmp[$i]['folder'] . '/.desc.php')) {
        $name = '';
        //	Подключение файлов локализации.
        if (is_file(DOC . 'admin/~' . $tmp[$i]['folder'] . '/langs/' . $current_lang . '.lang.php')) {
            require DOC . 'admin/~' . $tmp[$i]['folder'] . '/langs/' . $current_lang . '.lang.php';
        }
        //	Подключение настроек модуля
        require DOC . 'admin/~' . $tmp[$i]['folder'] . '/.desc.php';
        //	Заполнение массива.
        $data['installed'][$tmp[$i]['folder']] = $tmp[$i];
        $data['installed'][$tmp[$i]['folder']]['name'] = $name;
    } elseif (is_file(DOC . 'modules/' . $tmp[$i]['folder'] . '/admin/.desc.php')) {
        $name = '';
        //	Подключение файлов локализации.
Exemplo n.º 21
0
Arquivo: login.php Projeto: klimjr/cms
<?php

//	Запрет на обращение к файлу.
if (realpath($_SERVER['SCRIPT_FILENAME']) == realpath(__FILE__)) {
    header('Location: /');
    exit;
}
if (isset($_SESSION['user'])) {
    header('Location: /admin/');
    exit;
}
$auth_loginname_str = Text::get_post('auth_loginname_str');
$auth_password_str = md5(Text::get_post('auth_password_str'));
$msg = '';
if (!empty($auth_loginname_str)) {
    $query = 'CALL `get_user_info`(:user_login, :user_pass)';
    $params = array(':user_login' => $auth_loginname_str, ':user_pass' => $auth_password_str);
    $result = PdoWrap::selectRow($query, $params);
    if (!empty($result)) {
        $return = '/admin/';
        if (Text::get_get('return') != '') {
            $return = urldecode(Text::get_get('return'));
        }
        $_SESSION['user'] = $result;
        location($return);
    } else {
        $msg = 'В доступе отказано';
    }
}
$smarty->assign('msg', $msg);
Exemplo n.º 22
0
    public function search_data($search_query)
    {
        $data = array();
        if ($search_query != '') {
            $tmp = preg_split('/\\s/', $search_query);
            $count = count($tmp);
            $query = '
				(
				SELECT
					`p`.`name`,
					`p`.`image`,
					`p`.`link`,
					`p`.`text`,
					CONCAT_WS(" ", `p`.`name`, `p`.`alias`, `p`.`h1`, `p`.`text`, `p`.`head_title`, `p`.`meta_description`, `p`.`meta_keywords`) AS `search_string`
				FROM
					`' . PREF . 'pages` `p`
				WHERE
					`p`.`type` != 3
				HAVING
					`search_string` LIKE "%' . htmlspecialchars($count > 1 ? $search_query : $this->stemmer->stem_word($search_query)) . '%"
			';
            if ($count > 1) {
                $query .= '
						OR
					(
				';
                for ($i = 0; $i < $count; $i++) {
                    if ($i != 0) {
                        $query .= '
							OR
						';
                    }
                    $query .= '
						`search_string` LIKE "%' . htmlspecialchars($this->stemmer->stem_word($tmp[$i])) . '%"
					';
                }
                $query .= '
						)
				';
            }
            $query .= '
					)
			';
            $query .= '
				UNION (
				SELECT
					`p`.`name`,
					(SELECT `i`.`image` FROM `' . PREF . 'catalog_images` `i` WHERE `i`.`item_id` = `p`.`id` ORDER BY `position` DESC LIMIT 1) AS `image`,
					CONCAT(`g`.`link`, `p`.`alias`, ".html") AS `link`,
					`p`.`text`,
					CONCAT_WS(" ", `p`.`name`, `p`.`alias`, `p`.`text`, `p`.`head_title`, `p`.`meta_description`, `p`.`meta_keywords`) AS `search_string`
				FROM
					`' . PREF . 'catalog_items` `p`
				LEFT JOIN
					`' . PREF . 'catalog_groups` `g`
				ON
                    `p`.`group_id` = `g`.`id`
				WHERE
					`p`.`active` = "1"
				HAVING
					`search_string` LIKE "%' . htmlspecialchars($count > 1 ? $search_query : $this->stemmer->stem_word($search_query)) . '%"
			';
            if ($count > 1) {
                $query .= '
						OR
					(
				';
                for ($i = 0; $i < $count; $i++) {
                    if ($i != 0) {
                        $query .= '
							OR
						';
                    }
                    $query .= '
						`search_string` LIKE "%' . htmlspecialchars($this->stemmer->stem_word($tmp[$i])) . '%"
					';
                }
                $query .= '
						)
				';
            }
            $query .= '
					)
			';
            $query .= '
				UNION (
				SELECT
					`p`.`name`,
					`p`.`icon` AS `image`,
					`p`.`link`,
					`p`.`text`,
					CONCAT_WS(" ", `p`.`name`, `p`.`alias`, `p`.`text`, `p`.`head_title`, `p`.`meta_description`, `p`.`meta_keywords`) AS `search_string`
				FROM
					`' . PREF . 'catalog_groups` `p`
				WHERE
					`p`.`active` = "1"
				HAVING
					`search_string` LIKE "%' . htmlspecialchars($count > 1 ? $search_query : $this->stemmer->stem_word($search_query)) . '%"
			';
            if ($count > 1) {
                $query .= '
						OR
					(
				';
                for ($i = 0; $i < $count; $i++) {
                    if ($i != 0) {
                        $query .= '
							OR
						';
                    }
                    $query .= '
						`search_string` LIKE "%' . htmlspecialchars($this->stemmer->stem_word($tmp[$i])) . '%"
					';
                }
                $query .= '
						)
				';
            }
            $query .= '
					)
			';
            $data = PdoWrap::select($query);
        }
        return $data;
    }
Exemplo n.º 23
0
 /**
  * обратная Транслитерация строк.
  * @param string $value
  * @return string
  */
 static function untransliterate($value)
 {
     $query = 'CALL get_untransliterate(:value_field)';
     $params = array(':value_field' => $value);
     $data = PdoWrap::selectCell($query, $params);
     if (isset($data) && !empty($data)) {
         return $data;
     } else {
         return $value;
     }
 }
Exemplo n.º 24
0
Arquivo: list.php Projeto: klimjr/cms
                $_POST[$key] = $value['name'];
            }
        }
    }
    PdoWrap::execute('CALL clear_options_checkboxes()');
    foreach ($_POST as $key => $value) {
        if ($key != 'do' && $key != 'save') {
            if (isset($_POST['delete'][$key])) {
                $_POST[$key] = '';
            }
            $query = 'CALL options_update(:field_name, :field_value, :field_user_edit)';
            $params = array(':field_name' => $key, ':field_value' => Text::get_post($key), ':field_user_edit' => $_SESSION['user']['id']);
            PdoWrap::execute($query, $params);
        }
    }
    location($__return);
    exit;
}
// Получение списка настроек
$data = getSiteOptions2();
// Получение списка таблиц
$tables_tmp = PdoWrap::select('SHOW TABLES');
$tables = array();
for ($i = 0; $i < count($tables_tmp); $i++) {
    foreach ($tables_tmp[$i] as $value) {
        $tables[] = preg_replace('/^(' . PREF . ')(.+)$/', '$2', $value);
    }
}
$smarty->assign('data', $data);
$smarty->assign('tables', $tables);
$smarty->assign('page_title', $page_title);
Exemplo n.º 25
0
Arquivo: index.php Projeto: klimjr/cms
     foreach ($rights as $key => $value) {
         if ($value['read'] == 1) {
             $available_actions[] = $key;
         }
     }
     if (!in_array($action, $available_actions)) {
         $action = $available_actions[0];
     }
 }
 /**
  * Формирование верхнего меню.
  */
 //	Массив меню.
 $top_menu = array();
 //	Получение данных о модулях.
 $tmp = PdoWrap::select('CALL get_modules_data()');
 //	Подсчет количества записей.
 $count = count($tmp);
 // Иконка для меню по умолчанию
 $menu_pic = 'text.png';
 $name = '';
 $title = '';
 $bread_crumbs = array(array('link' => '/admin/', 'name' => $__lang['main']));
 //	Заполнение массива.
 if ($action != 'ajax') {
     for ($i = 0; $i < $count; $i++) {
         if (!isset($rights[$tmp[$i]['folder']]) || $rights[$tmp[$i]['folder']]['read'] == 0) {
             continue;
         }
         //	Проверка наличия файла описания.
         if (is_file(DOC . 'admin/~' . $tmp[$i]['folder'] . '/.desc.php')) {
Exemplo n.º 26
0
 /**
  * Получение настроект для колонки таблици
  * @param $table_name
  * @param $table_cell
  * @return mixed|null
  */
 public function getTableOption($table_name, $table_cell)
 {
     $query = 'CALL get_table_option(:table_name, :table_cell)';
     $params = array(':table_name' => PREF . $table_name, ':table_cell' => $table_cell);
     return PdoWrap::selectRow($query, $params);
 }
Exemplo n.º 27
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();
Exemplo n.º 28
0
 /**
  * Вывод шаблона
  * @param $template
  */
 public function displayAndCach($template)
 {
     $cache_id = null;
     $current_data = System_Settings::getCurrentData();
     if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] != '') {
         $query = 'CALL insert_cach_id(:link, :template, :table_name, :table_id)';
         $params = array(':link' => $_SERVER['REQUEST_URI'], ':template' => $template, ':table_name' => isset($current_data['table']) ? $current_data['table'] : NULL, ':table_id' => isset($current_data['id']) ? $current_data['id'] : NULL);
         $cache_id = PdoWrap::selectCell($query, $params);
     }
     parent::display($template, $cache_id);
 }
Exemplo n.º 29
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;
}
Exemplo n.º 30
0
 /**
  * Получение одного комментария
  * @param int $id
  * @return array
  */
 public function getComment($id)
 {
     $query = 'CALL get_comment(:comment_id)';
     $params = array(':comment_id' => $id);
     return PdoWrap::selectRow($query, $params);
 }