/** * show thread * * @param integer $intThreadId * @return bool */ function showThread($intThreadId) { global $objDatabase, $_ARRAYLANG; $objFWUser = \FWUser::getFWUserObject(); $this->_communityLogin(); $intThreadId = intval($intThreadId); if (!empty($_REQUEST['notification_update']) && $_REQUEST['notification_update'] == $_ARRAYLANG['TXT_FORUM_UPDATE_NOTIFICATION']) { $this->_updateNotification($intThreadId); } $intCatId = !empty($_REQUEST['category_id']) ? intval($_REQUEST['category_id']) : '0'; if ($intCatId == 0) { $intCatId = $this->_getCategoryIdFromThread($intThreadId); } if (empty($intCatId)) { \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum'); die; } if ($objFWUser->objUser->login()) { $this->_objTpl->touchBlock('notificationRow'); } else { $this->_objTpl->hideBlock('notificationRow'); } $intPostId = !empty($_REQUEST['postid']) ? intval($_REQUEST['postid']) : 0; $intPostId = $intPostId == 0 && !empty($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : $intPostId; $this->_objTpl->setVariable('FORUM_EDIT_POST_ID', $intPostId); $_REQUEST['act'] = !empty($_REQUEST['act']) ? $_REQUEST['act'] : ''; if ($_REQUEST['act'] == 'delete') { if ($this->_checkAuth($intCatId, 'delete')) { if ($this->_deletePost($intCatId, $intThreadId, $_REQUEST['postid'])) { $this->_objTpl->setVariable('TXT_FORUM_SUCCESS', '<br />' . $_ARRAYLANG['TXT_FORUM_DELETED_SUCCESSFULLY']); } else { $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_DELETE_FAILED']); } } else { $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_NO_ACCESS']); } } $pos = !empty($_REQUEST['pos']) ? intval($_REQUEST['pos']) : 0; $this->_objTpl->setVariable(array('FORUM_PAGING_POS' => $pos)); if (!empty($_REQUEST['preview_new'])) { $pos = $this->_getLastPos($intPostId, $intThreadId); } if (!empty($_REQUEST['postid'])) { if ($_REQUEST['act'] == 'quote') { $pos = $this->_getLastPos($intPostId, $intThreadId); } if ($_REQUEST['act'] == 'edit') { $pos = $this->_getEditPos($intPostId, $intThreadId); } } if (!empty($_REQUEST['l']) && $_REQUEST['l'] == 1) { $pos = $this->_getEditPos($intPostId, $intThreadId); } $arrPosts = $this->createPostArray($intThreadId, $pos); if (!empty($_REQUEST['preview_edit']) && $_REQUEST['post_id'] != 0 && $_REQUEST['act'] != 'quote') { $intPostId = intval($intPostId); $pos = $this->_getEditPos($intPostId, $intThreadId); $arrPosts = $this->createPostArray($intThreadId, $pos); $arrPosts[$intPostId]['subject'] = !empty($_REQUEST['subject']) ? contrexx_strip_tags($_REQUEST['subject']) : $_ARRAYLANG['TXT_FORUM_NO_SUBJECT']; $arrPosts[$intPostId]['content'] = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput(contrexx_input2raw($_REQUEST['message'])); } $userId = $objFWUser->objUser->login() ? $objFWUser->objUser->getId() : 0; $icon = !empty($_REQUEST['icons']) ? intval($_REQUEST['icons']) : 1; if ($_REQUEST['act'] == 'edit') { //submit is an edit $arrEditedPost = $this->_getPostingData($intPostId); $subject = addcslashes(htmlentities($arrEditedPost['subject'], ENT_QUOTES, CONTREXX_CHARSET), '\\'); $content = $arrEditedPost['content']; $keywords = addcslashes(htmlentities($arrEditedPost['keywords'], ENT_QUOTES, CONTREXX_CHARSET), '\\'); $attachment = $arrEditedPost['attachment']; $this->_objTpl->setVariable('FORUM_POST_EDIT_USERID', $arrPosts[$intPostId]['user_id']); if (!empty($attachment)) { $this->_objTpl->setVariable('TXT_FORUM_DELETE_ATTACHMENT', sprintf($_ARRAYLANG['TXT_FORUM_DELETE_ATTACHMENT'], $attachment)); } $this->_objTpl->touchBlock('updatePost'); $this->_objTpl->hideBlock('createPost'); $this->_objTpl->hideBlock('previewNewPost'); $this->_objTpl->touchBlock('previewEditPost'); } else { //new post if ($this->_objTpl->blockExists('delAttachment')) { $this->_objTpl->hideBlock('delAttachment'); } $subject = !empty($_REQUEST['subject']) ? contrexx_strip_tags($_REQUEST['subject']) : ''; $content = !empty($_REQUEST['message']) ? contrexx_input2raw(strip_tags($_REQUEST['message'])) : ''; $keywords = !empty($_REQUEST['keywords']) ? contrexx_strip_tags($_REQUEST['keywords']) : ''; $attachment = !empty($_REQUEST['attachment']) ? contrexx_strip_tags($_REQUEST['attachment']) : ''; $this->_objTpl->touchBlock('createPost'); $this->_objTpl->hideBlock('updatePost'); $this->_objTpl->touchBlock('previewNewPost'); $this->_objTpl->hideBlock('previewEditPost'); } if ($_REQUEST['act'] == 'quote') { $quoteContent = $this->_getPostingData($intPostId); $subject = 'RE: ' . addcslashes(htmlentities($quoteContent['subject'], ENT_QUOTES, CONTREXX_CHARSET), '\\'); $content = '[quote=' . $arrPosts[$intPostId]['user_name'] . ']' . strip_tags($quoteContent['content']) . '[/quote]'; } $firstPost = current($arrPosts); if ($this->_arrSettings['wysiwyg_editor'] == 1) { //IF WYSIWIG enabled.. $strMessageInputHTML = new \Cx\Core\Wysiwyg\Wysiwyg('message', $content, 'bbcode'); } else { //plain textarea $strMessageInputHTML = '<textarea style="width: 400px; height: 150px;" rows="5" cols="10" name="message">' . contrexx_raw2xhtml($content) . '</textarea>'; } $this->_objTpl->setGlobalVariable(array('FORUM_JAVASCRIPT_GOTO' => $this->getJavascript('goto'), 'FORUM_JAVASCRIPT_DELETE' => $this->getJavascript('deletePost'), 'FORUM_JAVASCRIPT_SCROLLTO' => $this->getJavascript('scrollto'), 'FORUM_SCROLLPOS' => !empty($_REQUEST['scrollpos']) ? intval($_REQUEST['scrollpos']) : '0', 'FORUM_JAVASCRIPT_INSERT_TEXT' => $this->getJavascript('insertText', array($intCatId, $intThreadId, $firstPost)), 'FORUM_NAME' => $this->_shortenString($firstPost['subject'], $this->_maxStringlength), 'FORUM_TREE' => $this->_createNavTree($intCatId) . '<a title="' . $this->_arrTranslations[$intCatId][$this->_intLangId]['name'] . '" href="index.php?section=Forum&cmd=board&id=' . $intCatId . '">' . $this->_shortenString($this->_arrTranslations[$intCatId][$this->_intLangId]['name'], $this->_maxStringlength) . '</a> > ', 'FORUM_DROPDOWN' => $this->createForumDD('forum_quickaccess', $intCatId, 'onchange="gotoForum(this);"', ''), 'TXT_FORUM_COMMA_SEPARATED_KEYWORDS' => $_ARRAYLANG['TXT_FORUM_COMMA_SEPARATED_KEYWORDS'], 'TXT_FORUM_KEYWORDS' => $_ARRAYLANG['TXT_FORUM_KEYWORDS'], 'TXT_FORUM_FILE_ATTACHMENT' => $_ARRAYLANG['TXT_FORUM_FILE_ATTACHMENT'], 'TXT_FORUM_RATING' => $_ARRAYLANG['TXT_FORUM_RATING'], 'TXT_FORUM_ADD_POST' => $_ARRAYLANG['TXT_FORUM_ADD_POST'], 'TXT_FORUM_SUBJECT' => $_ARRAYLANG['TXT_FORUM_SUBJECT'], 'TXT_FORUM_MESSAGE' => $_ARRAYLANG['TXT_FORUM_MESSAGE'], 'TXT_FORUM_RESET' => $_ARRAYLANG['TXT_FORUM_RESET'], 'TXT_FORUM_CREATE_POST' => $_ARRAYLANG['TXT_FORUM_CREATE_POST'], 'TXT_FORUM_ICON' => $_ARRAYLANG['TXT_FORUM_ICON'], 'TXT_FORUM_QUOTE' => $_ARRAYLANG['TXT_FORUM_QUOTE'], 'TXT_FORUM_EDIT' => $_ARRAYLANG['TXT_FORUM_EDIT'], 'TXT_FORUM_DELETE' => $_ARRAYLANG['TXT_FORUM_DELETE'], 'TXT_FORUM_PREVIEW' => $_ARRAYLANG['TXT_FORUM_PREVIEW'], 'TXT_FORUM_UPDATE_POST' => $_ARRAYLANG['TXT_FORUM_UPDATE_POST'], 'TXT_FORUM_NOTIFY_NEW_POSTS' => $_ARRAYLANG['TXT_FORUM_NOTIFY_NEW_POSTS'], 'TXT_FORUM_QUICKACCESS' => $_ARRAYLANG['TXT_FORUM_QUICKACCESS'], 'TXT_FORUM_UPDATE_NOTIFICATION' => $_ARRAYLANG['TXT_FORUM_UPDATE_NOTIFICATION'], 'TXT_FORUM_THREAD_ACTION_DESC' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_DESC'], 'TXT_FORUM_THREAD_ACTION_MOVE' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_MOVE'], 'TXT_FORUM_THREAD_ACTION_CLOSE' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_CLOSE_' . $firstPost['is_locked']], 'TXT_FORUM_THREAD_ACTION_STICKY' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_STICKY_' . $firstPost['is_sticky']], 'TXT_FORUM_THREAD_ACTION_DELETE' => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_DELETE'], 'TXT_FORUM_CHOOSE_FILE' => $_ARRAYLANG['TXT_FORUM_CHOOSE_FILE'], 'FORUM_NOTIFICATION_CHECKBOX_CHECKED' => $this->_hasNotification($intThreadId) ? 'checked="checked"' : '', 'FORUM_SUBJECT' => stripslashes($subject), 'FORUM_KEYWORDS' => stripslashes($keywords), 'FORUM_ATTACHMENT_OLDNAME' => $attachment, 'FORUM_MESSAGE_INPUT' => $strMessageInputHTML, 'FORUM_CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode(), 'FORUM_THREAD_ID' => $intThreadId, 'FORUM_CATEGORY_ID' => $intCatId, 'FORUM_POSTS_PAGING' => getPaging($this->_postCount, $pos, '§ion=Forum&cmd=thread&id=' . $intThreadId, $_ARRAYLANG['TXT_FORUM_OVERVIEW_POSTINGS'], true, $this->_arrSettings['posting_paging']))); if ($objFWUser->objUser->login()) { $this->_objTpl->hideBlock('captcha'); } else { $this->_objTpl->touchBlock('captcha'); } $this->_setIcons($this->_getIcons()); if (!$this->_checkAuth($intCatId, 'read')) { $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_NO_ACCESS']); return false; } $intCounter = 0; foreach ($arrPosts as $postId => $arrValues) { $strRating = '<span id="forum_current_rating_' . $postId . '" class="rating_%s">%s</span>'; if ($arrValues['rating'] == 0) { $class = 'none'; } elseif ($arrValues['rating'] > 0) { $class = 'pos'; } else { $class = 'neg'; } $strRating = sprintf($strRating, $class, $arrValues['rating']); $strUserProfileLink = $arrValues['user_id'] > 0 ? '<a title="' . $arrValues['user_name'] . '" href="index.php?section=Access&cmd=user&id=' . $arrValues['user_id'] . '">' . $arrValues['user_name'] . '</a>' : $this->_anonymousName; $arrAttachment = $this->_getAttachment($arrValues['attachment']); $this->_objTpl->setGlobalVariable(array('FORUM_POST_ROWCLASS' => $intCounter++ % 2 + 1)); $quoteLink = "id=" . $intThreadId . "&act=quote&postid=" . $postId; $quoteLinkLoggedIn = "location.href='" . \Cx\Core\Csrf\Controller\Csrf::enhanceURI("index.php?section=Forum") . "&cmd=thread&" . htmlentities($quoteLink) . "';"; $quoteLinkNotLoggedIn = "location.href='" . \Cx\Core\Csrf\Controller\Csrf::enhanceURI("index.php?section=Login") . "&redirect=" . base64_encode("index.php?section=Forum&cmd=thread&" . $quoteLink) . "';"; $this->_objTpl->setVariable(array('FORUM_POST_DATE' => $arrValues['time_created'], 'FORUM_POST_LAST_EDITED' => $arrValues['time_edited'] != date(ASCMS_DATE_FORMAT, 0) ? $_ARRAYLANG['TXT_FORUM_LAST_EDITED'] . $arrValues['time_edited'] : '', 'FORUM_USER_ID' => $arrValues['user_id'], 'FORUM_USER_NAME' => $strUserProfileLink, 'FORUM_USER_IMAGE' => !empty($arrValues['user_image']) ? '<img border="0" width="60" height="60" src="' . $arrValues['user_image'] . '" title="' . $arrValues['user_name'] . '\'s avatar" alt="' . $arrValues['user_name'] . '\'s avatar" />' : '', 'FORUM_USER_GROUP' => '', 'FORUM_USER_RANK' => '', 'FORUM_USER_REGISTERED_SINCE' => '', 'FORUM_USER_POSTING_COUNT' => '', 'FORUM_USER_CONTACTS' => '', 'FORUM_POST_NUMBER' => '#' . $arrValues['post_number'], 'FORUM_POST_ICON' => $arrValues['post_icon'], 'FORUM_POST_SUBJECT' => $arrValues['subject'], 'FORUM_POST_MESSAGE' => $arrValues['content'], 'FORUM_POST_RATING' => $strRating, 'FORUM_POST_ATTACHMENT_LINK' => $arrAttachment['webpath'], 'FORUM_POST_ATTACHMENT_FILENAME' => $arrAttachment['name'], 'FORUM_POST_ATTACHMENT_ICON' => $arrAttachment['icon'], 'FORUM_POST_ATTACHMENT_FILESIZE' => $arrAttachment['size'], 'FORUM_QUOTE_ONCLICK' => $this->_checkAuth($intCatId, 'write') ? $quoteLinkLoggedIn : $quoteLinkNotLoggedIn)); if (!$objFWUser->objUser->login() && !$this->_checkAuth($intCatId, 'write')) { $button = '<input type="button" value="' . $_ARRAYLANG['TXT_FORUM_CREATE_POST'] . '" onclick="location.href=\'' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?section=Login') . '&redirect=' . base64_encode($_SERVER['REQUEST_URI']) . '\';" />'; $this->_objTpl->setVariable(array('FORUM_POST_REPLY_REDIRECT' => $button)); } $this->_objTpl->setVariable(array('FORUM_POST_ID' => $postId, 'FORUM_RATING_POST_ID' => $postId)); if ($firstPost['is_locked'] != 1 && ($this->_checkAuth($intCatId, 'edit') || $objFWUser->objUser->login() && $arrValues['user_id'] == $objFWUser->objUser->getId())) { $this->_objTpl->touchBlock('postEdit'); } else { $this->_objTpl->hideBlock('postEdit'); } if ($firstPost['is_locked'] != 1 && ($this->_checkAuth($intCatId, 'write') || !$firstPost['is_locked'])) { $this->_objTpl->touchBlock('postQuote'); } else { $this->_objTpl->hideBlock('postQuote'); } if ($this->_checkAuth($intCatId, 'delete') && $arrValues['post_number'] != 1) { $this->_objTpl->setVariable(array('FORUM_POST_ID' => $postId)); $this->_objTpl->touchBlock('postDelete'); } else { $this->_objTpl->hideBlock('postDelete'); } if ($this->_objTpl->blockExists('rating')) { if ($objFWUser->objUser->login() && !$this->_hasRated($postId)) { $this->_objTpl->parse('rating'); } else { $this->_objTpl->hideBlock('rating'); } } if ($this->_objTpl->blockExists('attachment')) { if (!empty($arrValues['attachment'])) { $this->_objTpl->parse('attachment'); } else { $this->_objTpl->hideBlock('attachment'); } } $this->_objTpl->parse('forumPosts'); } if (!$this->_checkAuth($intCatId, 'write') || $firstPost['is_locked'] == 1) { $this->_objTpl->hideBlock('addPost'); $this->_objTpl->hideBlock('addPostAnchor'); } else { $this->_objTpl->touchBlock('addPostAnchor'); } // initialize the uploader $this->initForumUploader(); //addpost code if (!empty($_REQUEST['create']) && $_REQUEST['create'] == $_ARRAYLANG['TXT_FORUM_CREATE_POST']) { if (!$this->_checkAuth($intCatId, 'write') && $firstPost['is_locked'] != 1) { //auth check $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_NO_ACCESS']); $this->_objTpl->hideBlock('addPost'); return false; } if (!$objFWUser->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) { //captcha check return false; } if (strlen(trim($content)) < $this->_minPostlength) { //content check $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_POST_EMPTY'], $this->_minPostlength)); return false; } if (false !== ($match = $this->_hasBadWords($content))) { $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_BANNED_WORD'], $match[1])); return false; } $fileInfo = $this->_handleUpload('forum_attachment'); if ($fileInfo === false) { //an error occured, the file wasn't properly transferred. exit function to display error set in _handleUpload() return false; } $lastPostIdQuery = ' SELECT max( id ) as last_post_id FROM ' . DBPREFIX . 'module_forum_postings WHERE category_id = ' . $intCatId . ' AND thread_id = ' . $intThreadId; if (($objRSmaxId = $objDatabase->SelectLimit($lastPostIdQuery, 1)) !== false) { $intPrevPostId = $objRSmaxId->fields['last_post_id']; } else { die('Database error: ' . $objDatabase->ErrorMsg()); } $insertQuery = 'INSERT INTO ' . DBPREFIX . 'module_forum_postings ( id, category_id, thread_id, prev_post_id, user_id, time_created, time_edited, is_locked, is_sticky, rating, views, icon, keywords, subject, content, attachment ) VALUES ( NULL, ' . $intCatId . ', ' . $intThreadId . ', ' . $intPrevPostId . ', ' . $userId . ', ' . time() . ', 0, 0, 0, 0, 0, ' . $icon . ",\n '{$keywords}' ,'" . $subject . "', '" . contrexx_raw2db($content) . "', '" . $fileInfo['name'] . "'\n )"; if ($objDatabase->Execute($insertQuery) !== false) { $lastInsertId = $objDatabase->Insert_ID(); $this->updateViewsNewItem($intCatId, $lastInsertId, true); $this->_updateNotification($intThreadId); $this->_sendNotifications($intThreadId, $subject, $content); $pageId = \Cx\Core\Core\Controller\Cx::instanciate()->getPage()->getId(); $cacheManager = new \Cx\Core_Modules\Cache\Controller\CacheManager(); $cacheManager->deleteSingleFile($pageId); } \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum&cmd=thread&id=' . $intThreadId . '&pos=' . $this->_getLastPos($postId, $intThreadId)); die; } if (!empty($_REQUEST['preview_new'])) { $content = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput($content); if (false !== ($match = $this->_hasBadWords($content))) { $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_BANNED_WORD'], $match[1])); return false; } if (strlen(trim($content)) < $this->_minPostlength) { //content check $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_POST_EMPTY'], $this->_minPostlength)); return false; } $this->_objTpl->setVariable(array('FORUM_POST_ROWCLASS' => $intCounter++ % 2 + 1, 'FORUM_POST_DATE' => date(ASCMS_DATE_FORMAT, time()), 'FORUM_USER_ID' => $userId, 'FORUM_USER_NAME' => $objFWUser->objUser->login() ? '<a href="index.php?section=Access&cmd=user&id=' . $userId . '" title="' . htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET) . '">' . htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET) . '</a>' : $this->_anonymousName, 'FORUM_USER_IMAGE' => !empty($arrValues['user_image']) ? '<img border="0" width="60" height="60" src="' . $arrValues['user_image'] . '" title="' . $arrValues['user_name'] . '\'s avatar" alt="' . $arrValues['user_name'] . '\'s avatar" />' : '', 'FORUM_USER_GROUP' => '', 'FORUM_USER_RANK' => '', 'FORUM_USER_REGISTERED_SINCE' => '', 'FORUM_USER_POSTING_COUNT' => '', 'FORUM_USER_CONTACTS' => '', 'FORUM_POST_NUMBER' => '#' . ($this->_postCount + 1), 'FORUM_POST_ICON' => $this->getThreadIcon($icon), 'FORUM_POST_SUBJECT' => stripslashes($subject), 'FORUM_POST_MESSAGE' => $content, 'FORUM_POST_RATING' => '0')); $this->_objTpl->touchBlock('createPost'); $this->_objTpl->hideBlock('updatePost'); if ($this->_objTpl->blockExists('attachment')) { $this->_objTpl->hideBlock('attachment'); } $this->_objTpl->hideBlock('postEdit'); $this->_objTpl->hideBlock('postQuote'); $this->_objTpl->touchBlock('previewNewPost'); $this->_objTpl->hideBlock('previewEditPost'); $this->_objTpl->parse('forumPosts'); } if (!empty($_REQUEST['update']) && $_REQUEST['update'] == $_ARRAYLANG['TXT_FORUM_UPDATE_POST']) { if (strlen(trim($content)) < $this->_minPostlength) { //content size check $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_POST_EMPTY'], $this->_minPostlength)); return false; } if (!$this->_checkAuth($intCatId, 'edit') && (!$objFWUser->objUser->login() || $arrValues['user_id'] != $objFWUser->objUser->getId())) { $this->_objTpl->setVariable('TXT_FORUM_ERROR', '<br />' . $_ARRAYLANG['TXT_FORUM_NO_ACCESS']); $this->_objTpl->hideBlock('postEdit'); return false; } if (!$objFWUser->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) { $this->_objTpl->touchBlock('updatePost'); $this->_objTpl->hideBlock('createPost'); return false; } if (false !== ($match = $this->_hasBadWords($content))) { $this->_objTpl->setVariable('TXT_FORUM_ERROR', sprintf('<br />' . $_ARRAYLANG['TXT_FORUM_BANNED_WORD'], $match[1])); return false; } $fileInfo = $this->_handleUpload('forum_attachment'); if ($fileInfo === false) { //an error occured, the file wasn't properly transferred. exit function to display error set in _handleUpload() return false; } if (empty($_POST['forum_delete_attachment']) && empty($fileInfo['name']) && !empty($_REQUEST['forum_attachment_oldname'])) { $fileInfo['name'] = contrexx_addslashes($_REQUEST['forum_attachment_oldname']); } elseif (!empty($_POST['forum_delete_attachment']) && $_POST['forum_delete_attachment'] == 1 || !empty($_REQUEST['forum_attachment_oldname']) && $fileInfo['name'] != $_REQUEST['forum_attachment_oldname']) { unlink(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteMediaForumUploadPath() . '/' . str_replace(array('./', '.\\'), '', $_REQUEST['forum_attachment_oldname'])); } $updateQuery = 'UPDATE ' . DBPREFIX . 'module_forum_postings SET time_edited = ' . mktime() . ', icon = ' . $icon . ', subject = \'' . $subject . '\', keywords = \'' . $keywords . '\', content = \'' . contrexx_raw2db($content) . '\', attachment = \'' . $fileInfo['name'] . '\' WHERE id = ' . $intPostId; if ($objDatabase->Execute($updateQuery) !== false) { $this->updateViews($intThreadId, $intPostId); $pageId = \Cx\Core\Core\Controller\Cx::instanciate()->getPage()->getId(); $cacheManager = new \Cx\Core_Modules\Cache\Controller\CacheManager(); $cacheManager->deleteSingleFile($pageId); } \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum&cmd=thread&id=' . $intThreadId . '&pos=' . $this->_getLastPos($postId, $intThreadId)); die; } if (!empty($_REQUEST['preview_edit'])) { $this->_objTpl->touchBlock('updatePost'); $this->_objTpl->hideBlock('createPost'); $this->_objTpl->hideBlock('previewNewPost'); $this->_objTpl->touchBlock('previewEditPost'); } $hasAccess = false; foreach (array('STICKY', 'MOVE', 'CLOSE', 'DELETE') as $action) { if (!$this->_checkAuth($intCatId, strtolower($action))) { $this->_objTpl->setVariable('FORUM_THREAD_ACTIONS_DISABLED_' . $action, 'disabled="disabled"'); } else { $hasAccess = true; } } if ($this->_objTpl->blockExists('threadActionsSelect')) { if ($userId < 1 || !$hasAccess) { $this->_objTpl->hideBlock('threadActionsSelect'); } else { $this->_objTpl->touchBlock('threadActionsSelect'); } } if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'move' && !empty($_REQUEST['id'])) { $thread = intval($_REQUEST['id']); $newCat = intval($_REQUEST['moveToThread']); $oldCat = $this->_getCategoryIdFromThread($thread); $query = "UPDATE `" . DBPREFIX . "module_forum_postings` SET `category_id` = {$newCat} WHERE `thread_id` = " . $thread; if ($objDatabase->Execute($query)) { $intMovedPosts = $objDatabase->Affected_Rows(); $query = "SELECT max( `id` ) as `lastid` FROM `" . DBPREFIX . "module_forum_postings` WHERE `thread_id` = {$thread}"; $objRS = $objDatabase->SelectLimit($query, 1); $intMovedPostLastId = $objRS->fields['lastid']; $query = "SELECT max( `id` ) as `lastid` FROM `" . DBPREFIX . "module_forum_postings` WHERE `category_id` = {$oldCat}"; $objRS = $objDatabase->SelectLimit($query, 1); $query = "UPDATE `" . DBPREFIX . "module_forum_statistics` SET `thread_count` = `thread_count` - 1, `post_count` = `post_count` - {$intMovedPosts}, `last_post_id` = " . (intval($objRS->fields['lastid']) > 0 ? intval($objRS->fields['lastid']) : 0) . " WHERE `category_id` = {$oldCat}"; $objDatabase->Execute($query); $query = "SELECT `id` FROM `" . DBPREFIX . "module_forum_postings` WHERE `category_id` = {$newCat} GROUP BY `time_created` DESC"; $objRS = $objDatabase->Execute($query); $query = "UPDATE `" . DBPREFIX . "module_forum_statistics` SET `thread_count` = `thread_count` + 1, `post_count` = `post_count` + {$intMovedPosts}, `last_post_id` = " . $objRS->fields['id'] . " WHERE `category_id` = {$newCat}"; $objDatabase->Execute($query); $this->_objTpl->hideBlock('moveForm'); $this->_objTpl->setVariable(array('TXT_THREAD_ACTION_' . ($success ? 'SUCCESS' : 'ERROR') => $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_MOVE' . (!$success ? 'UN' : '') . 'SUCCESSFUL'], 'FORUM_CATEGORY_ID' => $intCatId, 'FORUM_THREAD_ID' => $intThreadId)); \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum&cmd=thread&id=' . $thread); } } if (!empty($_GET['a'])) { $this->_objTpl->setVariable(array('TXT_FORUM_' . ($_GET['r'] == 1 ? 'SUCCESS' : 'ERROR') => '<br />' . $_ARRAYLANG['TXT_FORUM_THREAD_ACTION_' . strtoupper($_GET['a']) . '_' . (!$_GET['r'] ? 'UN' : '') . 'SUCCESSFUL' . $_GET['s']])); } $success = false; if (!empty($_REQUEST['thread_actions'])) { $action = contrexx_addslashes($_REQUEST['thread_actions']); if ($this->_checkAuth($intCatId, $action)) { switch ($action) { case 'move': $arrForums = $this->createForumArray($this->_intLangId); foreach ($arrForums as $intCatID => $arrThread) { $strOptions .= '<option value="' . $intCatID . '" ' . ($arrThread['level'] == 0 ? 'disabled="disabled"' : '') . '>' . str_repeat(' ', $arrThread['level'] * 2) . $arrThread['name'] . '</option>'; } $this->_objTpl->setVariable(array('FORUM_THREADS' => $strOptions)); $success = true; $suffix = ''; \Env::get('cx')->getPage()->setTitle($_ARRAYLANG['TXT_FORUM_THREAD_ACTION_MOVE']); break; case 'close': $query = "UPDATE `" . DBPREFIX . "module_forum_postings` SET `is_locked` = IF(`is_locked` = '0' OR `is_locked` = '', '1', '0') WHERE thread_id = " . intval($_REQUEST['id']); if ($objDatabase->Execute($query) !== false) { $success = true; } $suffix = '_' . $firstPost['is_locked']; break; case 'sticky': $query = "UPDATE `" . DBPREFIX . "module_forum_postings` SET `is_sticky` = IF(`is_sticky` = '0' OR `is_sticky` = '', '1', '0') WHERE thread_id = " . intval($_REQUEST['id']); if ($objDatabase->Execute($query) !== false) { $success = true; } $suffix = '_' . $firstPost['is_sticky']; break; default: break; } if ($action != 'move') { \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Forum&cmd=thread&id=' . $intThreadId . '&a=' . $action . '&r=' . $success . '&s=' . $suffix); } } else { $this->_objTpl->setVariable('TXT_THREAD_ACTION_ERROR', $_ARRAYLANG['TXT_FORUM_NO_ACCESS']); } $this->_objTpl->parse('threadActions'); $this->_objTpl->touchBlock('threadActions'); $this->_objTpl->hideBlock('threadDisplay'); } else { $this->updateViews($intThreadId, $intPostId); $this->_objTpl->hideBlock('threadActions'); } return true; }
/** * Save the event to the database * * @param array $data * * @return boolean true if saved successfully, false otherwise */ function save($data) { global $objDatabase, $_LANGID, $_CONFIG, $objInit; parent::getSettings(); if (empty($data['startDate']) || empty($data['endDate']) || empty($data['category']) || $data['seriesStatus'] == 1 && $data['seriesType'] == 2 && empty($data['seriesWeeklyDays'])) { return false; } foreach ($_POST['showIn'] as $key => $langId) { if (empty($_POST['title'][$langId]) && empty($_POST['title'][$_LANGID])) { return false; } } list($startDate, $strStartTime) = explode(' ', $data['startDate']); list($startHour, $startMin) = explode(':', $strStartTime); list($endDate, $strEndTime) = explode(' ', $data['endDate']); list($endHour, $endMin) = explode(':', $strEndTime); if ($data['all_day']) { list($startHour, $startMin) = array(0, 0); list($endHour, $endMin) = array(23, 59); } //event data $id = isset($data['copy']) && !empty($data['copy']) ? 0 : (isset($data['id']) ? intval($data['id']) : 0); $type = isset($data['type']) ? intval($data['type']) : 0; $startDate = date("Y-m-d H:i:s", parent::getDateTimestamp($startDate, intval($startHour), intval($startMin))); $endDate = date("Y-m-d H:i:s", parent::getDateTimestamp($endDate, intval($endHour), intval($endMin))); $google = isset($data['map'][$_LANGID]) ? intval($data['map'][$_LANGID]) : 0; $allDay = isset($data['all_day']) ? 1 : 0; $convertBBCode = $objInit->mode == 'frontend' && empty($id); $useCustomDateDisplay = isset($data['showDateSettings']) ? 1 : 0; $showStartDateList = isset($data['showStartDateList']) ? $data['showStartDateList'] : 0; $showEndDateList = isset($data['showEndDateList']) ? $data['showEndDateList'] : 0; if ($objInit->mode == 'backend') { // reset time values if "no time" is selected if ($data['showTimeTypeList'] == 0) { $showStartTimeList = 0; $showEndTimeList = 0; } else { $showStartTimeList = isset($data['showStartTimeList']) ? $data['showStartTimeList'] : ''; $showEndTimeList = isset($data['showEndTimeList']) ? $data['showEndTimeList'] : ''; } $showTimeTypeList = isset($data['showTimeTypeList']) ? $data['showTimeTypeList'] : ''; $showStartDateDetail = isset($data['showStartDateDetail']) ? $data['showStartDateDetail'] : ''; $showEndDateDetail = isset($data['showEndDateDetail']) ? $data['showEndDateDetail'] : ''; // reset time values if "no time" is selected if ($data['showTimeTypeDetail'] == 0) { $showStartTimeDetail = 0; $showEndTimeDetail = 0; } else { $showStartTimeDetail = isset($data['showStartTimeDetail']) ? $data['showStartTimeDetail'] : ''; $showEndTimeDetail = isset($data['showEndTimeDetail']) ? $data['showEndTimeDetail'] : ''; } $showTimeTypeDetail = isset($data['showTimeTypeDetail']) ? $data['showTimeTypeDetail'] : ''; } else { $showStartDateList = $this->arrSettings['showStartDateList'] == 1 ? 1 : 0; $showEndDateList = $this->arrSettings['showEndDateList'] == 1 ? 1 : 0; $showStartTimeList = $this->arrSettings['showStartTimeList'] == 1 ? 1 : 0; $showEndTimeList = $this->arrSettings['showEndTimeList'] == 1 ? 1 : 0; // reset time values if "no time" is selected if ($showStartTimeList == 1 || $showEndTimeList == 1) { $showTimeTypeList = 1; } else { $showStartTimeList = 0; $showEndTimeList = 0; $showTimeTypeList = 0; } $showStartDateDetail = $this->arrSettings['showStartDateDetail'] == 1 ? 1 : 0; $showEndDateDetail = $this->arrSettings['showEndDateDetail'] == 1 ? 1 : 0; $showStartTimeDetail = $this->arrSettings['showStartTimeDetail'] == 1 ? 1 : 0; $showEndTimeDetail = $this->arrSettings['showEndTimeDetail'] == 1 ? 1 : 0; // reset time values if "no time" is selected if ($showStartTimeDetail == 1 || $showEndTimeDetail == 1) { $showTimeTypeDetail = 1; } else { $showStartTimeDetail = 0; $showEndTimeDetail = 0; $showTimeTypeDetail = 0; } } $access = isset($data['access']) ? intval($data['access']) : 0; $priority = isset($data['priority']) ? intval($data['priority']) : 0; $placeMediadir = isset($data['placeMediadir']) ? intval($data['placeMediadir']) : 0; $hostMediadir = isset($data['hostMediadir']) ? intval($data['hostMediadir']) : 0; $price = isset($data['price']) ? contrexx_addslashes(contrexx_strip_tags($data['price'])) : 0; $link = isset($data['link']) ? contrexx_addslashes(contrexx_strip_tags($data['link'])) : ''; $pic = isset($data['picture']) ? contrexx_addslashes(contrexx_strip_tags($data['picture'])) : ''; $attach = isset($data['attachment']) ? contrexx_addslashes(contrexx_strip_tags($data['attachment'])) : ''; $catId = isset($data['category']) ? intval($data['category']) : ''; $showIn = isset($data['showIn']) ? contrexx_addslashes(contrexx_strip_tags(join(",", $data['showIn']))) : ''; $invited_groups = isset($data['selectedGroups']) ? join(',', $data['selectedGroups']) : ''; $invited_mails = isset($data['invitedMails']) ? contrexx_addslashes(contrexx_strip_tags($data['invitedMails'])) : ''; $send_invitation = isset($data['sendInvitation']) ? intval($data['sendInvitation']) : 0; $invitationTemplate = isset($data['invitationEmailTemplate']) ? contrexx_input2db($data['invitationEmailTemplate']) : 0; $registration = isset($data['registration']) ? intval($data['registration']) : 0; $registration_form = isset($data['registrationForm']) ? intval($data['registrationForm']) : 0; $registration_num = isset($data['numSubscriber']) ? intval($data['numSubscriber']) : 0; $registration_notification = isset($data['notificationTo']) ? contrexx_addslashes(contrexx_strip_tags($data['notificationTo'])) : ''; $email_template = isset($data['emailTemplate']) ? contrexx_input2db($data['emailTemplate']) : 0; $ticket_sales = isset($data['ticketSales']) ? intval($data['ticketSales']) : 0; $num_seating = isset($data['numSeating']) ? json_encode(explode(',', $data['numSeating'])) : ''; $related_hosts = isset($data['selectedHosts']) ? $data['selectedHosts'] : ''; $locationType = isset($data['eventLocationType']) ? (int) $data['eventLocationType'] : $this->arrSettings['placeData']; $hostType = isset($data['eventHostType']) ? (int) $data['eventHostType'] : $this->arrSettings['placeDataHost']; $place = isset($data['place']) ? contrexx_input2db(contrexx_strip_tags($data['place'])) : ''; $street = isset($data['street']) ? contrexx_input2db(contrexx_strip_tags($data['street'])) : ''; $zip = isset($data['zip']) ? contrexx_input2db(contrexx_strip_tags($data['zip'])) : ''; $city = isset($data['city']) ? contrexx_input2db(contrexx_strip_tags($data['city'])) : ''; $country = isset($data['country']) ? contrexx_input2db(contrexx_strip_tags($data['country'])) : ''; $placeLink = isset($data['placeLink']) ? contrexx_input2db($data['placeLink']) : ''; $placeMap = isset($data['placeMap']) ? contrexx_input2db($data['placeMap']) : ''; $update_invitation_sent = $send_invitation == 1; if (!empty($placeLink)) { if (!preg_match('%^(?:ftp|http|https):\\/\\/%', $placeLink)) { $placeLink = "http://" . $placeLink; } } if ($objInit->mode == 'frontend') { $unique_id = intval($_REQUEST[self::MAP_FIELD_KEY]); if (!empty($unique_id)) { $picture = $this->_handleUpload('mapUpload', $unique_id); if (!empty($picture)) { $placeMap = $picture; } } } $orgName = isset($data['organizerName']) ? contrexx_input2db($data['organizerName']) : ''; $orgStreet = isset($data['organizerStreet']) ? contrexx_input2db($data['organizerStreet']) : ''; $orgZip = isset($data['organizerZip']) ? contrexx_input2db($data['organizerZip']) : ''; $orgCity = isset($data['organizerCity']) ? contrexx_input2db($data['organizerCity']) : ''; $orgCountry = isset($data['organizerCountry']) ? contrexx_input2db($data['organizerCountry']) : ''; $orgLink = isset($data['organizerLink']) ? contrexx_input2db($data['organizerLink']) : ''; $orgEmail = isset($data['organizerEmail']) ? contrexx_input2db($data['organizerEmail']) : ''; if (!empty($orgLink)) { if (!preg_match('%^(?:ftp|http|https):\\/\\/%', $orgLink)) { $orgLink = "http://" . $orgLink; } } // create thumb if not exists if (!file_exists(\Env::get('cx')->getWebsitePath() . "{$placeMap}.thumb")) { $objImage = new \ImageManager(); $objImage->_createThumb(dirname(\Env::get('cx')->getWebsitePath() . "{$placeMap}") . "/", '', basename($placeMap), 180); } //frontend picture upload & thumbnail creation if ($objInit->mode == 'frontend') { $unique_id = intval($_REQUEST[self::PICTURE_FIELD_KEY]); $attachmentUniqueId = intval($_REQUEST[self::ATTACHMENT_FIELD_KEY]); if (!empty($unique_id)) { $picture = $this->_handleUpload('pictureUpload', $unique_id); if (!empty($picture)) { //delete thumb if (file_exists("{$this->uploadImgPath}{$pic}.thumb")) { \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$pic}.thumb"); } //delete image if (file_exists("{$this->uploadImgPath}{$pic}")) { \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$pic}"); } $pic = $picture; } } if (!empty($attachmentUniqueId)) { $attachment = $this->_handleUpload('attachmentUpload', $attachmentUniqueId); if ($attachment) { //delete file if (file_exists("{$this->uploadImgPath}{$attach}")) { \Cx\Lib\FileSystem\FileSystem::delete_file($this->uploadImgPath . "/.{$attach}"); } $attach = $attachment; } } } else { // create thumb if not exists if (!file_exists(\Env::get('cx')->getWebsitePath() . "{$pic}.thumb")) { $objImage = new \ImageManager(); $objImage->_createThumb(dirname(\Env::get('cx')->getWebsitePath() . "{$pic}") . "/", '', basename($pic), 180); } } $seriesStatus = isset($data['seriesStatus']) ? intval($data['seriesStatus']) : 0; //series pattern $seriesStatus = isset($data['seriesStatus']) ? intval($data['seriesStatus']) : 0; $seriesType = isset($data['seriesType']) ? intval($data['seriesType']) : 0; $seriesPatternCount = 0; $seriesPatternWeekday = 0; $seriesPatternDay = 0; $seriesPatternWeek = 0; $seriesPatternMonth = 0; $seriesPatternType = 0; $seriesPatternDouranceType = 0; $seriesPatternEnd = 0; $seriesExeptions = ''; $seriesPatternEndDate = 0; if ($seriesStatus == 1) { if (!empty($data['seriesExeptions'])) { $exeptions = array(); foreach ($data['seriesExeptions'] as $key => $exeptionDate) { $exeptions[] = date("Y-m-d", parent::getDateTimestamp($exeptionDate, 23, 59)); } sort($exeptions); $seriesExeptions = join(",", $exeptions); } switch ($seriesType) { case 1: if ($seriesStatus == 1) { $seriesPatternType = isset($data['seriesDaily']) ? intval($data['seriesDaily']) : 0; if ($seriesPatternType == 1) { $seriesPatternWeekday = 0; $seriesPatternDay = isset($data['seriesDailyDays']) ? intval($data['seriesDailyDays']) : 0; } else { $seriesPatternWeekday = "1111100"; $seriesPatternDay = 0; } $seriesPatternWeek = 0; $seriesPatternMonth = 0; $seriesPatternCount = 0; } break; case 2: if ($seriesStatus == 1) { $seriesPatternWeek = isset($data['seriesWeeklyWeeks']) ? intval($data['seriesWeeklyWeeks']) : 0; for ($i = 1; $i <= 7; $i++) { if (isset($data['seriesWeeklyDays'][$i])) { $weekdayPattern .= "1"; } else { $weekdayPattern .= "0"; } } $seriesPatternWeekday = $weekdayPattern; $seriesPatternCount = 0; $seriesPatternDay = 0; $seriesPatternMonth = 0; $seriesPatternType = 0; } break; case 3: if ($seriesStatus == 1) { $seriesPatternType = isset($data['seriesMonthly']) ? intval($data['seriesMonthly']) : 0; if ($seriesPatternType == 1) { $seriesPatternMonth = isset($data['seriesMonthlyMonth_1']) ? intval($data['seriesMonthlyMonth_1']) : 0; $seriesPatternDay = isset($data['seriesMonthlyDay']) ? intval($data['seriesMonthlyDay']) : 0; $seriesPatternWeekday = 0; } else { $seriesPatternCount = isset($data['seriesMonthlyDayCount']) ? intval($data['seriesMonthlyDayCount']) : 0; $seriesPatternMonth = isset($data['seriesMonthlyMonth_2']) ? intval($data['seriesMonthlyMonth_2']) : 0; if ($seriesPatternMonth < 1) { // the increment must be at least once a month, otherwise we will end up in a endless loop in the presence $seriesPatternMonth = 1; } $seriesPatternWeekday = isset($data['seriesMonthlyWeekday']) ? $data['seriesMonthlyWeekday'] : ''; $seriesPatternDay = 0; } $seriesPatternWeek = 0; } break; } $seriesPatternDouranceType = isset($data['seriesDouranceType']) ? intval($data['seriesDouranceType']) : 0; switch ($seriesPatternDouranceType) { case 1: $seriesPatternEnd = 0; break; case 2: $seriesPatternEnd = isset($data['seriesDouranceEvents']) ? intval($data['seriesDouranceEvents']) : 0; break; case 3: $seriesPatternEndDate = date("Y-m-d H:i:s", parent::getDateTimestamp($data['seriesDouranceDate'], 23, 59)); break; } } $formData = array('type' => $type, 'startdate' => $startDate, 'enddate' => $endDate, 'use_custom_date_display' => $useCustomDateDisplay, 'showStartDateList' => $showStartDateList, 'showEndDateList' => $showEndDateList, 'showStartTimeList' => $showStartTimeList, 'showEndTimeList' => $showEndTimeList, 'showTimeTypeList' => $showTimeTypeList, 'showStartDateDetail' => $showStartDateDetail, 'showEndDateDetail' => $showEndDateDetail, 'showStartTimeDetail' => $showStartTimeDetail, 'showEndTimeDetail' => $showEndTimeDetail, 'showTimeTypeDetail' => $showTimeTypeDetail, 'google' => $google, 'access' => $access, 'priority' => $priority, 'price' => $price, 'link' => $link, 'pic' => $pic, 'catid' => $catId, 'attach' => $attach, 'place_mediadir_id' => $placeMediadir, 'host_mediadir_id' => $hostMediadir, 'show_in' => $showIn, 'invited_groups' => $invited_groups, 'invited_mails' => $invited_mails, 'invitation_email_template' => json_encode($invitationTemplate), 'registration' => $registration, 'registration_form' => $registration_form, 'registration_num' => $registration_num, 'registration_notification' => $registration_notification, 'email_template' => json_encode($email_template), 'ticket_sales' => $ticket_sales, 'num_seating' => $num_seating, 'series_status' => $seriesStatus, 'series_type' => $seriesType, 'series_pattern_count' => $seriesPatternCount, 'series_pattern_weekday' => $seriesPatternWeekday, 'series_pattern_day' => $seriesPatternDay, 'series_pattern_week' => $seriesPatternWeek, 'series_pattern_month' => $seriesPatternMonth, 'series_pattern_type' => $seriesPatternType, 'series_pattern_dourance_type' => $seriesPatternDouranceType, 'series_pattern_end' => $seriesPatternEnd, 'series_pattern_end_date' => $seriesPatternEndDate, 'series_pattern_exceptions' => $seriesExeptions, 'all_day' => $allDay, 'location_type' => $locationType, 'host_type' => $hostType, 'place' => $place, 'place_id' => 0, 'place_street' => $street, 'place_zip' => $zip, 'place_city' => $city, 'place_country' => $country, 'place_link' => $placeLink, 'place_map' => $placeMap, 'org_name' => $orgName, 'org_street' => $orgStreet, 'org_zip' => $orgZip, 'org_city' => $orgCity, 'org_country' => $orgCountry, 'org_link' => $orgLink, 'org_email' => $orgEmail, 'invitation_sent' => $update_invitation_sent ? 1 : 0); if ($id != 0) { $query = \SQL::update("module_{$this->moduleTablePrefix}_event", $formData) . " WHERE id = '{$id}'"; $objResult = $objDatabase->Execute($query); if ($objResult !== false) { $this->id = $id; $query = "DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_event_field\n WHERE event_id = '" . $id . "'"; $objResult = $objDatabase->Execute($query); $query = "DELETE FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_event_host\n WHERE event_id = '" . $id . "'"; $objResult = $objDatabase->Execute($query); } else { return false; } } else { $objFWUser = \FWUser::getFWUserObject(); $objUser = $objFWUser->objUser; if ($objInit->mode == 'frontend') { $status = 1; $confirmed = $this->arrSettings['confirmFrontendEvents'] == 1 ? 0 : 1; $author = $objUser->login() ? intval($objUser->getId()) : 0; } else { $status = 0; $confirmed = 1; $author = intval($objUser->getId()); } $formData['status'] = $status; $formData['confirmed'] = $confirmed; $formData['author'] = $author; $query = \SQL::insert("module_{$this->moduleTablePrefix}_event", $formData); $objResult = $objDatabase->Execute($query); if ($objResult !== false) { $id = intval($objDatabase->Insert_ID()); $this->id = $id; } else { return false; } } if ($id != 0) { foreach ($data['showIn'] as $key => $langId) { $title = contrexx_addslashes(contrexx_strip_tags($data['title'][$langId])); $description = contrexx_addslashes($data['description'][$langId]); if ($convertBBCode) { $description = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($data['description'][$langId], true); } $redirect = contrexx_addslashes($data['calendar-redirect'][$langId]); if ($type == 0) { $redirect = ''; } else { $description = ''; } $query = "INSERT INTO " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_event_field\n (`event_id`,`lang_id`,`title`, `description`,`redirect`)\n VALUES\n ('" . intval($id) . "','" . intval($langId) . "','" . $title . "','" . $description . "','" . $redirect . "')"; $objResult = $objDatabase->Execute($query); if ($objResult === false) { return false; } } if (!empty($related_hosts)) { foreach ($related_hosts as $key => $hostId) { $query = "INSERT INTO " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_event_host\n (`host_id`,`event_id`) \n VALUES ('" . intval($hostId) . "','" . intval($id) . "')"; $objResult = $objDatabase->Execute($query); } } } if ($send_invitation == 1) { $objMailManager = new \Cx\Modules\Calendar\Controller\CalendarMailManager(); foreach ($invitationTemplate as $templateId) { $objMailManager->sendMail(intval($id), \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_INVITATION, null, $templateId); } } return true; }
/** * Insert new locales after submit news from frontend * @global ADONewConnection * @param Integer $newsId * @param String $title * @param String $text * @param String $teaser_text * @return Boolean */ private function storeLocalesOfSubmittedNewsMessage($newsId, $title, $text, $teaser_text) { global $objDatabase; if (empty($newsId)) { return false; } $status = true; $arrActiveFrontendLanguages = array_keys(\FWLanguage::getActiveFrontendLanguages()); foreach ($arrActiveFrontendLanguages as $langId) { $query = "INSERT INTO " . DBPREFIX . "module_news_locale (`lang_id`, `news_id`, `title`, `text`, `teaser_text`)\n VALUES (" . intval($langId) . ", " . intval($newsId) . ", '" . contrexx_raw2db($title) . "', '" . \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($text, true) . "', '" . contrexx_raw2db($teaser_text) . "')"; if (!$objDatabase->Execute($query)) { $status = false; } } return $status; }
/** * create an array containing all posts from the specified thread * if the second argument $pos is -1, then all posts are being returned, otherwise * it will be limited to the thread_paging setting * * if $intThreadId = 0 and $pos = -1, then all posts from all threads are returned * * @param integer $intThreadId ID of the thread * @param integer $pos position at which the posts will be read from (for paging) * @return array $arrReturn */ function createPostArray($intThreadId = 0, $pos = 0) { global $objDatabase, $_ARRAYLANG; $intThreadId = intval($intThreadId); $arrReturn = array(); if ($intThreadId > 0) { $WHERE = ' WHERE thread_id=' . $intThreadId; } elseif ($pos < 0) { $WHERE = ' '; } $objRSCount = $objDatabase->SelectLimit(' SELECT count(1) AS `cnt` FROM ' . DBPREFIX . 'module_forum_postings ' . $WHERE, 1); if ($objRSCount !== false) { $this->_postCount = $objRSCount->fields['cnt']; } if ($pos == -1) { $this->_arrSettings['posting_paging'] = $this->_postCount + 1; $pos = 0; } $objResult = $objDatabase->SelectLimit('SELECT id, category_id, thread_id, user_id, time_created, time_edited, is_locked, is_sticky, rating, views, icon, keywords, subject, content, attachment FROM ' . DBPREFIX . 'module_forum_postings ' . $WHERE . ' ORDER BY prev_post_id, time_created ASC ', $this->_arrSettings['posting_paging'], $pos); $intReplies = $objResult->RecordCount(); $postNumber = $pos + 1; while (!$objResult->EOF) { $strAuthor = $this->_getUserName($objResult->fields['user_id']); // $content = stripslashes($objResult->fields['content']); $content = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput($objResult->fields['content']); $arrReturn[$objResult->fields['id']] = array('id' => $objResult->fields['id'], 'thread_id' => $objResult->fields['thread_id'], 'category_id' => $objResult->fields['category_id'], 'user_id' => $objResult->fields['user_id'], 'user_name' => $strAuthor, 'time_created' => date(ASCMS_DATE_FORMAT, $objResult->fields['time_created']), 'time_edited' => date(ASCMS_DATE_FORMAT, $objResult->fields['time_edited']), 'timestamp_created' => $objResult->fields['time_created'], 'timestamp_edited' => $objResult->fields['time_edited'], 'is_locked' => intval($objResult->fields['is_locked']), 'is_sticky' => intval($objResult->fields['is_sticky']), 'rating' => intval($objResult->fields['rating']), 'post_icon' => $this->getThreadIcon($objResult->fields['icon']), 'replies' => $intReplies, 'views' => intval($objResult->fields['views']), 'icon' => intval($objResult->fields['icon']), 'keywords' => htmlspecialchars($objResult->fields['keywords'], ENT_QUOTES, CONTREXX_CHARSET), 'subject' => !trim($objResult->fields['subject']) == '' ? htmlspecialchars($objResult->fields['subject'], ENT_QUOTES, CONTREXX_CHARSET) : $_ARRAYLANG['TXT_FORUM_NO_SUBJECT'], 'content' => $content, 'attachment' => htmlspecialchars($objResult->fields['attachment'], ENT_QUOTES, CONTREXX_CHARSET), 'post_number' => $postNumber++); $objResult->MoveNext(); } return $arrReturn; }
/** * Shows all existing comments of the entry with the id $intEntryId. * * @global array * @global array * @global ADONewConnection * @param integer $intEntryId: The comments of this entry will shown. */ function showComments($intEntryId) { global $_CORELANG, $_ARRAYLANG, $objDatabase; $this->_strPageTitle = $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_COMMENTS']; $this->_objTpl->loadTemplateFile('module_blog_entries_comments.html', true, true); $this->_objTpl->setVariable(array('TXT_COMMENTS_TITLE' => $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_COMMENTS'], 'TXT_COMMENTS_DATE' => $_ARRAYLANG['TXT_BLOG_ENTRY_VOTES_DATE'], 'TXT_COMMENTS_SUBJECT' => $_ARRAYLANG['TXT_BLOG_ENTRY_ADD_SUBJECT'], 'TXT_COMMENTS_CONTENT' => $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_COMMENT'], 'TXT_COMMENTS_LANGUAGE' => $_ARRAYLANG['TXT_BLOG_ENTRY_COMMENTS_LANGUAGE'], 'TXT_COMMENTS_USER' => $_CORELANG['TXT_USER'], 'TXT_COMMENTS_ACTION' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_ACTIONS'], 'TXT_COMMENTS_MARKED' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_MARKED'], 'TXT_COMMENTS_SELECT_ALL' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_SELECT'], 'TXT_COMMENTS_DESELECT_ALL' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_DESELECT'], 'TXT_COMMENTS_SUBMIT_SELECT' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_ACTION'], 'TXT_COMMENTS_SUBMIT_ACTIVATE' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_ACTIVATE'], 'TXT_COMMENTS_SUBMIT_DEACTIVATE' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_DEACTIVATE'], 'TXT_COMMENTS_SUBMIT_DELETE' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_DELETE'], 'TXT_COMMENTS_SUBMIT_DELETE_JS' => $_ARRAYLANG['TXT_BLOG_ENTRY_COMMENTS_DELETE_JS_ALL'], 'TXT_COMMENTS_DELETE_JS' => $_ARRAYLANG['TXT_BLOG_ENTRY_COMMENTS_DELETE_JS'], 'TXT_COMMENTS_BUTTON_BACK' => ucfirst($_CORELANG['TXT_BACK']))); $intEntryId = intval($intEntryId); $intPagingPosition = isset($_GET['pos']) ? intval($_GET['pos']) : 0; if ($intEntryId > 0) { // TODO: $arrEntries is not defined // @$this->_objTpl->setVariable('COMMENTS_SUBJECT', $arrEntries[$intEntryId]['subject']); $objCommentsResult = $objDatabase->Execute('SELECT comment_id, lang_id, is_active, time_created, user_id, user_name, subject, comment FROM ' . DBPREFIX . 'module_blog_comments WHERE message_id=' . $intEntryId . ' ORDER BY time_created DESC, comment_id DESC LIMIT ' . $intPagingPosition . ',' . $this->getPagingLimit() . ' '); if ($objCommentsResult->RecordCount() > 0) { $objFWUser = \FWUser::getFWUserObject(); $intRowClass = 1; while (!$objCommentsResult->EOF) { $this->_objTpl->setVariable(array('TXT_IMGALT_STATUS' => $_ARRAYLANG['TXT_BLOG_ENTRY_COMMENTS_STATUS'], 'TXT_IMGALT_EDIT' => $_ARRAYLANG['TXT_BLOG_ENTRY_COMMENTS_EDIT'], 'TXT_IMGALT_DELETE' => $_ARRAYLANG['TXT_BLOG_ENTRY_COMMENTS_DELETE'])); $strComment = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput($objCommentsResult->fields['comment']); $strComment = strlen($strComment) > 60 ? substr($strComment, 0, 60) . ' ...' : $strComment; $this->_objTpl->setVariable(array('COMMENT_ROWCLASS' => $intRowClass % 2 == 0 ? 'row1' : 'row2', 'COMMENT_ID' => $objCommentsResult->fields['comment_id'], 'COMMENT_STATUS_ICON' => $objCommentsResult->fields['is_active'] == 1 ? 'led_green' : 'led_red', 'COMMENT_DATE' => date(ASCMS_DATE_FORMAT, $objCommentsResult->fields['time_created']), 'COMMENT_SUBJECT' => htmlentities(stripslashes($objCommentsResult->fields['subject']), ENT_QUOTES, CONTREXX_CHARSET), 'COMMENT_CONTENT' => stripslashes($strComment), 'COMMENT_LANGUAGE' => $this->_arrLanguages[$objCommentsResult->fields['lang_id']]['long'], 'COMMENT_USER' => $objCommentsResult->fields['user_id'] != 0 && ($objUser = $objFWUser->objUser->getUser($objCommentsResult->fields['user_id'])) !== false ? '<a href="index.php?cmd=Access&act=user&tpl=modify&id=' . $objCommentsResult->fields['user_id'] . '" title="' . htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET) . '">' . htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET) . '</a>' : htmlentities(stripslashes($objCommentsResult->fields['user_name']), ENT_QUOTES, CONTREXX_CHARSET))); $this->_objTpl->parse('showComments'); $objCommentsResult->MoveNext(); ++$intRowClass; } //Show paging if needed if ($this->countComments($intEntryId) > $this->getPagingLimit()) { $strPaging = getPaging($this->countComments($intEntryId), $intPagingPosition, '&cmd=Blog&act=showComments&id=' . $intEntryId, '<strong>' . $_ARRAYLANG['TXT_BLOG_ENTRY_VOTES_DETAILS'] . '</strong>', true, $this->getPagingLimit()); $this->_objTpl->setVariable('COMMENTS_PAGING', $strPaging); } } else { $this->_objTpl->setVariable('TXT_COMMENTS_NONE', $_ARRAYLANG['TXT_BLOG_ENTRY_COMMENTS_NONE']); $this->_objTpl->parse('noComments'); } } else { $this->_strErrMessage = $_ARRAYLANG['TXT_BLOG_ENTRY_EDIT_ERROR_ID']; } }
/** * Show the message when the user clicks on the notification * * @global $_ARRAYLANG $objDatabase $_CORELANG */ function showMessage() { global $_ARRAYLANG, $objDatabase, $_CORELANG; if (!empty($_GET["msgID"])) { $messageID = $_GET["msgID"]; } $arrMessage = $this->createEntryShowMessage($messageID); if ($_REQUEST['status'] == "outboxmsg") { $this->_objTpl->setVariable(array('PRIVATE_MESSAGE_ID' => $messageID, 'PRIVATE_MESSAGE_TITLE' => $arrMessage["message_title"], 'PRIVATE_MESSAGE_TEXT' => \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput($arrMessage["message"]), 'U2U_USER_JOINED' => $arrMessage["registerd_date"], 'MESSAGE_AUTHOR_NAME' => $arrMessage["username"], 'MESSAGE_SENT_DATE' => $arrMessage["date_time"], 'TXT_PRIVATE_MESSAGE' => $_ARRAYLANG['TXT_U2U_PRIVATE_MESSAGE'], 'TXT_U2U_ENTRY_ADD_SUCCESS_MESSAGE' => $_ARRAYLANG['TXT_U2U_ENTRY_ADD_SUCCESS_MESSAGE'], 'TXT_U2U_AUTHOR' => $_ARRAYLANG['TXT_U2U_RECEIPENT_USER_OUTBOX'], 'TXT_U2U_MESSAGE_SENT_DATE' => $_ARRAYLANG['TXT_U2U_MESSAGE_SENT_DATE'], 'TXT_U2U_OUTBOX_SEND_MESSAGE' => $_ARRAYLANG['TXT_U2U_OUTBOX_SEND_MESSAGE'], 'TXT_U2U_USER_JOINED_DATE' => $_ARRAYLANG['TXT_U2U_USER_JOINED_DATE'], 'TXT_U2U_DELETE_THIS_MESSAGE' => $_ARRAYLANG['TXT_U2U_DELETE_THIS_MESSAGE'], 'TXT_U2U_DELETE_MESSAGE' => $_ARRAYLANG['TXT_U2U_DELETE_MESSAGE'], 'TXT_U2U_DELETE_STRING' => $_ARRAYLANG['TXT_U2U_DELETE_STRING'])); $this->_objTpl->hideBlock('showForwardandReply'); } else { $this->_objTpl->setVariable(array('PRIVATE_MESSAGE_ID' => $messageID, 'PRIVATE_MESSAGE_TITLE' => $arrMessage["message_title"], 'PRIVATE_MESSAGE_TEXT' => \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForOutput($arrMessage["message"]), 'U2U_USER_JOINED' => $arrMessage["registerd_date"], 'MESSAGE_AUTHOR_NAME' => $arrMessage["username"], 'MESSAGE_SENT_DATE' => $arrMessage["date_time"], 'TXT_PRIVATE_MESSAGE' => $_ARRAYLANG['TXT_U2U_PRIVATE_MESSAGE'], 'TXT_U2U_ENTRY_ADD_SUCCESS_MESSAGE' => $_ARRAYLANG['TXT_U2U_ENTRY_ADD_SUCCESS_MESSAGE'], 'TXT_U2U_AUTHOR' => $_ARRAYLANG['TXT_U2U_AUTHOR'], 'TXT_U2U_MESSAGE_SENT_DATE' => $_ARRAYLANG['TXT_U2U_MESSAGE_SENT_DATE'], 'TXT_U2U_USER_JOINED_DATE' => $_ARRAYLANG['TXT_U2U_USER_JOINED_DATE'], 'TXT_U2U_DELETE_THIS_MESSAGE' => $_ARRAYLANG['TXT_U2U_DELETE_THIS_MESSAGE'], 'TXT_U2U_DELETE_MESSAGE' => $_ARRAYLANG['TXT_U2U_DELETE_MESSAGE'], 'TXT_U2U_DELETE_STRING' => $_ARRAYLANG['TXT_U2U_DELETE_STRING'], 'TXT_U2U_FORWARD' => $_ARRAYLANG['TXT_U2U_FORWARD'], 'TXT_U2U_REPLY' => $_ARRAYLANG['TXT_U2U_REPLY'])); $this->_objTpl->hideBlock('sendMessageOutbox'); } }
/** * Insert a new comment for a message into database, if the function is activated. Furthermore, all input values are validated. * Sends also the notification mail to the administrator, if it is enabled in options. * * @global ADONewConnection * @global array * @global array */ function addComment() { global $objDatabase, $_ARRAYLANG, $_CONFIG; \Cx\Core\Csrf\Controller\Csrf::check_code(); $this->initUserId(); //Check for activated function if (!$this->_arrSettings['blog_comments_activated']) { $this->_strErrorMessage = $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_ERROR_ACTIVATED']; return; } if ($this->hasUserJustCommented()) { $this->_strErrorMessage = str_replace('[SECONDS]', intval($this->_arrSettings['blog_comments_timeout']), $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_ERROR_TIMEOUT']); return; } //Create validator-object $objValidator = new \FWValidator(); //Get general-input $intMessageId = intval($_POST['frmAddComment_MessageId']); $strSubject = contrexx_addslashes(strip_tags($_POST['frmAddComment_Subject'])); $strComment = \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($_POST['frmAddComment_Comment']); //Get specified-input if ($this->_intCurrentUserId == 0) { $intUserId = 0; $strName = contrexx_addslashes(strip_tags($_POST['frmAddComment_Name'])); $strEMail = contrexx_addslashes(strip_tags($_POST['frmAddComment_EMail'])); $strWWW = contrexx_addslashes(strip_tags($objValidator->getUrl($_POST['frmAddComment_WWW']))); } else { $intUserId = $this->_intCurrentUserId; $strName = ''; $strEMail = ''; $strWWW = ''; } //Get options $intIsActive = intval($this->_arrSettings['blog_comments_autoactivate']); $intIsNotification = intval($this->_arrSettings['blog_comments_notification']); //Validate general-input if ($intMessageId <= 0) { $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MID']); } if (empty($strSubject)) { $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_SUBJECT']); } if (empty($strComment)) { $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_COMMENT']); } //Validate specified-input if ($this->_intCurrentUserId == 0) { if (empty($strName)) { $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_NAME']); } if (!$objValidator->isEmail($strEMail)) { $this->_strErrorMessage .= $this->getFormError($_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_ADD_EMAIL']); } } $captchaCheck = true; if (!\FWUser::getFWUserObject()->objUser->login() && !\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) { $captchaCheck = false; } //Now check error-string if (empty($this->_strErrorMessage) && $captchaCheck) { //No errors, insert entry $objDatabase->Execute(' INSERT INTO ' . DBPREFIX . 'module_blog_comments SET message_id = ' . $intMessageId . ', lang_id = ' . $this->_intLanguageId . ', is_active = "' . $intIsActive . '", time_created = ' . time() . ', ip_address = "' . $_SERVER['REMOTE_ADDR'] . '", user_id = ' . $intUserId . ', user_name = "' . $strName . '", user_mail = "' . $strEMail . '", user_www = "' . $strWWW . '", subject = "' . $strSubject . '", comment = "' . $strComment . '" '); //Set a cookie with the current timestamp. Avoids flooding. setcookie('BlogCommentLast', time(), 0, ASCMS_PATH_OFFSET . '/'); $this->_strStatusMessage = $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_SUCCESS']; $this->writeCommentRSS(); if ($intIsNotification) { //Send notification to administrator if (\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) { $objMail = new \phpmailer(); if ($_CONFIG['coreSmtpServer'] > 0) { if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) { $objMail->IsSMTP(); $objMail->Host = $arrSmtp['hostname']; $objMail->Port = $arrSmtp['port']; $objMail->SMTPAuth = true; $objMail->Username = $arrSmtp['username']; $objMail->Password = $arrSmtp['password']; } } if ($this->_intCurrentUserId > 0) { $objFWUser = \FWUser::getFWUserObject(); $strName = htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET); } $strMailSubject = str_replace('[SUBJECT]', $strSubject, $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MAIL_SUBJECT']); $strMailBody = str_replace('[USERNAME]', $strName, $_ARRAYLANG['TXT_BLOG_FRONTEND_DETAILS_COMMENT_INSERT_MAIL_BODY']); $strMailBody = str_replace('[DOMAIN]', ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, $strMailBody); $strMailBody = str_replace('[SUBJECT]', $strSubject, $strMailBody); $strMailBody = str_replace('[COMMENT]', $strComment, $strMailBody); $objMail->CharSet = CONTREXX_CHARSET; $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']); $objMail->AddAddress($_CONFIG['coreAdminEmail']); $objMail->Subject = $strMailSubject; $objMail->IsHTML(false); $objMail->Body = $strMailBody; $objMail->Send(); } } } }