/** * Функция добавления ссылки: */ public static function CreateLink($params) { $cache = KVS::getInstance(); $id = $cache->incr(__CLASS__, null, 'nextId'); if (!ControlModel::CheckLinkfilter($params['link']) && ($category = self::CheckCategory($params['link'])) !== false) { $params['description'] = TexyHelper::typo($params['description']); $record = array('id' => $id, 'link' => preg_replace('/(#.*)$/i', '', $params['link']), 'description' => $params['description'], 'category' => $category, 'board' => $category['board'], 'clicks' => 0, 'visitors' => array($_SERVER['REMOTE_ADDR'])); $cache->set(__CLASS__, 'links', $id, serialize($record)); $cache->expire(__CLASS__, 'links', $id, 60 * 60 * 24); // expire after 24 hours $cache->listAdd(__CLASS__, null, 'links', $id); $cache->set(__CLASS__, null, 'lastUpdate', time()); EventModel::getInstance()->Broadcast('add_online_link', $record); return true; } return false; }
/** * Редактирование комнаты: */ public static function EditRoom($id, $params) { $cache = KVS::getInstance(); $room = self::GetRoom($id); if ($room) { $params = array_merge($room, $params); $params['title'] = TexyHelper::typo($params['title']); $params['description'] = TexyHelper::typo($params['description']); $record = array('room_id' => $id, 'alias' => $params['alias'], 'title' => $params['title'], 'description' => $params['description'], 'controlword' => $params['controlword'], 'password' => $params['password'], 'public' => $params['public']); $cache->set(__CLASS__, $id, 'room', serialize($record)); EventModel::getInstance()->Broadcast('edit_room', $record); } }
/** * Редактирование поста: */ public static function EditPost($id, $params, $safeMode = true) { $session = Session::getInstance(); $dbh = PDOQuery::getInstance(); $post = self::GetPost($id); if ($post['category'] != $params['category']) { Blog_BlogCategoryModel::CountCategory($post['category'], false); Blog_BlogCategoryModel::CountCategory($params['category'], true); } $params['title'] = TexyHelper::typo($params['title']); $params['text'] = TexyHelper::markup($params['text'], !$session->isAdminSession()); $params['text_full'] = TexyHelper::markup($params['text_full'], !$session->isAdminSession()); $record = array('category' => $params['category'], 'link' => $params['link'], 'title' => $params['title'], 'text' => $params['text'], 'text_full' => $params['text_full']); if (!$safeMode) { $record = array_merge($record, array('ip' => $params['ip'], 'hidden' => (bool) $params['hidden'], 'pinned' => (bool) $params['pinned'], 'rated' => (bool) $params['rated'], 'closed' => (bool) $params['closed'], 'rateable' => (bool) $params['rateable'], 'bumpable' => (bool) $params['bumpable'], 'special_comment' => (bool) $params['special_comment'])); } EventModel::getInstance()->Broadcast('edit_post', $id, $record); return $dbh->update('1chan_post', $record, 'id = ' . $dbh->q($id)); }
/** * Действие предпросмотра поста (ajax): */ public function previewPostAjaxAction(Application $application) { $preview = array(); $preview['title'] = TexyHelper::typo(@$_POST['title']); $preview['text'] = TexyHelper::markup(@$_POST['text'], true); $preview['text_full'] = TexyHelper::markup(@$_POST['text_full'], true); $preview['icon'] = @$_POST['link'] ? TemplateHelper::getIcon(@$_POST['link']) : 'http://' . TemplateHelper::getSiteUrl() . '/ico/favicons/1chan.ru.gif'; if (array_key_exists('category', $_POST) && !empty($_POST['category'])) { if (Blog_BlogCategoryModel::CategoryExists($_POST['category'])) { $category = Blog_BlogCategoryModel::GetCategoryByCode($_POST['category']); $preview['category'] = TemplateHelper::BlogCategory($category['id'], 'title'); } } return $preview; }