} } //END ATTACHMENT PROCESSING } else { $smarty->assign('was_queued', 'n'); $_REQUEST['was_queued'] = 'n'; if ($_REQUEST["comments_threadId"] == 0) { $message_id = ''; if (isset($_REQUEST["anonymous_name"])) { $anonymous_name = trim(strip_tags($_REQUEST["anonymous_name"])); } else { $anonymous_name = ''; } // Handle "Post as Anonymous" feature $post_author = $post_as_anonymous ? '' : $user; $qId = $commentslib->post_new_comment($comments_objectId, $parent_id, $post_author, $_REQUEST["comments_title"], $_REQUEST["comments_data"], $message_id, $in_reply_to, 'n', '', '', isset($_REQUEST['contributions']) ? $_REQUEST['contributions'] : '', $anonymous_name); if ($object[0] != "forum") { $smarty->assign("comments_parentId", 0); // to display all the comments $_REQUEST["comments_parentId"] = 0; } $_REQUEST["comments_reply_threadId"] = $_REQUEST["comments_parentId"]; // to have the right re: $smarty->assign("comments_reply_threadId", $_REQUEST["comments_parentId"]); // without the flag } else { $qId = $_REQUEST["comments_threadId"]; if ($tiki_p_edit_comments == 'y' && (!isset($forum_mode) || $forum_mode == 'n') || ($tiki_p_forum_post == 'y' || $tiki_p_admin_forum == 'y') && isset($forum_mode) && $forum_mode == 'y' || $commentslib->user_can_edit_post($user, $_REQUEST["comments_threadId"])) { $commentslib->update_comment($_REQUEST["comments_threadId"], $_REQUEST["comments_title"], $_REQUEST["comment_rating"], $_REQUEST["comments_data"], 'n', '', '', $comments_objectId, isset($_REQUEST['contributions']) ? $_REQUEST['contributions'] : ''); } }
$_REQUEST["comments_data"] = strip_tags($_REQUEST["comments_data"]); if ($_REQUEST["comments_threadId"] == 0) { if (isset($_REQUEST["comments_reply_threadId"]) && !empty($_REQUEST["comments_reply_threadId"])) { $reply_info = $commentslib->get_comment($_REQUEST["comments_reply_threadId"]); $in_reply_to = $reply_info["message_id"]; } else { $in_reply_to = ''; } $message_id = ''; $object = explode(':', $comments_objectId); if ($object[0] == 'forum' && !empty($_REQUEST["comments_grandParentId"])) { $parent_id = $_REQUEST["comments_grandParentId"]; } else { $parent_id = $_REQUEST["comments_parentId"]; } $qId = $commentslib->post_new_comment($comments_objectId, $parent_id, $user, $_REQUEST["comments_title"], $_REQUEST["comments_data"], $message_id, $in_reply_to); if ($object[0] != "forum") { $smarty->assign("comments_parentId", 0); // to display all the comments $_REQUEST["comments_parentId"] = 0; } $_REQUEST["comments_reply_threadId"] = $_REQUEST["comments_parentId"]; // to have the right re: $smarty->assign("comments_reply_threadId", $_REQUEST["comments_parentId"]); // without the flag } else { $qId = $_REQUEST["comments_threadId"]; if ($tiki_p_edit_comments == 'y' && (!isset($forum_mode) || $forum_mode == 'n') || ($tiki_p_forum_post == 'y' || $tiki_p_admin_forum == 'y') && isset($forum_mode) && $forum_mode == 'y' || $commentslib->user_can_edit_post($user, $_REQUEST["comments_threadId"])) { $commentslib->update_comment($_REQUEST["comments_threadId"], $_REQUEST["comments_title"], $_REQUEST["comment_rating"], $_REQUEST["comments_data"]); } }
/** * Insert comments for a wiki page or post * * @param int|string $objId int for a post id or string for a wiki page name (used as id) * @param string $objType 'blog post' or 'wiki page' * @param array $comments * @return void */ function insertComments($objId, $objType, $comments) { global $commentslib; require_once 'lib/comments/commentslib.php'; if (!is_object($commentslib)) { $commentslib = new Comments(); } $objRef = $objType . ':' . $objId; // not used but required by $commentslib->post_new_comment() as is passed by reference $message_id = ''; foreach ($comments as $comment) { // set empty values for comments properties if they are not set if (!isset($comment['author'])) { $comment['author'] = ''; } if (!isset($comment['author_email'])) { $comment['author_email'] = ''; } if (!isset($comment['author_url'])) { $comment['author_url'] = ''; } $commentId = $commentslib->post_new_comment($objRef, 0, null, '', $comment['data'], $message_id, '', 'n', '', '', '', $comment['author'], $comment['created'], $comment['author_email'], $comment['author_url']); if ($comment['approved'] == 0) { $commentslib->approve_comment($commentId, 'n'); } } }
function create_page($info) { global $tikilib, $wikilib, $prefs, $tiki_p_wiki_attach_files, $tiki_p_edit_comments, $dbTiki, $tikidomain; if (($info['data'] = $this->zip->getFromName($info['zip'])) === false) { $this->errors[] = 'Can not unzip'; $this->errorsArgs[] = $info['zip']; return false; } if ($this->page_exists($info['name'])) { $old = true; $tikilib->update_page($info['name'], $info['data'], 'Updated from import', !empty($this->config['fromUser']) ? $this->config['fromUser'] : $info['user'], !empty($this->config['fromSite']) ? $this->config['fromSite'] : $info['ip'], $info['description'], 0, isset($info['lang']) ? $info['lang'] : '', isset($info['is_html']) ? $info['is_html'] : false, null, null, isset($info['wysiwyg']) ? $info['wysiwyg'] : NULL); } else { $old = false; $tikilib->create_page($info['name'], $info['hits'], $info['data'], $info['lastModif'], $info['comment'], !empty($this->config['fromUser']) ? $this->config['fromUser'] : $info['user'], !empty($this->config['fromSite']) ? $this->config['fromSite'] : $info['ip'], $info['description'], isset($info['lang']) ? $info['lang'] : '', isset($info['is_html']) ? $info['is_html'] : false, null, isset($info['wysiwyg']) ? $info['wysiwyg'] : NULL, '', 0, $info['created']); } if ($prefs['feature_wiki_comments'] == 'y' && $tiki_p_edit_comments == 'y' && !empty($info['comments'])) { foreach ($info['comments'] as $comment) { global $commentslib; include_once 'lib/comments/commentslib.php'; $commentslib = new Comments($dbTiki); $parentId = empty($comment['parentId']) ? 0 : $newThreadIds[$comment['parentId']]; if ($parentId) { $reply_info = $commentslib->get_comment($parentd); $in_reply_to = $reply_info['message_id']; } $newThreadIds[$comment['threadId']] = $commentslib->post_new_comment('wiki page:' . $info['name'], $parentId, $config['fromUser'] ? $config['fromUser'] : $comment['user'], $comment['title'], $comment['data'], $message_id, $reply_to, 'n', '', '', '', '', $comment['date']); } } if ($prefs['feature_wiki_attachments'] == 'y' && $tiki_p_wiki_attach_files == 'y' && !empty($info['attachments'])) { foreach ($info['attachments'] as $attachment) { if (($attachment['data'] = $this->zip->getFromName($attachment['zip'])) === false) { $this->errors[] = 'Can not unzip attachment'; $this->errorsArgs[] = $attachment['zip']; return false; } if ($prefs['w_use_db'] == 'y') { $fhash = ''; } else { $fhash = $this->get_attach_hash_file_name($attachment['filename']); if ($fw = fopen($prefs['w_use_dir'] . $fhash, 'wb')) { if (!fwrite($fw, $attachment['data'])) { $this->errors[] = 'Cannot write to this file'; $this->errorsArgs[] = $prefs['w_use_dir'] . $fhash; } fclose($fw); $attachment['data'] = ''; } else { $this->errors[] = 'Cannot open this file'; $this->errorsArgs[] = $prefs['w_use_dir'] . $fhash; } } global $wikilib; include_once 'lib/wiki/wikilib.php'; $wikilib->wiki_attach_file($info['name'], $attachment['filename'], $attachment['filetype'], $attachment['filesize'], $attachment['data'], $attachment['comment'], $attachment['user'], $fhash, $attachment['created']); //change the page data attach is needed $res['attId'] //$res = $wikilib->get_wiki_attach_file($info['name'], $attachment['filename'], $attachment['type'], $attachment['size']); } } if ($prefs['feature_wiki_pictures'] == 'y' && !empty($info['images'])) { foreach ($info['images'] as $image) { if (empty($image['zip'])) { //external link to image continue; } if (($image['data'] = $this->zip->getFromName($image['zip'])) === false) { $this->errors[] = 'Can not unzip image'; $this->errorsArgs[] = $image['zip']; return false; } if ($image['where'] == 'wiki') { $wiki_up = 'img/wiki_up/'; if ($tikidomain) { $wiki_up .= "{$tikidomain}/"; } $name = str_replace('img/wiki_up/', '', $image['wiki']); file_put_contents($wiki_up . $name, $image['data']); chmod($wiki_up . $name, 0644); } } } if ($prefs['feature_history'] == 'y' && !empty($info['history'])) { $query = 'select max(`version`) from `tiki_history` where `pageName`=?'; $maxVersion = $this->getOne($query, array($info['name'])); if (!$maxVersion) { $maxVersion = 0; } $newVersion = $maxVersion; foreach ($info['history'] as $version) { if (($version['data'] = $this->zip->getFromName($version['zip'])) === false) { $this->errors[] = 'Can not unzip history'; $this->errorsArgs[] = $version['version']; return false; } $query = 'insert into `tiki_history`(`pageName`, `version`, `lastModif`, `user`, `ip`, `comment`, `data`, `description`) values(?,?,?,?,?,?,?,?)'; $this->query($query, array($info['name'], $version['version'] + $maxVersion, $old ? $tikilib->now : $version['lastModif'], $version['user'], $version['ip'], $version['comment'], $version['data'], $version['description'])); $newVersion = max($version['version'] + $maxVersion, $newVersion); } $query = 'update `tiki_pages` set `version`=? where `pageName`=?'; $this->query($query, array($newVersion, $info['name'])); } if ($prefs['feature_wiki_structure'] == 'y' && !empty($info['structure'])) { global $structlib; include_once 'lib/structures/structlib.php'; //TODO alias if ($info['structure'] == 1) { $this->structureStack[$info['structure']] = $structlib->s_create_page(null, null, $info['name'], ''); if (empty($this->structureStack[$info['structure']])) { $this->errors[] = 'A structure already exists'; $this->errorsArgs[] = $info['name']; return false; } } elseif (!empty($info['structure'])) { $this->structureStack[$info['structure']] = $structlib->s_create_page($this->structureStack[$info['structure'] - 1], isset($this->structureStack[$info['structure']]) ? $this->structureStack[$info['structure']] : '', $info['name'], '', $this->structureStack[1]); } } return true; }
// Now process attchement here (queued attachment) } else { $smarty->assign('was_queued', 'n'); if ($_REQUEST["comments_threadId"] == 0) { if (!isset($_REQUEST['comment_topicsummary'])) { $_REQUEST['comment_topicsummary'] = ''; } if (!isset($_REQUEST['comment_topicsmiley'])) { $_REQUEST['comment_topicsmiley'] = ''; } $message_id = ''; // Check if the thread/topic already exist $threadId = $commentslib->check_for_topic($_REQUEST["comments_title"], $_REQUEST["comments_data"]); // The thread/topic does not already exist if (!$threadId) { $threadId = $commentslib->post_new_comment($comments_objectId, 0, $user, $_REQUEST["comments_title"], $_REQUEST["comments_data"], $message_id, '', $_REQUEST["comment_topictype"], $_REQUEST["comment_topicsummary"], $_REQUEST['comment_topicsmiley']); // The thread *WAS* successfully created. if ($threadId) { // Deal with mail notifications. include_once 'lib/notifications/notificationemaillib.php'; sendForumEmailNotification('forum_post_topic', $_REQUEST['forumId'], $forum_info, $_REQUEST["comments_title"], $_REQUEST["comments_data"], $user, $_REQUEST["comments_title"], $message_id, '', $threadId); } } // PROCESS ATTACHMENT HERE if ($threadId && isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_name'])) { check_ticket('view-forum'); $fp = fopen($_FILES['userfile1']['tmp_name'], "rb"); $commentslib->add_thread_attachment($forum_info, $threadId, $fp, '', $_FILES['userfile1']['name'], $_FILES['userfile1']['type'], $_FILES['userfile1']['size']); } //END ATTACHMENT PROCESSING $commentslib->register_forum_post($_REQUEST["forumId"], 0);
$_REQUEST['comment_topicsummary'] = ''; } if (!isset($_REQUEST['comment_topicsmiley'])) { $_REQUEST['comment_topicsmiley'] = ''; } $message_id = ''; // Check if the thread/topic already exist $threadId = $commentslib->check_for_topic($_REQUEST["comments_title"], $_REQUEST["comments_data"]); // The thread/topic does not already exist if (!$threadId) { if (isset($_REQUEST["anonymous_name"])) { $anonymous_name = trim(strip_tags($_REQUEST["anonymous_name"])); } else { $anonymous_name = ''; } $threadId = $commentslib->post_new_comment($comments_objectId, 0, $user, $_REQUEST["comments_title"], $_REQUEST["comments_data"], $message_id, '', $_REQUEST["comment_topictype"], $_REQUEST["comment_topicsummary"], $_REQUEST['comment_topicsmiley'], isset($_REQUEST['contributions']) ? $_REQUEST['contributions'] : '', $anonymous_name); // The thread *WAS* successfully created. // TAG Stuff $cat_type = 'forum post'; $cat_objid = $threadId; $cat_desc = substr($_REQUEST["comments_data"], 0, 200); $cat_name = $_REQUEST["comments_title"]; $cat_href = "tiki-view_forum_thread.php?comments_parentId=" . $threadId . "&forumId=" . $_REQUEST["forumId"]; include_once "freetag_apply.php"; // PROCESS ATTACHMENT HERE if ($threadId && isset($_FILES['userfile1']) && !empty($_FILES['userfile1']['name'])) { if (is_uploaded_file($_FILES['userfile1']['tmp_name'])) { check_ticket('view-forum'); $fp = fopen($_FILES['userfile1']['tmp_name'], "rb"); $commentslib->add_thread_attachment($forum_info, $threadId, $fp, '', $_FILES['userfile1']['name'], $_FILES['userfile1']['type'], $_FILES['userfile1']['size']); } else {