function mod_cart($module_id, $cfg) { $inDB = cmsDatabase::getInstance(); $inUser = cmsUser::getInstance(); cmsCore::includeFile('components/catalog/includes/shopcore.php'); $sid = session_id(); $items = array(); $total_summ = 0; $user_sql = $inUser->id ? "c.user_id='{$inUser->id}'" : "c.session_id='{$sid}'"; $sql = "SELECT i.title, i.price, i.category_id, i.id, c.itemscount\n FROM cms_uc_cart c\n INNER JOIN cms_uc_items i ON i.id = c.item_id\n WHERE {$user_sql}"; $result = $inDB->query($sql); $items_count = $inDB->num_rows($result); if ($items_count) { while ($con = $inDB->fetch_assoc($result)) { $price = shopDiscountPrice($con['id'], $con['category_id'], $con['price']); $totalcost = $con['itemscount'] * $price; $total_summ += $totalcost; $con['price'] = number_format($price, 2, '.', ' '); $con['totalcost'] = number_format($totalcost, 2, '.', ' '); $items[] = $con; } } cmsPage::initTemplate('modules', 'mod_cart')->assign('cfg', $cfg)->assign('items_count', $items_count)->assign('total_summ', number_format($total_summ, 2, '.', ' '))->assign('items', $items)->display('mod_cart.tpl'); return true; }
function mod_uc_random($mod, $cfg) { if ($cfg['cat_id']>0) { if (!$cfg['subs']) { //select from category $catsql = ' AND i.category_id = '. $cfg['cat_id']; } else { //select from category and subcategories $rootcat = cmsCore::c('db')->get_fields('cms_uc_cats', "id='". $cfg['cat_id'] ."'", 'NSLeft, NSRight'); if (!$rootcat) { return false; } $catsql = "AND (c.NSLeft >= ". $rootcat['NSLeft'] ." AND c.NSRight <= ". $rootcat['NSRight'] .")"; } } else { $catsql = ''; } $sql = "SELECT i.*, c.title as category, c.view_type as viewtype FROM cms_uc_items i LEFT JOIN cms_uc_cats c ON c.id = i.category_id WHERE i.published = 1 ". $catsql ." ORDER BY RAND() LIMIT ". $cfg['count']; $result = cmsCore::c('db')->query($sql) ; $items = array(); $is_uc = false; if (cmsCore::c('db')->num_rows($result)) { $is_uc = true; while ($item=cmsCore::c('db')->fetch_assoc($result)) { if (mb_strlen($item['imageurl']) < 4) { $item['imageurl'] = 'nopic.jpg'; } else if (!file_exists(PATH .'/images/catalog/small/'. $item['imageurl'])) { $item['imageurl'] = 'nopic.jpg'; } if ($item['viewtype'] == 'shop') { cmsCore::includeFile('components/catalog/includes/shopcore.php'); $item['price'] = number_format(shopDiscountPrice($item['id'], $item['category_id'], $item['price']), 2, '.', ' '); } $items[] = $item; } } cmsPage::initTemplate('modules', $cfg['tpl'])-> assign('items', $items)-> assign('cfg', $cfg)-> assign('is_uc', $is_uc)-> display(); return true; }
public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); // подключаем хелпер основного шаблона if (!cmsCore::includeFile('templates/' . self::$instance->getName() . '/assets/helper.php')) { cmsCore::loadLib('template.helper'); } } return self::$instance; }
private function loadSmarty() { if (isset(self::$i_smarty)) { return self::$i_smarty; } cmsCore::includeFile('/includes/smarty/libs/Smarty.class.php'); $smarty = new Smarty(); $smarty->setCompileDir(PATH . '/cache/'); $smarty->setCacheDir(PATH . '/cache/'); $smarty->assign('is_ajax', cmsCore::isAjax()); $smarty->assign('is_auth', cmsUser::getInstance()->id); self::$i_smarty = $smarty; return $smarty; }
function mod_rss($module_id, $cfg) { cmsCore::includeFile('includes/rss/lastRSS.php'); $rss = new lastRSS(); $rss->cache_dir = PATH . '/cache'; $rss->cache_time = (int) @$cfg['cachetime'] * 3600; $rss->cp = 'UTF-8'; $rss->items_limit = $cfg['itemslimit']; $rs = $rss->Get($cfg['rssurl']); if (!$rs) { return false; } cmsPage::initTemplate('modules', 'mod_rss')->assign('rs', $rs)->assign('cfg', $cfg)->display('mod_rss.tpl'); return true; }
function __construct($name = '') { $config = cmsConfig::getInstance(); $this->name = $name ? $name : $config->template; $this->setLayout('main'); $this->title = $config->sitename; $is_no_def_meta = isset($config->is_no_meta) ? $config->is_no_meta : false; if (!$is_no_def_meta) { $this->metakeys = $config->metakeys; $this->metadesc = $config->metadesc; } $this->path = $config->root_path . 'templates/' . $this->name; $this->options = $this->getOptions(); if (!cmsCore::includeFile('templates/' . $this->name . '/assets/helper.php')) { cmsCore::loadLib('template.helper'); } }
private function loadSmarty() { if (isset(self::$i_smarty)) { return self::$i_smarty; } cmsCore::includeFile('/includes/smarty/libs/Smarty.class.php'); $smarty = new Smarty(); $smarty->compile_dir = PATH . '/cache'; $smarty->register_function('wysiwyg', 'cmsSmartyWysiwyg'); $smarty->register_function('profile_url', 'cmsSmartyProfileURL'); $smarty->register_function('component', 'cmsSmartyCurrentComponent'); $smarty->register_function('template', 'cmsSmartyCurrentTemplate'); $smarty->register_function('add_js', 'cmsSmartyAddJS'); $smarty->register_function('add_css', 'cmsSmartyAddCSS'); $smarty->register_function('comments', 'cmsSmartyComments'); $smarty->assign('is_ajax', cmsCore::isAjax()); self::$i_smarty = $smarty; return $smarty; }
public static function getControllersMapping() { if (self::$mapping !== null) { return self::$mapping; } self::$mapping = array(); $map_file = 'system/config/remap.php'; $map_function = 'remap_controllers'; if (!cmsCore::includeFile($map_file)) { return false; } if (!function_exists($map_function)) { return false; } self::$mapping = call_user_func($map_function); if (!is_array(self::$mapping)) { return false; } return self::$mapping; }
public function execute($event = '', $item = array()) { parent::execute(); $inUser = cmsUser::getInstance(); cmsCore::includeFile('plugins/p_fckeditor/fckeditor/fckeditor.php'); $oFCKeditor = new FCKeditor($item['name']); $oFCKeditor->BasePath = '/plugins/p_fckeditor/fckeditor/'; $oFCKeditor->Height = $item['height']; $oFCKeditor->Width = $item['width']; $oFCKeditor->ToolbarSet = $inUser->is_admin ? 'Admin' : 'Basic'; $oFCKeditor->Value = $item['text']; $oFCKeditor->Config['DefaultLanguage'] = cmsConfig::getConfig('lang'); $oFCKeditor->Config['AutoDetectLanguage'] = false; if (!$inUser->is_admin) { $oFCKeditor->Config['ImageBrowser'] = false; $oFCKeditor->Config['LinkUpload'] = false; $oFCKeditor->Config['LinkBrowser'] = false; } ob_start(); $oFCKeditor->Create(); return ob_get_clean(); }
function mod_cart($mod, $cfg) { cmsCore::includeFile('components/catalog/includes/shopcore.php'); $sid = session_id(); $items = array(); $total_summ = 0; $user_sql = cmsCore::c('user')->id ? "c.user_id='". cmsCore::c('user')->id ."'" : "c.session_id='". $sid ."'"; $sql = "SELECT i.title, i.price, i.category_id, i.id, c.itemscount FROM cms_uc_cart c INNER JOIN cms_uc_items i ON i.id = c.item_id WHERE ". $user_sql; $result = cmsCore::c('db')->query($sql); $items_count = cmsCore::c('db')->num_rows($result); if ($items_count) { while($con = cmsCore::c('db')->fetch_assoc($result)){ $price = shopDiscountPrice($con['id'], $con['category_id'], $con['price']); $totalcost = $con['itemscount']*$price; $total_summ += $totalcost; $con['price'] = number_format($price, 2, '.', ' '); $con['totalcost'] = number_format($totalcost, 2, '.', ' '); $items[] = $con; } } cmsPage::initTemplate('modules', $cfg['tpl'])-> assign('cfg', $cfg)-> assign('items_count', $items_count)-> assign('total_summ', number_format($total_summ, 2, '.', ' '))-> assign('items', $items)-> display(); return true; }
function html_wysiwyg($field_id, $content = '', $wysiwyg = false) { $config = cmsConfig::getInstance(); if (!$wysiwyg) { $config = cmsConfig::getInstance(); $wysiwyg = $config->wysiwyg; } $connector = 'wysiwyg/' . $wysiwyg . '/wysiwyg.class.php'; if (!file_exists($config->root_path . $connector)) { return '<textarea id="' . $field_id . '" name="' . $field_id . '">' . $content . '</textarea>'; } cmsCore::includeFile($connector); $class_name = 'cmsWysiwyg' . ucfirst($wysiwyg); $editor = new $class_name(); ob_start(); $editor->displayEditor($field_id, $content); return ob_get_clean(); }
// InstantCMS v1.10.6 // // http://www.instantcms.ru/ // // // // written by InstantCMS Team, 2007-2015 // // produced by InstantSoft, (www.instantsoft.ru) // // // // LICENSED BY GNU/GPL v2 // // // /******************************************************************************/ session_start(); setlocale(LC_ALL, "ru_RU.UTF-8"); header('Content-Type: text/html; charset=utf-8'); define('VALID_CMS', 1); define('PATH', $_SERVER['DOCUMENT_ROOT']); include PATH . '/core/cms.php'; cmsCore::includeFile('install/function.php'); cmsCore::loadClass('config'); cmsCore::loadClass('db'); cmsCore::loadClass('user'); cmsCore::loadClass('page'); cmsCore::loadClass('actions'); $inConf = cmsConfig::getInstance(); // Мультиязычная установка $inConf->lang = isset($_SESSION['inst_lang']) ? $_SESSION['inst_lang'] : $inConf->lang; $langs = cmsCore::getDirsList('/languages'); // запрос на смену языка if (cmsCore::inRequest('lang')) { $inst_lang = cmsCore::request('lang', 'html', 'ru'); if (in_array($inst_lang, $langs)) { $_SESSION['inst_lang'] = $inst_lang; $inConf->lang = $inst_lang;
/** * Подготавливает строку поиска для sql запроса * формирует $this->against и $this->words * @return bool */ protected function getAgainst() { // если уже получали, возвращаемся if (!empty($this->against) && !empty($this->words)) { return true; } $this->against = array(); $this->words = array(); // Подключаем стеммер Портера cmsCore::includeFile('includes/stemmer/stemmer.php'); $stemmer = new Lingua_Stem_Ru(); // формируем массив слов $words = preg_split('/[\s,-]+/', $this->query, null, PREG_SPLIT_NO_EMPTY); if ($this->look == 'anyword' || $this->look == 'allwords') { foreach($words as $w) { $w = trim($w); if (mb_strlen($w) > 3) { if (mb_strlen($w) == 4) { $this->against[] = '('. $w .' | *'. $w .'*)'; $this->words[] = $w; } else { $w = $stemmer->stem_word($w); $this->against[] = '('. $w .' | *'. $w .'*)'; $this->words[] = $w; } } } } // любое слово if ($this->look == 'anyword') { $this->against = implode(' | ', $this->against); } // все слова if ($this->look == 'allwords') { $this->against = implode(' & ', $this->against); } // фраза целиком if ($this->look == 'phrase') { $this->against = '*'. $this->query .'*'; $this->words = $words; } else { $this->words = implode(' ', $this->words); } return true; }
public function loadModuleInstaller($module) { return cmsCore::includeFile('modules/' . $module . '/install.php'); }
<?php /******************************************************************************/ // // // InstantCMS v1.10.4 // // http://www.instantcms.ru/ // // // // written by InstantCMS Team, 2007-2014 // // produced by InstantSoft, (www.instantsoft.ru) // // // // LICENSED BY GNU/GPL v2 // // // /******************************************************************************/ define('PATH', $_SERVER['DOCUMENT_ROOT']); include PATH . '/core/ajax/ajax_core.php'; cmsCore::loadLanguage('modules/mod_latest'); $module_id = cmsCore::request('module_id', 'int', ''); if (!$module_id) { cmsCore::halt(); } $cfg = $inCore->loadModuleConfig($module_id); // номер страницы передаем через конфиг $cfg['page'] = cmsCore::request('page', 'int', 1); cmsCore::includeFile('modules/mod_latest/module.php'); mod_latest($module_id, $cfg);
public function runWidget($widget) { $user = cmsUser::getInstance(); $is_user_view = $user->isInGroups($widget['groups_view']); $is_user_hide = !empty($widget['groups_hide']) && $user->isInGroups($widget['groups_hide']) && !$user->is_admin; if ($is_user_hide) { return false; } if (!$is_user_view) { return false; } $path = 'system/' . cmsCore::getWidgetPath($widget['name'], $widget['controller']); $file = $path . '/widget.php'; cmsCore::includeFile($file); cmsCore::loadWidgetLanguage($widget['name'], $widget['controller']); $class = 'widget' . ($widget['controller'] ? string_to_camel('_', $widget['controller']) : '') . string_to_camel('_', $widget['name']); $widget_object = new $class($widget); $cache_key = "widgets.{$widget['id']}"; $cache = cmsCache::getInstance(); if (!$widget_object->isCacheable() || false === ($result = $cache->get($cache_key))) { $result = call_user_func_array(array($widget_object, 'run'), array()); if ($result) { // Отдельно кешируем имя шаблона виджета, поскольку оно могло быть // изменено внутри виджета, а в кеш у нас попадает только тот массив // который возвращается кодом виджета (без самих свойств $widget_object) $result['_wd_template'] = $widget_object->getTemplate(); } $cache->set($cache_key, $result); } if ($result === false) { return false; } if (isset($result['_wd_template'])) { $widget_object->setTemplate($result['_wd_template']); } cmsTemplate::getInstance()->renderWidget($widget_object, $result); }
<?php /******************************************************************************/ // // // InstantCMS v1.10.6 // // http://www.instantcms.ru/ // // // // written by InstantCMS Team, 2007-2015 // // produced by InstantSoft, (www.instantsoft.ru) // // // // LICENSED BY GNU/GPL v2 // // // /******************************************************************************/ define('PATH', $_SERVER['DOCUMENT_ROOT']); include PATH . '/core/ajax/ajax_core.php'; $module_id = cmsCore::request('module_id', 'int', 0); if (!$module_id) { cmsCore::halt(); } $cfg = $inCore->loadModuleConfig($module_id); cmsCore::includeFile('modules/mod_polls/module.php'); mod_polls(array('id' => $module_id), $cfg);
/** * Выполняет переданную задачу * @param array $job * @return bool */ public static function executeJob($job) { $job_result = true; /* ================================================ */ /* ============== внешний php-файл ============== */ /* ================================================ */ if ($job['custom_file']) { cmsCore::includeFile(ltrim($job['custom_file'], '/')); } /* ================================================ */ /* ================ метод модели ================= */ /* ================================================ */ if ($job['component'] && $job['model_method']) { cmsCore::loadModel($job['component']); $classname = "cms_model_{$job['component']}"; if (class_exists($classname)) { $model = new $classname(); if (method_exists($model, $job['model_method'])) { $job_result = call_user_func(array($model, $job['model_method'])); } } } /* ================================================ */ /* ================= метод класса ================ */ /* ================================================ */ if ($job['class_name'] && $job['class_method']) { $classfile = ''; if (!mb_strstr($job['class_name'], '|')) { $classname = $job['class_name']; } else { $job['class_name'] = explode('|', $job['class_name']); $classfile = $job['class_name'][0]; $classname = $job['class_name'][1]; } if ($classfile) { cmsCore::loadClass($classfile); } if (class_exists($classname)) { if (method_exists($classname, $job['class_method'])) { $job_result = $job_result && call_user_func(array($classname, $job['class_method'])); } } } if ($job_result) { self::jobSuccess($job['id']); } return $job_result; }
/******************************************************************************/ // // // InstantCMS v1.10.6 // // http://www.instantcms.ru/ // // // // written by InstantCMS Team, 2007-2015 // // produced by InstantSoft, (www.instantsoft.ru) // // // // LICENSED BY GNU/GPL v2 // // // /******************************************************************************/ define('PATH', $_SERVER['DOCUMENT_ROOT']); define("VALID_CMS_ADMIN", 1); include PATH . '/core/ajax/ajax_core.php'; cmsCore::includeFile('admin/includes/cp.php'); cmsCore::loadClass('formgen'); cmsCore::loadLanguage('admin/lang'); cmsCore::loadLanguage('admin/applets/applet_modules'); if (!$inUser->is_admin) { cmsCore::halt($_LANG['ACCESS_DENIED']); } $adminAccess = cmsUser::getAdminAccess(); if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) { cmsCore::halt($_LANG['ACCESS_DENIED']); } $module_id = cmsCore::request('id', 'int'); $mod = $inDB->get_fields('cms_modules', "id='{$module_id}'", '*'); if (!$mod) { cmsCore::halt(); }
function rssfeed($component = null, $item_id = null) { $inCore = cmsCore::getInstance(); $inConf = cmsConfig::getInstance(); $model = new cms_model_rssfeed(); global $_LANG; $component = isset($component) ? $component : cmsCore::request('target', 'str', 'rss'); $item_id = isset($item_id) ? $item_id : cmsCore::request('item_id', 'str', 'all'); if (!$inCore->isComponentInstalled($component)) { cmsCore::error404(); } if (!preg_match('/^([a-z0-9_\\-]+)$/ui', $item_id)) { $item_id = 0; } if ($item_id == 'all') { $item_id = 0; } //////////////////////////////////////////////////////////////////////////////// if ($inCore->do == 'view') { if (!file_exists(PATH . '/components/' . $component . '/prss.php')) { header('HTTP/1.0 404 Not Found'); header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); cmsCore::halt($_LANG['NOT_RSS_GENERATOR']); } cmsCore::loadLanguage('components/' . $component); cmsCore::includeFile('components/' . $component . '/prss.php'); $rssdata = call_user_func_array('rss_' . $component, array($item_id, $model->config)); if (!$rssdata['channel']) { header('HTTP/1.1 203 Non-Authoritative Information'); cmsCore::halt($_LANG['NOT_POST_IN_RSS']); } $channel = $rssdata['channel']; $items = $rssdata['items']; if ($model->config['addsite']) { $channel['title'] .= ' :: ' . $inConf->sitename; } $channel['title'] = trim(htmlspecialchars(strip_tags($channel['title']))); header('Content-Type: application/rss+xml; charset=utf-8'); $rss = '<?xml version="1.0" encoding="utf-8" ?>' . "\n"; $rss .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n"; $rss .= '<channel>' . "\n"; // Канал $rss .= '<title>' . $channel['title'] . '</title>' . "\n"; $rss .= '<link>' . $channel['link'] . '</link>' . "\n"; $rss .= '<description><![CDATA[' . trim(htmlspecialchars(strip_tags($channel['description']))) . ']]></description>' . "\n"; if ($model->config['icon_on']) { $rss .= '<image>' . "\n"; $rss .= '<title>' . $channel['title'] . '</title>' . "\n"; $rss .= '<url>' . $model->config['icon_url'] . '</url>' . "\n"; $rss .= '<link>' . $channel['link'] . '</link>' . "\n"; $rss .= '</image>' . "\n"; } // Содержимое канала if (is_array($items) && $items) { foreach ($items as $item) { $rss .= '<item>' . "\n"; $rss .= '<title>' . trim(htmlspecialchars(strip_tags($item['title']))) . '</title>' . "\n"; $rss .= '<pubDate>' . date('r', strtotime($item['pubdate']) + $inConf->timediff * 3600) . '</pubDate>' . "\n"; $rss .= '<guid>' . $item['link'] . '</guid>' . "\n"; $rss .= '<link>' . $item['link'] . '</link>' . "\n"; if (!empty($item['description'])) { $rss .= '<description><![CDATA[' . $item['description'] . ']]></description>' . "\n"; } $rss .= '<category>' . $item['category'] . '</category>' . "\n"; $rss .= '<comments>' . $item['comments'] . '</comments>' . "\n"; if (!empty($item['image'])) { $rss .= '<enclosure url="' . $item['image'] . '" length="' . $item['size'] . '" type="image/jpeg" />' . "\n"; } if (!empty($item['custom_enclosure'])) { $rss .= '<enclosure url="' . $item['custom_enclosure']['url'] . '" length="' . $item['custom_enclosure']['length'] . '" type="' . $item['custom_enclosure']['type'] . '" />' . "\n"; } $rss .= '</item>' . "\n"; } } $rss .= '</channel>' . "\n"; $rss .= '</rss>'; cmsCore::halt($rss); } //////////////////////////////////////////////////////////////////////////////// }
function code_2html($elem) { global $_LANG; $lang = $elem['attrib']['code']; if (!$lang) { $lang = 'php'; } $str = '<div class="bb_tag_code">'; $str .= '<strong>' . $_LANG['CODE'] . ' ' . mb_strtoupper($this->cleanAttrValue($lang)) . ':</strong><br/>'; cmsCore::includeFile('includes/geshi/geshi.php'); foreach ($elem['val'] as $item) { if ('item' == $item['type']) { continue; } $item['str'] = str_replace('’', "'", $item['str']); $item['str'] = str_replace('’', "'", $item['str']); } $geshi = new GeSHi($item['str'], $lang); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $str .= $geshi->parse_code(); $str .= '</div>'; return $str; }
/** * Возвращает объект класса генерации карты компонента * @param string $component Идентификатор компонента * @return boolean|object */ public function getSitemapClass($component) { if (!cmsCore::includeFile('components/'. $component .'/sitemap.php')) { return false; } $class = $component .'_sitemap'; if (!class_exists($class)) { return false; } cmsCore::loadLanguage('components/'. $component); $this->objects[$component] = new $class(); $cfg = $this->config[$component]; $cfg['component'] = $component; $this->objects[$component]->config = $cfg; return $this->objects[$component]; }
function mod_uc($module_id, $cfg) { $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('catalog'); if (!in_array(@$cfg['sort'], array('rating', 'hits', 'pubdate'))) { $cfg['sort'] = 'pubdate'; } global $_LANG; if (@$cfg['cat_id'] > 0) { if (!@$cfg['subs']) { //select from category $catsql = ' AND i.category_id = ' . $cfg['cat_id']; } else { //select from category and subcategories $rootcat = $inDB->get_fields('cms_uc_cats', "id='{$cfg['cat_id']}'", 'NSLeft, NSRight'); if (!$rootcat) { return false; } $catsql = "AND (c.NSLeft >= {$rootcat['NSLeft']} AND c.NSRight <= {$rootcat['NSRight']})"; } } else { $catsql = ''; } $sql = "SELECT i.* , IFNULL(AVG( r.points ), 0) AS rating, c.view_type as viewtype\n FROM cms_uc_items i\n LEFT JOIN cms_uc_cats c ON c.id = i.category_id\n LEFT JOIN cms_uc_ratings r ON r.item_id = i.id\n WHERE i.published = 1 {$catsql}\n GROUP BY i.id\n ORDER BY {$cfg['sort']} DESC\n LIMIT " . $cfg['num']; $result = $inDB->query($sql); $items = array(); if (!$inDB->num_rows($result)) { return false; } cmsCore::includeFile('components/catalog/includes/shopcore.php'); if ($cfg['showtype'] == 'thumb') { while ($item = $inDB->fetch_assoc($result)) { if (mb_strlen($item['imageurl']) < 4) { $item['imageurl'] = 'nopic.jpg'; } elseif (!file_exists(PATH . '/images/catalog/small/' . $item['imageurl'])) { $item['imageurl'] = 'nopic.jpg'; } if ($item['viewtype'] == 'shop') { $item['price'] = number_format(shopDiscountPrice($item['id'], $item['category_id'], $item['price']), 2, '.', ' '); } $items[] = $item; } } if ($cfg['showtype'] == 'list') { while ($item = $inDB->fetch_assoc($result)) { $item['fieldsdata'] = cmsCore::yamlToArray($item['fieldsdata']); $item['title'] = mb_substr($item['title'], 0, 40); for ($f = 0; $f < $cfg['showf']; $f++) { $item['fdata'][] = cms_model_catalog::getUCSearchLink($item['category_id'], $item['fieldsdata'][$f]); } if ($cfg['sort'] == 'rating') { $item['key'] = '<a href="/catalog/item' . $item['id'] . '.html" title="' . $_LANG['UC_MODULE_RATING'] . ': ' . round($item['rating'], 2) . '">' . cms_model_catalog::buildRating(round($item['rating'], 2)) . '</a>'; } elseif ($cfg['sort'] == 'hits') { $item['key'] = $_LANG['UC_MODULE_VIEWS'] . ': <a href="/catalog/item' . $item['id'] . '.html" title="' . $_LANG['UC_MODULE_VIEWS'] . '">' . $item['hits'] . '</a>'; } else { $item['key'] = cmsCore::dateFormat($item['pubdate']); } if ($item['viewtype'] == 'shop') { $item['price'] = number_format(shopDiscountPrice($item['id'], $item['category_id'], $item['price']), 2, '.', ' '); } $items[] = $item; } } cmsPage::initTemplate('modules', 'mod_uc')->assign('items', $items)->assign('cfg', $cfg)->display('mod_uc.tpl'); return true; }
cmsCore::halt(); } if (!$inUser->is_admin) { cmsCore::jsonOutput(array('error' => true, 'html' => ' Редактирование доступно только админам!')); cmsCore::halt(); } if (!$component) { cmsCore::jsonOutput(array('error' => true, 'html' => ' Не получен идентификатор компонента!')); cmsCore::halt(); } if (!$item_id) { cmsCore::jsonOutput(array('error' => true, 'html' => ' Не получен идентификатор записи!')); cmsCore::halt(); } //библиотека тегов cmsCore::includeFile('/core/lib_tags.php'); //шаблон формы редактирования $template = 'p_front_editor_' . $component . '.tpl'; //получаем запись для редактирования $item = $inDB->get_fields('cms_' . $component, "id = {$item_id}", '*'); // теги статьи if ($item) { $target = $component == 'blog_posts' ? 'blogpost' : $component; $item['tags'] = cmsTagLine("{$target}", $item_id, false); } if (!$item) { cmsCore::jsonOutput(array('error' => true, 'html' => ' Не получена запись для редактирования!')); cmsCore::halt(); } //изображение статьи для формы редактирования статей if ($component == 'content') {
cmsCore::addSessionMessage($_LANG['AD_NO_LOAD_EXCEL_FILE'], 'error'); cmsCore::redirectBack(); } $xls_file = PATH .'/upload/'. md5(microtime().uniqid()). '.xls'; if (!cmsCore::moveUploadedFile($_FILES['xlsfile']['tmp_name'], $xls_file, $_FILES['xlsfile']['error'])) { cmsCore::addSessionMessage($_LANG['AD_NO_LOAD_EXCEL_FILE'], 'error'); cmsCore::redirectBack(); } $file = $model->uploadPhoto(); if ($file) { $item['imageurl'] = $file['filename']; } cmsCore::includeFile('includes/excel/excel_reader2.php'); $data = new Spreadsheet_Excel_Reader($xls_file, true, $charset); for ($r=0; $r<$rows; $r++) { $fields = array(); $title = ''; $item['price'] = ''; foreach ($cells as $cell_id=>$pos) { if (isset($pos['ignore'])) { $celldata = $pos['other']; } else { $celldata = ($charset == 'cp1251') ? iconv('cp1251', 'UTF-8', $data->val($r+$pos['row'],$pos['col'],$sheet-1)) : $data->val($r+$pos['row'],$pos['col'],$sheet-1); }
function catalog(){ $inCore = cmsCore::getInstance(); $inPage = cmsPage::getInstance(); $inDB = cmsDatabase::getInstance(); $inUser = cmsUser::getInstance(); global $_LANG; $model = new cms_model_catalog(); define('IS_BILLING', $inCore->isComponentInstalled('billing')); if (IS_BILLING) { cmsCore::loadClass('billing'); } $pagetitle = $inCore->getComponentTitle(); $inPage->addPathway($pagetitle, '/catalog'); $inPage->setTitle($pagetitle); $inPage->setDescription($model->config['meta_desc'] ? $model->config['meta_desc'] : $pagetitle); $inPage->setKeywords($model->config['meta_keys'] ? $model->config['meta_keys'] : $pagetitle); $cfg = $inCore->loadComponentConfig('catalog'); if (cmsCore::inRequest('cat_id')){ $id = cmsCore::request('cat_id', 'int', 0); } else { $id = cmsCore::request('id', 'int', 0); } $do = $inCore->do; cmsCore::includeFile('components/catalog/includes/shopcore.php'); //////////////////////////// RATING SUBMISSION /////////////////////////////////////////////////////////////////// if (cmsCore::inRequest('rating')){ $points = cmsCore::request('points', 'int', 0); $item_id = cmsCore::request('item_id', 'int', 0); $ip = $inUser->ip; if (!alreadyVoted($item_id)){ $inDB->query("INSERT INTO cms_uc_ratings (item_id, points, ip) VALUES ($item_id, $points, '$ip')") ; $inDB->query("DELETE FROM cms_uc_ratings WHERE item_id = $item_id AND ip = '0.0.0.0'") ; } } //////////////////////////// SEARCH BY TAG /////////////////////////////////////////////////////////////////////// if ($do == 'tag') { $tag = $inCore->strClear(urldecode($inCore->request('tag', 'html', ''))); $sql = "SELECT tag FROM cms_tags WHERE tag = '$tag' AND target='catalog' LIMIT 1"; $result = $inDB->query($sql) ; if ($inDB->num_rows($result)==1){ $item = $inDB->fetch_assoc($result); $query = $inCore->strClear($item['tag']); $findsql = "SELECT * FROM cms_uc_items WHERE category_id = '$id' AND published = 1 AND tags LIKE '%$query%'"; $do = 'cat'; } else { echo $_LANG['NO_MATCHING_FOUND']; } } //////////////////////////// ADVANCED SEARCH //////////////////////////////////////////////////////////////////// if ($do == 'search') { if (cmsCore::inRequest('gosearch')){ $fdata = cmsCore::request('fdata', 'array', array()); $query = cmsCore::strClear(implode('%', $fdata)); $title = cmsCore::request('title', 'str', ''); $tags = cmsCore::request('tags', 'str', ''); if ($query || $title || $tags){ $findsql = "SELECT i.* , IFNULL(AVG(r.points),0) AS rating FROM cms_uc_items i LEFT JOIN cms_uc_ratings r ON r.item_id = i.id WHERE i.published = 1 AND i.category_id = '$id' "; if($query){ $findsql .= " AND i.fieldsdata LIKE '%{$query}%' "; } if($title){ $findsql .= " AND i.title LIKE '%$title%' "; } if($tags){ $findsql .= "AND (i.tags LIKE '%".$tags."%')"; } $findsql .= " GROUP BY i.id"; $advsearch = 1; } $do = 'cat'; } else { //show search form $sql = "SELECT * FROM cms_uc_cats WHERE id = '$id'"; $result = $inDB->query($sql) ; if ($inDB->num_rows($result)==1){ $cat = $inDB->fetch_assoc($result); $fstruct = cmsCore::yamlToArray($cat['fieldsstruct']); //heading $inPage->addPathway($cat['title'], '/catalog/'.$cat['id']); $inPage->addPathway($_LANG['SEARCH'], '/catalog/'.$cat['id'].'/search.html'); $inPage->setTitle($_LANG['SEARCH_IN_CAT']); $inPage->addHeadJS('components/catalog/js/search.js'); $fstruct_ready = array(); foreach($fstruct as $key=>$value) { if (mb_strstr($value, '/~h~/')) { $ftype = 'html'; $value=str_replace('/~h~/', '', $value); } elseif (mb_strstr($value, '/~l~/')) { $ftype = 'link'; $value=str_replace('/~l~/', '', $value); } else { $ftype='text'; } if (mb_strstr($value, '/~m~/')) { $value = str_replace('/~m~/', '', $value); } $fstruct_ready[stripslashes($key)] = stripslashes($value); } //searchform cmsPage::initTemplate('components', 'com_catalog_search')-> assign('id', $id)-> assign('cat', $cat)-> assign('fstruct', $fstruct_ready)-> display('com_catalog_search.tpl'); } else { cmsCore::error404(); } }//search form } //////////////////////////// SEARCH BY FIRST LETTER OF TITLE /////////////////////////////////////////////////////// if ($do == 'findfirst') { $id = cmsCore::request('cat_id', 'int'); $query = mb_substr(cmsCore::strClear(urldecode(cmsCore::request('text', 'html', ''))), 0, 1); $findsql = "SELECT i.* , IFNULL(AVG( r.points ),0) AS rating FROM cms_uc_items i LEFT JOIN cms_uc_ratings r ON r.item_id = i.id WHERE i.published = 1 AND i.category_id = $id AND UPPER(LTRIM(i.title)) LIKE UPPER('$query%') GROUP BY i.id"; $do = 'cat'; $advsearch = 0; $pagemode = 'findfirst'; } //////////////////////////// SEARCH BY FIELD //////////////////////////////////////////////////////////////////// if ($do == 'find') { $id = cmsCore::request('cat_id', 'int'); $query = cmsCore::strClear(urldecode(cmsCore::request('text', 'html', ''))); $findsql = "SELECT i.* , IFNULL(AVG(r.points),0) AS rating FROM cms_uc_items i LEFT JOIN cms_uc_ratings r ON r.item_id = i.id WHERE i.published = 1 AND i.category_id = $id AND i.fieldsdata LIKE '%$query%' GROUP BY i.id"; $do = 'cat'; $advsearch = 0; $query = stripslashes($query); $pagemode = 'find'; } //////////////////////////// LIST OF CATEGORIES //////////////////////////////////////////////////////////////////// if ($do == 'view'){ //List of all categories $cats_html = subCatsList(); $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="'.$_LANG['CATALOG'].'" href="'.HOST.'/rss/catalog/all/feed.rss">'); cmsPage::initTemplate('components', 'com_catalog_index')-> assign('cfg', $cfg)-> assign('title', $pagetitle)-> assign('cats_html', $cats_html)-> display('com_catalog_index.tpl'); } //////////////////////////// VIEW CATEGORY /////////////////////////////////////////////////////////////////////// if ($do == 'cat'){ //get category data $sql = "SELECT * FROM cms_uc_cats WHERE id = $id"; $catres = $inDB->query($sql); if (!$inDB->num_rows($catres)){ cmsCore::error404(); } $cat = $inDB->fetch_assoc($catres); $fstruct = cmsCore::yamlToArray($cat['fieldsstruct']); $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="'.$_LANG['CATALOG'].'" href="'.HOST.'/rss/catalog/'.$cat['id'].'/feed.rss">'); //heading //PATHWAY ENTRY $path_list = $model->getCategoryPath($cat['NSLeft'], $cat['NSRight']); if ($path_list){ foreach($path_list as $pcat){ $inPage->addPathway($pcat['title'], '/catalog/'.$pcat['id']); } } $inPage->setTitle($cat['pagetitle'] ? $cat['pagetitle'] : $cat['title']); //subcategories $subcats = subCatsList($cat['id'], $cat['NSLeft'], $cat['NSRight']); //alphabetic list if ($cat['showabc']){ $alphabet = getAlphaList($cat['id']); } else { $alphabet = ''; } //Tool links $shopcartlink = shopCartLink(); //get items SQL if (!isset($findsql)){ $sql = "SELECT i.* , IFNULL(AVG( r.points ), 0) AS rating, i.price as price FROM cms_uc_items i LEFT JOIN cms_uc_ratings r ON r.item_id = i.id WHERE i.published = 1 AND i.category_id = $id GROUP BY i.id"; } else { $sql = $findsql; if (!$advsearch){ $inPage->addPathway(icms_ucfirst($query)); } else { $inPage->addPathway($_LANG['SEARCH_RESULT']); } } // сортировка if(cmsCore::inRequest('orderby')){ $orderby = cmsCore::request('orderby', array('hits','rating','pubdate','title','price'), $cat['orderby']); cmsUser::sessionPut('uc_orderby', $orderby); } elseif(cmsUser::sessionGet('uc_orderby')){ $orderby = cmsUser::sessionGet('uc_orderby'); } else { $orderby = $cat['orderby']; } if(cmsCore::inRequest('orderto')){ $orderto = cmsCore::request('orderto', array('asc','desc'), $cat['orderto']); cmsUser::sessionPut('uc_orderto', $orderto); } elseif(cmsUser::sessionGet('uc_orderto')){ $orderto = cmsUser::sessionGet('uc_orderto'); } else { $orderto = $cat['orderto']; } $sql .= " ORDER BY ".$orderby." ".$orderto; //get total items count $result = $inDB->query($sql); $itemscount = $inDB->num_rows($result); //can user add items here? $is_cat_access = $model->checkCategoryAccess($cat['id'], $cat['is_public'], $inUser->group_id); $is_can_add = $is_cat_access || $inUser->is_admin; $tpl = cmsPage::initTemplate('components', 'com_catalog_view')-> assign('id', $id)-> assign('cat', $cat)-> assign('subcats', $subcats)-> assign('alphabet', $alphabet)-> assign('shopcartlink', $shopcartlink)-> assign('itemscount', $itemscount)-> assign('is_can_add', $is_can_add)-> assign('orderform', orderForm($orderby, $orderto, ($cat['view_type']=='shop'))); //pagination if (!@$advsearch) { $perpage = $cat['perpage']; } else { $perpage='100'; } $page = $inCore->request('page', 'int', 1); //request items using pagination $sql .= " LIMIT ".(($page-1)*$perpage).", $perpage"; $result = $inDB->query($sql) ; //search details, if needed $search_details = ''; if (isset($findsql)){ if ($advsearch){ $search_details = '<div class="uc_queryform"><strong>'.$_LANG['SEARCH_RESULT'].' - </strong> '.$_LANG['FOUNDED'].': '.$itemscount.' | <a href="/catalog/'.$cat['id'].'">'.$_LANG['CANCEL_SEARCH'].'</a></div>'; } else { $search_details = '<div class="uc_queryform"><strong>'.$_LANG['SEARCH_BY_TAG'].'</strong> "'.htmlspecialchars(icms_ucfirst(stripslashes($query))).'" ('.$_LANG['MATCHES'].': '.$itemscount.') <a href="/catalog/'.$cat['id'].'">'.$_LANG['CANCEL_SEARCH'].'</a></div>'; } } $items = array(); while($item = $inDB->fetch_assoc($result)){ $item['ratingdata'] = ratingData($item['id']); $item['fdata'] = cmsCore::yamlToArray($item['fieldsdata']); $item['price'] = number_format(shopDiscountPrice($item['id'], $item['category_id'], $item['price']), 2, '.', ' '); $item['rating'] = cms_model_catalog::buildRating($item['ratingdata']['rating']); $item['is_new'] = isNew($item['id'], $cat['shownew'], $cat['newint']); $item['tagline'] = tagLine($item['tags'], $cat['id']); $item['can_edit'] = ($cat['can_edit'] && $is_cat_access && ($inUser->id == $item['user_id'])) || $inUser->is_admin; $item['fields'] = array(); if (sizeof($fstruct)>0){ $fields_show = 0; foreach($fstruct as $key=>$value){ if ($fields_show < $cat['fields_show']){ if ($item['fdata'][$key]){ if (mb_strstr($value, '/~h~/')){ $value = str_replace('/~h~/', '', $value); $is_html = true; } else { $is_html = false; } if (mb_strstr($value, '/~m~/')){ $value = str_replace('/~m~/', '', $value); $makelink = true; } else {$makelink = false; } if (!$is_html){ if (mb_strstr($value, '/~l~/')){ if (@$item['fdata'][$key]!=''){ $field = '<a class="uc_fieldlink" href="/load/url=-'.base64_encode($item['fdata'][$key]).'" target="_blank">'.str_replace('/~l~/', '', $value).'</a> ('.$inCore->fileDownloadCount($item['fdata'][$key]).')'; } } else { if ($makelink){ $field = $model->getUCSearchLink($cat['id'], $item['fdata'][$key]); } else { $field = $item['fdata'][$key]; } } } else { $field = $item['fdata'][$key]; } if (isset($query)) { if (mb_stristr($field, $query)) { $field .= '<span class="uc_findsame"> ← <i>'.$_LANG['MATCHE'].'</i></span>';} } $fields_show++; $item['fields'][stripslashes($value)] = stripslashes($field); } } else { break; } } } $items[] = $item; } if (!@$pagemode){ $pagebar = cmsPage::getPagebar($itemscount, $page, $perpage, '/catalog/'.$id.'-%page%'); } else { if ($pagemode=='findfirst'){ $pagebar = cmsPage::getPagebar($itemscount, $page, $perpage, '/catalog/'.$id.'-%page%/find-first/'.urlencode(urlencode($query))); } if ($pagemode=='find'){ $pagebar = cmsPage::getPagebar($itemscount, $page, $perpage, '/catalog/'.$id.'-%page%/find/'.urlencode(urlencode($query))); } } // SEO if($cat['NSLevel'] > 0){ // meta description if($cat['meta_desc']){ $meta_desc = $cat['meta_desc']; } elseif(mb_strlen(strip_tags($cat['description']))>=250){ $meta_desc = crop($cat['description']); } else { $meta_desc = $cat['title']; } $inPage->setDescription($meta_desc); // meta keywords if($cat['meta_keys']){ $meta_keys = $cat['meta_keys']; } elseif($items){ foreach($items as $c){ $k[] = $c['title']; } $meta_keys = implode(', ', $k); } else { $meta_keys = $cat['title']; } $inPage->setKeywords($meta_keys); } $tpl->assign('cfg', $cfg)-> assign('page', $page)-> assign('search_details', $search_details)-> assign('fstruct', $fstruct)-> assign('items', $items)-> assign('pagebar', $pagebar)-> display('com_catalog_view.tpl'); return true; } //////////////////////////// VIEW ITEM DETAILS /////////////////////////////////////////////////////////////////////// if ($do == 'item'){ $id = $inCore->request('id', 'int'); $sql = "SELECT * FROM cms_uc_items WHERE id = '$id'"; $itemres = $inDB->query($sql) ; if (!$inDB->num_rows($itemres)){ cmsCore::error404(); } $item = $inDB->fetch_assoc($itemres); if ((!$item['published'] || $item['on_moderate']) && !$inUser->is_admin){ cmsCore::error404(); } $fdata = cmsCore::yamlToArray($item['fieldsdata']); if ($item['meta_keys']) { $inPage->setKeywords($item['meta_keys']); } if ($item['meta_desc']) { $inPage->setDescription($item['meta_desc']); } $ratingdata = ratingData($id); $sql = "SELECT * FROM cms_uc_cats WHERE id = '{$item['category_id']}'"; $catres = $inDB->query($sql) ; $cat = $inDB->fetch_assoc($catres); $fstruct = cmsCore::yamlToArray($cat['fieldsstruct']); $is_cat_access = $inUser->id ? $model->checkCategoryAccess($cat['id'], $cat['is_public'], $inUser->group_id) : false; $item['can_edit'] = ($cat['can_edit'] && $is_cat_access && ($inUser->id == $item['user_id'])) || $inUser->is_admin; //PATHWAY ENTRY $path_list = $model->getCategoryPath($cat['NSLeft'], $cat['NSRight']); if ($path_list){ foreach($path_list as $pcat){ $inPage->addPathway($pcat['title'], '/catalog/'.$pcat['id']); } } $inPage->addPathway($item['title'], '/catalog/item'.$item['id'].'.html'); $inPage->setTitle($item['title']); if ($cat['view_type']=='shop'){ $shopCartLink=shopCartLink(); } //update hits $inDB->query("UPDATE cms_uc_items SET hits = hits + 1 WHERE id = '$id'") ; //print item details $fields = array(); if (sizeof($fstruct)>0){ foreach($fstruct as $key=>$value){ if (@$fdata[$key]){ if (mb_strstr($value, '/~h~/')){ $value = str_replace('/~h~/', '', $value); $htmlfield = true; } if (mb_strstr($value, '/~m~/')){ $value = str_replace('/~m~/', '', $value); $makelink = true; } else {$makelink = false; } $field = (string)str_replace('<p>', '<p style="margin-top:0px; margin-bottom:5px">', $fdata[$key]); if (mb_strstr($value, '/~l~/')){ $field = '<a class="uc_detaillink" href="/load/url=-'.base64_encode($field).'" target="_blank">'.str_replace('/~l~/', '', $value).'</a> ('.$inCore->fileDownloadCount($field).')'; } else { if (isset($htmlfield)) { if ($makelink) { $field = $model->getUCSearchLink($cat['id'], $field); } else { //PROCESS FILTERS, if neccessary if ($cat['filters']){ $filters = $inCore->getFilters(); if ($filters){ foreach($filters as $id=>$_data){ require_once PATH.'/filters/'.$_data['link'].'/filter.php'; $_data['link']($field); } } } $field = stripslashes($field); } } else { if ($makelink) { $field = $model->getUCSearchLink($cat['id'], $field); } } } $fields[stripslashes($value)] = stripslashes($field); } } } if ($cat['view_type']=='shop'){ $item['price'] = number_format(shopDiscountPrice($item['id'], $item['category_id'], $item['price']), 2, '.', ' '); } $user = $inDB->get_fields('cms_users', "id='{$item['user_id']}'", 'login, nickname'); $getProfileLink = cmsUser::getProfileLink($user['login'], $user['nickname']); if ($cat['is_ratings']){ $ratingForm = ratingForm($ratingdata, $item['id']); } cmsPage::initTemplate('components', 'com_catalog_item')-> assign('shopCartLink', (isset($shopCartLink) ? $shopCartLink : ''))-> assign('getProfileLink', $getProfileLink)-> assign('tagline', tagLine($item['tags'], $cat['id']))-> assign('item', $item)-> assign('cat', $cat)-> assign('fields', $fields)-> assign('ratingForm', (isset($ratingForm) ? $ratingForm : ''))-> display('com_catalog_item.tpl'); if ($item['is_comments'] && $inCore->isComponentEnable('comments')) { cmsCore::includeComments(); comments('catalog', $item['id'], array(), ($inUser->id == $item['user_id'])); } return true; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////// S H O P ///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////// ADD TO CART ///////////////////////////////////////////////////////////////////////////// if ($do == 'addcart'){ shopAddToCart($id, 1); $inCore->redirect('/catalog/viewcart.html'); } ///////////////////////// VIEW CART ///////////////////////////////////////////////////////////////////////////// if ($do == 'viewcart'){ shopCart(); } ///////////////////////// DELETE FROM CART ///////////////////////////////////////////////////////////////////////////// if ($do == 'cartremove'){ shopRemoveFromCart($id); $inCore->redirectBack(); } ///////////////////////// CLEAR CART ///////////////////////////////////////////////////////////////////////////// if ($do == 'clearcart'){ shopClearCart(); $inCore->redirectBack(); } ///////////////////////// CLEAR CART ///////////////////////////////////////////////////////////////////////////// if ($do == 'savecart'){ $itemcounts = $inCore->request('kolvo', 'array_int'); if (is_array($itemcounts)){ shopUpdateCart($itemcounts); } $inCore->redirectBack(); } ///////////////////////// ORDER ////////////////////////////////////////////////////////////////////////////////// if ($do == 'order'){ shopOrder($cfg); } ///////////////////////// ORDER ////////////////////////////////////////////////////////////////////////////////// if ($do == 'finish'){ shopFinishOrder($cfg); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($do == 'add_item' || $do == 'edit_item'){ $cat_id = cmsCore::request('cat_id', 'int'); $item_id = cmsCore::request('item_id', 'int', 0); if ($do == 'add_item'){ $cat = $inDB->get_fields('cms_uc_cats', "id='$cat_id'", '*'); if (!$cat){ cmsCore::error404(); } $inPage->setTitle($_LANG['ADD_ITEM']); if (!($model->checkCategoryAccess($cat['id'], $cat['is_public'], $inUser->group_id) || $inUser->is_admin)){ cmsCore::error404(); } $item = array(); $fdata = array(); if ($cat['cost']=='') { $cat['cost'] = false; } if (IS_BILLING){ cmsBilling::checkBalance('catalog', 'add_catalog_item', false, $cat['cost']); } $item['is_comments'] = 1; } if ($do == 'edit_item'){ $inPage->setTitle($_LANG['EDIT_ITEM']); $item = $inDB->get_fields('cms_uc_items', "id='$item_id'", '*'); if (!$item) { cmsCore::error404(); } $cat = $inDB->get_fields('cms_uc_cats', "id='{$item['category_id']}'", '*'); if (!$cat){ cmsCore::error404(); } $is_cat_access = $model->checkCategoryAccess($cat['id'], $cat['is_public'], $inUser->group_id); $is_can_edit = ($cat['can_edit'] && $is_cat_access && ($inUser->id == $item['user_id'])) || $inUser->is_admin; if (!$is_can_edit) { cmsCore::error404(); } $fdata = cmsCore::yamlToArray($item['fieldsdata']); } $path_list = $model->getCategoryPath($cat['NSLeft'], $cat['NSRight']); if ($path_list){ foreach($path_list as $pcat){ $inPage->addPathway($pcat['title'], '/catalog/'.$pcat['id']); } } if($do == 'add_item'){ $inPage->addPathway($_LANG['ADD_ITEM']); } else { $inPage->addPathway($_LANG['EDIT_ITEM']); } $cats = $inCore->getListItems('cms_uc_cats', $cat['id'], 'id', 'ASC', 'parent_id > 0 AND published = 1'); $fields = array(); $fstruct = cmsCore::yamlToArray($cat['fieldsstruct']); foreach($fstruct as $f_id=>$value){ if (mb_strstr($value, '/~h~/')) { $ftype = 'html'; $value=str_replace('/~h~/', '', $value); } elseif (mb_strstr($value, '/~l~/')) { $ftype = 'link'; $value=str_replace('/~l~/', '', $value); } else { $ftype='text'; } if (mb_strstr($value, '/~m~/')) { $makelink = true; $value=str_replace('/~m~/', '', $value); } else { $makelink = false; } $next['ftype'] = stripslashes($ftype); $next['title'] = stripslashes($value); $next['makelink'] = stripslashes($makelink); if (!empty($fdata[$f_id])){ $next['value'] = stripslashes($fdata[$f_id]); } else { $next['value'] = ''; } $fields[$f_id] = $next; } cmsPage::initTemplate('components', 'com_catalog_add')-> assign('do', $do)-> assign('item', $item)-> assign('fields', $fields)-> assign('cat', $cat)-> assign('cats', $cats)-> assign('cfg', $cfg)-> assign('is_admin', $inUser->is_admin)-> assign('cat_id', $cat['id'])-> display('com_catalog_add.tpl'); return; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($do == 'submit_item'){ $opt = cmsCore::request('opt', 'str', 'add'); $new_cat_id = cmsCore::request('new_cat_id', 'int', 0); $cat_id = $new_cat_id ? $new_cat_id : cmsCore::request('cat_id', 'int', 0); $item_id = cmsCore::request('item_id', 'int', 0); $cat = $inDB->get_fields('cms_uc_cats', "id='$cat_id'", '*'); if(!$cat){ cmsCore::error404(); } if ($opt == 'add'){ if(!$inUser->is_admin && !$model->checkCategoryAccess($cat['id'], $cat['is_public'], $inUser->group_id)){ cmsCore::error404(); } } else { $item = $inDB->get_fields('cms_uc_items', "id='{$item_id}'", '*'); if(!$item){ cmsCore::error404(); } if(!$inUser->is_admin && !($cat['can_edit'] && ($inUser->id == $item['user_id']) && $model->checkCategoryAccess($cat['id'], $cat['is_public'], $inUser->group_id))){ cmsCore::error404(); } } $item['title'] = cmsCore::request('title', 'str'); if (!$item['title']) { cmsCore::addSessionMessage($_LANG['NEED_TITLE'], 'error'); cmsCore::redirectBack(); } $item['category_id'] = $cat_id; $item['published'] = ($cfg['premod'] && !$inUser->is_admin ? 0 : 1); $item['on_moderate'] = ($cfg['premod'] && !$inUser->is_admin ? 1 : 0); $item['fdata'] = cmsCore::request('fdata', 'array', array());; foreach($item['fdata'] as $key=>$value) { $item['fdata'][$key] = cmsCore::badTagClear($value); } $item['fieldsdata'] = $inDB->escape_string(cmsCore::arrayToYaml($item['fdata'])); $item['is_comments'] = $inUser->is_admin ? cmsCore::request('is_comments', 'int', 0) : $cfg['is_comments']; $item['tags'] = cmsCore::request('tags', 'str', ''); $item['canmany'] = 1; $item['imageurl'] = ($opt == 'add' ? '' : $item['imageurl']); $item['price'] = 0; $item['canmany'] = 1; if($inUser->is_admin){ $meta_desc = cmsCore::request('meta_desc', 'str', ''); $meta_keys = cmsCore::request('meta_keys', 'str', ''); $item['meta_desc'] = $meta_desc ? $meta_desc : $item['title']; $item['meta_keys'] = $meta_keys ? $meta_keys : $item['tags']; } else { $item['meta_desc'] = @$item['meta_desc'] ? $item['meta_desc'] : $item['title']; $item['meta_keys'] = @$item['meta_keys'] ? $item['meta_keys'] : $item['tags']; } if (cmsCore::inRequest('price')) { $price = cmsCore::request('price', 'str', ''); $price = str_replace(',', '.', $price); $item['price'] = round($price, 2); $item['canmany']= cmsCore::request('canmany', 'int', 0); } if (cmsCore::request('delete_img', 'int', 0)){ @unlink(PATH."/images/catalog/".$item['imageurl']); @unlink(PATH."/images/catalog/small/".$item['imageurl']); @unlink(PATH."/images/catalog/medium/".$item['imageurl']); $item['imageurl'] = ''; } $file = $model->uploadPhoto($item['imageurl']); if($file){ $item['imageurl'] = $file['filename']; } if ($opt=='add'){ $item['pubdate'] = date('Y-m-d H:i'); $item['user_id'] = $inUser->id; $item['id'] = $model->addItem($item); if (IS_BILLING){ if ($cat['cost']=='') { $cat['cost'] = false; } cmsBilling::process('catalog', 'add_catalog_item', $cat['cost']); } if (!$cfg['premod'] || $inUser->is_admin) { cmsCore::callEvent('ADD_CATALOG_DONE', $item); //регистрируем событие cmsActions::log('add_catalog', array( 'object' => $item['title'], 'object_url' => '/catalog/item'.$item['id'].'.html', 'object_id' => $item['id'], 'target' => $cat['title'], 'target_url' => '/catalog/'.$cat['id'], 'target_id' => $cat['id'], 'description' => '' )); } } if ($opt=='edit'){ $model->updateItem($item['id'], $item); cmsActions::updateLog('add_catalog', array('object' => $item['title']), $item['id']); } if ($inUser->id != 1 && $cfg['premod'] && $cfg['premod_msg']){ $link = '<a href="/catalog/item'.$item['id'].'.html">'.$item['title'].'</a>'; $user = '******'.cmsUser::getProfileURL($inUser->login).'">'.$inUser->nickname.'</a>'; if ($opt=='add') { $message = $_LANG['MSG_ITEM_SUBMIT']; } if ($opt=='edit') { $message = $_LANG['MSG_ITEM_EDITED']; } $message = str_replace('%user%', $user, $message); $message = str_replace('%link%', $link, $message); cmsUser::sendMessage(USER_UPDATER, 1, $message); cmsCore::addSessionMessage($_LANG['ITEM_PREMOD_NOTICE'], 'info'); cmsCore::redirect('/catalog/'.$item['category_id']); } cmsCore::redirect('/catalog/item'.$item['id'].'.html'); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($do == 'accept_item'){ $item_id = cmsCore::request('item_id', 'int'); $item = $inDB->get_fields('cms_uc_items', "id='{$item_id}'", 'title, user_id, category_id'); if (!$item || !$inUser->is_admin){ cmsCore::error404(); } $inDB->query("UPDATE cms_uc_items SET published=1, on_moderate=0 WHERE id='{$item_id}'"); $cat = $inDB->get_fields('cms_uc_cats', 'id='.$item['category_id'], 'id, title'); cmsCore::callEvent('ADD_CATALOG_DONE', $item); //регистрируем событие cmsActions::log('add_catalog', array( 'object' => $item['title'], 'user_id' => $item['user_id'], 'object_url' => '/catalog/item'.$item_id.'.html', 'object_id' => $item_id, 'target' => $cat['title'], 'target_url' => '/catalog/'.$cat['id'], 'target_id' => $cat['id'], 'description' => '' )); $item_link = '<a href="/catalog/item'.$item_id.'.html">'.$item['title'].'</a>'; $message = str_replace('%link%', $item_link, $_LANG['MSG_ITEM_ACCEPTED']); cmsUser::sendMessage(USER_UPDATER, $item['user_id'], $message); cmsCore::redirectBack(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($do == 'delete_item'){ $item_id = cmsCore::request('item_id', 'int'); $item = $inDB->get_fields('cms_uc_items', "id='{$item_id}'", '*'); if(!$item){ cmsCore::error404(); } if (!($item['user_id']==$inUser->id || $inUser->is_admin)){ cmsCore::error404(); } $model->deleteItem($item_id); $message = str_replace('%item%', $item['title'], $_LANG['MSG_ITEM_REJECTED']); cmsUser::sendMessage(USER_UPDATER, $item['user_id'], $message); cmsCore::redirect('/catalog/'.$item['category_id']); } }
if (!$config->isReady()) { $root = str_replace(str_replace(DIRECTORY_SEPARATOR, '/', realpath(ROOT)), '', str_replace(DIRECTORY_SEPARATOR, '/', PATH)); header('location:' . $root . '/install/'); die; } // Загружаем локализацию cmsCore::loadLanguage(); // устанавливаем локаль языка if (function_exists('lang_setlocale')) { lang_setlocale(); } // Устанавливаем часовую зону date_default_timezone_set($config->time_zone); // Подключаем все необходимые классы и библиотеки cmsCore::loadLib('html.helper'); cmsCore::loadLib('strings.helper'); cmsCore::loadLib('files.helper'); cmsCore::loadLib('spyc.class'); // подключаем хелпер шаблона, если он есть if (!cmsCore::includeFile('templates/' . $config->template . '/assets/helper.php')) { cmsCore::loadLib('template.helper'); } // Инициализируем ядро $core = cmsCore::getInstance(); // Подключаем базу $core->connectDB(); if (!$core->db->ready()) { cmsCore::error(ERR_DATABASE_CONNECT, $core->db->connectError()); } // Запускаем кеш cmsCache::getInstance()->start();
<?php /******************************************************************************/ // // // InstantCMS v1.10.5 // // http://www.instantcms.ru/ // // // // written by InstantCMS Team, 2007-2014 // // produced by InstantSoft, (www.instantsoft.ru) // // // // LICENSED BY GNU/GPL v2 // // // /******************************************************************************/ // загружаем библиотеку Smarty cmsCore::includeFile('/includes/smarty/libs/Smarty.class.php'); /** * Класс инициализации шаблонизатора Smarty */ class smartyTpl { private static $i_smarty; private $smarty; public function __construct($tpl_folder, $tpl_file) { global $_LANG; $tpl_folder = rtrim($tpl_folder, '/'); $tpl_folder = explode('/', $tpl_folder); unset($tpl_folder[count($tpl_folder) - 1]); $template_dir = implode('/', $tpl_folder); $this->smarty = $this->loadSmarty(); $tdirs = array('components' => $template_dir . '/components', 'modules' => $template_dir . '/modules', 'plugins' => $template_dir . '/plugins', 'special' => $template_dir . '/special', 'splash' => $template_dir . '/splash');
/** * Формирует модуль * @param array $mod * @return html */ private function renderModule($mod) { $inCore = cmsCore::getInstance(); // флаг показа модуля $callback = true; // html код модуля $html = ''; // для php модулей загружаем файл локализации if (!$mod['user']) { cmsCore::loadLanguage('modules/' . $mod['content']); } // Собственный модуль, созданный в админке if (!$mod['is_external']) { $mod['body'] = cmsCore::processFilters($mod['content']); } else { // Отдельный модуль if (cmsCore::includeFile('modules/' . $mod['content'] . '/module.php')) { // Если есть кеш, берем тело модуля из него if ($mod['cache'] && cmsCore::isCached('module', $mod['id'], $mod['cachetime'], $mod['cacheint'])) { $mod['body'] = cmsCore::getCache('module', $mod['id']); $callback = true; } else { $cfg = cmsCore::yamlToArray($mod['config']); // переходный костыль для указания шаблона if (!isset($cfg['tpl'])) { $cfg['tpl'] = $mod['content'] . '.tpl'; } $inCore->cacheModuleConfig($mod['id'], $cfg); ob_start(); $callback = call_user_func($mod['content'], $mod['id'], $cfg); $mod['body'] = ob_get_clean(); if ($mod['cache']) { cmsCore::saveCache('module', $mod['id'], $mod['body']); } } } } // выводим модуль в шаблоне если модуль вернул true if ($callback) { $module_tpl = file_exists(TEMPLATE_DIR . 'modules/' . $mod['template']) ? $mod['template'] : 'module.tpl'; $cfglink = cmsConfig::getConfig('fastcfg') && cmsUser::getInstance()->is_admin ? true : false; ob_start(); self::initTemplate('modules', $module_tpl)->assign('cfglink', $cfglink)->assign('mod', $mod)->display($module_tpl); $html = ob_get_clean(); } return $html; }
public function includeRecaptchaLib() { $lib_file = 'system/controllers/recaptcha/lib/recaptchalib.php'; cmsCore::includeFile($lib_file); }