function _nav_modifier_article_m($input) { global $articles; if (!is_a($articles, 'articles')) { $arts = new articles(); } else { $arts =& $articles; } $data = explode('/', $input, 3); $mode = sizeof($data); $containers = $arts->getContainers(0); switch ($mode) { case 1: if (!empty($containers[$data[0]])) { return array('?module=articles&c=' . urlencode($data[0]), $containers[$data[0]]); } break; case 2: if ($arts->setWorkContainer($data[0])) { $categories = $arts->getCategories(true, false, false); if ($data[0] == '#hidden' || $data[0] == '#root' && ($article = $arts->getArticle(0, (int) $data[1], false, false, false, false))) { return array('?module=articles&c=' . urlencode($data[0]) . '&a=' . (int) $data[1], $article['title']); } elseif ($categories && !empty($categories[(int) $data[1]])) { return array('?module=articles&c=' . urlencode($data[0]) . '&b=' . (int) $data[1], $categories[$data[1]]); } } break; case 3: if ($arts->setWorkContainer($data[0])) { if ($article = $arts->getArticle((int) $data[1], (int) $data[2], false, false, false, false)) { return array('?module=articles&c=' . urlencode($data[0]) . '&b=' . (int) $data[1] . '&a=' . (int) $data[2], $article['title']); } } break; } return false; }
if (!$arrErrors) { // присваеваем полученные данные объекту $articles->arrBindFields = $arrBindFields; $articles->arrNoBindFields = $arrNoBindFields; // производим запись в таблицу БД !$articles->recArticle() ? $arrErrors[] = db::$message_error ? db::$message_error : ERROR_MISMATCH_FIELDS : messages::messageChangeSaved(MESSAGE_ARTICLE_ADDED, false, CONF_ADMIN_FILE . '?m=manager&s=articles'); } else { $smarty->assign('return_data', $arrBindFields + $arrNoBindFields); } } } elseif ($arrActions['edit']) { if (!empty($_GET['id']) && ($id = validate::checkNaturalNumber($_GET['id']))) { // инициируем "Наименование страницы" отображаемое в форме $arrNamePage[] = array('name' => MENU_ACTION_EDIT, 'link' => false); // проверяем существование новости $article = $articles->getArticle("token IN ('active','archived') AND id=" . secure::escQuoteData($id)); if (!empty($article) && is_array($article)) { $smarty->assignByRef('return_data', $article); // передаем новость в шаблон // сохраняем изменения if (isset($_POST['save'])) { // получаем из формы поля обязательные для заполнения $arrBindFields = $_POST['arrBindFields']; // получаем из формы поля не обязательные для заполнения $arrNoBindFields = $_POST['arrNoBindFields']; $arrNoBindFields['noComments'] = !empty($_POST['arrNoBindFields']['noComments']) ? 1 : 0; // устанавливаем состояние новости $arrBindFields['token'] = isset($arrBindFields['token']) ? 'active' : 'archived'; // устанавливаем дату новости $arrBindFields['datetime'] = !$_POST['date'] ? terms::currentDateTime() : $_POST['date'] . ' ' . $_POST['time']['Time_Hour'] . ':' . $_POST['time']['Time_Minute']; ///////////////////////////////////////////////////////////////
/****************************************************************************** * Perform deletion of articles * ******************************************************************************/ if (!empty($_POST['delete'])) { foreach ($_POST['delete'] as $id => $chk) { if ($chk && $articles->setWorkContainer($c) && $articles->deleteArticle($b, $id)) { rcms_showAdminMessage(__('Article removed') . ': ' . $c . '/' . $b . '/' . $id); } else { rcms_showAdminMessage($articles->last_error . ': ' . $c . '/' . $b . '/' . $id); } } } /****************************************************************************** * Perform changing of article * ******************************************************************************/ if (!empty($_POST['save']) && !empty($c) && (!empty($b) || $c == '#hidden' || $c == '#root') && !empty($a) && $articles->setWorkContainer($c) && ($article = $articles->getArticle($b, $a, false, true, true, false)) !== false) { $time = sql_to_unix_time($_POST['time']); if ($_POST['mode'] == 'php' && !$system->checkForRight('GENERAL')) { return rcms_showAdminMessage(__('Error occurred') . ': ' . __('You are not administrator of this site')); } if (!@$articles->saveArticle($b, $a, $_POST['title'], $_POST['source'], $_POST['keywords'], $_POST['sef_desc'], $_POST['description'], $_POST['text'], $_POST['mode'], $_POST['comments'], $time)) { rcms_showAdminMessage($articles->last_error); } else { rcms_showAdminMessage(__('Article saved')); sleep(1); if (!empty($nb) && $nb != $b) { if (!$articles->moveArticle($b, $a, $nb)) { rcms_showAdminMessage($articles->last_error); } else { rcms_showAdminMessage(__('Article moved')); }
} } } else { $arrErrors[] = ERROR_TO_PERFORM_ACTION_SPECIFY_ALIAS; } } elseif ($arrActions['edit']) { // инициируем "Наименование страницы" отображаемое в заголовке формы $arrNamePage[] = array('name' => constant('FORM_ARTICLES_EDIT'), 'link' => false); /** Проверяем id статьи **/ if (!empty($_GET['id']) && strings::ifInt($_GET['id'])) { $id = (int) $_GET['id']; /** Проверяем псевдоним пользователя **/ if (!empty($arrUser['alias'])) { // получаем данные статьи $strWhere = "id IN (" . secure::escQuoteData($id) . ") AND id_user IN (" . secure::escQuoteData($arrUser['id']) . ") AND token IN ('active','archived','new','correction')"; if ($arrArticle = $articles->getArticle($strWhere)) { /** Проверяем токен статьи и права пользователя **/ if ($arrArticle['token'] == 'correction' || !empty($_SESSION['sd_' . DB_PREFIX . 'codex']['rights']['edit_articles'])) { /** Сохраняем статью **/ if (isset($_POST['save'])) { /** Проверяем на непустые поля **/ if (!empty($_POST['arrBindFields']) && !empty($_POST['date']) && !empty($_POST['time'])) { $arrData = $_POST['arrBindFields'] + $_POST['date'] + $_POST['time']; if (validate::arrDataNotEmpty($arrData)) { $arrBindFields = $_POST['arrBindFields']; $arrBindFields['datetime'] = $_POST['date']['Date_Year'] . '-' . $_POST['date']['Date_Month'] . '-' . $_POST['date']['Date_Day'] . ' ' . $_POST['time']['Time_Hour'] . ':' . $_POST['time']['Time_Minute']; } else { $arrErrors[] = ERROR_EMPTY_BIND_FIELDS; } } else { $arrErrors[] = ERROR_EMPTY_BIND_FIELDS;
@unlink($_FILES[$inputName]['tmp_name']); } // печатаем данные о загруженном файле в формате JSON echo ajax::sdgJSONencode($_FILES[$inputName]); } else { echo 'ErrInputFile'; } } elseif (isset($_GET['editVisibility']) && !empty($_POST['visibility']) && ('visible' === $_POST['visibility'] || 'visiblehc' === $_POST['visibility'] || 'members' === $_POST['visibility'] || 'membershc' === $_POST['visibility'] || 'hide' === $_POST['visibility']) && (int) $_POST['id'] && 0 < $_POST['id']) { $resume = new resume(); echo !$resume->setVisibility($_POST['visibility'], $_POST['id']) ? 'errSet' : 'success'; } elseif (!empty($_POST['checkAlias']) && !empty($_POST['uID'])) { $user = new user(); echo $user->issetUser("id NOT IN (" . secure::escQuoteData($_POST['uID']) . ") AND alias IN (" . secure::escQuoteData($_POST['checkAlias']) . ") AND token IN ('active','archived','moderate','new')") ? 'true' : 'false'; } elseif (!empty($_POST['getArticleDetail'])) { $articles = new articles(); $arrArticle = $articles->getArticle("id IN (" . secure::escQuoteData($_POST['getArticleDetail']) . ")"); $smarty->assignByRef('arrArticle', $arrArticle); $smarty->display('user.articles.detail.tpl'); } elseif (!empty($_POST['getNewsDetail'])) { $news = new news(); $arrNews = $news->getNews("id=" . secure::escQuoteData($_POST['getNewsDetail'])); $smarty->assignByRef('arrNews', $arrNews); $smarty->display('user.news.detail.tpl'); } elseif (!empty($_GET['getAnnounceData']) && ('vacancy' === $_GET['getAnnounceData'] || 'resume' === $_GET['getAnnounceData']) && !empty($_POST['unikey'])) { $objAnnounce = new $_GET['getAnnounceData'](); if (empty($_SESSION['sd_user']['data']['id'])) { die('{"result":"error", "error":"' . ERROR_DATA . '"}'); // ошибка: объявление не существует } elseif (!$objAnnounce->getAnnounceByUnikey($_POST['unikey'], "id_user IN (" . secure::escQuoteData($_SESSION['sd_user']['data']['id']) . ") AND token IN ('active')")) { die('{"result":"error", "error":"' . ERROR_ANNOUNCE_NOT_EXISTS . '"}'); // ошибка: объявление не существует
<?php //////////////////////////////////////////////////////////////////////////////// // Copyright (C) ReloadCMS Development Team // // http://reloadcms.com // // This product released under GNU General Public License v2 // //////////////////////////////////////////////////////////////////////////////// $articles = new articles(); $container = empty($articles->config['cpop']) ? 'articles' : $articles->config['cpop']; if (!$articles->setWorkContainer($container)) { return show_window(__('Most commented articles'), __('Error occurred') . ':<br />' . $articles->last_error); } if ($list = $articles->getLimitedStat('ccnt', $system->config['num_of_latest'], true)) { $result = '<table cellspacing="0" cellpadding="0" border="0" width="100%">'; $i = 2; foreach ($list as $id => $time) { $id = explode('.', $id); if (($article = $articles->getArticle($id[0], $id[1], false, false, false, false)) !== false) { $result .= '<tr><td class="row' . $i . '"><a href="index.php?module=articles&c=' . $container . '&b=' . $id[0] . '&a=' . $id[1] . '"><abbr title="' . $article['author_nick'] . ', ' . rcms_format_time('d.m.Y H:i:s', $article['time']) . '">' . $article['title'] . ' (' . $article['comcnt'] . ')</abbr></a></td></tr>'; $i++; if ($i > 3) { $i = 2; } } } $result .= '</table>'; show_window(__('Most commented articles'), $result); }
// var_dump($alert); if (!isset($alert)) { header('Location: ./?page=unpublished'); exit; } } break; case 'view': if (!$id) { header('Location: /404.php'); exit; } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php'; $stop_words = new stop_words(hasPermissions('articles')); $content = 'content_view.php'; $article = articles::getArticle($id, $uid); $FBShare = array('title' => htmlspecialchars($article['title'], ENT_QUOTES), 'description' => '', 'image' => HTTP_PREFIX . 'www.free-lance.ru/images/free-lance_logo.jpg'); if (!$article) { header('Location: /404.php'); exit; } if ($article['approved'] == 't') { $js_file = array('highlight.min.js', 'highlight.init.js', 'comments.all.js', 'banned.js'); } if ($article['title']) { $page_title = "{$article['title']} - фриланс, удаленная работа на FL.ru"; $page_descr = "{$article['title']} - фриланс, удаленная работа на FL.ru"; } $hidden = array(); if ($article['hidden_threads']) { $hidden_db = preg_replace('/[\\{\\}]/', '', $article['hidden_threads']);
/** * protected функция считывает данные из таблицы БД * * @return bool */ protected function pGetCategorys() { if (CONF_ENABLE_CACHING) { if ($this->getCachingEntrys()) { return true; } else { // записываем в робота дату обновления кеша $articles = new articles(); $strWhere = "token IN ('active') AND datetime>NOW()"; $arrFields = array('datetime'); $arrArticle = $articles->getArticle($strWhere, $arrFields); $arrRobotData[$this->retTableName()] = !empty($arrArticle['datetime']) ? strtotime($arrArticle['datetime']) : false; robot::putClearCacheData($arrRobotData); return !$this->getSubSelectEntrys(false, true, $this->pRetCategoryConf()) ? false : $this->setCachingEntrys(); } } else { return !$this->getSubSelectEntrys(false, true, $this->pRetCategoryConf()) ? false : true; } }
/** * Устанавливает/обновляет закладку * * @param integer $user_id ид пользователя * @param integer $article_id ид сатьи * @param integer $star тип звезды - число от 0 дл 4 * @return bool */ function bookmarkArticle($user_id, $article_id, $star) { global $DB; $article = articles::getArticle($article_id, $user_id); if ($article['bookmark'] === NULL) { $sql = "INSERT INTO articles_users (user_id, article_id, bookmark, bookmark_time)\n VALUES (?i, ?i, ?i, NOW())"; if (!$DB->query($sql, $user_id, $article_id, $star)) { return false; } } else { $sql = "UPDATE articles_users SET bookmark = ?i, bookmark_time = NOW()\n WHERE user_id = ?i AND article_id = ?i"; if (!$DB->query($sql, $star, $user_id, $article_id)) { return false; } } return true; }
<?php //////////////////////////////////////////////////////////////////////////////// // Copyright (C) ReloadCMS Development Team // // http://reloadcms.com // // This product released under GNU General Public License v2 // //////////////////////////////////////////////////////////////////////////////// $articles = new articles(); $c = empty($_GET['c']) || $_GET['c'] == '#hidden' ? null : $_GET['c']; $b = empty($_GET['b']) ? null : (int) $_GET['b']; $a = empty($_GET['a']) ? null : (int) $_GET['a']; if (!empty($a) && (!empty($b) && !empty($c) || $c == '#root')) { if (!$articles->setWorkContainer($c)) { show_error($articles->last_error); } elseif (!($article = $articles->getArticle($b, $a, true, true, true, true))) { show_error($articles->last_error); } elseif ($c !== '#root' && !($category = $articles->getCategory($b, false))) { show_error($articles->last_error); } else { if (!empty($category)) { $article['cat_data'] = $category; } $containers = $articles->getContainers(); $com_text = ''; /* If user posting a comment */ if (!empty($_POST['comtext']) && $article['comments'] == 'yes') { if (isset($system->config['article-guest']) and !LOGGED_IN) { show_error(__('You are not logined!')); } else { if (isset($_POST['antispam']) and isset($_POST['captcheckout'])) { $defcatp = substr(md5($_POST['antispam']), 0, 5);
$total = $system->config['perpage']; $end = $total + $start; if ($end > sizeof($list)) { $end = sizeof($list); } } else { $pages = 1; $page = 0; $start = 0; $total = sizeof($list); } $keys = array_keys($list); for ($a = $start; $a < $end; $a++) { $time =& $list[$keys[$a]]; $id = explode('.', $keys[$a]); if (($category = $articles->getCategory($id[0], true)) !== false && ($article = $articles->getArticle($id[0], $id[1], true, true, false, false)) !== false) { $result .= rcms_parse_module_template('art-article.tpl', $article + array('showtitle' => true, 'linktext' => $articles->linktextArticle($article['text_nonempty'], $article['comcnt'], $article['views']), 'iconurl' => '?module=articles&c=' . $news_container . '&b=' . $id[0], 'linkurl' => '?module=articles&c=' . $news_container . '&b=' . $id[0] . '&a=' . $article['id'], 'cat_data' => $category)); } } $title = isset($category['title']) ? $category['title'] : __(file_get_contents(ARTICLES_PATH . $news_container . '/title')); if (!empty($list)) { $result .= '<div align="right">' . rcms_pagination(sizeof($list), $system->config['perpage'], $page + 1, '?module=' . $module) . '</div>'; } else { $result = __('Nothing founded'); } } show_window($title, $result); } $system->config['pagename'] = __('Latest news'); } } elseif ($system->config['index_module'] != 'empty' && !empty($system->modules['main'][$module])) {