function applet_config() { // получаем оригинальный конфиг $config = cmsConfig::getDefaultConfig(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); } cmsCore::c('page')->setTitle($_LANG['AD_SITE_SETTING']); cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config'); $do = cmsCore::request('do', 'str', 'list'); if ($do == 'save') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $newCFG = cmsCore::getArrayFromRequest(array('scheme' => array('scheme', array('http', 'https'), ''), 'sitename' => array('sitename', 'str', ''), 'title_and_sitename' => array('title_and_sitename', 'int', 0), 'title_and_page' => array('title_and_page', 'int', 0), 'hometitle' => array('hometitle', 'str', ''), 'homecom' => array('homecom', 'str', ''), 'com_without_name_in_url' => array('com_without_name_in_url', 'str', ''), 'siteoff' => array('siteoff', 'int', 0), 'only_authorized' => array('only_authorized', 'int', 0), 'debug' => array('debug', 'int', 0), 'offtext' => array('offtext', 'str', ''), 'keywords' => array('keywords', 'str', ''), 'metadesc' => array('metadesc', 'str', ''), 'seourl' => array('seourl', 'int', 0), 'lang' => array('lang', 'str', 'ru'), 'is_change_lang' => array('is_change_lang', 'int', 0), 'sitemail' => array('sitemail', 'str', ''), 'sitemail_name' => array('sitemail_name', 'str', ''), 'wmark' => array('wmark', 'str', ''), 'template' => array('template', 'str', ''), 'admin_template' => array('admin_template', 'str', ''), 'cache' => array('cache', 'int', 0), 'cache_type' => array('cache_type', array('file', 'memcached'), ''), 'memcached_host' => array('memcached_host', 'str', ''), 'memcached_port' => array('memcached_port', 'int', 0), 'combine_css_enable' => array('combine_css_enable', 'int', 0), 'combine_css' => array('combine_css', 'html', ''), 'combine_js_enable' => array('combine_js_enable', 'int', 0), 'combine_js' => array('combine_js', 'html', ''), 'splash' => array('splash', 'int', 0), 'slight' => array('slight', 'int', 0), 'show_pw' => array('show_pw', 'int', 0), 'last_item_pw' => array('last_item_pw', 'int', 0), 'index_pw' => array('index_pw', 'int', 0), 'fastcfg' => array('fastcfg', 'int', 0), 'mailer' => array('mailer', 'str', ''), 'smtpsecure' => array('smtpsecure', 'str', ''), 'smtpauth' => array('smtpauth', 'int', 0), 'smtpuser' => array('smtpuser', 'str', $config['smtpuser']), 'smtppass' => array('smtppass', 'str', $config['smtppass']), 'smtphost' => array('smtphost', 'str', ''), 'smtpport' => array('smtpport', 'int', '25'), 'timezone' => array('timezone', 'str', $config['timezone']), 'user_stats' => array('user_stats', 'int', 0), 'seo_url_count' => array('seo_url_count', 'int', 0), 'max_pagebar_links' => array('max_pagebar_links', 'int', 0), 'allow_ip' => array('allow_ip', 'str', ''), 'iframe_enable' => array('iframe_enable', 'int', 0), 'vk_enable' => array('vk_enable', 'int', 0), 'vk_id' => array('vk_id', 'str', ''), 'vk_private_key' => array('vk_private_key', 'str', ''))); $newCFG['sitename'] = stripslashes($newCFG['sitename']); $newCFG['hometitle'] = stripslashes($newCFG['hometitle']); $newCFG['offtext'] = htmlspecialchars($newCFG['offtext'], ENT_QUOTES); $newCFG['db_host'] = $config['db_host']; $newCFG['db_base'] = $config['db_base']; $newCFG['db_user'] = $config['db_user']; $newCFG['db_pass'] = $config['db_pass']; $newCFG['db_prefix'] = $config['db_prefix']; if (cmsConfig::saveToFile($newCFG)) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success'); } else { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SITE_ERROR'], 'error'); } cmsCore::clearCache(); cmsCore::redirect('index.php?view=config'); } cpCheckWritable('/includes/config/config.inc.json'); $result = cmsCore::c('db')->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '" . $config['db_base'] . "'", true); if (!cmsCore::c('db')->error()) { $s = cmsCore::c('db')->fetch_assoc($result); } else { $s['size'] = 0; } cmsCore::c('page')->initTemplate('applets', 'config')->assign('config', $config)->assign('timezone_opt', cmsCore::getTimeZonesOptions($config['timezone']))->assign('admin_templates', cmsCore::getDirsList('/templates/admin'))->assign('templates', cmsCore::getDirsList('/templates'))->assign('tpl_info', cmsCore::c('page')->getTplInfo(cmsCore::c('page')->template))->assign('components_opt', cmsCore::getListItems('cms_components', $config['com_without_name_in_url'], 'title', 'ASC', 'internal=0', 'link'))->assign('homecom_opt', cmsCore::getListItems('cms_components', $config['homecom'], 'title', 'ASC', 'internal=0', 'link'))->assign('langs', cmsCore::getDirsList('/languages'))->assign('db_size', round($s['size'], 2))->display(); }
function blogs() { $inCore = cmsCore::getInstance(); cmsCore::c('blog')->owner = 'user'; global $_LANG; define('IS_BILLING', $inCore->isComponentInstalled('billing')); if (IS_BILLING) { cmsCore::loadClass('billing'); } //Получаем параметры $id = cmsCore::request('id', 'int', 0); $post_id = cmsCore::request('post_id', 'int', 0); $bloglink = cmsCore::request('bloglink', 'str', ''); $seolink = cmsCore::request('seolink', 'str', ''); $page = cmsCore::request('page', 'int', 1); $cat_id = cmsCore::request('cat_id', 'int', 0); $ownertype = cmsCore::request('ownertype', 'str', ''); $on_moderate = cmsCore::request('on_moderate', 'int', 0); $pagetitle = $inCore->getComponentTitle(); cmsCore::c('page')->addPathway($pagetitle, '/blogs'); cmsCore::c('page')->setTitle($pagetitle); cmsCore::c('page')->setDescription(cmsCore::m('blogs')->config['meta_desc'] ? cmsCore::m('blogs')->config['meta_desc'] : $pagetitle); cmsCore::c('page')->setKeywords(cmsCore::m('blogs')->config['meta_keys'] ? cmsCore::m('blogs')->config['meta_keys'] : $pagetitle); cmsCore::c('page')->addHeadJsLang(array('CONFIG_BLOG','DEL_BLOG','YOU_REALY_DELETE_BLOG','NEW_CAT','RENAME_CAT','YOU_REALY_DELETE_CAT','YOU_REALY_DELETE_POST','NO_PUBLISHED')); ///////////////////////// МОЙ БЛОГ ///////////////////////////////////////// if ($inCore->do == 'my_blog'){ if(!cmsCore::c('user')->id){ cmsCore::error404(); } $my_blog = cmsCore::c('blog')->getBlogByUserId(cmsCore::c('user')->id); if (!$my_blog) { cmsCore::redirect('/blogs/createblog.html'); } else { cmsCore::redirect(cmsCore::m('blogs')->getBlogURL($my_blog['seolink'])); } } ///////////////////////// ПОСЛЕДНИЕ ПОСТЫ ////////////////////////////////// if ($inCore->do=='view'){ cmsCore::c('page')->addHead('<link rel="alternate" type="application/rss+xml" title="'.$_LANG['RSS_BLOGS'].'" href="'.HOST.'/rss/blogs/all/feed.rss">'); // кроме админов в списке только с доступом для всех if(!cmsCore::c('user')->is_admin){ cmsCore::c('blog')->whereOnlyPublic(); } // ограничиваем по рейтингу если надо if(cmsCore::m('blogs')->config['list_min_rating']){ cmsCore::c('blog')->ratingGreaterThan(cmsCore::m('blogs')->config['list_min_rating']); } // всего постов $total = cmsCore::c('blog')->getPostsCount(cmsCore::c('user')->is_admin); //устанавливаем сортировку cmsCore::c('db')->orderBy('p.pubdate', 'DESC'); cmsCore::c('db')->limitPage($page, cmsCore::m('blogs')->config['perpage']); // сами посты $posts = cmsCore::c('blog')->getPosts(cmsCore::c('user')->is_admin, cmsCore::m('blogs')); if(!$posts && $page > 1){ cmsCore::error404(); } cmsPage::initTemplate('components', 'com_blog_view_posts')-> assign('pagetitle', $pagetitle)-> assign('ownertype', $ownertype)-> assign('total', $total)-> assign('posts', $posts)-> assign('pagination', cmsPage::getPagebar($total, $page, cmsCore::m('blogs')->config['perpage'], '/blogs/latest-%page%.html'))-> assign('cfg', cmsCore::m('blogs')->config)-> display(); } ////////// СОЗДАНИЕ БЛОГА ////////////////////////////////////////////////// if ($inCore->do=='create'){ //Проверяем авторизацию if (!cmsCore::c('user')->id){ cmsUser::goToLogin(); } //Если у пользователя уже есть блог, то выходим if (cmsCore::c('blog')->getUserBlogId(cmsCore::c('user')->id)) { cmsCore::redirectBack(); } cmsCore::c('page')->addPathway($_LANG['PATH_CREATING_BLOG']); cmsCore::c('page')->setTitle($_LANG['CREATE_BLOG']); if (IS_BILLING){ cmsBilling::checkBalance('blogs', 'add_blog'); } //Показ формы создания блога if (!cmsCore::inRequest('goadd')){ cmsPage::initTemplate('components', 'com_blog_create')-> assign('is_restrictions', (!cmsCore::c('user')->is_admin && cmsCore::m('blogs')->config['min_karma']))-> assign('cfg', cmsCore::m('blogs')->config)-> display(); } //Сам процесс создания блога if (cmsCore::inRequest('goadd')){ $title = cmsCore::request('title', 'str'); $allow_who = cmsCore::request('allow_who', 'str', 'all'); $ownertype = cmsCore::request('ownertype', 'str', 'single'); //Проверяем название if (mb_strlen($title)<5){ cmsCore::addSessionMessage($_LANG['BLOG_ERR_TITLE'], 'error'); cmsCore::redirect('/blogs/createblog.html'); } //Проверяем хватает ли кармы, но только если это не админ if (cmsCore::m('blogs')->config['min_karma'] && !cmsCore::c('user')->is_admin){ // если персональный блог if ($ownertype=='single' && (cmsCore::c('user')->karma < cmsCore::m('blogs')->config['min_karma_private'])){ cmsCore::addSessionMessage($_LANG['BLOG_YOU_NEED'].' <a href="/users/'.cmsCore::c('user')->id.'/karma.html">'.$_LANG['BLOG_KARMS'].'</a> '.$_LANG['FOR_CREATE_PERSON_BLOG'].' — '.cmsCore::m('blogs')->config['min_karma_private'].', '.$_LANG['BLOG_HEAVING'].' — '.cmsCore::c('user')->karma, 'error'); cmsCore::redirect('/blogs/createblog.html'); } // если коллективный блог if ($ownertype=='multi' && (cmsCore::c('user')->karma < cmsCore::m('blogs')->config['min_karma_public'])){ cmsCore::addSessionMessage($_LANG['BLOG_YOU_NEED'].' <a href="/users/'.cmsCore::c('user')->id.'/karma.html">'.$_LANG['BLOG_KARMS'].'</a> '.$_LANG['FOR_CREATE_TEAM_BLOG'].' — '.cmsCore::m('blogs')->config['min_karma_public'].', '.$_LANG['BLOG_HEAVING'].' — '.cmsCore::c('user')->karma, 'error'); cmsCore::redirect('/blogs/createblog.html'); } } //Добавляем блог в базу $blog_id = cmsCore::c('blog')->addBlog(array('user_id'=>cmsCore::c('user')->id, 'title'=>$title, 'allow_who'=>$allow_who, 'ownertype'=>$ownertype, 'forall'=>1)); $blog_link = cmsCore::c('db')->get_field('cms_blogs', "id='{$blog_id}'", 'seolink'); //регистрируем событие cmsActions::log('add_blog', array( 'object' => $title, 'object_url' => cmsCore::m('blogs')->getBlogURL($blog_link), 'object_id' => $blog_id, 'target' => '', 'target_url' => '', 'target_id' => 0, 'description' => '' )); if (IS_BILLING){ cmsBilling::process('blogs', 'add_blog'); } cmsCore::addSessionMessage($_LANG['BLOG_CREATED_TEXT'], 'info'); cmsCore::redirect(cmsCore::m('blogs')->getBlogURL($blog_link)); } } ////////// НАСТРОЙКИ БЛОГА ///////////////////////////////////////////////// if ($inCore->do=='config'){ if(!cmsCore::c('user')->id) { cmsCore::error404(); } if(!cmsCore::isAjax()) { cmsCore::error404(); } // получаем блог $blog = cmsCore::c('blog')->getBlog($id); if (!$blog) { cmsCore::error404(); } //Проверяем является пользователь хозяином блога или админом if ($blog['user_id'] != cmsCore::c('user')->id && !cmsCore::c('user')->is_admin ) { cmsCore::halt(); } //Если нет запроса на сохранение, показываем форму настроек блога if (!cmsCore::inRequest('goadd')){ //Получаем список авторов блога $authors = cmsCore::c('blog')->getBlogAuthors($blog['id']); cmsPage::initTemplate('components', 'com_blog_config')-> assign('blog', $blog)-> assign('form_action', '/blogs/'.$blog['id'].'/editblog.html')-> assign('authors_list', cmsUser::getAuthorsList($authors))-> assign('users_list', cmsUser::getUsersList(false, $authors))-> assign('is_restrictions', (!cmsCore::c('user')->is_admin && cmsCore::m('blogs')->config['min_karma']))-> assign('cfg', cmsCore::m('blogs')->config)-> assign('is_admin', cmsCore::c('user')->is_admin)-> display(); cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean())); } //Если пришел запрос на сохранение if (cmsCore::inRequest('goadd')){ //Получаем настройки $title = cmsCore::request('title', 'str'); $allow_who = cmsCore::request('allow_who', 'str', 'all'); $ownertype = cmsCore::request('ownertype', 'str', 'single'); $premod = cmsCore::request('premod', 'int', 0); $forall = cmsCore::request('forall', 'int', 1); $showcats = cmsCore::request('showcats', 'int', 1); $authors = cmsCore::request('authorslist', 'array_int', array()); if (cmsCore::m('blogs')->config['seo_user_access'] || cmsCore::c('user')->is_admin) { $page_title = cmsCore::request('pagetitle', 'str', ''); $meta_keys = cmsCore::request('meta_keys', 'str', ''); $meta_desc = cmsCore::request('meta_desc', 'str', ''); } else { $page_title = $meta_keys = $meta_desc = ''; } //Проверяем настройки if (mb_strlen($title)<5) { $title = $blog['title']; } //Проверяем ограничения по карме (для смены типа блога) if (cmsCore::m('blogs')->config['min_karma'] && !cmsCore::c('user')->is_admin){ // если персональный блог if ($ownertype=='single' && (cmsCore::c('user')->karma < cmsCore::m('blogs')->config['min_karma_private'])){ cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['BLOG_YOU_NEED'].' <a href="/users/'.cmsCore::c('user')->id.'/karma.html">'.$_LANG['BLOG_KARMS'].'</a> '.$_LANG['FOR_CREATE_PERSON_BLOG'].' — '.cmsCore::m('blogs')->config['min_karma_private'].', '.$_LANG['BLOG_HEAVING'].' — '.cmsCore::c('user')->karma)); } // если коллективный блог if ($ownertype=='multi' && (cmsCore::c('user')->karma < cmsCore::m('blogs')->config['min_karma_public'])){ cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['BLOG_YOU_NEED'].' <a href="/users/'.cmsCore::c('user')->id.'/karma.html">'.$_LANG['BLOG_KARMS'].'</a> '.$_LANG['FOR_CREATE_TEAM_BLOG'].' — '.cmsCore::m('blogs')->config['min_karma_public'].', '.$_LANG['BLOG_HEAVING'].' — '.cmsCore::c('user')->karma)); } } if(!cmsUser::checkCsrfToken()) { cmsCore::halt(); } //сохраняем авторов cmsCore::c('blog')->updateBlogAuthors($blog['id'], $authors); //сохраняем настройки блога $blog['seolink_new'] = cmsCore::c('blog')->updateBlog($blog['id'], array( 'title' => $title, 'pagetitle' => $page_title, 'meta_keys' => $meta_keys, 'meta_desc' => $meta_desc, 'allow_who' => $allow_who, 'showcats' => $showcats, 'ownertype' => $ownertype, 'premod' => $premod, 'forall' => $forall ), cmsCore::m('blogs')->config['update_seo_link_blog']); $blog['seolink'] = $blog['seolink_new'] ? $blog['seolink_new'] : $blog['seolink']; if(stripslashes($title) != $blog['title']){ // обновляем записи постов cmsActions::updateLog('add_post', array('target' => $title, 'target_url' => cmsCore::m('blogs')->getBlogURL($blog['seolink'])), 0, $blog['id']); // обновляем запись добавления блога cmsActions::updateLog('add_blog', array('object' => $title, 'object_url' => cmsCore::m('blogs')->getBlogURL($blog['seolink'])), $blog['id']); } cmsCore::jsonOutput(array('error' => false, 'redirect' => cmsCore::m('blogs')->getBlogURL($blog['seolink']))); } } ////////// СПИСОК БЛОГОВ /////////////////////////////////////////////////// if ($inCore->do=='view_blogs'){ // rss в адресной строке cmsCore::c('page')->addHead('<link rel="alternate" type="application/rss+xml" title="'.$_LANG['BLOGS'].'" href="'.HOST.'/rss/blogs/all/feed.rss">'); // тип блога if($ownertype && $ownertype != 'all'){ cmsCore::c('blog')->whereOwnerTypeIs($ownertype); } // всего блогов $total = cmsCore::c('blog')->getBlogsCount(); //устанавливаем сортировку cmsCore::c('db')->orderBy('b.rating', 'DESC'); cmsCore::c('db')->limitPage($page, cmsCore::m('blogs')->config['perpage_blog']); //Получаем список блогов $blogs = cmsCore::c('blog')->getBlogs(cmsCore::m('blogs')); if(!$blogs && $page > 1){ cmsCore::error404(); } //Генерируем панель со страницами и устанавливаем заголовки страниц и глубиномера switch ($ownertype){ case 'all': cmsCore::c('page')->setTitle($_LANG['ALL_BLOGS']); cmsCore::c('page')->setDescription($_LANG['BLOGS'] .' - '. $_LANG['ALL_BLOGS']); cmsCore::c('page')->addPathway($_LANG['ALL_BLOGS']); $link = '/blogs/all-%page%.html'; break; case 'single': cmsCore::c('page')->setTitle($_LANG['PERSONALS']); cmsCore::c('page')->setDescription($_LANG['PERSONALS'] .' '. $_LANG['BLOGS']); cmsCore::c('page')->addPathway($_LANG['PERSONALS']); $link = '/blogs/single-%page%.html'; break; case 'multi': cmsCore::c('page')->setTitle($_LANG['COLLECTIVES']); cmsCore::c('page')->setDescription($_LANG['COLLECTIVES'] .' '. $_LANG['BLOGS']); cmsCore::c('page')->addPathway($_LANG['COLLECTIVES']); $link = '/blogs/multi-%page%.html'; break; } if ($blogs) { foreach ($blogs as $b) { $k[] = $b['title']; } cmsCore::c('page')->setKeywords(implode(', ', $k)); } cmsPage::initTemplate('components', 'com_blog_view_all')-> assign('cfg', cmsCore::m('blogs')->config)-> assign('total', $total)-> assign('ownertype', $ownertype)-> assign('blogs', $blogs)-> assign('pagination', cmsPage::getPagebar($total, $page, cmsCore::m('blogs')->config['perpage_blog'], $link))-> display(); } ////////// ПРОСМОТР БЛОГА ////////////////////////////////////////////////// if ($inCore->do == 'blog'){ // получаем блог $blog = cmsCore::c('blog')->getBlog($bloglink); // Совместимость со старыми ссылками на клубные блоги // Пробуем клубный блог получить по ссылке if (!$blog) { $blog_user_id = cmsCore::c('db')->get_field('cms_blogs', "seolink = '$bloglink' AND owner = 'club'", 'user_id'); if($blog_user_id){ cmsCore::redirect('/clubs/'.$blog_user_id.'_blog', '301'); } } if (!$blog) { cmsCore::error404(); } // Права доступа $myblog = (cmsCore::c('user')->id && cmsCore::c('user')->id == $blog['user_id']); // автор блога $is_writer = cmsCore::c('blog')->isUserBlogWriter($blog, cmsCore::c('user')->id); // может ли пользователь писать в блог cmsCore::c('page')->addPathway($blog['title'], cmsCore::m('blogs')->getBlogURL($blog['seolink'])); // rss в адресной строке cmsCore::c('page')->addHead('<link rel="alternate" type="application/rss+xml" title="'.htmlspecialchars(strip_tags($blog['title'])).'" href="'.HOST.'/rss/blogs/'.$blog['id'].'/feed.rss">'); if($myblog || cmsCore::c('user')->is_admin){ cmsCore::c('page')->addHeadJS('components/blogs/js/blog.js'); } //Если доступа нет, возвращаемся и выводим сообщение об ошибке if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])){ cmsCore::addSessionMessage($_LANG['CLOSED_BLOG'].'<br>'.$_LANG['CLOSED_BLOG_TEXT'], 'error'); cmsCore::redirect('/blogs'); } // Если показываем посты на модерации, если запрашиваем их if($on_moderate){ if(!cmsCore::c('user')->is_admin && !($myblog && $blog['ownertype'] == 'multi' && $blog['premod'])){ cmsCore::error404(); } cmsCore::c('blog')->whereNotPublished(); cmsCore::c('page')->setTitle($_LANG['POSTS_ON_MODERATE']); cmsCore::c('page')->addPathway($_LANG['POSTS_ON_MODERATE']); $blog['title'] .= ' - '.$_LANG['POSTS_ON_MODERATE']; } //Получаем html-код ссылки на автора с иконкой его пола $blog['author'] = cmsUser::getGenderLink($blog['user_id']); // посты данного блога cmsCore::c('blog')->whereBlogIs($blog['id']); // кроме админов автора в списке только с доступом для всех if(!cmsCore::c('user')->is_admin && !$myblog && !cmsCore::c('user')->isFriend($blog['user_id'])){ cmsCore::c('blog')->whereOnlyPublic(); } // если пришла категория if($cat_id){ $all_total = cmsCore::c('blog')->getPostsCount(cmsCore::c('user')->is_admin || $myblog); cmsCore::c('blog')->whereCatIs($cat_id); } // всего постов $total = cmsCore::c('blog')->getPostsCount(cmsCore::c('user')->is_admin || $myblog); //устанавливаем сортировку cmsCore::c('db')->orderBy('p.pubdate', 'DESC'); cmsCore::c('db')->limitPage($page, cmsCore::m('blogs')->config['perpage']); // сами посты $posts = cmsCore::c('blog')->getPosts((cmsCore::c('user')->is_admin || $myblog), cmsCore::m('blogs')); if(!$posts && $page > 1){ cmsCore::error404(); } //Если нужно, получаем список рубрик (категорий) этого блога $blogcats = $blog['showcats'] ? cmsCore::c('blog')->getBlogCats($blog['id']) : false; //Считаем количество постов, ожидающих модерации $on_moderate = (cmsCore::c('user')->is_admin || $myblog) && !$on_moderate ? cmsCore::c('blog')->getModerationCount($blog['id']) : false; // админлинки $blog['moderate_link'] = cmsCore::m('blogs')->getBlogURL($blog['seolink']).'/moderate.html'; $blog['blog_link'] = cmsCore::m('blogs')->getBlogURL($blog['seolink']); $blog['add_post_link'] = '/blogs/'.$blog['id'].'/newpost'.($cat_id ? $cat_id : '').'.html'; //Генерируем панель со страницами if ($cat_id){ $pagination = cmsPage::getPagebar($total, $page, cmsCore::m('blogs')->config['perpage'], $blog['blog_link'].'/page-%page%/cat-'.$cat_id); } else { $pagination = cmsPage::getPagebar($total, $page, cmsCore::m('blogs')->config['perpage'], $blog['blog_link'].'/page-%page%'); } // SEO cmsCore::c('page')->setTitle($blog['pagetitle'] ? $blog['pagetitle'] : $blog['title']); cmsCore::c('page')->setDescription($blog['meta_desc'] ? $blog['meta_desc'] : $blog['title']); // keywords if ($blog['meta_keys']) { $meta_keys = $blog['meta_keys']; } else if ($posts) { foreach ($posts as $p) { $k[] = $p['title']; } $meta_keys = implode(', ', $k); } else { $meta_keys = $blog['title']; } cmsCore::c('page')->setKeywords($meta_keys); cmsPage::initTemplate('components', 'com_blog_view')-> assign('myblog', $myblog)-> assign('is_config', true)-> assign('is_admin', cmsCore::c('user')->is_admin)-> assign('is_writer', $is_writer)-> assign('on_moderate', $on_moderate)-> assign('cat_id', $cat_id)-> assign('blogcats', $blogcats)-> assign('total', $total)-> assign('all_total', (isset($all_total) ? $all_total : 0))-> assign('blog', $blog)->assign('posts', $posts)-> assign('pagination', $pagination)-> display(); } ////////// НОВЫЙ ПОСТ / РЕДАКТИРОВАНИЕ ПОСТА /////////////////////////////// if ($inCore->do == 'newpost' || $inCore->do == 'editpost'){ if (!cmsCore::c('user')->id){ cmsUser::goToLogin(); } // для редактирования сначала получаем пост if($inCore->do == 'editpost'){ $post = cmsCore::c('blog')->getPost($post_id); if (!$post){ cmsCore::error404(); } $id = $post['blog_id']; $post['tags'] = cmsTagLine('blogpost', $post['id'], false); } // получаем блог $blog = cmsCore::c('blog')->getBlog($id); if (!$blog) { cmsCore::error404(); } //Если доступа нет, возвращаемся и выводим сообщение об ошибке if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])){ cmsCore::addSessionMessage($_LANG['CLOSED_BLOG'].'<br>'.$_LANG['CLOSED_BLOG_TEXT'], 'error'); cmsCore::redirect('/blogs'); } // Права доступа $myblog = (cmsCore::c('user')->id && cmsCore::c('user')->id == $blog['user_id']); // автор блога $is_writer = cmsCore::c('blog')->isUserBlogWriter($blog, cmsCore::c('user')->id); // может ли пользователь писать в блог // если не его блог, пользователь не писатель и не админ, вне зависимости от авторства показываем 404 if (!$myblog && !$is_writer && !cmsCore::c('user')->is_admin ) { cmsCore::error404(); } // проверяем является ли пользователь автором, если редактируем пост if (($inCore->do == 'editpost') && !cmsCore::c('user')->is_admin && $post['user_id'] != cmsCore::c('user')->id) { cmsCore::error404(); } //Если еще не было запроса на сохранение if (!cmsCore::inRequest('goadd')){ cmsCore::c('page')->addPathway($blog['title'], cmsCore::m('blogs')->getBlogURL($blog['seolink'])); //для нового поста if ($inCore->do == 'newpost'){ if (IS_BILLING){ cmsBilling::checkBalance('blogs', 'add_post'); } cmsCore::c('page')->addPathway($_LANG['NEW_POST']); cmsCore::c('page')->setTitle($_LANG['NEW_POST']); $post = cmsUser::sessionGet('mod'); if ($post){ cmsUser::sessionDel('mod'); } else { $post['cat_id'] = $cat_id; $post['comments'] = 1; } } //для редактирования поста if ($inCore->do=='editpost'){ cmsCore::c('page')->addPathway($post['title'], cmsCore::m('blogs')->getPostURL($blog['seolink'], $post['seolink'])); cmsCore::c('page')->addPathway($_LANG['EDIT_POST']); cmsCore::c('page')->setTitle($_LANG['EDIT_POST']); } cmsCore::c('page')->initAutocomplete(); $autocomplete_js = cmsCore::c('page')->getAutocompleteJS('tagsearch', 'tags'); //получаем рубрики блога $cat_list = cmsCore::getListItems('cms_blog_cats', $post['cat_id'], 'id', 'ASC', "blog_id = '{$blog['id']}'"); //получаем код панелей bbcode и смайлов $bb_toolbar = cmsPage::getBBCodeToolbar('message',cmsCore::m('blogs')->config['img_on'], 'blogs', 'blog_post', $post_id); $smilies = cmsPage::getSmilesPanel('message'); $inCore->initAutoGrowText('#message'); //показываем форму cmsPage::initTemplate('components', 'com_blog_edit_post')-> assign('blog', $blog)-> assign('pagetitle', ($inCore->do=='editpost' ? $_LANG['EDIT_POST'] : $_LANG['NEW_POST']))-> assign('mod', $post)-> assign('cat_list', $cat_list)-> assign('bb_toolbar', $bb_toolbar)-> assign('smilies', $smilies)-> assign('is_admin', cmsCore::c('user')->is_admin)-> assign('cfg', cmsCore::m('blogs')->config)-> assign('myblog', $myblog)-> assign('user_can_iscomments', cmsUser::isUserCan('comments/iscomments'))-> assign('autocomplete_js', $autocomplete_js)-> display(); } //Если есть запрос на сохранение if (cmsCore::inRequest('goadd')) { $errors = false; //Получаем параметры $mod['title'] = cmsCore::request('title', 'str'); $mod['content'] = cmsCore::request('content', 'html'); $mod['feel'] = cmsCore::request('feel', 'str', ''); $mod['music'] = cmsCore::request('music', 'str', ''); $mod['cat_id'] = cmsCore::request('cat_id', 'int'); $mod['allow_who']= cmsCore::request('allow_who', 'str', $blog['allow_who']); $mod['tags'] = cmsCore::request('tags', 'str', ''); $mod['comments'] = cmsCore::request('comments', 'int', 1); if (cmsCore::m('blogs')->config['seo_user_access'] || cmsCore::c('user')->is_admin) { $mod['pagetitle'] = cmsCore::request('pagetitle', 'str', ''); $mod['meta_keys'] = cmsCore::request('meta_keys', 'str', ''); $mod['meta_desc'] = cmsCore::request('meta_desc', 'str', ''); } $mod['published']= ($myblog || !$blog['premod']) ? 1 : 0; $mod['blog_id'] = $blog['id']; //Проверяем их if (mb_strlen($mod['title'])<2) { cmsCore::addSessionMessage($_LANG['POST_ERR_TITLE'], 'error'); $errors = true; } if (mb_strlen($mod['content'])<5) { cmsCore::addSessionMessage($_LANG['POST_ERR_TEXT'], 'error'); $errors = true; } // Если есть ошибки, возвращаемся назад if($errors){ cmsUser::sessionPut('mod', $mod); cmsCore::redirectBack(); } //Если нет ошибок //добавляем новый пост... if ($inCore->do=='newpost'){ if (IS_BILLING){ cmsBilling::process('blogs', 'add_post'); } $mod['pubdate'] = date( 'Y-m-d H:i:s'); $mod['user_id'] = cmsCore::c('user')->id; // добавляем пост, получая его id и seolink $added = cmsCore::c('blog')->addPost($mod); $mod = array_merge($mod, $added); if ($mod['published']) { $mod['seolink'] = cmsCore::m('blogs')->getPostURL($blog['seolink'], $mod['seolink']); if ($blog['allow_who'] != 'nobody' && $mod['allow_who'] != 'nobody') { cmsCore::callEvent('ADD_POST_DONE', $mod); cmsActions::log('add_post', array( 'object' => $mod['title'], 'object_url' => $mod['seolink'], 'object_id' => $mod['id'], 'target' => $blog['title'], 'target_url' => cmsCore::m('blogs')->getBlogURL($blog['seolink']), 'target_id' => $blog['id'], 'description' => '', 'is_friends_only' => (int)($blog['allow_who'] == 'friends' || $mod['allow_who'] == 'friends') )); } cmsCore::addSessionMessage($_LANG['POST_CREATED'], 'success'); cmsCore::redirect($mod['seolink']); } if (!$mod['published']) { $message = str_replace('%user%', cmsUser::getProfileLink(cmsCore::c('user')->login, cmsCore::c('user')->nickname), $_LANG['MSG_POST_SUBMIT']); $message = str_replace('%post%', '<a href="'.cmsCore::m('blogs')->getPostURL($blog['seolink'], $added['seolink']).'">'.$mod['title'].'</a>', $message); $message = str_replace('%blog%', '<a href="'.cmsCore::m('blogs')->getBlogURL($blog['seolink']).'">'.$blog['title'].'</a>', $message); cmsUser::sendMessage(USER_UPDATER, $blog['user_id'], $message); cmsCore::addSessionMessage($_LANG['POST_PREMODER_TEXT'], 'info'); cmsCore::redirect(cmsCore::m('blogs')->getBlogURL($blog['seolink'])); } } //...или сохраняем пост после редактирования if ($inCore->do=='editpost') { if (cmsCore::m('blogs')->config['update_date']){ $mod['pubdate'] = date( 'Y-m-d H:i:s'); } $mod['edit_times'] = (int)$post['edit_times']+1; $new_post_seolink = cmsCore::c('blog')->updatePost($post['id'], $mod, cmsCore::m('blogs')->config['update_seo_link']); $post['seolink'] = is_string($new_post_seolink) ? $new_post_seolink : $post['seolink']; cmsActions::updateLog( 'add_post', array( 'object' => $mod['title'], 'pubdate' => cmsCore::m('blogs')->config['update_date'] ? $mod['pubdate'] : $post['pubdate'], 'object_url' => cmsCore::m('blogs')->getPostURL($blog['seolink'], $post['seolink']) ), $post['id'] ); if (!$mod['published']) { $message = str_replace('%user%', cmsUser::getProfileLink(cmsCore::c('user')->login, cmsCore::c('user')->nickname), $_LANG['MSG_POST_UPDATE']); $message = str_replace('%post%', '<a href="'.cmsCore::m('blogs')->getPostURL($blog['seolink'], $post['seolink']).'">'.$mod['title'].'</a>', $message); $message = str_replace('%blog%', '<a href="'.cmsCore::m('blogs')->getBlogURL($blog['seolink']).'">'.$blog['title'].'</a>', $message); cmsUser::sendMessage(USER_UPDATER, $blog['user_id'], $message); cmsCore::addSessionMessage($_LANG['POST_PREMODER_TEXT'], 'info'); } else { cmsCore::addSessionMessage($_LANG['POST_UPDATED'], 'success'); } cmsCore::redirect(cmsCore::m('blogs')->getPostURL($blog['seolink'], $post['seolink'])); } } } ////////// НОВАЯ РУБРИКА / РЕДАКТИРОВАНИЕ РУБРИКИ ////////////////////////// if ($inCore->do == 'newcat' || $inCore->do == 'editcat'){ if(!cmsCore::c('user')->id) { cmsCore::error404(); } if(!cmsCore::isAjax()) { cmsCore::error404(); } $cat = array(); // Для редактирования сначала получаем рубрику if ($inCore->do == 'editcat'){ $cat = cmsCore::c('blog')->getBlogCategory($cat_id); if (!$cat) { cmsCore::halt(); } $id = $cat['blog_id']; } // получаем блог $blog = cmsCore::c('blog')->getBlog($id); if (!$blog) { cmsCore::halt(); } //Проверяем является пользователь хозяином блога или админом if ($blog['user_id'] != cmsCore::c('user')->id && !cmsCore::c('user')->is_admin ) { cmsCore::halt(); } //Если нет запроса на сохранение if (!cmsCore::inRequest('goadd')){ cmsPage::initTemplate('components', 'com_blog_edit_cat')-> assign('mod', $cat)-> assign('form_action', ($inCore->do=='newcat' ? '/blogs/'.$blog['id'].'/newcat.html' : '/blogs/editcat'.$cat['id'].'.html'))-> display(); cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean())); } //Если есть запрос на сохранение if (cmsCore::inRequest('goadd')){ $new_cat['title'] = cmsCore::request('title', 'str', ''); $new_cat['description'] = cmsCore::request('description', 'str', ''); $new_cat['blog_id'] = $blog['id']; if (mb_strlen($new_cat['title'])<3) { cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['CAT_ERR_TITLE'])); } if(!cmsUser::checkCsrfToken()) { cmsCore::halt(); } //новая рубрика if ($inCore->do=='newcat'){ $cat['id'] = cmsCore::c('blog')->addBlogCategory($new_cat); cmsCore::addSessionMessage($_LANG['CAT_IS_ADDED'], 'success'); } //редактирование рубрики if ($inCore->do=='editcat'){ cmsCore::c('blog')->updateBlogCategory($cat['id'], $new_cat); cmsCore::addSessionMessage($_LANG['CAT_IS_UPDATED'], 'success'); } cmsCore::jsonOutput(array('error' => false, 'redirect' => cmsCore::m('blogs')->getBlogURL($blog['seolink'], 1, $cat['id']))); } } ///////////////////////// УДАЛЕНИЕ РУБРИКИ ///////////////////////////////// if ($inCore->do == 'delcat'){ if(!cmsCore::c('user')->id) { cmsCore::error404(); } if(!cmsCore::isAjax()) { cmsCore::error404(); } $cat = cmsCore::c('blog')->getBlogCategory($cat_id); if (!$cat) { cmsCore::halt(); } $blog = cmsCore::c('blog')->getBlog($cat['blog_id']); if (!$blog) { cmsCore::halt(); } if ($blog['user_id'] != cmsCore::c('user')->id && !cmsCore::c('user')->is_admin) { cmsCore::halt(); } if(!cmsUser::checkCsrfToken()) { cmsCore::halt(); } cmsCore::c('blog')->deleteBlogCategory($cat['id']); cmsCore::addSessionMessage($_LANG['CAT_IS_DELETED'], 'success'); cmsCore::jsonOutput(array('error' => false, 'redirect' => cmsCore::m('blogs')->getBlogURL($blog['seolink']))); } ////////////////////////// ПРОСМОТР ПОСТА ////////////////////////////////// if($inCore->do == 'post'){ $post = cmsCore::c('blog')->getPost($seolink); if (!$post){ cmsCore::error404(); } $blog = cmsCore::c('blog')->getBlog($post['blog_id']); // Совместимость со старыми ссылками на клубные посты блога if (!$blog) { $blog_user_id = cmsCore::c('db')->get_field('cms_blogs', "id = '{$post['blog_id']}' AND owner = 'club'", 'user_id'); if($blog_user_id){ cmsCore::redirect('/clubs/'.$blog_user_id.'_'.$post['seolink'].'.html', '301'); } } if (!$blog) { cmsCore::error404(); } // Проверяем сеолинк блога и делаем редирект если он изменился if($bloglink != $blog['seolink']) { cmsCore::redirect(cmsCore::m('blogs')->getPostURL($blog['seolink'], $post['seolink']), '301'); } // право просмотра блога if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])){ cmsCore::addSessionMessage($_LANG['CLOSED_BLOG'].'<br>'.$_LANG['CLOSED_BLOG_TEXT'], 'error'); cmsCore::redirect('/blogs'); } // право просмотра самого поста if (!cmsUser::checkUserContentAccess($post['allow_who'], $post['user_id'])){ cmsCore::addSessionMessage($_LANG['CLOSED_POST'].'<br>'.$_LANG['CLOSED_POST_TEXT'], 'error'); cmsCore::redirect(cmsCore::m('blogs')->getBlogURL($blog['seolink'])); } if (cmsCore::c('user')->id) { cmsCore::c('page')->addHeadJS('components/blogs/js/blog.js'); } cmsCore::c('page')->addPathway($blog['title'], cmsCore::m('blogs')->getBlogURL($blog['seolink'])); cmsCore::c('page')->addPathway($post['title']); cmsCore::c('page')->setTitle($post['pagetitle'] ? $post['pagetitle'] : $post['title']); cmsCore::c('page')->setDescription($post['meta_desc'] ? $post['meta_desc'] : crop($post['content_html'])); cmsCore::c('page')->setKeywords($post['meta_keys'] ? $post['meta_keys'] : $post['title']); if ($post['cat_id']){ $cat = cmsCore::c('blog')->getBlogCategory($post['cat_id']); } $post['tags'] = cmsTagBar('blogpost', $post['id']); $is_author = (cmsCore::c('user')->id && cmsCore::c('user')->id == $post['user_id']); // увеличиваем кол-во просмотров if (!$is_author) { cmsCore::c('db')->setFlag('cms_blog_posts', $post['id'], 'hits', $post['hits']+1); } cmsPage::initTemplate('components', 'com_blog_view_post')-> assign('post', $post)-> assign('blog', $blog)->assign('cat', $cat)-> assign('is_author', $is_author)-> assign('is_writer', cmsCore::c('blog')->isUserBlogWriter($blog, cmsCore::c('user')->id))-> assign('myblog', (cmsCore::c('user')->id && cmsCore::c('user')->id == $blog['user_id']))-> assign('is_admin', cmsCore::c('user')->is_admin)-> assign('karma_form', cmsKarmaForm('blogpost', $post['id'], $post['rating'], $is_author))-> assign('navigation', cmsCore::c('blog')->getPostNavigation($post['id'], $blog['id'], cmsCore::m('blogs'), $blog['seolink']))-> display(); if ($inCore->isComponentEnable('comments') && $post['comments']) { cmsCore::includeComments(); comments('blog', $post['id'], array(), $is_author); } } ///////////////////////// УДАЛЕНИЕ ПОСТА /////////////////////////////////// if ($inCore->do == 'delpost'){ if(!cmsCore::c('user')->id) { cmsCore::error404(); } if(!cmsCore::isAjax()) { cmsCore::error404(); } $post = cmsCore::c('blog')->getPost($post_id); if (!$post){ cmsCore::halt(); } $blog = cmsCore::c('blog')->getBlog($post['blog_id']); if (!$blog) { cmsCore::halt(); } $myblog = (cmsCore::c('user')->id == $blog['user_id']); // автор блога $is_writer = cmsCore::c('blog')->isUserBlogWriter($blog, cmsCore::c('user')->id); // если не его блог, пользователь не писатель и не админ if (!$myblog && !$is_writer && !cmsCore::c('user')->is_admin ) { cmsCore::halt(); } // проверяем является ли пользователь автором if (!cmsCore::c('user')->is_admin && !$myblog && $post['user_id'] != cmsCore::c('user')->id) { cmsCore::halt(); } if(!cmsUser::checkCsrfToken()) { cmsCore::halt(); } cmsCore::c('blog')->deletePost($post['id']); if (cmsCore::c('user')->id != $post['user_id']){ cmsUser::sendMessage(USER_UPDATER, $post['user_id'], $_LANG['YOUR_POST'].' <b>«'.$post['title'].'»</b> '.$_LANG['WAS_DELETED_FROM_BLOG'].' <b>«<a href="'.cmsCore::m('blogs')->getBlogURL($blog['seolink']).'">'.$blog['title'].'</a>»</b>'); } cmsCore::addSessionMessage($_LANG['POST_IS_DELETED'], 'success'); cmsCore::jsonOutput(array('error' => false, 'redirect' => cmsCore::m('blogs')->getBlogURL($blog['seolink']))); } ///////////////////////// ПУБЛИКАЦИЯ ПОСТА ///////////////////////////////// if ($inCore->do == 'publishpost'){ if(!cmsCore::c('user')->id) { cmsCore::error404(); } if(!cmsCore::isAjax()) { cmsCore::error404(); } $post = cmsCore::c('blog')->getPost($post_id); if (!$post){ cmsCore::halt(); } $blog = cmsCore::c('blog')->getBlog($post['blog_id']); if (!$blog) { cmsCore::halt(); } // публикуют авторы блога и админы if ($blog['user_id'] != cmsCore::c('user')->id && !cmsCore::c('user')->is_admin) { cmsCore::halt(); } cmsCore::c('blog')->publishPost($post_id); $post['seolink'] = cmsCore::m('blogs')->getPostURL($blog['seolink'], $post['seolink']); if ($blog['allow_who'] == 'all' && $post['allow_who'] == 'all') { cmsCore::callEvent('ADD_POST_DONE', $post); } if ($blog['allow_who'] != 'nobody' && $post['allow_who'] != 'nobody'){ cmsActions::log('add_post', array( 'object' => $post['title'], 'user_id' => $post['user_id'], 'object_url' => $post['seolink'], 'object_id' => $post['id'], 'target' => $blog['title'], 'target_url' => cmsCore::m('blogs')->getBlogURL($blog['seolink']), 'target_id' => $blog['id'], 'description' => '', 'is_friends_only' => (int)($blog['allow_who'] == 'friends' || $post['allow_who'] == 'friends') )); } cmsUser::sendMessage(USER_UPDATER, $post['user_id'], $_LANG['YOUR_POST'].' <b>«<a href="'.$post['seolink'].'">'.$post['title'].'</a>»</b> '.$_LANG['PUBLISHED_IN_BLOG'].' <b>«<a href="'.cmsCore::m('blogs')->getBlogURL($blog['seolink']).'">'.$blog['title'].'</a>»</b>'); cmsCore::halt('ok'); } ///////////////////////// УДАЛЕНИЕ БЛОГА /////////////////////////////////// if ($inCore->do == 'delblog'){ if(!cmsCore::c('user')->id) { cmsCore::error404(); } if(!cmsCore::isAjax()) { cmsCore::error404(); } // получаем блог $blog = cmsCore::c('blog')->getBlog($id); if (!$blog) { cmsCore::error404(); } //Проверяем является пользователь хозяином блога или админом if ($blog['user_id'] != cmsCore::c('user')->id && !cmsCore::c('user')->is_admin ) { cmsCore::halt(); } if(!cmsUser::checkCsrfToken()) { cmsCore::halt(); } cmsCore::c('blog')->deleteBlog($blog['id']); cmsCore::addSessionMessage($_LANG['BLOG_IS_DELETED'], 'success'); cmsCore::jsonOutput(array('error' => false, 'redirect' => '/blogs')); } ////////// VIEW POPULAR POSTS ////////////////////////////////////////////// if ($inCore->do=='best'){ cmsCore::c('page')->setTitle($_LANG['POPULAR_IN_BLOGS']); cmsCore::c('page')->addPathway($_LANG['POPULAR_IN_BLOGS']); cmsCore::c('page')->setDescription($_LANG['POPULAR_IN_BLOGS']); // кроме админов в списке только с доступом для всех if(!cmsCore::c('user')->is_admin){ cmsCore::c('blog')->whereOnlyPublic(); } // ограничиваем по рейтингу если надо if(cmsCore::m('blogs')->config['list_min_rating']){ cmsCore::c('blog')->ratingGreaterThan(cmsCore::m('blogs')->config['list_min_rating']); } // всего постов $total = cmsCore::c('blog')->getPostsCount(cmsCore::c('user')->is_admin); //устанавливаем сортировку cmsCore::c('db')->orderBy('p.rating', 'DESC'); cmsCore::c('db')->limitPage($page, cmsCore::m('blogs')->config['perpage']); // сами посты $posts = cmsCore::c('blog')->getPosts(cmsCore::c('user')->is_admin, cmsCore::m('blogs')); if(!$posts && $page > 1){ cmsCore::error404(); } cmsPage::initTemplate('components', 'com_blog_view_posts')-> assign('pagetitle', $_LANG['POPULAR_IN_BLOGS'])-> assign('total', $total)-> assign('ownertype', $ownertype)-> assign('posts', $posts)-> assign('pagination', cmsPage::getPagebar($total, $page, cmsCore::m('blogs')->config['perpage'], '/blogs/popular-%page%.html'))-> assign('cfg', cmsCore::m('blogs')->config)-> display(); } }
function applet_config() { // получаем оригинальный конфиг $config = cmsConfig::getDefaultConfig(); $inPage = cmsPage::getInstance(); $inDB = cmsDatabase::getInstance(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); } $GLOBALS['cp_page_title'] = $_LANG['AD_SITE_SETTING']; cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config'); $do = cmsCore::request('do', 'str', 'list'); if ($do == 'save') { if (!cmsCore::validateForm()) { cmsCore::error404(); } $newCFG = array(); $newCFG['sitename'] = stripslashes(cmsCore::request('sitename', 'str', '')); $newCFG['title_and_sitename'] = cmsCore::request('title_and_sitename', 'int', 0); $newCFG['title_and_page'] = cmsCore::request('title_and_page', 'int', 0); $newCFG['hometitle'] = stripslashes(cmsCore::request('hometitle', 'str', '')); $newCFG['homecom'] = cmsCore::request('homecom', 'str', ''); $newCFG['siteoff'] = cmsCore::request('siteoff', 'int', 0); $newCFG['debug'] = cmsCore::request('debug', 'int', 0); $newCFG['offtext'] = htmlspecialchars(cmsCore::request('offtext', 'str', ''), ENT_QUOTES); $newCFG['keywords'] = cmsCore::request('keywords', 'str', ''); $newCFG['metadesc'] = cmsCore::request('metadesc', 'str', ''); $newCFG['seourl'] = cmsCore::request('seourl', 'int', 0); $newCFG['lang'] = cmsCore::request('lang', 'str', 'ru'); $newCFG['is_change_lang'] = cmsCore::request('is_change_lang', 'int', 0); $newCFG['sitemail'] = cmsCore::request('sitemail', 'str', ''); $newCFG['sitemail_name'] = cmsCore::request('sitemail_name', 'str', ''); $newCFG['wmark'] = cmsCore::request('wmark', 'str', ''); $newCFG['template'] = cmsCore::request('template', 'str', ''); $newCFG['splash'] = cmsCore::request('splash', 'int', 0); $newCFG['slight'] = cmsCore::request('slight', 'int', 0); $newCFG['db_host'] = $config['db_host']; $newCFG['db_base'] = $config['db_base']; $newCFG['db_user'] = $config['db_user']; $newCFG['db_pass'] = $config['db_pass']; $newCFG['db_prefix'] = $config['db_prefix']; $newCFG['show_pw'] = cmsCore::request('show_pw', 'int', 0); $newCFG['last_item_pw'] = cmsCore::request('last_item_pw', 'int', 0); $newCFG['index_pw'] = cmsCore::request('index_pw', 'int', 0); $newCFG['fastcfg'] = cmsCore::request('fastcfg', 'int', 0); $newCFG['mailer'] = cmsCore::request('mailer', 'str', ''); $newCFG['smtpsecure'] = cmsCore::request('smtpsecure', 'str', ''); $newCFG['smtpauth'] = cmsCore::request('smtpauth', 'int', 0); $newCFG['smtpuser'] = cmsCore::inRequest('smtpuser') ? cmsCore::request('smtpuser', 'str', '') : $config['smtpuser']; $newCFG['smtppass'] = cmsCore::inRequest('smtppass') ? cmsCore::request('smtppass', 'str', '') : $config['smtppass']; $newCFG['smtphost'] = cmsCore::request('smtphost', 'str', ''); $newCFG['smtpport'] = cmsCore::request('smtpport', 'int', '25'); $newCFG['timezone'] = cmsCore::request('timezone', 'str', ''); $newCFG['timediff'] = cmsCore::request('timediff', 'str', ''); $newCFG['user_stats'] = cmsCore::request('user_stats', 'int', 0); $newCFG['allow_ip'] = cmsCore::request('allow_ip', 'str', ''); if (cmsConfig::saveToFile($newCFG)) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success'); } else { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SITE_ERROR'], 'error'); } cmsCore::clearCache(); cmsCore::redirect('index.php?view=config'); } ?> <div> <?php cpCheckWritable('/includes/config.inc.php'); ?> <div id="config_tabs" class="uitabs"> <ul id="tabs"> <li><a href="#basic"><span><?php echo $_LANG['AD_SITE']; ?> </span></a></li> <li><a href="#home"><span><?php echo $_LANG['AD_MAIN']; ?> </span></a></li> <li><a href="#design"><span><?php echo $_LANG['AD_DESIGN']; ?> </span></a></li> <li><a href="#time"><span><?php echo $_LANG['AD_TIME']; ?> </span></a></li> <li><a href="#database"><span><?php echo $_LANG['AD_DB']; ?> </span></a></li> <li><a href="#mail"><span><?php echo $_LANG['AD_POST']; ?> </span></a></li> <li><a href="#other"><span><?php echo $_LANG['AD_PATHWAY']; ?> </span></a></li> <li><a href="#seq"><span><?php echo $_LANG['AD_SECURITY']; ?> </span></a></li> </ul> <form action="/admin/index.php?view=config" method="post" name="CFGform" target="_self" id="CFGform" style="margin-bottom:30px"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?> " /> <div id="basic"> <table width="720" border="0" cellpadding="5"> <tr> <td> <strong><?php echo $_LANG['AD_SITENAME']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_USE_HEADER']; ?> </span> </td> <td width="350" valign="top"> <input name="sitename" type="text" id="sitename" value="<?php echo htmlspecialchars($config['sitename']); ?> " style="width:358px" /> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_TAGE_ADD']; ?> </strong> </td> <td valign="top"> <label><input name="title_and_sitename" type="radio" value="1" <?php if ($config['title_and_sitename']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="title_and_sitename" type="radio" value="0" <?php if (!$config['title_and_sitename']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_TAGE_ADD_PAGINATION']; ?> </strong> </td> <td valign="top"> <label><input name="title_and_page" type="radio" value="1" <?php if ($config['title_and_page']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="title_and_page" type="radio" value="0" <?php if (!$config['title_and_page']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['TEMPLATE_INTERFACE_LANG']; ?> :</strong> </td> <td width="350" valign="top"> <select name="lang" id="lang" style="width:364px"> <?php $langs = cmsCore::getDirsList('/languages'); foreach ($langs as $lng) { echo '<option value="' . $lng . '" ' . ($config['lang'] == $lng ? 'selected="selected"' : '') . '>' . $lng . '</option>'; } ?> </select> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SITE_LANGUAGE_CHANGE']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_VIEW_FORM_LANGUAGE_CHANGE']; ?> </span> </td> <td valign="top"> <label><input name="is_change_lang" type="radio" value="1" <?php if ($config['is_change_lang']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="is_change_lang" type="radio" value="0" <?php if (!$config['is_change_lang']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SITE_ON']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_ONLY_ADMINS']; ?> </span> </td> <td valign="top"> <label><input name="siteoff" type="radio" value="0" <?php if (!$config['siteoff']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="siteoff" type="radio" value="1" <?php if ($config['siteoff']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_DEBUG_ON']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_WIEW_DB_ERRORS']; ?> </span> </td> <td valign="top"> <label><input name="debug" type="radio" value="1" <?php if ($config['debug']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="debug" type="radio" value="0" <?php if (!$config['debug']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td valign="middle"> <strong><?php echo $_LANG['AD_WHY_STOP']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_VIEW_WHY_STOP']; ?> </span> </td> <td valign="top"><input name="offtext" type="text" id="offtext" value="<?php echo htmlspecialchars($config['offtext']); ?> " style="width:358px" /></td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_WATERMARK']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_WATERMARK_NAME']; ?> </span> </td> <td> <input name="wmark" type="text" id="wmark" value="<?php echo $config['wmark']; ?> " style="width:358px" /> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_QUICK_CONFIG']; ?> </strong> <br /> <span class="hinttext"><?php echo $_LANG['AD_MODULE_CONFIG']; ?> </span> </td> <td valign="top"> <label><input name="fastcfg" type="radio" value="1" <?php if ($config['fastcfg']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="fastcfg" type="radio" value="0" <?php if (!$config['fastcfg']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_ONLINESTATS']; ?> </strong> </td> <td valign="top"> <label><input name="user_stats" type="radio" value="0" <?php if (!$config['user_stats']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_NO_ONLINESTATS']; ?> </label><br> <label><input name="user_stats" type="radio" value="1" <?php if ($config['user_stats'] == 1) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_YES_ONLINESTATS']; ?> </label><br> <label><input name="user_stats" type="radio" value="2" <?php if ($config['user_stats'] == 2) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_CRON_ONLINESTATS']; ?> </label> </td> </tr> </table> </div> <div id="home"> <table width="720" border="0" cellpadding="5"> <tr> <td> <strong><?php echo $_LANG['AD_MAIN_PAGE']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_MAIN_SITENAME']; ?> </span><br/> <span class="hinttext"><?php echo $_LANG['AD_BROWSER_TITLE']; ?> </span> </td> <td width="350" valign="top"> <input name="hometitle" type="text" id="hometitle" value="<?php echo htmlspecialchars($config['hometitle']); ?> " style="width:358px" /> </td> </tr> <tr> <td valign="top"> <strong><?php echo $_LANG['AD_KEY_WORDS']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_FROM_COMMA']; ?> </span> <div class="hinttext" style="margin-top:4px"><a style="color:#09C" href="http://tutorial.semonitor.ru/#5" target="_blank"><?php echo $_LANG['AD_WHAT_KEY_WORDS']; ?> </a></div> </td> <td> <textarea name="keywords" style="width:350px" rows="3" id="keywords"><?php echo $config['keywords']; ?> </textarea> </td> </tr> <tr> <td valign="top"> <strong><?php echo $_LANG['AD_DESCRIPTION']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_LESS_THAN']; ?> </span> <div class="hinttext" style="margin-top:4px"><a style="color:#09C" href="http://tutorial.semonitor.ru/#219" target="_blank"><?php echo $_LANG['AD_WHAT_DESCRIPTION']; ?> </a></div> </td> <td> <textarea name="metadesc" style="width:350px" rows="3" id="metadesc"><?php echo $config['metadesc']; ?> </textarea> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_MAIN_PAGE_COMPONENT']; ?> </strong> </td> <td width="350" valign="top"> <select name="homecom" style="width:358px"> <option value="" <?php if (!$config['homecom']) { ?> selected="selected"<?php } ?> ><?php echo $_LANG['AD_ONLY_MODULES']; ?> </option> <?php echo cmsCore::getListItems('cms_components', $config['homecom'], 'title', 'ASC', 'internal=0', 'link'); ?> </select> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_GATE_PAGE']; ?> </strong> <br/> <span class="hinttext"><?php echo $_LANG['AD_FIRST_VISIT']; ?> </span> <br/> <span class="hinttext"><?php echo $_LANG['AD_FIRST_VISIT_TEMPLATE']; ?> </strong></span> </td> <td valign="top"> <label><input name="splash" type="radio" value="0" <?php if (!$config['splash']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['HIDE']; ?> </label> <label><input name="splash" type="radio" value="1" <?php if ($config['splash']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['SHOW']; ?> </label> </td> </tr> </table> </div> <div id="design"> <table width="720" border="0" cellpadding="5"> <tr> <td valign="top"> <div style="margin-top:2px"> <strong><?php echo $_LANG['TEMPLATE']; ?> :</strong><br /> <span class="hinttext"><?php echo $_LANG['AD_TEMPLATE_FOLDER']; ?> </span> </div> </td> <td> <select name="template" id="template" style="width:350px" onchange="document.CFGform.submit();"> <?php $templates = cmsCore::getDirsList('/templates'); foreach ($templates as $template) { echo '<option value="' . $template . '" ' . ($config['template'] == $template ? 'selected="selected"' : '') . '>' . $template . '</option>'; } $tpl_info = $inPage->getCurrentTplInfo(); ?> </select> <?php if (file_exists(PATH . '/templates/' . TEMPLATE . '/positions.jpg')) { ?> <script> $(function() { $('#pos').dialog({modal: true, autoOpen: false, closeText: LANG_CLOSE, width: 'auto'}); }); </script> <a onclick="$('#pos').dialog('open');return false;" href="#" class="ajaxlink"><?php echo $_LANG['AD_TPL_POS']; ?> </a> <div id="pos" title="<?php echo $_LANG['AD_TPL_POS']; ?> "><img src="/templates/<?php echo TEMPLATE; ?> /positions.jpg" alt="<?php echo $_LANG['AD_TPL_POS']; ?> " /></div> <?php } ?> <div style="margin-top:5px" class="hinttext"> <?php echo sprintf($_LANG['AD_TEMPLATE_INFO'], $tpl_info['author'], $tpl_info['renderer'], $tpl_info['ext']); ?> </div> </td> </tr> <tr> <td><strong><?php echo $_LANG['AD_SEARCH_RESULT']; ?> </strong></td> <td valign="top"> <label><input name="slight" type="radio" value="1" <?php if ($config['slight']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="slight" type="radio" value="0" <?php if (!$config['slight']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> </table> </div> <div id="time"> <table width="720" border="0" cellpadding="5"> <tr> <td valign="top" width="100"> <div style="margin-top:2px"> <strong><?php echo $_LANG['AD_TIME_ARREA']; ?> </strong> </div> </td> <td> <select name="timezone" id="timezone" style="width:350px"> <?php include PATH . '/admin/includes/timezones.php'; ?> <?php foreach ($timezones as $tz) { ?> <option value="<?php echo $tz; ?> " <?php if ($tz == $config['timezone']) { ?> selected="selected"<?php } ?> ><?php echo $tz; ?> </option> <?php } ?> </select> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_TIME_SLIP']; ?> </strong> </td> <td width="350"> <select name="timediff" id="timediff" style="width:60px"> <?php for ($h = -12; $h <= 12; $h++) { ?> <option value="<?php echo $h; ?> " <?php if ($h == $config['timediff']) { ?> selected="selected"<?php } ?> ><?php echo $h > 0 ? '+' . $h : $h; ?> </option> <?php } ?> </select> </td> </tr> </table> </div> <div id="database"> <table width="720" border="0" cellpadding="5" style="margin-top:15px;"> <tr> <td> <strong><?php echo $_LANG['AD_DB_SIZE']; ?> </strong> </td> <td width="350"> <?php $result = $inDB->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '{$config['db_base']}'", true); if (!$inDB->error()) { $s = $inDB->fetch_assoc($result); echo round($s['size'], 2) . ' ' . $_LANG['SIZE_MB']; } else { echo $_LANG['AD_DB_SIZE_ERROR']; } ?> </td> </tr> <tr> <td colspan="2"><span class="hinttext"><?php echo $_LANG['AD_MYSQL_CONFIG']; ?> </span></td> </tr> </table> </div> <div id="mail"> <table width="720" border="0" cellpadding="5" style="margin-top:15px;"> <tr> <td width="250"> <strong><?php echo $_LANG['AD_SITE_EMAIL']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_SITE_EMAIL_POST']; ?> </span> </td> <td> <input name="sitemail" type="text" id="sitemail" value="<?php echo $config['sitemail']; ?> " style="width:358px" /> </td> </tr> <tr> <td width="250"> <strong><?php echo $_LANG['AD_SENDER_EMAIL']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_IF_NOT_HANDLER']; ?> </span> </td> <td> <input name="sitemail_name" type="text" id="sitemail_name" value="<?php echo $config['sitemail_name']; ?> " style="width:358px" /> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SEND_METHOD']; ?> </strong> </td> <td> <select name="mailer" style="width:354px"> <option value="mail" <?php if ($config['mailer'] == 'mail') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_PHP_MAILER']; ?> </option> <option value="sendmail" <?php if ($config['mailer'] == 'sendmail') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_SEND_MAILER']; ?> </option> <option value="smtp" <?php if ($config['mailer'] == 'smtp') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_SMTP_MAILER']; ?> </option> </select> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_ENCRYPTING']; ?> </strong> </td> <td> <label><input name="smtpsecure" type="radio" value="" <?php if (!$config['smtpsecure']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> <label><input name="smtpsecure" type="radio" value="tls" <?php if ($config['smtpsecure'] == 'tls') { echo 'checked="checked"'; } ?> /> tls</label> <label><input name="smtpsecure" type="radio" value="ssl" <?php if ($config['smtpsecure'] == 'ssl') { echo 'checked="checked"'; } ?> /> ssl</label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_LOGIN']; ?> </strong> </td> <td> <label><input name="smtpauth" type="radio" value="1" <?php if ($config['smtpauth']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="smtpauth" type="radio" value="0" <?php if (!$config['smtpauth']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_USER']; ?> </strong> </td> <td> <?php if (!$config['smtpuser']) { ?> <input name="smtpuser" type="text" id="smtpuser" value="<?php echo $config['smtpuser']; ?> " style="width:350px" /> <?php } else { ?> <span class="hinttext"><?php echo $_LANG['AD_IF_CHANGE_USER']; ?> </span> <?php } ?> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_PASS']; ?> </strong> </td> <td> <?php if (!$config['smtppass']) { ?> <input name="smtppass" type="password" id="smtppass" value="<?php echo $config['smtppass']; ?> " style="width:350px" /> <?php } else { ?> <span class="hinttext"><?php echo $_LANG['AD_IF_CHANGE_PASS']; ?> </span> <?php } ?> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_HOST']; ?> </strong><br> <span class="hinttext"><?php echo $_LANG['AD_SOME_HOST']; ?> </span> </td> <td> <input name="smtphost" type="text" id="smtphost" value="<?php echo $config['smtphost']; ?> " style="width:350px" /> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_PORT']; ?> </strong> </td> <td> <input name="smtpport" type="text" id="smtpport" value="<?php echo $config['smtpport']; ?> " style="width:350px" /> </td> </tr> </table> </div> <div id="other"> <table width="720" border="0" cellpadding="5"> <tr> <td> <strong><?php echo $_LANG['AD_VIEW_PATHWAY']; ?> </strong><br /> <span class="hinttext"> <?php echo $_LANG['AD_PATH_TO_CATEGORY']; ?> </span> </td> <td> <label><input name="show_pw" type="radio" value="1" <?php if ($config['show_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="show_pw" type="radio" value="0" <?php if (!$config['show_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td><strong><?php echo $_LANG['AD_MAINPAGE_PATHWAY']; ?> </strong></td> <td> <label><input name="index_pw" type="radio" value="1" <?php if ($config['index_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="index_pw" type="radio" value="0" <?php if (!$config['index_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td><strong><?php echo $_LANG['AD_PAGE_PATHWAY']; ?> </strong></td> <td> <label><input name="last_item_pw" type="radio" value="0" <?php if (!$config['last_item_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['HIDE']; ?> </label> <label><input name="last_item_pw" type="radio" value="1" <?php if ($config['last_item_pw'] == 1) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_PAGE_PATHWAY_LINK']; ?> </label> <label><input name="last_item_pw" type="radio" value="2" <?php if ($config['last_item_pw'] == 2) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_PAGE_PATHWAY_TEXT']; ?> </label> </td> </tr> </table> </div> <div id="seq"> <table width="720" border="0" cellpadding="5"> <tr> <td> <strong><?php echo $_LANG['AD_IP_ADMIN']; ?> </strong> <br /> <span class="hinttext"><?php echo $_LANG['AD_IP_COMMA']; ?> </span></td> <td valign="top"> <input name="allow_ip" type="text" id="allow_ip" value="<?php echo htmlspecialchars($config['allow_ip']); ?> " style="width:358px" /></td> </tr> </table> <p style="color:#900"><?php echo $_LANG['AD_ATTENTION']; ?> </p> </div> <div align="left"> <input name="do" type="hidden" id="do" value="save" /> <input name="save" type="submit" id="save" value="<?php echo $_LANG['SAVE']; ?> " /> <input name="back" type="button" id="back" value="<?php echo $_LANG['CANCEL']; ?> " onclick="window.history.back();" /> </div> </form> </div></div> <?php }
} //для редактирования поста if ($bdo=='editpost'){ $inPage->addPathway($post['title'], $model->getPostURL($club['id'], $post['seolink'])); $inPage->addPathway($_LANG['EDIT_POST']); $inPage->setTitle($_LANG['EDIT_POST']); } $inPage->initAutocomplete(); $autocomplete_js = $inPage->getAutocompleteJS('tagsearch', 'tags'); //получаем рубрики блога $cat_list = cmsCore::getListItems('cms_blog_cats', $post['cat_id'], 'id', 'ASC', "blog_id = '{$blog['id']}'"); //получаем код панелей bbcode и смайлов $bb_toolbar = cmsPage::getBBCodeToolbar('message', true, 'clubs', 'blog_post', $post_id); $smilies = cmsPage::getSmilesPanel('message'); $inCore->initAutoGrowText('#message'); //показываем форму cmsPage::initTemplate('components', 'com_blog_edit_post')-> assign('blog', $blog)-> assign('pagetitle', ($do=='editpost' ? $_LANG['EDIT_POST'] : $_LANG['NEW_POST']))-> assign('mod', $post)-> assign('cat_list', $cat_list)-> assign('bb_toolbar', $bb_toolbar)-> assign('smilies', $smilies)->
<select name="country_id" style="width: 300px;"> <?php echo cmsCore::getListItems('cms_geo_countries', @$item['country_id'], 'name', 'ASC', '', 'id', 'name'); ?> </select> </td> </tr> <tr> <td><strong><?php echo $_LANG['AD_REGION']; ?> </strong></td> <td width="" valign="top"> <select name="region_id" style="width: 300px;"> <?php echo cmsCore::getListItems('cms_geo_regions', @$item['region_id'], 'name', 'ASC', @$item['country_id'] ? "country_id = '{$item['country_id']}'" : '', 'id', 'name'); ?> </select> </td> </tr> <?php } ?> </table> <p> <input name="opt" type="hidden" value="do_<?php echo $opt; ?> " /> <input name="sub_opt" type="hidden" value="<?php echo $sub_opt;
// 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 // // // /******************************************************************************/ $opt = cmsCore::request('opt', 'str', 'in'); $whith_id = cmsCore::request('with_id', 'int', 0); $perpage = 15; $show_notice = false; $new_msg = cmsUser::getNewMessages($inUser->id); $friends = cmsUser::getFriends($inUser->id); $interlocutors = cmsCore::getListItems("cms_users u INNER JOIN cms_user_msg m ON m.from_id = u.id AND m.to_id = '{$id}'", $whith_id, 'm.from_id', 'ASC', "m.from_del = 0 AND m.to_del = 0 GROUP BY m.from_id", 'from_id', 'nickname'); switch ($opt) { case 'in': $page_title = $_LANG['INBOX']; $inDB->addJoin("INNER JOIN cms_user_msg m ON m.from_id = u.id AND m.to_id = '{$id}' AND m.to_del = 0"); $msg_count = $model->getMessagesCount(); $pagebar = cmsPage::getPagebar($msg_count, $page, $perpage, 'javascript:centerLink(\'/users/' . $id . '/messages%page%.html\')'); break; case 'out': $page_title = $_LANG['SENT']; $inDB->addJoin("INNER JOIN cms_user_msg m ON m.to_id = u.id AND m.from_id = '{$id}' AND m.from_del = 0"); $msg_count = $model->getMessagesCount(); $pagebar = cmsPage::getPagebar($msg_count, $page, $perpage, 'javascript:centerLink(\'/users/' . $id . '/messages-sent%page%.html\')'); break; case 'notices': $page_title = $_LANG['NOTICES'];
function forum() { $inCore = cmsCore::getInstance(); $inPage = cmsPage::getInstance(); $inDB = cmsDatabase::getInstance(); $inUser = cmsUser::getInstance(); $model = new cms_model_forum(); define('IS_BILLING', $inCore->isComponentInstalled('billing')); if (IS_BILLING) { cmsCore::loadClass('billing'); } global $_LANG; $pagetitle = $inCore->getComponentTitle(); $inPage->addPathway($pagetitle, '/forum'); $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); $id = cmsCore::request('id', 'int', 0); $do = $inCore->do; $page = cmsCore::request('page', 'int', 1); $inPage->addHeadJS('components/forum/js/common.js'); $inPage->addHeadJsLang(array('CONFIRM_DELETE_POLL', 'CONFIRM_DEL_POST', 'CONFIRM_DEL_THREAD', 'MOVE_THREAD', 'MOVE_POST', 'RENAME_THREAD', 'CONFIRM_DELETE_FILE', 'SELECT_NEW_FILE_UPLOAD', 'SELECT_TEXT_QUOTE', 'CONFIRM_DELETE_ALL_USER_POSTS')); //============================================================================// //=============================== Список Форумов ============================// //============================================================================// if ($do == 'view') { $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . $_LANG['FORUMS'] . '" href="' . HOST . '/rss/forum/all/feed.rss">'); $forums = $model->getForums(); cmsPage::initTemplate('components', 'com_forum_list')->assign('pagetitle', $pagetitle)->assign('forums', $forums)->assign('forum', array())->assign('user_id', $inUser->id)->assign('cfg', $model->config)->display('com_forum_list.tpl'); } //============================================================================// //================ Список тем форума + список подфорумов ====================// //============================================================================// if ($do == 'forum') { $forum = $model->getForum($id); if (!$forum) { cmsCore::error404(); } $forum = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $forum); $moderators = $model->getForumModerators($forum['moder_list']); // опции просмотра $order_by = cmsCore::getSearchVar('order_by', 'pubdate'); $order_to = cmsCore::getSearchVar('order_to', 'desc'); if (!in_array($order_by, array('pubdate', 'title', 'post_count', 'hits'))) { $order_by = 'pubdate'; } if (!in_array($order_to, array('asc', 'desc'))) { $order_to = 'desc'; } $daysprune = (int) cmsCore::getSearchVar('daysprune'); if (!cmsCore::checkContentAccess($forum['access_list'])) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . htmlspecialchars($forum['title']) . '" href="' . HOST . '/rss/forum/' . $forum['id'] . '/feed.rss">'); $inPage->setTitle($forum['pagetitle'] ? $forum['pagetitle'] : $forum['title']); $inPage->setDescription($forum['meta_desc'] ? $forum['meta_desc'] : crop($forum['description'] ? $forum['description'] : $forum['title'])); $inPage->setKeywords($forum['meta_keys'] ? $forum['meta_keys'] : $forum['title']); // Получаем дерево форумов $path_list = $inDB->getNsCategoryPath('cms_forums', $forum['NSLeft'], $forum['NSRight'], 'id, title, access_list, moder_list'); // Строим глубиномер if ($path_list) { $path_list = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $path_list); foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $inPage->addPathway($pcat['title'], '/forum/' . $pcat['id']); } } // Получим подфорумы $model->whereNestedForum($forum['NSLeft'], $forum['NSRight']); $sub_forums = $model->getForums(); cmsPage::initTemplate('components', 'com_forum_list')->assign('pagetitle', $forum['title'])->assign('forums', $sub_forums)->assign('forum', $forum)->assign('cfg', $model->config)->assign('user_id', $inUser->id)->display('com_forum_list.tpl'); // Получим темы if ($daysprune) { $model->whereDayIntervalIs($daysprune); } $model->whereForumIs($forum['id']); $inDB->orderBy('t.pinned', 'DESC, t.' . $order_by . ' ' . $order_to); $inDB->limitPage($page, $model->config['pp_forum']); $threads = $model->getThreads(); if (!$threads && $page > 1) { cmsCore::error404(); } cmsPage::initTemplate('components', 'com_forum_view')->assign('threads', $threads)->assign('show_panel', true)->assign('order_by', $order_by)->assign('order_to', $order_to)->assign('daysprune', $daysprune)->assign('moderators', $moderators)->assign('pagination', cmsPage::getPagebar($forum['thread_count'], $page, $model->config['pp_forum'], '/forum/' . $forum['id'] . '-%page%'))->display('com_forum_view.tpl'); } //============================================================================// //======================== Просмотр темы форума =============================// //============================================================================// if ($do == 'thread') { $thread = $model->getThread($id); if (!$thread) { cmsCore::error404(); } // Строим глубиномер $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list'); if ($path_list) { $path_list = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $path_list); foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $inPage->addPathway($pcat['title'], '/forum/' . $pcat['id']); } // Для последнего форума проверяем // не модератор ли текущий пользователь $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } $inPage->addPathway($thread['title'], '/forum/thread' . $thread['id'] . '.html'); if (!$thread['is_mythread']) { $inDB->setFlag('cms_forum_threads', $thread['id'], 'hits', $thread['hits'] + 1); } // получаем посты $model->whereThreadIs($thread['id']); $inDB->orderBy('p.pinned', 'DESC, p.pubdate ASC'); $inDB->limitPage($page, $model->config['pp_thread']); $posts = $model->getPosts(); if (!$posts) { cmsCore::error404(); } // SEO $inPage->setTitle($thread['title']); // meta description if (!$thread['description']) { $first_post = current($posts); $first_post_content = strip_tags($first_post['content_html']); if (mb_strlen($first_post_content) >= 100) { $inPage->setDescription(crop($first_post_content)); } else { $inPage->setDescription($thread['title']); } } else { $inPage->setDescription(crop($thread['description'])); } // meta keywords $all_post_content = ''; foreach ($posts as $p) { $all_post_content .= ' ' . strip_tags($p['content_html']); } $meta_keys = cmsCore::getKeywords($all_post_content); $inPage->setKeywords($meta_keys ? $meta_keys : $thread['title']); cmsCore::initAutoGrowText('#message'); cmsPage::initTemplate('components', 'com_forum_view_thread')->assign('forum', $pcat)->assign('forums', $model->getForums())->assign('is_subscribed', cmsUser::isSubscribed($inUser->id, 'forum', $thread['id']))->assign('thread', $thread)->assign('prev_thread', $inDB->get_fields('cms_forum_threads', "id < '{$thread['id']}' AND forum_id = '{$thread['forum_id']}'", 'id, title', 'id DESC'))->assign('next_thread', $inDB->get_fields('cms_forum_threads', "id > '{$thread['id']}' AND forum_id = '{$thread['forum_id']}'", 'id, title', 'id ASC'))->assign('posts', $posts)->assign('thread_poll', $model->getThreadPoll($thread['id']))->assign('page', $page)->assign('num', ($page - 1) * $model->config['pp_thread'] + 1)->assign('lastpage', ceil($thread['post_count'] / $model->config['pp_thread']))->assign('pagebar', cmsPage::getPagebar($thread['post_count'], $page, $model->config['pp_thread'], '/forum/thread' . $thread['id'] . '-%page%.html'))->assign('user_id', $inUser->id)->assign('do', $do)->assign('is_moder', $is_forum_moder)->assign('is_admin', $inUser->is_admin)->assign('is_can_add_post', cmsUser::isUserCan('forum/add_post'))->assign('cfg', $model->config)->assign('bb_toolbar', $inUser->id && $model->config['fast_on'] && $model->config['fast_bb'] ? cmsPage::getBBCodeToolbar('message', $model->config['img_on']) : '')->assign('smilies', $inUser->id && $model->config['fast_on'] && $model->config['fast_bb'] ? cmsPage::getSmilesPanel('message') : '')->display('com_forum_view_thread.tpl'); } //============================================================================// //================ Новая тема, написать/редактировать пост ===================// //============================================================================// if (in_array($do, array('newthread', 'newpost', 'editpost'))) { if (!$inUser->id) { cmsUser::goToLogin(); } // id первого поста в теме $first_post_id = false; // опросов по умолчанию нет $thread_poll = array(); // применяется при редактировании поста $is_allow_attach = true; // ограничение по карме if (in_array($do, array('newthread', 'newpost'))) { if ($inUser->karma < $model->config['min_karma_add'] && !$inUser->is_admin) { cmsCore::addSessionMessage(sprintf($_LANG['ADD_KARMA_LIMIT'], cmsCore::spellCount($model->config['min_karma_add'], $_LANG['KPOINT1'], $_LANG['KPOINT2'], $_LANG['KPOINT10']), $inUser->karma), 'error'); cmsCore::redirectBack(); } } // новая тема if ($do == 'newthread') { // права доступа if (!cmsUser::isUserCan('forum/add_thread') && !$inUser->is_admin) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $forum = $model->getForum($id); if (!$forum) { cmsCore::error404(); } if (!cmsCore::checkContentAccess($forum['access_list'])) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $path_list = $inDB->getNsCategoryPath('cms_forums', $forum['NSLeft'], $forum['NSRight'], 'id, title, access_list, moder_list'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $inPage->addPathway($pcat['title'], '/forum/' . $pcat['id']); } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } if (IS_BILLING && $forum['topic_cost']) { cmsBilling::checkBalance('forum', 'add_thread', false, $forum['topic_cost']); } $pagetitle = $_LANG['NEW_THREAD']; $thread = cmsUser::sessionGet('thread'); if ($thread) { cmsUser::sessionDel('thread'); } $last_post['content'] = cmsUser::sessionGet('post_content'); if ($last_post['content']) { cmsUser::sessionDel('post_content'); } } // новый пост if ($do == 'newpost') { // права доступа if (!cmsUser::isUserCan('forum/add_post') && !$inUser->is_admin) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $thread = $model->getThread($id); if (!$thread || $thread['closed']) { cmsCore::error404(); } $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $inPage->addPathway($pcat['title'], '/forum/' . $pcat['id']); } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } $inPage->addPathway($thread['title'], '/forum/thread' . $thread['id'] . '.html'); $pagetitle = $_LANG['NEW_POST']; $last_post = $model->getPost(cmsCore::request('replyid', 'int', 0)); if ($last_post) { $last_post['content'] = preg_replace('/\\[hide(.*?)\\](.*?)\\[\\/hide\\]/sui', '', $last_post['content']); $last_post['content'] = preg_replace('/\\[hide(.*?)\\](.*?)$/sui', '', $last_post['content']); $quote_nickname = $inDB->get_field('cms_users', "id = '{$last_post['user_id']}'", 'nickname'); $last_post['content'] = '[quote=' . $quote_nickname . ']' . "\r\n" . $last_post['content'] . "\r\n" . '[/quote]' . "\r\n\r\n"; $pagetitle = $_LANG['REPLY_FULL_QUOTE']; } } // редактирование поста if ($do == 'editpost') { $last_post = $model->getPost($id); if (!$last_post) { cmsCore::error404(); } $is_allow_attach = $last_post['attach_count'] < $model->config['fa_max']; // уменьшаем значение настроек согласно загруженных файлов $model->config['fa_max'] = $model->config['fa_max'] - $last_post['attach_count']; $thread = $model->getThread($last_post['thread_id']); if (!$thread || $thread['closed']) { cmsCore::error404(); } $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsPage::includeTemplateFile('special/accessdenied.php'); return; } $inPage->addPathway($pcat['title'], '/forum/' . $pcat['id']); } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } $inPage->addPathway($thread['title'], '/forum/thread' . $thread['id'] . '.html'); $end_min = $model->checkEditTime($last_post['pubdate']); $is_author_can_edit = (is_bool($end_min) ? $end_min : $end_min > 0) && $last_post['user_id'] == $inUser->id; // редактировать могут только администраторы, модераторы или авторы, если время есть if (!$inUser->is_admin && !$is_forum_moder && !$is_author_can_edit) { cmsCore::error404(); } if (!$inUser->is_admin && !$is_forum_moder && $model->config['edit_minutes']) { $msg_minute = str_replace('{min}', cmsCore::spellCount($end_min, $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10']), $_LANG['EDIT_INFO']); cmsCore::addSessionMessage($msg_minute, 'info'); } $first_post_id = $inDB->get_field('cms_forum_posts', "thread_id = '{$thread['id']}' ORDER BY pubdate ASC", 'id'); $thread_poll = $model->getThreadPoll($thread['id']); $pagetitle = $_LANG['EDIT_POST']; } ///////////////////////// /// Показываем форму /// ///////////////////////// if (!cmsCore::inRequest('gosend')) { $inPage->setTitle($pagetitle); $inPage->addPathway($pagetitle); $inPage->addHeadJsLang(array('FILE_SELECTED', 'FILE_DENIED', 'FILE_DUPLICATE')); cmsCore::initAutoGrowText('#message'); cmsPage::initTemplate('components', 'com_forum_add')->assign('pagetitle', $pagetitle)->assign('is_first_post', isset($last_post['id']) ? $first_post_id == $last_post['id'] : true)->assign('thread_poll', $thread_poll)->assign('cfg', $model->config)->assign('do', $do)->assign('forum', isset($forum) ? $forum : $pcat)->assign('is_subscribed', cmsUser::isSubscribed($inUser->id, 'forum', @$thread['id']))->assign('thread', $thread)->assign('post_content', htmlspecialchars($last_post['content']))->assign('is_moder', $is_forum_moder)->assign('is_admin', $inUser->is_admin)->assign('is_allow_attach', cmsCore::checkContentAccess($model->config['group_access']) && $is_allow_attach)->assign('bb_toolbar', cmsPage::getBBCodeToolbar('message', $model->config['img_on'], 'forum', 'post', @$last_post['id']))->assign('smilies', cmsPage::getSmilesPanel('message'))->display('com_forum_add.tpl'); } else { ///////////////////////// // Выполняем действия /// ///////////////////////// if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $message_bb = $inDB->escape_string(cmsCore::request('message', 'html', '')); $message_html = $inDB->escape_string(cmsCore::parseSmiles(cmsCore::request('message', 'html', ''), true)); if (!$message_html) { cmsCore::addSessionMessage($_LANG['NEED_TEXT_POST'], 'error'); cmsCore::redirectBack(); } $message_post = strip_tags($message_html); $message_post = mb_strlen($message_post) > 200 ? mb_substr($message_post, 0, 200) : $message_post; $post_pinned = 0; if (in_array($do, array('newthread', 'newpost'))) { if ($do == 'newthread') { $thread['title'] = cmsCore::request('title', 'str', ''); $thread['description'] = cmsCore::request('description', 'str', ''); $post_pinned = 1; if (!$thread['title']) { cmsCore::addSessionMessage($_LANG['NEED_TITLE_THREAD_YOUR_POST'], 'error'); cmsUser::sessionPut('thread', $thread); cmsUser::sessionPut('post_content', stripcslashes($message_bb)); cmsCore::redirectBack(); } $thread['is_hidden'] = cmsCore::yamlToArray($forum['access_list']) ? 1 : 0; $thread['forum_id'] = $forum['id']; $thread['user_id'] = $inUser->id; $thread['pubdate'] = date("Y-m-d H:i:s"); $thread['hits'] = 0; $thread['id'] = $model->addThread($thread); $thread['NSLeft'] = $forum['NSLeft']; $thread['NSRight'] = $forum['NSRight']; $thread['post_count'] = 0; if (IS_BILLING && $forum['topic_cost']) { cmsBilling::process('forum', 'add_thread', $forum['topic_cost']); } } $post_id = $model->addPost(array('thread_id' => $thread['id'], 'user_id' => $inUser->id, 'pinned' => $post_pinned, 'content' => $message_bb, 'content_html' => $message_html, 'pubdate' => date("Y-m-d H:i:s"), 'editdate' => date("Y-m-d H:i:s"))); // Обновляем количество постов в теме $thread_post_count = $model->updateThreadPostCount($thread['id']); // Закрываем тему если нужно $is_fixed = cmsCore::request('fixed', 'int', 0); if ($is_fixed && ($is_forum_moder || $inUser->is_admin || $thread['is_mythread'])) { $model->closeThread($thread['id']); } // Загружаем аттачи if ($model->config['fa_on'] && cmsCore::checkContentAccess($model->config['group_access'])) { $file_error = $model->addUpdatePostAttachments($post_id); if ($file_error === false) { cmsCore::addSessionMessage($_LANG['CHECK_SIZE_TYPE_FILE'] . $model->config['fa_max'], 'error'); } } // Обновляем кеши $model->updateForumCache($thread['NSLeft'], $thread['NSRight'], true); $total_pages = ceil($thread_post_count / $model->config['pp_thread']); // Проверяем награды cmsUser::checkAwards($inUser->id); // Рассылаем уведомления тем, кто подписан if ($do == 'newpost') { cmsUser::sendUpdateNotify('forum', $thread['id'], array('link' => '/forum/thread' . $thread['id'] . '-' . $total_pages . '.html#' . $post_id, 'title' => stripslashes($thread['title']), 'letter_file' => 'newforumpost', 'author' => $inUser->nickname)); } // Подписываемся сами если нужно if (cmsCore::inRequest('subscribe')) { cmsUser::subscribe($inUser->id, 'forum', $thread['id']); } // Если пост не в скрытый форум и не в объедненный с предыдущим, добавляем в ленту if (!$thread['is_hidden'] && $thread_post_count > $thread['post_count']) { if ($do == 'newthread') { cmsActions::log('add_thread', array('object' => $thread['title'], 'object_url' => '/forum/thread' . $thread['id'] . '-1.html', 'object_id' => $thread['id'], 'target' => $forum['title'], 'target_url' => '/forum/' . $forum['id'], 'target_id' => $forum['id'], 'description' => $message_post)); } else { cmsActions::log('add_fpost', array('object' => $_LANG['MESSAGE'], 'object_url' => '/forum/thread' . $thread['id'] . '-' . $total_pages . '.html#' . $post_id, 'object_id' => $post_id, 'target' => $thread['title'], 'target_url' => '/forum/thread' . $thread['id'] . '.html', 'target_id' => $thread['id'], 'description' => $message_post)); } } // Для новой темы прикрепляем опрос если нужно if ($do == 'newthread') { $model->addPoll(cmsCore::request('poll', 'array', array()), $thread['id']); $last_poll_error = $model->getLastAddPollError(); if ($last_poll_error) { cmsCore::addSessionMessage($last_poll_error, 'error'); cmsCore::redirect('/forum/editpost' . $post_id . '-1.html'); } } cmsCore::redirect('/forum/thread' . $thread['id'] . '-' . $total_pages . '.html#' . $post_id); } elseif ($do == 'editpost') { $model->updatePost(array('content' => $message_bb, 'content_html' => $message_html, 'edittimes' => $last_post['edittimes'] + 1, 'editdate' => date("Y-m-d H:i:s")), $last_post['id']); if ($model->config['fa_on'] && cmsCore::checkContentAccess($model->config['group_access'])) { $file_error = $model->addUpdatePostAttachments($last_post['id']); if ($file_error === false) { cmsCore::addSessionMessage($_LANG['CHECK_SIZE_TYPE_FILE'] . $model->config['fa_max'], 'error'); } } if ($first_post_id == $last_post['id']) { cmsActions::updateLog('add_thread', array('description' => $message_post), $thread['id']); if ($thread_poll) { $model->updatePoll(cmsCore::request('poll', 'array', array()), $thread_poll); } else { $model->addPoll(cmsCore::request('poll', 'array', array()), $thread['id']); } $last_poll_error = $model->getLastAddPollError(); if ($last_poll_error) { cmsUser::sessionPut('thread', $thread); cmsUser::sessionPut('post_content', stripcslashes($message_bb)); cmsCore::addSessionMessage($last_poll_error, 'error'); cmsCore::redirectBack(); } } else { cmsActions::updateLog('add_fpost', array('description' => $message_post), $last_post['id']); } $model->updateForumCache($thread['NSLeft'], $thread['NSRight'], true); cmsCore::redirect('/forum/thread' . $thread['id'] . '-' . $page . '.html#' . $last_post['id']); } } } ///////////////////////////// DELETE POST ///////////////////////////////////////////////////////////////////////////////////////////////// if ($do == 'deletepost') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } if (!$inUser->id) { cmsCore::error404(); } $post = $model->getPost($id); if (!$post) { cmsCore::error404(); } $thread = $model->getThread($post['thread_id']); if (!$thread) { cmsCore::error404(); } $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list, NSLeft, NSRight'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsCore::error404(); } } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } $end_min = $model->checkEditTime($post['pubdate']); $is_author_can_edit = (is_bool($end_min) ? $end_min : $end_min > 0) && $post['user_id'] == $inUser->id; if (!$inUser->is_admin && !($is_forum_moder && !cmsUser::userIsAdmin($post['user_id'])) && !$is_author_can_edit) { cmsCore::error404(); } $model->deletePost($post['id']); $model->updateThreadPostCount($post['thread_id']); $model->cacheThreadLastPost($post['thread_id']); if ($path_list) { $path_list = array_reverse($path_list); foreach ($path_list as $pcat) { $model->updateForumCache($pcat['NSLeft'], $pcat['NSRight']); } } cmsCore::addSessionMessage($_LANG['MSG_IS_DELETED'], 'info'); $total_pages = ceil(($thread['post_count'] - 1) / $model->config['pp_thread']); if ($page > $total_pages) { $page = $total_pages; } cmsCore::jsonOutput(array('error' => false, 'redirect' => '/forum/thread' . $thread['id'] . '-' . $page . '.html')); } //============================================================================// //========================== Операции с темами ===============================// //============================================================================// if (in_array($do, array('movethread', 'renamethread', 'deletethread', 'close', 'pin', 'pin_post', 'move_post'))) { if (!$inUser->id) { cmsCore::error404(); } $thread = $model->getThread($id); if (!$thread) { cmsCore::halt(); } $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list, NSLeft, NSRight'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsCore::halt(); } } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } //======================= Перемещение темы ===============================// if ($do == 'movethread') { if (!$inUser->is_admin && !$is_forum_moder) { cmsCore::halt(); } if (!cmsCore::inRequest('gomove')) { cmsPage::initTemplate('components', 'com_forum_move_thread')->assign('thread', $thread)->assign('forums', $model->getForums())->display('com_forum_move_thread.tpl'); cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean())); } else { $new_forum = $model->getForum(cmsCore::request('forum_id', 'int', 0)); if (!$new_forum) { cmsCore::error404(); } $is_hidden = 0; $path_list = $inDB->getNsCategoryPath('cms_forums', $new_forum['NSLeft'], $new_forum['NSRight'], 'id, title, access_list, moder_list'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsCore::halt(); } if (cmsCore::yamlToArray($pcat['access_list'])) { $is_hidden = 1; } } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } if (!$is_forum_moder && !$inUser->is_admin) { cmsCore::addSessionMessage($_LANG['YOU_NO_THIS_FORUM_MODER'], 'error'); cmsCore::redirect('/forum/thread' . $thread['id'] . '.html'); } $inDB->query("UPDATE cms_forum_threads SET forum_id = '{$new_forum['id']}', is_hidden = '{$is_hidden}' WHERE id = '{$thread['id']}'"); cmsActions::updateLog('add_thread', array('target' => $new_forum['title'], 'target_url' => '/forum/' . $new_forum['id'], 'target_id' => $new_forum['id']), $thread['id']); // Обновляем кешированные значения // для старого форума $model->updateForumCache($thread['NSLeft'], $thread['NSRight'], true); // для нового форума $model->updateForumCache($new_forum['NSLeft'], $new_forum['NSRight'], true); cmsCore::addSessionMessage($_LANG['THREAD_IS_MOVE'] . '"' . $new_forum['title'] . '"', 'success'); cmsCore::redirect('/forum/thread' . $thread['id'] . '.html'); } } //===================== Переименование темы ==============================// if ($do == 'renamethread') { if (!$inUser->is_admin && !$is_forum_moder && !$thread['is_mythread']) { cmsCore::halt(); } if (!cmsCore::inRequest('gorename')) { cmsPage::initTemplate('components', 'com_forum_rename_thread')->assign('thread', $thread)->display('com_forum_rename_thread.tpl'); cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean())); } else { $new_thread['title'] = cmsCore::request('title', 'str', $thread['title']); $new_thread['description'] = cmsCore::request('description', 'str', ''); $model->updateThread($new_thread, $thread['id']); cmsActions::updateLog('add_fpost', array('target' => $new_thread['title']), 0, $thread['id']); cmsActions::updateLog('add_thread', array('object' => $new_thread['title']), $thread['id']); $model->updateForumCache($thread['NSLeft'], $thread['NSRight'], true); cmsCore::jsonOutput(array('error' => false, 'title' => stripslashes($new_thread['title']), 'description' => stripslashes($new_thread['description']))); } } //======================= Удаление темы ==================================// if ($do == 'deletethread') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } if (!$inUser->is_admin && !($is_forum_moder && !cmsUser::userIsAdmin($thread['user_id'])) && !$thread['is_mythread']) { cmsCore::halt(); } $model->deleteThread($thread['id']); // Обновляем кешированные значения $model->updateForumCache($thread['NSLeft'], $thread['NSRight'], true); cmsCore::jsonOutput(array('error' => false, 'redirect' => '/forum/' . $thread['forum_id'])); } //=============== Прикрепление/открепление темы ==========================// if ($do == 'pin') { if (!$inUser->is_admin && !$is_forum_moder) { cmsCore::halt(); } $pinned = cmsCore::request('pinned', 'int', 0); $inDB->query("UPDATE cms_forum_threads SET pinned = '{$pinned}' WHERE id = '{$thread['id']}'"); cmsCore::halt($pinned); } //========== Прикрепление/открепление сообщения темы =====================// if ($do == 'pin_post') { if (!$inUser->is_admin && !$is_forum_moder) { cmsCore::halt(); } $pinned = cmsCore::request('pinned', 'int', 0); $post_id = cmsCore::request('post_id', 'int', 0); // Проверяем, принадлежит ли сообщение теме if (!$model->isBelongsToPostTopic($post_id, $thread['id'])) { cmsCore::halt(); } $inDB->query("UPDATE cms_forum_posts SET pinned = '{$pinned}' WHERE id = '{$post_id}' AND thread_id = '{$thread['id']}'"); // Ниже строки для тех, кто обновлялся с 1.9, если чистая установка, их можно удалить // Ставим принудительно для первого поста темы флаг pinned if ($pinned) { $first_post_id = $inDB->get_field('cms_forum_posts', "thread_id = '{$thread['id']}' ORDER BY pubdate ASC", 'id'); $inDB->query("UPDATE cms_forum_posts SET pinned = 1 WHERE id = '{$first_post_id}' AND thread_id = '{$thread['id']}'"); } cmsCore::redirect('/forum/thread' . $thread['id'] . '-1.html#' . $post_id); } //=========================== Перенос сообщения темы =====================// if ($do == 'move_post') { if (!$inUser->is_admin && !$is_forum_moder) { cmsCore::halt(); } $post_id = cmsCore::request('post_id', 'int', 0); // Проверяем, принадлежит ли сообщение теме if (!$model->isBelongsToPostTopic($post_id, $thread['id'])) { cmsCore::halt(); } cmsCore::callEvent('MOVE_FORUM_POST', array('thread' => $thread, 'post_id' => $post_id)); if (!cmsCore::inRequest('gomove')) { cmsPage::initTemplate('components', 'com_forum_move_post')->assign('thread', $thread)->assign('post_id', $post_id)->assign('threads', cmsCore::getListItems('cms_forum_threads', $thread['id'], 'title', 'ASC', "forum_id = '{$thread['forum_id']}'"))->display('com_forum_move_post.tpl'); cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean())); } else { $new_thread = $model->getThread(cmsCore::request('new_thread_id', 'int', 0)); if (!$new_thread) { cmsCore::error404(); } $n_path_list = $inDB->getNsCategoryPath('cms_forums', $new_thread['NSLeft'], $new_thread['NSRight'], 'id, title, access_list, moder_list, NSLeft, NSRight'); if ($n_path_list) { foreach ($n_path_list as $n_pcat) { if (!cmsCore::checkContentAccess($n_pcat['access_list'])) { cmsCore::halt(); } } $is_forum_moder = $model->isForumModerator($n_pcat['moder_list']); } if (!$is_forum_moder && !$inUser->is_admin) { cmsCore::error404(); } $model->updatePost(array('thread_id' => $new_thread['id'], 'pubdate' => date("Y-m-d H:i:s")), $post_id); $model->updateThreadPostCount($thread['id']); $thread_post_count = $model->updateThreadPostCount($new_thread['id']); $total_pages = ceil($thread_post_count / $model->config['pp_thread']); cmsActions::updateLog('add_fpost', array('target' => $new_thread['title'], 'target_url' => '/forum/thread' . $new_thread['id'] . '.html', 'target_id' => $new_thread['id'], 'object_url' => '/forum/thread' . $new_thread['id'] . '-' . $total_pages . '.html#' . $post_id, 'pubdate' => date("Y-m-d H:i:s")), $post_id); $model->cacheThreadLastPost($thread['id']); if ($path_list) { $path_list = array_reverse($path_list); foreach ($path_list as $pcat) { $model->cacheLastPost($pcat['NSLeft'], $pcat['NSRight']); } } if ($n_path_list) { $n_path_list = array_reverse($n_path_list); foreach ($n_path_list as $pcat) { $model->cacheLastPost($pcat['NSLeft'], $pcat['NSRight']); } } cmsCore::addSessionMessage($_LANG['POST_IS_MOVE'] . '"' . $new_thread['title'] . '"', 'success'); cmsCore::redirect('/forum/thread' . $new_thread['id'] . '-' . $total_pages . '.html#' . $post_id); } } //==================== Открытие/закрытие темы ============================// if ($do == 'close') { if (!$inUser->is_admin && !$is_forum_moder && !$thread['is_mythread']) { cmsCore::halt(); } $closed = cmsCore::request('closed', 'int', 0); if ($closed) { $model->closeThread($thread['id']); } else { $model->openThread($thread['id']); } cmsCore::halt($closed); } cmsCore::halt(); } //============================================================================// //========================== Операции с файлами ==============================// //============================================================================// if (in_array($do, array('download', 'delfile', 'reloadfile'))) { if (!$model->config['fa_on']) { cmsCore::error404(); } $file = $model->getPostAttachment($id); if (!$file) { cmsCore::error404(); } $post = $model->getPost($file['post_id']); if (!$post) { cmsCore::error404(); } $thread = $model->getThread($post['thread_id']); if (!$thread) { cmsCore::error404(); } $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsCore::error404(); } } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } //================= Скачивание прикрепленного файла ======================// if ($do == 'download') { $location = PATH . '/upload/forum/post' . $file['post_id'] . '/' . $file['filename']; if (!file_exists($location)) { cmsCore::error404(); } $inDB->query("UPDATE cms_forum_files SET hits = hits + 1 WHERE id = '{$file['id']}'"); ob_clean(); header('Content-Disposition: attachment; filename=' . htmlspecialchars($file['filename'])); header('Content-Type: application/x-force-download; name="' . htmlspecialchars($file['filename']) . '"'); header('Content-Length: ' . $file['filesize']); header('Accept-Ranges: bytes'); cmsCore::halt(file_get_contents($location)); } //=================== Удаление прикрепленного файла ======================// if ($do == 'delfile') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $end_min = $model->checkEditTime($post['pubdate']); $is_author_can_edit = (is_bool($end_min) ? $end_min : $end_min > 0) && $post['user_id'] == $inUser->id && cmsCore::checkContentAccess($model->config['group_access']); if (!$inUser->is_admin && !$is_forum_moder && !$is_author_can_edit) { cmsCore::halt(); } $model->deletePostAttachment($file); cmsCore::halt(1); } //================== Перезакачка прикрепленного файла ====================// if ($do == 'reloadfile') { $end_min = $model->checkEditTime($post['pubdate']); $is_author_can_edit = (is_bool($end_min) ? $end_min : $end_min > 0) && $post['user_id'] == $inUser->id && cmsCore::checkContentAccess($model->config['group_access']); if (!$inUser->is_admin && !$is_forum_moder && !$is_author_can_edit) { cmsCore::error404(); } if (!cmsCore::inRequest('goreload')) { cmsPage::initTemplate('components', 'com_forum_file_reload')->assign('file', $file)->assign('cfg', $model->config)->display('com_forum_file_reload.tpl'); cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean())); } else { $success = $model->addUpdatePostAttachments($post['id'], $file); if ($success) { $post['attached_files'] = $model->getPostAttachments($post['id']); $post['is_author_can_edit'] = $is_author_can_edit; cmsPage::initTemplate('components', 'com_forum_attached_files')->assign('post', $post)->assign('is_moder', $is_forum_moder)->assign('is_admin', $inUser->is_admin)->assign('cfg', $model->config)->display('com_forum_attached_files.tpl'); cmsCore::jsonOutput(array('error' => false, 'post_id' => $post['id'], 'html' => ob_get_clean())); } else { cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['CHECK_SIZE_TYPE_FILE'] . $model->config['fa_max'])); } } } cmsCore::halt(); } //============================================================================// //========================= Операции с опросами ==============================// //============================================================================// if ($do == 'view_poll') { $thread = $model->getThread($id); if (!$thread) { cmsCore::halt(); } $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsCore::halt(); } } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } $thread_poll = $model->getThreadPoll($thread['id']); if (!$thread_poll) { cmsCore::halt(); } if ($inUser->id && $thread_poll['is_user_vote'] && $thread_poll['options']['change'] && cmsCore::request('revote', 'int')) { $model->deleteVote($thread_poll); $thread_poll['is_user_vote'] = 0; $thread_poll['vote_count'] -= 1; } if (!$thread_poll['is_user_vote'] && !$thread_poll['options']['result']) { $thread_poll['show_result'] = cmsCore::request('show_result', 'int'); } cmsPage::initTemplate('components', 'com_forum_thread_poll')->assign('thread', $thread)->assign('thread_poll', $thread_poll)->assign('user_id', $inUser->id)->assign('do', $thread_poll['show_result'] ? $do : 'thread')->assign('is_moder', $is_forum_moder)->assign('is_admin', $inUser->is_admin)->display('com_forum_thread_poll.tpl'); cmsCore::halt(ob_get_clean()); } if ($do == 'delete_poll') { if (!$inUser->id) { cmsCore::halt(); } if (!cmsUser::checkCsrfToken()) { cmsCore::halt(); } $thread = $model->getThread($id); if (!$thread) { cmsCore::halt(); } $path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list'); if ($path_list) { foreach ($path_list as $pcat) { if (!cmsCore::checkContentAccess($pcat['access_list'])) { cmsCore::halt(); } } $is_forum_moder = $model->isForumModerator($pcat['moder_list']); } $thread_poll = $model->getThreadPoll($thread['id']); if (!$thread_poll) { cmsCore::halt(); } if (!$is_forum_moder && !$inUser->is_admin) { cmsCore::halt(); } $model->deletePoll($thread_poll['id']); cmsCore::halt(1); } if ($do == 'vote_poll') { if (!$inUser->id) { cmsCore::halt(); } if (!cmsUser::checkCsrfToken()) { cmsCore::halt(); } $answer = cmsCore::request('answer', 'str', ''); $poll = $model->getPollById(cmsCore::request('poll_id', 'int')); if (!$answer || !$poll) { cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['SELECT_THE_OPTION'])); } if ($model->isUserVoted($poll['id'])) { cmsCore::jsonOutput(array('error' => true, 'text' => '')); } $model->votePoll($poll, $answer); cmsCore::jsonOutput(array('error' => false, 'text' => '')); } //============================================================================// //========================= Последние сообщения ==============================// //============================================================================// if ($do == 'latest_posts') { $inActions = cmsActions::getInstance(); $inPage->setTitle($_LANG['LATEST_POSTS_ON_FORUM']); $inPage->addPathway($_LANG['FORUMS'], '/forum'); $inPage->addPathway($_LANG['LATEST_POSTS_ON_FORUM']); $inActions->showTargets(true); $action = $inActions->getAction('add_fpost'); $inActions->onlySelectedTypes(array($action['id'])); $total = $inActions->getCountActions(); $inDB->limitPage($page, 15); $actions = $inActions->getActionsLog(); if (!$actions && $page > 1) { cmsCore::error404(); } cmsPage::initTemplate('components', 'com_forum_actions')->assign('actions', $actions)->assign('total', $total)->assign('do', $do)->assign('user_id', $inUser->id)->assign('pagetitle', $_LANG['LATEST_POSTS_ON_FORUM'])->assign('pagebar', cmsPage::getPagebar($total, $page, 15, '/forum/latest_posts/page-%page%'))->display('com_forum_actions.tpl'); } //============================================================================// //============================= Последние темы ===============================// //============================================================================// if ($do == 'latest_thread') { $inActions = cmsActions::getInstance(); $inPage->setTitle($_LANG['NEW_THREADS_ON_FORUM']); $inPage->addPathway($_LANG['FORUMS'], '/forum'); $inPage->addPathway($_LANG['NEW_THREADS_ON_FORUM']); $inActions->showTargets(true); $action = $inActions->getAction('add_thread'); $inActions->onlySelectedTypes(array($action['id'])); $total = $inActions->getCountActions(); $inDB->limitPage($page, 15); $actions = $inActions->getActionsLog(); if (!$actions && $page > 1) { cmsCore::error404(); } cmsPage::initTemplate('components', 'com_forum_actions')->assign('actions', $actions)->assign('total', $total)->assign('do', $do)->assign('user_id', $inUser->id)->assign('pagetitle', $_LANG['NEW_THREADS_ON_FORUM'])->assign('pagebar', cmsPage::getPagebar($total, $page, 15, '/forum/latest_thread/page-%page%'))->display('com_forum_actions.tpl'); } //============================================================================// //========================== Просмотр категории ==============================// //============================================================================// if ($do == 'view_cat') { $cat = $model->getForumCat(cmsCore::request('seolink', 'str', '')); if (!$cat) { cmsCore::error404(); } $cat = translations::process(cmsConfig::getConfig('lang'), 'forum_forum_cats', $cat); $inPage->setTitle($cat['pagetitle'] ? $cat['pagetitle'] : $cat['title']); $inPage->setDescription($cat['meta_desc'] ? $cat['meta_desc'] : $cat['title']); $inPage->setKeywords($cat['meta_keys'] ? $cat['meta_keys'] : $cat['title']); $inPage->addPathway($cat['title']); $model->whereForumCatIs($cat['id']); $sub_forums = $model->getForums(); cmsPage::initTemplate('components', 'com_forum_list')->assign('pagetitle', $cat['title'])->assign('forums', $sub_forums)->assign('forum', array())->assign('cfg', $model->config)->assign('user_id', false)->display('com_forum_list.tpl'); $inDB->addJoin('INNER JOIN cms_forums f ON f.id = t.forum_id'); $inDB->where("t.is_hidden = 0"); $model->whereForumCatIs($cat['id']); $inDB->orderBy('t.pubdate', 'DESC, t.hits DESC'); $inDB->limit(15); $threads = $model->getThreads(); cmsPage::initTemplate('components', 'com_forum_view')->assign('threads', $threads)->display('com_forum_view.tpl'); } //============================================================================// //===================== Активность пользователя ==============================// //============================================================================// if ($do == 'user_activity') { $login = cmsCore::request('login', 'str', $inUser->login); $sub_do = cmsCore::request('sub_do', 'str', 'threads'); $user = cmsUser::getShortUserData($login); if (!$user) { cmsCore::error404(); } $my_profile = $inUser->login == $login; $pagetitle = $my_profile ? $_LANG['MY_ACTIVITY'] : $user['nickname'] . ' - ' . $_LANG['ACTIVITY_ON_FORUM']; $inPage->setTitle($pagetitle); $inPage->addPathway($pagetitle); $threads = array(); $posts = array(); if (!$my_profile && !$inUser->is_admin) { $model->wherePublicThreads(); } $model->whereThreadUserIs($user['id']); $thread_count = $model->getThreadsCount(); if ($sub_do == 'threads' && $thread_count) { $inDB->orderBy('t.pubdate', 'DESC, t.hits DESC'); $inDB->limitPage($page, 15); $threads = $model->getThreads(); $pagination = cmsPage::getPagebar($thread_count, $page, 15, "javascript:forum.getUserActivity('threads','/forum/{$user['login']}_activity.html','%page%');"); } $inDB->resetConditions(); // Если тем у пользователя нет, показываем вкладку сообщений if (!$thread_count) { $sub_do = 'posts'; } $inDB->addSelect('t.title as thread_title'); $inDB->addJoin('INNER JOIN cms_forum_threads t ON t.id = p.thread_id'); $model->wherePostUserIs($user['id']); if (!$my_profile && !$inUser->is_admin) { $model->wherePublicThreads(); } $post_count = $model->getPostsCount(); // Если сообщений нет, 404 if (!$post_count && !$my_profile) { cmsCore::error404(); } if ($sub_do == 'posts' && $post_count) { $inDB->orderBy('p.thread_id', 'DESC, p.pubdate DESC'); $inDB->limitPage($page, 10); $posts = $model->getPosts(); $pagination = cmsPage::getPagebar($post_count, $page, 10, "javascript:forum.getUserActivity('posts','/forum/{$user['login']}_activity.html','%page%');"); } $inDB->resetConditions(); cmsPage::initTemplate('components', 'com_forum_user_activity')->assign('threads', $threads)->assign('posts', $posts)->assign('post_count', $post_count)->assign('thread_count', $thread_count)->assign('pagetitle', $pagetitle)->assign('sub_do', $sub_do)->assign('page', $page)->assign('user_id', $user['id'])->assign('my_profile', $my_profile)->assign('is_admin', $inUser->is_admin)->assign('is_moderator', cmsUser::isUserCan('forum/moderate'))->assign('pagination', $pagination)->assign('link', '/forum/' . $user['login'] . '_activity.html')->display('com_forum_user_activity.tpl'); } //////////////////////////////////////////////////////////////////////////////// if ($do == 'delete_all_user_posts') { if (!$inUser->id) { cmsCore::error404(); } if (!$inUser->is_admin && !cmsUser::isUserCan('forum/moderate')) { cmsCore::error404(); } if (!cmsUser::checkCsrfToken()) { cmsCore::halt(); } $user = cmsUser::getShortUserData(cmsCore::request('user_id', 'int', 0)); if (!$user || $user['id'] == $inUser->id) { cmsCore::error404(); } $model->deleteAllUserPosts($user['id']); cmsCore::addSessionMessage($_LANG['ALL_USERPOSTS_ISDELETED'], 'success'); cmsCore::halt(); } }
function blog() { $inCore = cmsCore::getInstance(); $inPage = cmsPage::getInstance(); $inDB = cmsDatabase::getInstance(); $inUser = cmsUser::getInstance(); cmsCore::loadClass('blog'); $inBlog = cmsBlogs::getInstance(); $inBlog->owner = 'site'; global $_LANG; cmsCore::loadModel('blog'); $model = new cms_model_blog(); define('IS_BILLING', $inCore->isComponentInstalled('billing')); if (IS_BILLING) { cmsCore::loadClass('billing'); } // Проверяем включени ли компонент if (!$model->config['component_enabled']) { cmsCore::error404(); } //Получаем параметры $id = cmsCore::request('id', 'int', 0); $post_id = cmsCore::request('post_id', 'int', 0); $seolink = cmsCore::request('seolink', 'str', ''); $do = cmsCore::request('do', 'str', 'blog'); $page = cmsCore::request('page', 'int', 1); $cat_id = cmsCore::request('cat_id', 'int', 0); $ownertype = cmsCore::request('ownertype', 'str', ''); $on_moderate = cmsCore::request('on_moderate', 'int', 0); $pagetitle = $inCore->menuTitle(); $pagetitle = $pagetitle && $inCore->isMenuIdStrict() ? $pagetitle : $_LANG['RSS_BLOGS']; $inPage->addPathway($pagetitle, '/blog'); $inPage->setTitle($pagetitle); $inPage->setDescription($pagetitle); $blog_id = 25; ////////// НАСТРОЙКИ БЛОГА //////////////////////////////////////////////////////////////////////////////////////// if ($do == 'config') { if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { cmsCore::halt(); } if (!$inUser->id) { cmsCore::halt(); } // получаем блог $blog = $inBlog->getBlog($id); if (!$blog) { cmsCore::error404(); } //Проверяем является пользователь хозяином блога или админом if ($blog['user_id'] != $inUser->id && !$inUser->is_admin) { cmsCore::halt(); } //Если нет запроса на сохранение, показываем форму настроек блога if (!cmsCore::inRequest('goadd')) { //Получаем список авторов блога $authors = $inBlog->getBlogAuthors($blog['id']); $smarty = $inCore->initSmarty('components', 'com_blog_config.tpl'); $smarty->assign('blog', $blog); $smarty->assign('form_action', '/blog/' . $blog['id'] . '/editblog.html'); $smarty->assign('authors_list', cmsUser::getAuthorsList($authors)); $smarty->assign('users_list', cmsUser::getUsersList(false, $authors)); $smarty->assign('is_restrictions', !$inUser->is_admin && $model->config['min_karma']); $smarty->assign('cfg', $model->config); $smarty->display('com_blog_config.tpl'); cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean())); } //Если пришел запрос на сохранение if (cmsCore::inRequest('goadd')) { if (!cmsCore::validateForm()) { cmsCore::halt(); } //Получаем настройки $title = cmsCore::request('title', 'str'); $allow_who = cmsCore::request('allow_who', 'str', 'all'); $ownertype = cmsCore::request('ownertype', 'str', 'single'); $premod = cmsCore::request('premod', 'int', 0); $forall = cmsCore::request('forall', 'int', 1); $showcats = cmsCore::request('showcats', 'int', 1); $authors = cmsCore::request('authorslist', 'array_int', array()); //Проверяем настройки if (mb_strlen($title) < 5) { $title = $blog['title']; } //Проверяем ограничения по карме (для смены типа блога) if ($model->config['min_karma'] && !$inUser->is_admin) { // если персональный блог if ($ownertype == 'single' && $inUser->karma < $model->config['min_karma_private']) { cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['BLOG_YOU_NEED'] . ' <a href="/users/' . $inUser->id . '/karma.html">' . $_LANG['BLOG_KARMS'] . '</a> ' . $_LANG['FOR_CREATE_PERSON_BLOG'] . ' — ' . $model->config['min_karma_private'] . ', ' . $_LANG['BLOG_HEAVING'] . ' — ' . $inUser->karma)); } // если коллективный блог if ($ownertype == 'multi' && $inUser->karma < $model->config['min_karma_public']) { cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['BLOG_YOU_NEED'] . ' <a href="/users/' . $inUser->id . '/karma.html">' . $_LANG['BLOG_KARMS'] . '</a> ' . $_LANG['FOR_CREATE_TEAM_BLOG'] . ' — ' . $model->config['min_karma_public'] . ', ' . $_LANG['BLOG_HEAVING'] . ' — ' . $inUser->karma)); } } //сохраняем авторов $inBlog->updateBlogAuthors($blog['id'], $authors); //сохраняем настройки блога $blog['seolink_new'] = $inBlog->updateBlog($blog['id'], array('title' => $title, 'allow_who' => $allow_who, 'showcats' => $showcats, 'ownertype' => $ownertype, 'premod' => $premod, 'forall' => $forall), $model->config['update_seo_link_blog']); $blog['seolink'] = $blog['seolink_new'] ? $blog['seolink_new'] : $blog['seolink']; if (stripslashes($title) != $blog['title']) { // обновляем записи постов cmsActions::updateLog('add_post', array('target' => $title, 'target_url' => $model->getBlogURL()), 0, $blog['id']); // обновляем запись добавления блога cmsActions::updateLog('add_blog', array('object' => $title, 'object_url' => $model->getBlogURL()), $blog['id']); } // Очищаем токен cmsUser::clearCsrfToken(); cmsCore::jsonOutput(array('error' => false, 'redirect' => $model->getBlogURL())); } } ////////// ПРОСМОТР БЛОГА //////////////////////////////////////////////////////////////////////////////////////// if ($do == 'blog') { // получаем блог $blog = $inBlog->getBlog($blog_id); if (!$blog) { cmsCore::error404(); } // Права доступа $myblog = $inUser->id && $inUser->id == $blog['user_id']; // автор блога $is_writer = $inBlog->isUserBlogWriter($blog, $inUser->id); // может ли пользователь писать в блог // Заполняем head страницы $inPage->setTitle($blog['title']); //$inPage->addPathway($blog['title'], $model->getBlogURL($blog['seolink'])); $inPage->setDescription($blog['title']); // rss в адресной строке $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . htmlspecialchars(strip_tags($blog['title'])) . '" href="' . HOST . '/rss/blogs/' . $blog['id'] . '/feed.rss">'); if ($myblog || $inUser->is_admin) { $inPage->addHeadJS('components/blog/js/blog.js'); } //Если доступа нет, возвращаемся и выводим сообщение об ошибке if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])) { cmsCore::addSessionMessage($_LANG['CLOSED_BLOG'] . '<br>' . $_LANG['CLOSED_BLOG_TEXT'], 'error'); cmsCore::redirect('/'); } // Если показываем посты на модерации, если запрашиваем их if ($on_moderate) { if (!$inUser->is_admin && !($myblog && $blog['ownertype'] == 'multi' && $blog['premod'])) { cmsCore::error404(); } $inBlog->whereNotPublished(); $inPage->setTitle($_LANG['POSTS_ON_MODERATE']); $inPage->addPathway($_LANG['POSTS_ON_MODERATE']); $blog['title'] .= ' - ' . $_LANG['POSTS_ON_MODERATE']; } //Получаем html-код ссылки на автора с иконкой его пола $blog['author'] = cmsUser::getGenderLink($blog['user_id']); // посты данного блога $inBlog->whereBlogIs($blog['id']); // кроме админов автора в списке только с доступом для всех if (!$inUser->is_admin && !$myblog) { $inBlog->whereOnlyPublic(); } // если пришла категория if ($cat_id) { $all_total = $inBlog->getPostsCount($inUser->is_admin || $myblog); $inBlog->whereCatIs($cat_id); } // всего постов $total = $inBlog->getPostsCount($inUser->is_admin || $myblog); //устанавливаем сортировку $inDB->orderBy('p.pubdate', 'DESC'); $inDB->limitPage($page, $model->config['perpage']); // сами посты $posts = $inBlog->getPosts($inUser->is_admin || $myblog, $model); if (!$posts && $page > 1) { cmsCore::error404(); } //Если нужно, получаем список рубрик (категорий) этого блога $blogcats = $blog['showcats'] ? $inBlog->getBlogCats($blog['id']) : false; //Считаем количество постов, ожидающих модерации $on_moderate = ($inUser->is_admin || $myblog) && !$on_moderate ? $inBlog->getModerationCount($blog['id']) : false; // админлинки $blog['moderate_link'] = $model->getBlogURL() . '/moderate.html'; $blog['blog_link'] = $model->getBlogURL(); $blog['add_post_link'] = '/blog/newpost' . ($cat_id ? $cat_id : '') . '.html'; //Генерируем панель со страницами if ($cat_id) { $pagination = cmsPage::getPagebar($total, $page, $model->config['perpage'], $blog['blog_link'] . '/page-%page%/cat-' . $cat_id); } else { $pagination = cmsPage::getPagebar($total, $page, $model->config['perpage'], $blog['blog_link'] . '/page-%page%'); } $smarty = $inCore->initSmarty('components', 'com_blog_view.tpl'); $smarty->assign('myblog', $myblog); $smarty->assign('is_config', true); $smarty->assign('is_admin', $inUser->is_admin); $smarty->assign('is_writer', $is_writer); $smarty->assign('on_moderate', $on_moderate); $smarty->assign('cat_id', $cat_id); $smarty->assign('blogcats', $blogcats); $smarty->assign('total', $total); $smarty->assign('all_total', isset($all_total) ? $all_total : 0); $smarty->assign('blog', $blog); $smarty->assign('posts', $posts); $smarty->assign('pagination', $pagination); $smarty->display('com_blog_view.tpl'); } ////////// НОВЫЙ ПОСТ / РЕДАКТИРОВАНИЕ ПОСТА ////////////////////////////////////////////////////////////////// if ($do == 'newpost' || $do == 'editpost') { // для редактирования сначала получаем пост if ($do == 'editpost') { $post = $inBlog->getPost($post_id); if (!$post) { cmsCore::error404(); } $id = $post['blog_id']; $post['tags'] = cmsTagLine('blogpost', $post['id'], false); } // получаем блог $blog = $inBlog->getBlog($blog_id); if (!$blog) { cmsCore::error404(); } //Если доступа нет, возвращаемся и выводим сообщение об ошибке if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])) { cmsCore::addSessionMessage($_LANG['CLOSED_BLOG'] . '<br>' . $_LANG['CLOSED_BLOG_TEXT'], 'error'); cmsCore::redirect('/blog'); } // Права доступа $myblog = $inUser->id && $inUser->id == $blog['user_id']; // автор блога $is_writer = $inBlog->isUserBlogWriter($blog, $inUser->id); // может ли пользователь писать в блог // если не его блог, пользователь не писатель и не админ, вне зависимости от авторства показываем 404 if (!$myblog && !$is_writer && !$inUser->is_admin) { cmsCore::error404(); } // проверяем является ли пользователь автором, если редактируем пост if ($do == 'editpost' && !$inUser->is_admin && $post['user_id'] != $inUser->id) { cmsCore::error404(); } //Если еще не было запроса на сохранение if (!cmsCore::inRequest('goadd')) { $inPage->addPathway($blog['title'], $model->getBlogURL()); //для нового поста if ($do == 'newpost') { if (IS_BILLING) { cmsBilling::checkBalance('blogs', 'add_post'); } $inPage->addPathway($_LANG['NEW_POST']); $inPage->setTitle($_LANG['NEW_POST']); $post = cmsUser::sessionGet('mod'); if ($post) { cmsUser::sessionDel('mod'); } else { $post['cat_id'] = $cat_id; $post['comments'] = 1; } } //для редактирования поста if ($do == 'editpost') { $inPage->addPathway($post['title'], $model->getPostURL('', $post['seolink'])); $inPage->addPathway($_LANG['EDIT_POST']); $inPage->setTitle($_LANG['EDIT_POST']); } $inPage->initAutocomplete(); $autocomplete_js = $inPage->getAutocompleteJS('tagsearch', 'tags'); //получаем рубрики блога $cat_list = cmsCore::getListItems('cms_blog_cats', $post['cat_id'], 'id', 'ASC', "blog_id = '{$blog['id']}'"); //получаем код панелей bbcode и смайлов $bb_toolbar = cmsPage::getBBCodeToolbar('message', $model->config['img_on'], 'blogs', 'post', $post_id); $smilies = cmsPage::getSmilesPanel('message'); $inCore->initAutoGrowText('#message'); //показываем форму $smarty = $inCore->initSmarty('components', 'com_blog_edit_post.tpl'); $smarty->assign('blog', $blog); $smarty->assign('pagetitle', $do == 'editpost' ? $_LANG['EDIT_POST'] : $_LANG['NEW_POST']); $smarty->assign('mod', $post); $smarty->assign('cat_list', $cat_list); $smarty->assign('bb_toolbar', $bb_toolbar); $smarty->assign('smilies', $smilies); $smarty->assign('is_admin', $inUser->is_admin); $smarty->assign('myblog', $myblog); $smarty->assign('user_can_iscomments', cmsUser::isUserCan('comments/iscomments')); $smarty->assign('autocomplete_js', $autocomplete_js); $smarty->display('com_blog_edit_post.tpl'); } //Если есть запрос на сохранение if (cmsCore::inRequest('goadd')) { $error = false; //Получаем параметры $mod['title'] = cmsCore::request('title', 'str'); $mod['content'] = cmsCore::request('content', 'html'); $mod['feel'] = cmsCore::request('feel', 'str', ''); $mod['music'] = cmsCore::request('music', 'str', ''); $mod['cat_id'] = cmsCore::request('cat_id', 'int'); $mod['allow_who'] = cmsCore::request('allow_who', 'str', $blog['allow_who']); $mod['tags'] = cmsCore::request('tags', 'str', ''); $mod['comments'] = cmsCore::request('comments', 'int', 1); $mod['published'] = $myblog || !$blog['premod'] ? 1 : 0; $mod['blog_id'] = $blog['id']; //Проверяем их if (mb_strlen($mod['title']) < 2) { cmsCore::addSessionMessage($_LANG['POST_ERR_TITLE'], 'error'); $errors = true; } if (mb_strlen($mod['content']) < 5) { cmsCore::addSessionMessage($_LANG['POST_ERR_TEXT'], 'error'); $errors = true; } // Если есть ошибки, возвращаемся назад if ($errors) { cmsUser::sessionPut('mod', $mod); cmsCore::redirectBack(); } //Если нет ошибок //добавляем новый пост... if ($do == 'newpost') { if (IS_BILLING) { cmsBilling::process('blogs', 'add_post'); } $mod['pubdate'] = date('Y-m-d H:i:s'); $mod['user_id'] = $inUser->id; // добавляем пост, получая его id и seolink $added = $inBlog->addPost($mod); if ($mod['published']) { if ($blog['allow_who'] != 'nobody' && $mod['allow_who'] != 'nobody') { cmsActions::log('add_post', array('object' => $mod['title'], 'object_url' => $model->getPostURL('', $added['seolink']), 'object_id' => $added['id'], 'target' => $blog['title'], 'target_url' => $model->getBlogURL(), 'target_id' => $blog['id'], 'description' => '', 'is_friends_only' => (int) ($blog['allow_who'] == 'friends' || $mod['allow_who'] == 'friends'))); } cmsCore::addSessionMessage($_LANG['POST_CREATED'], 'success'); cmsCore::redirect($model->getPostURL('', $added['seolink'])); } if (!$mod['published']) { $message = str_replace('%user%', cmsUser::getProfileLink($inUser->login, $inUser->nickname), $_LANG['MSG_POST_SUBMIT']); $message = str_replace('%post%', '<a href="' . $model->getPostURL('', $added['seolink']) . '">' . $mod['title'] . '</a>', $message); $message = str_replace('%blog%', '<a href="' . $model->getBlogURL() . '">' . $blog['title'] . '</a>', $message); cmsUser::sendMessage(USER_UPDATER, $blog['user_id'], $message); cmsCore::addSessionMessage($_LANG['POST_PREMODER_TEXT'], 'info'); cmsCore::redirect($model->getBlogURL()); } } //...или сохраняем пост после редактирования if ($do == 'editpost') { if ($model->config['update_date']) { $mod['pubdate'] = date('Y-m-d H:i:s'); } $mod['edit_times'] = (int) $post['edit_times'] + 1; $new_post_seolink = $inBlog->updatePost($post['id'], $mod, $model->config['update_seo_link']); $post['seolink'] = is_string($new_post_seolink) ? $new_post_seolink : $post['seolink']; cmsActions::updateLog('add_post', array('object' => $mod['title'], 'pubdate' => $model->config['update_date'] ? $mod['pubdate'] : $post['pubdate'], 'object_url' => $model->getPostURL('', $post['seolink'])), $post['id']); if (!$mod['published']) { $message = str_replace('%user%', cmsUser::getProfileLink($inUser->login, $inUser->nickname), $_LANG['MSG_POST_UPDATE']); $message = str_replace('%post%', '<a href="' . $model->getPostURL('', $post['seolink']) . '">' . $mod['title'] . '</a>', $message); $message = str_replace('%blog%', '<a href="' . $model->getBlogURL() . '">' . $blog['title'] . '</a>', $message); cmsUser::sendMessage(USER_UPDATER, $blog['user_id'], $message); cmsCore::addSessionMessage($_LANG['POST_PREMODER_TEXT'], 'info'); } else { cmsCore::addSessionMessage($_LANG['POST_UPDATED'], 'success'); } cmsCore::redirect($model->getPostURL('', $post['seolink'])); } } } ////////// НОВАЯ РУБРИКА / РЕДАКТИРОВАНИЕ РУБРИКИ ////////////////////////////////////////////////////// if ($do == 'newcat' || $do == 'editcat') { if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { cmsCore::halt(); } if (!$inUser->id) { cmsCore::halt(); } // Для редактирования сначала получаем рубрику if ($do == 'editcat') { $cat = $inBlog->getBlogCategory($cat_id); if (!$cat) { cmsCore::halt(); } $id = $cat['blog_id']; } // получаем блог $blog = $inBlog->getBlog($id); if (!$blog) { cmsCore::halt(); } //Проверяем является пользователь хозяином блога или админом if ($blog['user_id'] != $inUser->id && !$inUser->is_admin) { cmsCore::halt(); } //Если нет запроса на сохранение if (!cmsCore::inRequest('goadd')) { $smarty = $inCore->initSmarty('components', 'com_blog_edit_cat.tpl'); $smarty->assign('mod', $cat); $smarty->assign('form_action', $do == 'newcat' ? '/blog/' . $blog['id'] . '/newcat.html' : '/blog/editcat' . $cat['id'] . '.html'); $smarty->display('com_blog_edit_cat.tpl'); cmsCore::jsonOutput(array('error' => false, 'html' => ob_get_clean())); } //Если есть запрос на сохранение if (cmsCore::inRequest('goadd')) { if (!cmsCore::validateForm()) { cmsCore::halt(); } $new_cat['title'] = cmsCore::request('title', 'str', ''); $new_cat['description'] = cmsCore::request('description', 'str', ''); $new_cat['blog_id'] = $blog['id']; if (mb_strlen($new_cat['title']) < 3) { cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['CAT_ERR_TITLE'])); } //новая рубрика if ($do == 'newcat') { $cat['id'] = $inBlog->addBlogCategory($new_cat); cmsCore::addSessionMessage($_LANG['CAT_IS_ADDED'], 'success'); } //редактирование рубрики if ($do == 'editcat') { $inBlog->updateBlogCategory($cat['id'], $new_cat); cmsCore::addSessionMessage($_LANG['CAT_IS_UPDATED'], 'success'); } cmsUser::clearCsrfToken(); cmsCore::jsonOutput(array('error' => false, 'redirect' => $model->getBlogURL(1, $cat['id']))); } } ///////////////////////// УДАЛЕНИЕ РУБРИКИ ///////////////////////////////////////////////////////////////////////// if ($do == 'delcat') { if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { cmsCore::halt(); } if (!$inUser->id) { cmsCore::halt(); } $cat = $inBlog->getBlogCategory($cat_id); if (!$cat) { cmsCore::halt(); } $blog = $inBlog->getBlog($cat['blog_id']); if (!$blog) { cmsCore::halt(); } if ($blog['user_id'] != $inUser->id && !$inUser->is_admin) { cmsCore::halt(); } if (!cmsCore::validateForm()) { cmsCore::halt(); } $inBlog->deleteBlogCategory($cat['id']); cmsCore::addSessionMessage($_LANG['CAT_IS_DELETED'], 'success'); cmsUser::clearCsrfToken(); cmsCore::jsonOutput(array('error' => false, 'redirect' => $model->getBlogURL())); } ////////////////////////// ПРОСМОТР ПОСТА ///////////////////////////////////////////////////////////////////////// if ($do == 'post') { $post = $inBlog->getPost($seolink); if (!$post) { cmsCore::error404(); } $blog = $inBlog->getBlog($post['blog_id']); if (!$blog) { cmsCore::error404(); } // право просмотра блога if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])) { cmsCore::addSessionMessage($_LANG['CLOSED_BLOG'] . '<br>' . $_LANG['CLOSED_BLOG_TEXT'], 'error'); cmsCore::redirect('/blog'); } // право просмотра самого поста if (!cmsUser::checkUserContentAccess($post['allow_who'], $post['user_id'])) { cmsCore::addSessionMessage($_LANG['CLOSED_POST'] . '<br>' . $_LANG['CLOSED_POST_TEXT'], 'error'); cmsCore::redirect($model->getBlogURL()); } if ($inUser->id) { $inPage->addHeadJS('components/blog/js/blog.js'); } $inPage->addPathway($blog['title'], $model->getBlogURL()); $inPage->setTitle($post['title']); $inPage->addPathway($post['title']); $inPage->setDescription($post['title']); if ($post['cat_id']) { $cat = $inBlog->getBlogCategory($post['cat_id']); } $post['tags'] = cmsTagBar('blogpost', $post['id']); $is_author = $inUser->id && $inUser->id == $post['user_id']; $smarty = $inCore->initSmarty('components', 'com_blog_view_post.tpl'); $smarty->assign('post', $post); $smarty->assign('blog', $blog); $smarty->assign('cat', $cat); $smarty->assign('is_author', $is_author); $smarty->assign('myblog', $inUser->id && $inUser->id == $blog['user_id']); $smarty->assign('is_admin', $inUser->is_admin); $smarty->assign('karma_form', cmsKarmaForm('blogpost', $post['id'], $post['rating'], $is_author)); $smarty->assign('navigation', $inBlog->getPostNavigation($post['id'], $blog['id'], $model, $blog['seolink'])); $smarty->display('com_blog_view_post.tpl'); if ($inCore->isComponentInstalled('comments') && $post['comments']) { cmsCore::includeComments(); comments('blog', $post['id']); } } ///////////////////////// УДАЛЕНИЕ ПОСТА ///////////////////////////////////////////////////////////////////////////// if ($do == 'delpost') { if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { cmsCore::halt(); } if (!$inUser->id) { cmsCore::halt(); } $post = $inBlog->getPost($post_id); if (!$post) { cmsCore::halt(); } $blog = $inBlog->getBlog($post['blog_id']); if (!$blog) { cmsCore::halt(); } // удалять могут авторы, авторы блога, админы if ($blog['user_id'] != $inUser->id && !$inUser->is_admin && $inUser->id != $post['user_id']) { cmsCore::halt(); } if (!cmsCore::validateForm()) { cmsCore::halt(); } $inBlog->deletePost($post['id']); if ($inUser->id != $post['user_id']) { cmsUser::sendMessage(USER_UPDATER, $post['user_id'], $_LANG['YOUR_POST'] . ' <b>«' . $post['title'] . '»</b> ' . $_LANG['WAS_DELETED_FROM_BLOG'] . ' <b>«<a href="' . $model->getBlogURL() . '">' . $blog['title'] . '</a>»</b>'); } cmsCore::addSessionMessage($_LANG['POST_IS_DELETED'], 'success'); cmsUser::clearCsrfToken(); cmsCore::jsonOutput(array('error' => false, 'redirect' => $model->getBlogURL())); } ///////////////////////// ПУБЛИКАЦИЯ ПОСТА ///////////////////////////////////////////////////////////////////////// if ($do == 'publishpost') { if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { cmsCore::halt(); } if (!$inUser->id) { cmsCore::halt(); } $post = $inBlog->getPost($post_id); if (!$post) { cmsCore::halt(); } $blog = $inBlog->getBlog($post['blog_id']); if (!$blog) { cmsCore::halt(); } // публикуют авторы блога и админы if ($blog['user_id'] != $inUser->id && !$inUser->is_admin) { cmsCore::halt(); } $inBlog->publishPost($post_id); if ($blog['allow_who'] == 'all' && $post['allow_who'] == 'all') { cmsCore::callEvent('ADD_POST_DONE', $post); } $post['seolink'] = $model->getPostURL('', $post['seolink']); if ($blog['allow_who'] != 'nobody' && $post['allow_who'] != 'nobody') { cmsActions::log('add_post', array('object' => $post['title'], 'user_id' => $post['user_id'], 'object_url' => $post['seolink'], 'object_id' => $post['id'], 'target' => $blog['title'], 'target_url' => $model->getBlogURL(), 'target_id' => $blog['id'], 'description' => '', 'is_friends_only' => (int) ($blog['allow_who'] == 'friends' || $post['allow_who'] == 'friends'))); } cmsUser::sendMessage(USER_UPDATER, $post['user_id'], $_LANG['YOUR_POST'] . ' <b>«<a href="' . $post['seolink'] . '">' . $post['title'] . '</a>»</b> ' . $_LANG['PUBLISHED_IN_BLOG'] . ' <b>«<a href="' . $model->getBlogURL() . '">' . $blog['title'] . '</a>»</b>'); cmsCore::halt('ok'); } ////////// VIEW POPULAR POSTS //////////////////////////////////////////////////////////////////////////////////////// if ($do == 'best') { $inPage->setTitle($_LANG['POPULAR_IN_BLOGS']); $inPage->addPathway($_LANG['POPULAR_IN_BLOGS']); $inPage->setDescription($_LANG['POPULAR_IN_BLOGS']); // кроме админов в списке только с доступом для всех if (!$inUser->is_admin) { $inBlog->whereOnlyPublic(); } // ограничиваем по рейтингу если надо if ($model->config['list_min_rating']) { $inBlog->ratingGreaterThan($model->config['list_min_rating']); } // всего постов $total = $inBlog->getPostsCount($inUser->is_admin); //устанавливаем сортировку $inDB->orderBy('p.rating', 'DESC'); $inDB->limitPage($page, $model->config['perpage']); // сами посты $posts = $inBlog->getPosts($inUser->is_admin, $model); if (!$posts && $page > 1) { cmsCore::error404(); } $smarty = $inCore->initSmarty('components', 'com_blog_view_posts.tpl'); $smarty->assign('pagetitle', $_LANG['POPULAR_IN_BLOGS']); $smarty->assign('total', $total); $smarty->assign('ownertype', $ownertype); $smarty->assign('posts', $posts); $smarty->assign('pagination', cmsPage::getPagebar($total, $page, $model->config['perpage'], '/blogs/popular-%page%.html')); $smarty->assign('cfg', $model->config); $smarty->display('com_blog_view_posts.tpl'); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// $inCore->executePluginRoute($do); }
<select class="form-control" name="country_id"> <?php echo cmsCore::getListItems('cms_geo_countries', cmsCore::getArrVal($item, 'country_id', 0), 'name', 'ASC', '', 'id', 'name'); ?> </select> </div> <?php } else { ?> <div class="form-group"> <label><?php echo $_LANG['AD_COUNTRY1']; ?></label> <select class="form-control" name="country_id"> <?php echo cmsCore::getListItems('cms_geo_countries', cmsCore::getArrVal($item, 'country_id', 0), 'name', 'ASC', '', 'id', 'name'); ?> </select> </div> <div class="form-group"> <label><?php echo $_LANG['AD_REGION']; ?></label> <select class="form-control" name="region_id"> <?php echo cmsCore::getListItems('cms_geo_regions', cmsCore::getArrVal($item, 'region_id', 0), 'name', 'ASC', (isset($item['country_id']) ? "country_id = '". $item['country_id'] ."'" : ''), 'id', 'name'); ?> </select> </div> <?php } ?> </div> <div> <input type="hidden" name="opt" value="do_<?php echo $opt; ?>" /> <input type="hidden" name="sub_opt" value="<?php echo $sub_opt; ?>" /> <input type="hidden" name="item_id" value="<?php echo cmsCore::getArrVal($item, 'id', ''); ?>" /> <input type="submit" class="btn btn-primary" name="save" value="<?php echo $_LANG['SAVE']; ?>" /> <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.location.href='index.php?view=components&do=config&id=<?php echo $id; ?>';"/> </div> </form> <?php
function applet_config() { // получаем оригинальный конфиг $config = cmsConfig::getDefaultConfig(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); } cmsCore::c('page')->setTitle($_LANG['AD_SITE_SETTING']); cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config'); $do = cmsCore::request('do', 'str', 'list'); if ($do == 'save') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $newCFG = cmsCore::getArrayFromRequest(array( 'scheme' => array('scheme', array('http', 'https'), ''), 'sitename' => array('sitename', 'str', ''), 'title_and_sitename' => array('title_and_sitename', 'int', 0), 'title_and_page' => array('title_and_page', 'int', 0), 'hometitle' => array('hometitle', 'str', ''), 'homecom' => array('homecom', 'str', ''), 'com_without_name_in_url' => array('com_without_name_in_url', 'str', ''), 'siteoff' => array('siteoff', 'int', 0), 'only_authorized' => array('only_authorized', 'int', 0), 'debug' => array('debug', 'int', 0), 'offtext' => array('offtext', 'str', ''), 'keywords' => array('keywords', 'str', ''), 'metadesc' => array('metadesc', 'str', ''), 'seourl' => array('seourl', 'int', 0), 'lang' => array('lang', 'str', 'ru'), 'is_change_lang' => array('is_change_lang', 'int', 0), 'sitemail' => array('sitemail', 'str', ''), 'sitemail_name' => array('sitemail_name', 'str', ''), 'wmark' => array('wmark', 'str', ''), 'template' => array('template', 'str', ''), 'cache' => array('cache', 'int', 0), 'cache_type' => array('cache_type', array('file', 'memcached'), ''), 'memcached_host' => array('memcached_host', 'str', ''), 'memcached_port' => array('memcached_port', 'int', 0), 'combine_css_enable' => array('combine_css_enable', 'int', 0), 'combine_css' => array('combine_css', 'html', ''), 'combine_js_enable' => array('combine_js_enable', 'int', 0), 'combine_js' => array('combine_js', 'html', ''), 'splash' => array('splash', 'int', 0), 'slight' => array('slight', 'int', 0), 'show_pw' => array('show_pw', 'int', 0), 'last_item_pw' => array('last_item_pw', 'int', 0), 'index_pw' => array('index_pw', 'int', 0), 'fastcfg' => array('fastcfg', 'int', 0), 'mailer' => array('mailer', 'str', ''), 'smtpsecure' => array('smtpsecure', 'str', ''), 'smtpauth' => array('smtpauth', 'int', 0), 'smtpuser' => array('smtpuser', 'str', $config['smtpuser']), 'smtppass' => array('smtppass', 'str', $config['smtppass']), 'smtphost' => array('smtphost', 'str', ''), 'smtpport' => array('smtpport', 'int', '25'), 'timezone' => array('timezone', 'str', $config['timezone']), 'user_stats' => array('user_stats', 'int', 0), 'seo_url_count' => array('seo_url_count', 'int', 0), 'max_pagebar_links' => array('max_pagebar_links', 'int', 0), 'allow_ip' => array('allow_ip', 'str', ''), 'iframe_enable' => array('iframe_enable', 'int', 0), 'vk_enable' => array('vk_enable', 'int', 0), 'vk_id' => array('vk_id', 'str', ''), 'vk_private_key' => array('vk_private_key', 'str', ''), )); $newCFG['sitename'] = stripslashes($newCFG['sitename']); $newCFG['hometitle'] = stripslashes($newCFG['hometitle']); $newCFG['offtext'] = htmlspecialchars($newCFG['offtext'], ENT_QUOTES); $newCFG['db_host'] = $config['db_host']; $newCFG['db_base'] = $config['db_base']; $newCFG['db_user'] = $config['db_user']; $newCFG['db_pass'] = $config['db_pass']; $newCFG['db_prefix'] = $config['db_prefix']; if (cmsConfig::saveToFile($newCFG)) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'] , 'success'); } else { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SITE_ERROR'], 'error'); } cmsCore::clearCache(); cmsCore::redirect('index.php?view=config'); } cpCheckWritable('/includes/config/config.inc.json'); ?> <form class="form-horizontal" role="form" action="/admin/index.php?view=config" method="post" name="CFGform" target="_self" id="CFGform" style="margin-bottom:30px"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" /> <div class="uitabs"> <ul id="tabs"> <li><a href="#basic"><span><?php echo $_LANG['AD_SITE']; ?></span></a></li> <li><a href="#home"><span><?php echo $_LANG['AD_MAIN']; ?></span></a></li> <li><a href="#cache"><span><?php echo $_LANG['AD_CACHE']; ?></span></a></li> <li><a href="#database"><span><?php echo $_LANG['AD_DB'] ; ?></span></a></li> <li><a href="#mail"><span><?php echo $_LANG['AD_POST']; ?></span></a></li> <li><a href="#other"><span><?php echo $_LANG['AD_PATHWAY']; ?></span></a></li> <li><a href="#seq"><span><?php echo $_LANG['AD_SECURITY']; ?></span></a></li> <li><a href="#soc_apps"><span><?php echo $_LANG['AD_SOC_APPS']; ?></span></a></li> </ul> <div id="basic"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SCHEME_TYPE']; ?></label> <div class="col-sm-7"> <select id="scheme" class="form-control" name="scheme"> <option value=""><?php echo $_LANG['AD_SCHEME_ANY']; ?></option> <option value="http" <?php if ($config['scheme'] == 'http') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SCHEME_http']; ?></option> <option value="https" <?php if ($config['scheme'] == 'https') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SCHEME_https']; ?></option> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TIME_ARREA']; ?></label> <div class="col-sm-7"> <select id="timezone" class="form-control" name="timezone"> <?php echo cmsCore::getTimeZonesOptions($config['timezone']); ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITENAME']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="sitename" value="<?php echo htmlspecialchars($config['sitename']);?>" /> <div class="help-block"><?php echo $_LANG['AD_USE_HEADER']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['TEMPLATE']; ?></label> <div class="col-sm-7"> <select id="template" class="form-control" name="template" onchange="document.CFGform.submit();"> <?php $templates = cmsCore::getDirsList('/templates'); foreach ($templates as $template) { if ($template == 'admin') { continue; } echo '<option value="'. $template .'" '. ($config['template'] == $template ? 'selected="selected"' : '') .'>'. $template .'</option>'; } $tpl_info = cmsCore::c('page')->getCurrentTplInfo(); ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEARCH_RESULT']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['slight']) { echo 'active'; } ?>"> <input type="radio" name="slight" <?php if ($config['slight']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['SHOW']; ?> </label> <label class="btn btn-default <?php if (!$config['slight']) { echo 'active'; } ?>"> <input type="radio" name="slight" <?php if (!$config['slight']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TAGE_ADD']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['title_and_sitename']) { echo 'active'; } ?>"> <input type="radio" name="title_and_sitename" <?php if ($config['title_and_sitename']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['title_and_sitename']) { echo 'active'; } ?>"> <input type="radio" name="title_and_sitename" <?php if (!$config['title_and_sitename']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TAGE_ADD_PAGINATION']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['title_and_page']) { echo 'active'; } ?>"> <input type="radio" name="title_and_page" <?php if ($config['title_and_page']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['title_and_page']) { echo 'active'; } ?>"> <input type="radio" name="title_and_page" <?php if (!$config['title_and_page']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_COM_WITHOUT_NAME_IN_URL']; ?></label> <div class="col-sm-7"> <select class="form-control" name="com_without_name_in_url"> <?php echo cmsCore::getListItems('cms_components', $config['com_without_name_in_url'], 'title', 'ASC', 'internal=0', 'link'); ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['TEMPLATE_INTERFACE_LANG']; ?></label> <div class="col-sm-7"> <select class="form-control" name="lang"> <?php $langs = cmsCore::getDirsList('/languages'); foreach ($langs as $lng) { echo '<option value="'. $lng .'" '. ($config['lang'] == $lng ? 'selected="selected"' : '') .'>'. $lng .'</option>'; } ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_LANGUAGE_CHANGE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['is_change_lang']) { echo 'active'; } ?>"> <input type="radio" name="is_change_lang" <?php if ($config['is_change_lang']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['is_change_lang']) { echo 'active'; } ?>"> <input type="radio" name="is_change_lang" <?php if (!$config['is_change_lang']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_VIEW_FORM_LANGUAGE_CHANGE']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_ON']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if (!$config['siteoff']) { echo 'active'; } ?>"> <input type="radio" name="siteoff" <?php if (!$config['siteoff']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if ($config['siteoff']) { echo 'active'; } ?>"> <input type="radio" name="siteoff" <?php if ($config['siteoff']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_ONLY_ADMINS']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_ONLY_AUTHORIZED']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['only_authorized']) { echo 'active'; } ?>"> <input type="radio" name="only_authorized" <?php if ($config['only_authorized']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['only_authorized']) { echo 'active'; } ?>"> <input type="radio" name="only_authorized" <?php if (!$config['only_authorized']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_SITE_ONLY_AUTHORIZED_INFO']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DEBUG_ON']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['debug']) { echo 'active'; } ?>"> <input type="radio" name="debug" <?php if ($config['debug']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['debug']) { echo 'active'; } ?>"> <input type="radio" name="debug" <?php if (!$config['debug']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_WIEW_DB_ERRORS']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_WHY_STOP']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="offtext" value="<?php echo htmlspecialchars($config['offtext']); ?>" /> <div class="help-block"><?php echo $_LANG['AD_VIEW_WHY_STOP']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_WATERMARK']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="wmark" value="<?php echo $config['wmark']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_WATERMARK_NAME']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_QUICK_CONFIG']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['fastcfg']) { echo 'active'; } ?>"> <input type="radio" name="fastcfg" <?php if ($config['fastcfg']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['fastcfg']) { echo 'active'; } ?>"> <input type="radio" name="fastcfg" <?php if (!$config['fastcfg']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_MODULE_CONFIG']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ONLINESTATS']; ?></label> <div class="col-sm-7"> <select class="form-control" name="user_stats"> <option value="0" <?php if (!$config['user_stats']) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_NO_ONLINESTATS']; ?></option> <option value="1" <?php if ($config['user_stats'] == 1) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_YES_ONLINESTATS']; ?></option> <option value="2" <?php if ($config['user_stats'] == 2) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_CRON_ONLINESTATS']; ?></option> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEO_URL_COUNT']; ?></label> <div class="col-sm-7"> <input type="number" class="form-control" name="seo_url_count" value="<?php echo $config['seo_url_count']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_SEO_URL_COUNT_HINT']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_PAGEBAR_MAX_LINKS']; ?></label> <div class="col-sm-7"> <input type="number" class="form-control" name="max_pagebar_links" value="<?php echo $config['max_pagebar_links']; ?>" /> </div> </div> </div> </div> <div id="home"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAIN_PAGE']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="hometitle" value="<?php echo htmlspecialchars($config['hometitle']); ?>" /> <div class="help-block"><?php echo $_LANG['AD_MAIN_SITENAME']; ?></div> <div class="help-block"><?php echo $_LANG['AD_BROWSER_TITLE']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_KEY_WORDS']; ?></label> <div class="col-sm-7"> <textarea class="form-control" name="keywords" rows="3"><?php echo $config['keywords']; ?></textarea> <div class="help-block"><?php echo $_LANG['AD_FROM_COMMA']; ?></div> <div class="help-block"><a style="color:#09C" href="http://tutorial.semonitor.ru/#5" target="_blank"><?php echo $_LANG['AD_WHAT_KEY_WORDS']; ?></a></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DESCRIPTION']; ?></label> <div class="col-sm-7"> <textarea class="form-control" name="metadesc" rows="3"><?php echo $config['metadesc']; ?></textarea> <div class="help-block"><?php echo $_LANG['AD_LESS_THAN']; ?></div> <div class="help-block"><a style="color:#09C" href="http://tutorial.semonitor.ru/#219" target="_blank"><?php echo $_LANG['AD_WHAT_DESCRIPTION']; ?></a></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAIN_PAGE_COMPONENT']; ?></label> <div class="col-sm-7"> <select class="form-control" name="homecom"> <option value="" <?php if (!$config['homecom']) { ?>selected="selected"<?php } ?>><?php echo $_LANG['AD_ONLY_MODULES']; ?></option> <?php echo cmsCore::getListItems('cms_components', $config['homecom'], 'title', 'ASC', 'internal=0', 'link'); ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_GATE_PAGE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['splash']) { echo 'active'; } ?>"> <input type="radio" name="splash" <?php if ($config['splash']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['SHOW']; ?> </label> <label class="btn btn-default <?php if (!$config['splash']) { echo 'active'; } ?>"> <input type="radio" name="splash" <?php if (!$config['splash']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_FIRST_VISIT']; ?></div> <div class="help-block"><?php echo $_LANG['AD_FIRST_VISIT_TEMPLATE']; ?></div> </div> </div> </div> </div> <div id="cache"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_CACHE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['cache']) { echo 'active'; } ?>"> <input type="radio" name="cache" <?php if ($config['cache']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['cache']) { echo 'active'; } ?>"> <input type="radio" name="cache" <?php if (!$config['cache']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"> <?php echo $_LANG['AD_CACHE_INFO']; ?> </div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_CACHE_TYPE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <select class="form-control" name="cache_type" onchange="if ($(this).val() == 'memcached'){$('.memcached').show();}else{$('.memcached').hide();}"> <option value="file" <?php if ($config['cache_type'] == 'file') { echo 'selected="selected"'; } ?>>File</option> <?php if (class_exists('Memcached')) { ?> <option value="memcached" <?php if ($config['cache_type'] == 'memcached') { echo 'selected="selected"'; } ?>>Memcached</option> <?php } ?> </select> <div class="help-block"> <?php echo $_LANG['AD_CACHE_TYPE_INFO']; ?> </div> </div> </div> <div class="form-group memcached" <?php if ($config['cache_type'] != 'memcached'){ ?>style="display:none;"<?php } ?>> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MEMCACHED_HOST']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <input type="text" class="form-control" name="memcached_host" value="<?php echo $config['memcached_host']; ?>" /> <div class="help-block"> <?php echo $_LANG['AD_MEMCACHED_HOST_INFO']; ?> </div> </div> </div> <div class="form-group memcached" <?php if ($config['cache_type'] != 'memcached'){ ?>style="display:none;"<?php } ?>> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MEMCACHED_PORT']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <input type="number" class="form-control" name="memcached_port" value="<?php echo $config['memcached_port']; ?>" /> <div class="help-block"> <?php echo $_LANG['AD_MEMCACHED_PORT_INFO']; ?> </div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"> <?php echo $_LANG['AD_COLLECT_CSS']; ?><br/> <input type="checkbox" name="combine_css_enable" value="1" <?php if ($config['combine_css_enable']) { ?>checked="checked"<?php } ?> /> <?php echo $_LANG['AD_DO_ENABLE']; ?> </label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <textarea class="form-control" style="height:150px;" name="combine_css"><?php echo cmsCore::getArrVal($config, 'combine_css', ''); ?></textarea> <div class="help-block"> <?php echo $_LANG['AD_COLLECT_CSS_INFO']; ?> </div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"> <?php echo $_LANG['AD_COLLECT_JS']; ?> <br/> <input type="checkbox" name="combine_js_enable" value="1" <?php if ($config['combine_js_enable']) { ?>checked="checked"<?php } ?> /> <?php echo $_LANG['AD_DO_ENABLE']; ?> </label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <textarea class="form-control" style="height:150px;" name="combine_js"><?php echo cmsCore::getArrVal($config, 'combine_js', ''); ?></textarea> <div class="help-block"> <?php echo $_LANG['AD_COLLECT_JS_INFO']; ?> </div> </div> </div> </div> </div> <div id="database"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DB_SIZE']; ?></label> <div class="col-sm-7"> <?php $result = cmsCore::c('db')->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '". $config['db_base'] ."'", true); if (!cmsCore::c('db')->error()) { $s = cmsCore::c('db')->fetch_assoc($result); echo round($s['size'], 2) .' '. $_LANG['SIZE_MB']; } else { echo $_LANG['AD_DB_SIZE_ERROR']; } ?> <div class="help-block"><?php echo $_LANG['AD_MYSQL_CONFIG']; ?></div> </div> </div> </div> </div> <div id="mail"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_EMAIL']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="sitemail" value="<?php echo $config['sitemail']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_SITE_EMAIL_POST']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SENDER_EMAIL']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="sitemail_name" value="<?php echo $config['sitemail_name']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_IF_NOT_HANDLER']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEND_METHOD']; ?></label> <div class="col-sm-7"> <select class="form-control" name="mailer"> <option value="mail" <?php if ($config['mailer'] == 'mail') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_PHP_MAILER']; ?></option> <option value="sendmail" <?php if ($config['mailer'] == 'sendmail') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SEND_MAILER']; ?></option> <option value="smtp" <?php if ($config['mailer'] == 'smtp') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SMTP_MAILER']; ?></option> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ENCRYPTING']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if (!$config['smtpsecure']) { echo 'active'; } ?>"> <input type="radio" name="smtpsecure" <?php if (!$config['smtpsecure']) { echo 'checked="checked"'; } ?> value="" /> <?php echo $_LANG['NO']; ?> </label> <label class="btn btn-default <?php if ($config['smtpsecure'] == 'tls') { echo 'active'; } ?>"> <input type="radio" name="smtpsecure" <?php if ($config['smtpsecure'] == 'tls') { echo 'checked="checked"'; } ?> value="tls" /> tls </label> <label class="btn btn-default <?php if ($config['smtpsecure'] == 'ssl') { echo 'active'; } ?>"> <input type="radio" name="smtpsecure" <?php if ($config['smtpsecure'] == 'ssl') { echo 'checked="checked"'; } ?> value="ssl" /> ssl </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_LOGIN']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['smtpauth']) { echo 'active'; } ?>"> <input type="radio" name="smtpauth" <?php if ($config['smtpauth']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['smtpauth']) { echo 'active'; } ?>"> <input type="radio" name="smtpauth" <?php if (!$config['smtpauth']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_USER']; ?></label> <div class="col-sm-7"> <?php if (!$config['smtpuser']) { ?> <input type="text" class="form-control" name="smtpuser" value="<?php echo $config['smtpuser']; ?>" /> <?php } else { ?> <div class="help-block"><?php echo $_LANG['AD_IF_CHANGE_USER']; ?></div> <?php } ?> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_PASS']; ?></label> <div class="col-sm-7"> <?php if (!$config['smtppass']) { ?> <input type="text" class="form-control" name="smtppass" value="<?php echo $config['smtppass']; ?>" /> <?php } else { ?> <div class="help-block"><?php echo $_LANG['AD_IF_CHANGE_PASS']; ?></div> <?php } ?> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_HOST']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="smtphost" value="<?php echo $config['smtphost']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_SOME_HOST']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_PORT']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="smtpport" value="<?php echo $config['smtpport']; ?>" /> </div> </div> </div> </div> <div id="other"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_VIEW_PATHWAY']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['show_pw']) { echo 'active'; } ?>"> <input type="radio" name="show_pw" <?php if ($config['show_pw']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['show_pw']) { echo 'active'; } ?>"> <input type="radio" name="show_pw" <?php if (!$config['show_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_PATH_TO_CATEGORY']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAINPAGE_PATHWAY']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['index_pw']) { echo 'active'; } ?>"> <input type="radio" name="index_pw" <?php if ($config['index_pw']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['index_pw']) { echo 'active'; } ?>"> <input type="radio" name="index_pw" <?php if (!$config['index_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_PAGE_PATHWAY']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if (!$config['last_item_pw']) { echo 'active'; } ?>"> <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?> </label> <label class="btn btn-default <?php if ($config['last_item_pw'] == 1) { echo 'active'; } ?>"> <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw'] == 1) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['AD_PAGE_PATHWAY_LINK']; ?> </label> <label class="btn btn-default <?php if ($config['last_item_pw'] == 2) { echo 'active'; } ?>"> <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw'] == 2) { echo 'checked="checked"'; } ?> value="2" /> <?php echo $_LANG['AD_PAGE_PATHWAY_TEXT']; ?> </label> </div> </div> </div> </div> <div id="seq"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IP_ADMIN']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="allow_ip" value="<?php echo htmlspecialchars($config['allow_ip']); ?>" /> <div class="help-block"><?php echo $_LANG['AD_IP_COMMA']; ?></div> </div> </div> <p style="color:#900"><?php echo $_LANG['AD_ATTENTION']; ?></p> </div> </div> <div id="soc_apps"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_ENABLE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if (cmsCore::getArrVal($config, 'iframe_enable')) { echo 'active'; } ?>"> <input type="radio" name="iframe_enable" <?php if (cmsCore::getArrVal($config, 'iframe_enable')) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!cmsCore::getArrVal($config, 'iframe_enable')) { echo 'active'; } ?>"> <input type="radio" name="iframe_enable" <?php if (!cmsCore::getArrVal($config, 'iframe_enable')) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <fieldset> <legend>VK.COM</legend> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ENABLE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['vk_enable']) { echo 'active'; } ?>"> <input type="radio" name="vk_enable" <?php if ($config['vk_enable']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['vk_enable']) { echo 'active'; } ?>"> <input type="radio" name="vk_enable" <?php if (!$config['vk_enable']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_APP_ID']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="vk_id" value="<?php echo $config['vk_id']; ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_APP_PRIVATE_KEY']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="vk_private_key" value="<?php echo $config['vk_private_key']; ?>" /> </div> </div> </fieldset> </div> </div> </div> <div> <input type="hidden" name="do" value="save" /> <input type="submit" class="btn btn-primary" name="save" value="<?php echo $_LANG['SAVE']; ?>" /> <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" /> </div> </form> <?php }
<select name="regions" style="width: 300px;" onchange="changeGeo(this, 'cities')"> <?php echo cmsCore::getListItems('cms_geo_regions', @$item['region_id'], 'name', 'ASC', @$item['country_id'] ? "country_id = '{$item['country_id']}'" : '', 'id', 'name'); ?> </select> </div> <div class="list" <?php if (!$item['city_id']) { echo ' style="dispay:none;"'; } ?> > <select name="cities" style="width: 300px;"> <?php echo cmsCore::getListItems('cms_geo_cities', @$item['city_id'], 'name', 'ASC', @$item['region_id'] ? "region_id = '{$item['region_id']}'" : '', 'id', 'name'); ?> </select> </div> </td> </tr> </table> <p> <input name="opt" type="hidden" value="<?php if ($opt == 'district_add') { echo 'district_submit'; } else { echo 'district_update'; } ?>
if ($opt == 'delete') { $sub_opt = cmsCore::request('sub_opt', 'str', ''); $item_id = cmsCore::request('item_id', 'int', 0); if (!$sub_opt || !$item_id) { cmsCore::error404(); } $table = $sub_opt == 'country' ? 'cms_geo_countries' : ($sub_opt == 'region' ? 'cms_geo_regions' : 'cms_geo_cities'); $redirect = $sub_opt == 'country' ? 'countries' : ($sub_opt == 'region' ? 'regions' : 'cities'); cmsCore::c('db')->delete($table, "id='" . $item_id . "'", 1); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirect('?view=components&do=config&id=' . $id . '&opt=' . $redirect); } if ($opt == 'add' || $opt == 'edit') { $sub_opt = cmsCore::request('sub_opt', 'str', ''); $item_id = cmsCore::request('item_id', 'int', 0); $tpl = cmsCore::c('page')->initTemplate('components', 'geo_add')->assign('opt', $opt)->assign('sub_opt', $sub_opt)->assign('item_id', $item_id)->assign('countries_opt', cmsCore::getListItems('cms_geo_countries', cmsCore::getArrVal($item, 'country_id', 0), 'name', 'ASC', '', 'id', 'name'))->assign('regions_opt', cmsCore::getListItems('cms_geo_regions', cmsCore::getArrVal($item, 'region_id', 0), 'name', 'ASC', isset($item['country_id']) ? "country_id = '" . $item['country_id'] . "'" : '', 'id', 'name')); if ($item_id) { $table = $sub_opt == 'country' ? 'cms_geo_countries' : ($sub_opt == 'region' ? 'cms_geo_regions' : 'cms_geo_cities'); $item = cmsCore::c('db')->get_fields($table, "id='" . $item_id . "'", '*'); if (!$item) { cmsCore::error404(); } if (!isset($item['ordering'])) { $item['ordering'] = 1 + cmsCore::c('db')->get_field('cms_geo_countries', "1=1 ORDER BY ordering DESC", 'ordering'); } $tpl->assign('item', $item); cpAddPathway($_LANG['EDIT'] . ' ' . mb_strtolower($_LANG['AD_' . mb_strtoupper($sub_opt)])); } else { if ($sub_opt) { cpAddPathway($_LANG['ADD'] . ' ' . mb_strtolower($_LANG['AD_' . mb_strtoupper($sub_opt)])); } else {