本文整理汇总了PHP中createPost函数的典型用法代码示例。如果您正苦于以下问题:PHP createPost函数的具体用法?PHP createPost怎么用?PHP createPost使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createPost函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loggedin
function loggedin($db)
{
do {
echo "\n***************************************************\n";
echo "\n Enter 1 to post a question\n";
echo "\n Enter 2 to Answer a question\n";
echo " \n Enter 3 to vote Posts\n";
echo "\n Enter 0 to quit\n";
echo "\n***************************************************\n";
fscanf(STDIN, "%d\n", $val);
switch ($val) {
case 1:
createPost();
break;
case 2:
answerPost();
break;
case 3:
castVote();
break;
default:
echo "You entered other number\n";
break;
}
} while ($val != 0);
}
示例2: recursiveParseArray
function recursiveParseArray($array)
{
static $recurseLevel = 0;
$recurseLevel++;
if ($recurseLevel > 90) {
print var_dump($array);
die(wfBacktrace());
}
global $subject, $rootPost;
if (is_array($array) && isset($array['title'])) {
$subject = $array['title'];
recursiveParseArray($array['content']);
$rootPost = null;
} elseif (is_array($array) && isset($array['user'])) {
// We have a post.
$t = createPost($array, $subject, $rootPost);
if (!$rootPost) {
$rootPost = $t;
}
} elseif (is_array($array)) {
foreach ($array as $info) {
recursiveParseArray($info);
}
$rootPost = null;
}
$recurseLevel--;
}
示例3: setUp
/**
* Prepare some test data, to use in these tests.
* setUp() is run automatically by the testing framework before each test method.
*/
function setUp()
{
// make sure a topic exists
require_once SUBSDIR . '/Post.subs.php';
// post variables
$msgOptions = array('id' => 0, 'subject' => 'Test poll topic', 'smileys_enabled' => true, 'body' => 'This is a test poll.', 'attachments' => array(), 'approved' => 1);
$topicOptions = array('id' => 0, 'board' => 1, 'mark_as_read' => false);
$posterOptions = array('id' => 1, 'name' => 'test', 'email' => 'noemail@test.tes', 'update_post_count' => false, 'ip' => '');
// Attempt to make the new topic.
createPost($msgOptions, $topicOptions, $posterOptions);
// Keep id of the new topic.
$this->id_topic = $topicOptions['id'];
}
示例4: postSplitRedirect
/**
* Post a message at the end of the original topic
*
* @param string $reason the text that will become the message body
* @param string $subject the text that will become the message subject
* @param mixed[] $board_info some board informations (at least id, name, if posts are counted)
* @param string $new_topic used to buld the url for moving to a new topic
*/
function postSplitRedirect($reason, $subject, $board_info, $new_topic)
{
global $scripturl, $user_info, $language, $txt, $topic, $board;
// Should be in the boardwide language.
if ($user_info['language'] != $language) {
loadLanguage('index', $language);
}
preparsecode($reason);
// Add a URL onto the message.
$reason = strtr($reason, array($txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $board_info['id'] . '.0]' . $board_info['name'] . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $new_topic . '.0[/iurl]'));
$msgOptions = array('subject' => $txt['split'] . ': ' . strtr(Util::htmltrim(Util::htmlspecialchars($subject)), array("\r" => '', "\n" => '', "\t" => '')), 'body' => $reason, 'icon' => 'moved', 'smileys_enabled' => 1);
$topicOptions = array('id' => $topic, 'board' => $board, 'mark_as_read' => true);
$posterOptions = array('id' => $user_info['id'], 'update_post_count' => empty($board_info['count_posts']));
createPost($msgOptions, $topicOptions, $posterOptions);
}
示例5: getPosts
<?php
require MODELES . 'membres/checkAdmin.php';
if (checkAdmin()) {
require MODELES . '/faq/getPosts.php';
if (isset($_GET['id']) && $_GET['id'] == 'new') {
// si on a posté le formulaire :
if (!empty($_POST)) {
require MODELES . 'backoffice/createPost.php';
if ($postId = createPost($_POST['question'], $_POST['reponse'])) {
$message = 'Nouvelle entrée créée avec succès !';
} else {
$message = 'Oups ! Une erreur s\'est produite...';
}
$post = ['id' => $postId, 'question' => $_POST['question'], 'reponse' => $_POST['reponse']];
} else {
$post = ['id' => 'new', 'question' => '', 'reponse' => ''];
}
} else {
if (isset($_GET['id']) && ($post = getPosts($_GET['id']))) {
// si on a posté le formulaire :
if (!empty($_POST)) {
require MODELES . 'backoffice/setPost.php';
if (setPost($_GET['id'], $_POST['question'], $_POST['reponse'])) {
$message = 'La modification a été effectuée !';
} else {
$message = 'Oups ! Une erreur s\'est produite...';
}
}
$post = getPosts($_GET['id']);
} else {
示例6: DoWelcomePost
function DoWelcomePost($memberName = '', $memberID = 0)
{
global $smcFunc, $modSettings, $sourcedir;
if (empty($memberName)) {
$result = $smcFunc['db_query']('', "\n\t\tSELECT \n\t\t\treal_name \n\t\tFROM {db_prefix}members \n\t\tWHERE ID_MEMBER = {$memberID} LIMIT 1");
$memRow = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);
$memberName = $memRow['real_name'];
}
require_once $sourcedir . '/Subs-Post.php';
if ($modSettings['welcome_boardid'] != 0) {
$result = $smcFunc['db_query']('', "\n\t\tSELECT \n\t\t\twelcomesubject, welcomebody \n\t\tFROM {db_prefix}welcome \n\t\t ORDER BY RAND() LIMIT 1");
if ($smcFunc['db_num_rows']($result) != 0) {
$row2 = $smcFunc['db_fetch_assoc']($result);
$msgOptions = array('id' => 0, 'subject' => str_replace("[username]", $memberName, $row2['welcomesubject']), 'body' => str_replace("[username]", $memberName, $row2['welcomebody']), 'icon' => 'xx', 'smileys_enabled' => 1, 'attachments' => array());
$topicOptions = array('id' => 0, 'board' => $modSettings['welcome_boardid'], 'poll' => null, 'lock_mode' => null, 'sticky_mode' => null, 'mark_as_read' => false);
$posterOptions = array('id' => $modSettings['welcome_memberid'], 'name' => $modSettings['welcome_membername'], 'email' => '', 'update_post_count' => $modSettings['welcome_memberid'] == 0 ? 0 : 1);
createPost($msgOptions, $topicOptions, $posterOptions);
}
$smcFunc['db_free_result']($result);
}
}
示例7: pbe_create_topic
/**
* Create a new topic by email
*
* What it does:
* - Called by pbe_topic to create a new topic or by pbe_main to create a new topic via a subject change
* - checks posting permissions, but requires all email validation checks are complete
* - Calls pbe_load_text to prepare text for the post
* - Uses createPost to do the actual "posting"
* - Calls sendNotifications to announce the new post
* - Calls query_update_member_stats to show they did something
* - Requires the pbe, email_message and board_info arrays to be populated.
*
* @package Maillist
* @param mixed[] $pbe array of pbe 'user_info' values
* @param Email_Parse $email_message
* @param mixed[] $board_info
*/
function pbe_create_topic($pbe, $email_message, $board_info)
{
global $txt, $modSettings;
// It does not work like that
if (empty($pbe) || empty($email_message)) {
return false;
}
// We have the board info, and their permissions - do they have a right to start a new topic?
$becomesApproved = true;
if (!$pbe['user_info']['is_admin']) {
if (!in_array('postby_email', $pbe['user_info']['permissions'])) {
return pbe_emailError('error_permission', $email_message);
} elseif ($modSettings['postmod_active'] && in_array('post_unapproved_topics', $pbe['user_info']['permissions']) && !in_array('post_new', $pbe['user_info']['permissions'])) {
$becomesApproved = false;
} elseif (!in_array('post_new', $pbe['user_info']['permissions'])) {
return pbe_emailError('error_cant_start', $email_message);
}
}
// Approving all new topics by email anyway, smart admin this one is ;)
if (!empty($modSettings['maillist_newtopic_needsapproval'])) {
$becomesApproved = false;
}
// First on the agenda the subject
$subject = pbe_clean_email_subject($email_message->subject);
$subject = strtr(Util::htmlspecialchars($subject), array("\r" => '', "\n" => '', "\t" => ''));
// Not to long not to short
if (Util::strlen($subject) > 100) {
$subject = Util::substr($subject, 0, 100);
} elseif ($subject == '') {
return pbe_emailError('error_no_subject', $email_message);
}
// The message itself will need a bit of work
$html = $email_message->html_found;
$text = pbe_load_text($html, $email_message, $pbe);
if (empty($text)) {
return pbe_emailError('error_no_message', $email_message);
}
// Build the attachment array if needed
if (!empty($email_message->attachments) && !empty($modSettings['maillist_allow_attachments']) && !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1) {
if ($modSettings['postmod_active'] && in_array('post_unapproved_attachments', $pbe['user_info']['permissions']) || in_array('post_attachment', $pbe['user_info']['permissions'])) {
$attachIDs = pbe_email_attachments($pbe, $email_message);
} else {
$text .= "\n\n" . $txt['error_no_attach'] . "\n";
}
}
// If we get to this point ... then its time to play, lets start a topic !
require_once SUBSDIR . '/Post.subs.php';
// Setup the topic variables.
$msgOptions = array('id' => 0, 'subject' => $subject, 'smileys_enabled' => true, 'body' => $text, 'attachments' => empty($attachIDs) ? array() : $attachIDs, 'approved' => $becomesApproved);
$topicOptions = array('id' => 0, 'board' => $board_info['id_board'], 'mark_as_read' => false);
$posterOptions = array('id' => $pbe['profile']['id_member'], 'name' => $pbe['profile']['real_name'], 'email' => $pbe['profile']['email_address'], 'update_post_count' => empty($board_info['count_posts']), 'ip' => isset($email_message->ip) ? $email_message->ip : $pbe['profile']['member_ip']);
// Attempt to make the new topic.
createPost($msgOptions, $topicOptions, $posterOptions);
// The auto_notify setting
$theme_settings = query_get_theme($pbe['profile']['id_member'], $pbe['profile']['id_theme'], $board_info);
$auto_notify = isset($theme_settings['auto_notify']) ? $theme_settings['auto_notify'] : 0;
// Notifications on or off
query_notifications($pbe['profile']['id_member'], $board_info['id_board'], $topicOptions['id'], $auto_notify, $pbe['user_info']['permissions']);
// Notify members who have notification turned on for this, (if it's approved)
if ($becomesApproved) {
require_once SUBSDIR . '/Notification.subs.php';
sendNotifications($topicOptions['id'], 'reply', array(), array(), $pbe);
}
// Update this users info so the log shows them as active
query_update_member_stats($pbe, $email_message, $topicOptions);
return true;
}
示例8: trim
$_POST['editor1'] = trim($_POST['editor1']);
//validation
if ($_POST['title'] == '') {
$error['title'] = 'Title is blank, please add one';
$form_valid = false;
} elseif (strlen($_POST['title']) > 25) {
$error['title'] = 'Title too long, keep it simple!';
$form_valid = false;
}
if ($_POST['editor1'] == '') {
$error['editor1'] = 'You have not entered any content! Try again yeh...?';
$form_valid = false;
}
// action taken if form filled in correctly...
if ($form_valid == true) {
createPost($_SESSION['userId'], $_POST['title'], $_POST['editor1'], $_POST['category']);
// variables set to createPost function for insertion into db...
header('Location: ?page=cmsUpdated&goto=cmsPostsTable');
}
}
include VIEWS . 'contentCMSCreate.php';
break;
case 'update':
if (!empty($_POST)) {
$form_valid = true;
// sanitization...
$_POST['title'] = trim($_POST['title']);
$_POST['editor1'] = trim($_POST['editor1']);
//validation
if ($_POST['title'] == '') {
$error['title'] = 'Title is blank, please add one';
示例9: createPost
<?php
require './post.php';
$wall = $_POST['wall'];
$title = $_POST['title'];
$content = $_POST['content'];
createPost($wall, $title, $content);
示例10: qa_post_text
$title = qa_post_text('title');
$content = qa_post_text('content');
$city = qa_post_text('city');
//城市分类
$postid = @$_POST['postid'];
//帖子id,如果创建帖子则为空
$istop = qa_post_text('istop');
//是否置顶。。
$isbase = @$_POST['isbase'];
//isbase为1:基础知识,2:相关技巧
$ishot = @$_POST['ishot'];
$citysub = @$_POST['citysub'];
//citysub为城市子类
$class = @$_POST['class'];
if (!$postid) {
$insert = createPost($title, $content, $city, $citysub, $class, $istop, $isbase, $ishot);
} else {
if (@$_POST['from'] == 'console') {
// $update = updatePost($postid,$title,$content,$city,$district,$security,$istop,$isbase,$ishot);
updatePost($postid, null, null, $city, $citysub, $class, $isbase, $istop, $ishot);
echo '1';
} else {
$update = updatePost($postid, $title, $content, $city, $citysub, $class, $isbase, $istop, $ishot);
}
}
qa_redirect_raw('console_page.php');
}
if (qa_post_text('doask')) {
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
$errors = array();
$doask = qa_post_text('doask');
示例11: Post2
//.........这里部分代码省略.........
$smcFunc['db_insert']('', '{db_prefix}polls', array('question' => 'string-255', 'hide_results' => 'int', 'max_votes' => 'int', 'expire_time' => 'int', 'id_member' => 'int', 'poster_name' => 'string-255', 'change_vote' => 'int', 'guest_vote' => 'int'), array($_POST['question'], $_POST['poll_hide'], $_POST['poll_max_votes'], empty($_POST['poll_expire']) ? 0 : time() + $_POST['poll_expire'] * 3600 * 24, $user_info['id'], $_POST['guestname'], $_POST['poll_change_vote'], $_POST['poll_guest_vote']), array('id_poll'));
$id_poll = $smcFunc['db_insert_id']('{db_prefix}polls', 'id_poll');
// Create each answer choice.
$i = 0;
$pollOptions = array();
foreach ($_POST['options'] as $option) {
$pollOptions[] = array($id_poll, $i, $option);
$i++;
}
$smcFunc['db_insert']('insert', '{db_prefix}poll_choices', array('id_poll' => 'int', 'id_choice' => 'int', 'label' => 'string-255'), $pollOptions, array('id_poll', 'id_choice'));
} else {
$id_poll = 0;
}
// Creating a new topic?
$newTopic = empty($_REQUEST['msg']) && empty($topic);
$_POST['icon'] = !empty($attachIDs) && $_POST['icon'] == 'xx' ? 'clip' : $_POST['icon'];
// Collect all parameters for the creation or modification of a post.
$msgOptions = array('id' => empty($_REQUEST['msg']) ? 0 : (int) $_REQUEST['msg'], 'subject' => $_POST['subject'], 'body' => $_POST['message'], 'icon' => preg_replace('~[\\./\\\\*:"\'<>]~', '', $_POST['icon']), 'smileys_enabled' => !isset($_POST['ns']), 'attachments' => empty($attachIDs) ? array() : $attachIDs, 'approved' => $becomesApproved);
$topicOptions = array('id' => empty($topic) ? 0 : $topic, 'board' => $board, 'poll' => isset($_REQUEST['poll']) ? $id_poll : null, 'lock_mode' => isset($_POST['lock']) ? (int) $_POST['lock'] : null, 'sticky_mode' => isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics']) ? (int) $_POST['sticky'] : null, 'mark_as_read' => true, 'is_approved' => !$modSettings['postmod_active'] || empty($topic) || !empty($board_info['cur_topic_approved']));
$posterOptions = array('id' => $user_info['id'], 'name' => $_POST['guestname'], 'email' => $_POST['email'], 'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']) && $board_info['posts_count']);
// This is an already existing message. Edit it.
if (!empty($_REQUEST['msg'])) {
// Have admins allowed people to hide their screwups?
if (time() - $row['poster_time'] > $modSettings['edit_wait_time'] || $user_info['id'] != $row['id_member']) {
$msgOptions['modify_time'] = time();
$msgOptions['modify_name'] = $user_info['name'];
}
// This will save some time...
if (empty($approve_has_changed)) {
unset($msgOptions['approved']);
}
modifyPost($msgOptions, $topicOptions, $posterOptions);
} else {
createPost($msgOptions, $topicOptions, $posterOptions);
if (isset($topicOptions['id'])) {
$topic = $topicOptions['id'];
}
}
// Editing or posting an event?
if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) {
require_once $sourcedir . '/Subs-Calendar.php';
// Make sure they can link an event to this post.
canLinkEvent();
// Insert the event.
$eventOptions = array('board' => $board, 'topic' => $topic, 'title' => $_POST['evtitle'], 'member' => $user_info['id'], 'start_date' => sprintf('%04d-%02d-%02d', $_POST['year'], $_POST['month'], $_POST['day']), 'span' => isset($_POST['span']) && $_POST['span'] > 0 ? min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1) : 0);
insertEvent($eventOptions);
} elseif (isset($_POST['calendar'])) {
$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
// Validate the post...
require_once $sourcedir . '/Subs-Calendar.php';
validateEventPost();
// If you're not allowed to edit any events, you have to be the poster.
if (!allowedTo('calendar_edit_any')) {
// Get the event's poster.
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}calendar
WHERE id_event = {int:id_event}', array('id_event' => $_REQUEST['eventid']));
$row2 = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
// Silly hacker, Trix are for kids. ...probably trademarked somewhere, this is FAIR USE! (parody...)
isAllowedTo('calendar_edit_' . ($row2['id_member'] == $user_info['id'] ? 'own' : 'any'));
}
// Delete it?
if (isset($_REQUEST['deleteevent'])) {
$smcFunc['db_query']('', '
示例12: createPost
<?php
include_once '../../config/init.php';
include_once $BASE_DIR . 'database/users.php';
include_once $BASE_DIR . 'database/posts.php';
if ($_POST['status'] && !$_FILES['picturepost']) {
createPost(getUserId($_SESSION['username']), $_POST['status']);
if ($_POST['circle']) {
createPostCircle($_POST['circle'], $_POST['status']);
}
} else {
if ($_POST['status'] && $_FILES['picturepost']) {
createPost(getUserId($_SESSION['username']), $_POST['status']);
$idpost = getPostIdByText($_POST['status']);
print_r($idpost);
if ($_POST['circle']) {
createPostCircle($_POST['circle'], $_POST['status']);
}
$fileName = $_FILES["picturepost"]["name"];
$fileTmpPath = $_FILES["picturepost"]["tmp_name"];
$fileType = $_FILES["picturepost"]["type"];
$fileSize = $_FILES["picturepost"]["size"];
$extension = end(explode(".", $_FILES["picturepost"]["name"]));
$fileFolder = $BASE_DIR . "images/posts/";
$filePath = $fileFolder . $idpost['idpost'] . "." . $extension;
insertPicPost($idpost['idpost'], $filePath);
move_uploaded_file($fileTmpPath, $filePath);
chmod($filePath, 0644);
unlink($fileTmpPath);
}
}
示例13: shd_tickettotopic2
//.........这里部分代码省略.........
$context['custom_fields_warning'] = true;
}
} elseif ($is_staff) {
// So they're staff. But the field might not be visible to them; they can't deal with it whatever.
if (!$field['visible']['staff']) {
fatal_lang_error('cannot_shd_move_ticket_topic_hidden_cfs', false);
} elseif (!$field['visible']['user']) {
$context['custom_fields_warning'] = true;
}
} else {
// Non staff aren't special. They should not be able to make this decision. If someone can't see it, they don't get to make the choice.
if (!$field['visible']['user'] || !$field['visible']['staff']) {
fatal_lang_error('cannot_shd_move_ticket_topic_hidden_cfs', false);
}
}
// Are we ignoring this field? If so, we can now safely get rid of it at this very point.
if (isset($_POST['field' . $field_id]) && $_POST['field' . $field_id] == 'lose') {
unset($context['custom_fields'][$field_id]);
}
}
// Were there any special fields? We need to check - and check that they ticked the right box!
if (!empty($context['custom_fields_warning']) && empty($_POST['accept_move'])) {
checkSubmitOnce('free');
fatal_lang_error('shd_ticket_move_reqd_nonselected', false);
}
// Just before we do this, make sure we call any hooks. $context has lots of interesting things, as does $_POST.
call_integration_hook('shd_hook_tickettotopic');
// OK, so we have some fields, and we're doing something with them. First we need to attach the fields from the ticket to the opening post.
shd_append_custom_fields($body, $context['ticket_id'], CFIELD_TICKET);
// All okay, it seems. Let's go create the topic.
$msgOptions = array('subject' => $subject, 'body' => $body, 'icon' => 'xx', 'smileys_enabled' => !empty($smileys_enabled) ? 1 : 0);
$topicOptions = array('board' => $_POST['toboard'], 'lock_mode' => 0, 'mark_as_read' => false);
$posterOptions = array('id' => $owner, 'update_post_count' => empty($pcounter));
createPost($msgOptions, $topicOptions, $posterOptions);
// Keep track of SHD msg id to SMF msg id
$msg_assoc[$shd_id_msg] = $msgOptions['id'];
// createPost() doesn't handle modified time and name, so we'll fix that here, along with the poster time.
if (!empty($modified_time)) {
shd_db_query('', '
UPDATE {db_prefix}messages
SET
modified_time = {int:modified_time},
modified_name = {string:modified_name},
poster_time = {int:poster_time}
WHERE id_msg = {int:id_msg}', array('id_msg' => $firstmsg, 'modified_time' => $modified_time, 'modified_name' => $modified_name, 'poster_time' => $time));
}
// Topic created, let's dig out the replies and post them in the topic, if there are any.
if (isset($topicOptions['id'])) {
$request = shd_db_query('', '
SELECT body, id_member, poster_time, poster_name, poster_email, poster_ip, smileys_enabled,
modified_time, modified_member, modified_name, poster_time, id_msg, message_status
FROM {db_prefix}helpdesk_ticket_replies AS hdtr
WHERE id_ticket = {int:ticket}
AND id_msg > {int:ticket_msg}
ORDER BY id_msg', array('ticket' => $context['ticket_id'], 'ticket_msg' => $firstmsg));
// The ID of the topic we created
$topic = $topicOptions['id'];
if ($smcFunc['db_num_rows']($request) != 0) {
// Now loop through each reply and post it. Hopefully there aren't too many. *looks at clock*
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if ($row['message_status'] == MSG_STATUS_DELETED && !empty($context['deleted_prompt']) && $context['deleted_prompt'] == 'delete') {
// we don't want these replies!
continue;
}
shd_append_custom_fields($row['body'], $row['id_msg'], CFIELD_REPLY);
$msgOptions = array('subject' => $txt['response_prefix'] . $subject, 'body' => $row['body'], 'icon' => 'xx', 'smileys_enabled' => !empty($row['smileys_enabled']) ? 1 : 0);
示例14: action_movetopic2
/**
* Execute the move of a topic.
* It is called on the submit of action_movetopic.
* This function logs that topics have been moved in the moderation log.
* If the member is the topic starter requires the move_own permission,
* otherwise requires the move_any permission.
* Upon successful completion redirects to message index.
* Accessed via ?action=movetopic2.
*
* @uses subs/Post.subs.php.
*/
public function action_movetopic2()
{
global $txt, $board, $topic, $scripturl, $context, $language, $user_info;
if (empty($topic)) {
fatal_lang_error('no_access', false);
}
// You can't choose to have a redirection topic and use an empty reason.
if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) {
fatal_lang_error('movetopic_no_reason', false);
}
// You have to tell us were you are moving to
if (!isset($_POST['toboard'])) {
fatal_lang_error('movetopic_no_board', false);
}
// We will need this
require_once SUBSDIR . '/Topic.subs.php';
moveTopicConcurrence();
// Make sure this form hasn't been submitted before.
checkSubmitOnce('check');
// Get the basic details on this topic
$topic_info = getTopicInfo($topic);
$context['is_approved'] = $topic_info['approved'];
// Can they see it?
if (!$context['is_approved']) {
isAllowedTo('approve_posts');
}
// Can they move topics on this board?
if (!allowedTo('move_any')) {
if ($topic_info['id_member_started'] == $user_info['id']) {
isAllowedTo('move_own');
} else {
isAllowedTo('move_any');
}
}
checkSession();
require_once SUBSDIR . '/Post.subs.php';
require_once SUBSDIR . '/Boards.subs.php';
// The destination board must be numeric.
$toboard = (int) $_POST['toboard'];
// Make sure they can see the board they are trying to move to (and get whether posts count in the target board).
$board_info = boardInfo($toboard, $topic);
if (empty($board_info)) {
fatal_lang_error('no_board');
}
// Remember this for later.
$_SESSION['move_to_topic'] = array('move_to' => $toboard);
// Rename the topic...
if (isset($_POST['reset_subject'], $_POST['custom_subject']) && $_POST['custom_subject'] != '') {
$custom_subject = strtr(Util::htmltrim(Util::htmlspecialchars($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
// Keep checking the length.
if (Util::strlen($custom_subject) > 100) {
$custom_subject = Util::substr($custom_subject, 0, 100);
}
// If it's still valid move onwards and upwards.
if ($custom_subject != '') {
$all_messages = isset($_POST['enforce_subject']);
if ($all_messages) {
// Get a response prefix, but in the forum's default language.
$context['response_prefix'] = response_prefix();
topicSubject($topic_info, $custom_subject, $context['response_prefix'], $all_messages);
} else {
topicSubject($topic_info, $custom_subject);
}
// Fix the subject cache.
updateStats('subject', $topic, $custom_subject);
}
}
// Create a link to this in the old board.
// @todo Does this make sense if the topic was unapproved before? I'd just about say so.
if (isset($_POST['postRedirect'])) {
// Should be in the boardwide language.
if ($user_info['language'] != $language) {
loadLanguage('index', $language);
}
$reason = Util::htmlspecialchars($_POST['reason'], ENT_QUOTES);
preparsecode($reason);
// Add a URL onto the message.
$reason = strtr($reason, array($txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $toboard . '.0]' . $board_info['name'] . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'));
// Auto remove this MOVED redirection topic in the future?
$redirect_expires = !empty($_POST['redirect_expires']) ? (int) $_POST['redirect_expires'] : 0;
// Redirect to the MOVED topic from topic list?
$redirect_topic = isset($_POST['redirect_topic']) ? $topic : 0;
// And remember the last expiry period too.
$_SESSION['move_to_topic']['redirect_topic'] = $redirect_topic;
$_SESSION['move_to_topic']['redirect_expires'] = $redirect_expires;
$msgOptions = array('subject' => $txt['moved'] . ': ' . $board_info['subject'], 'body' => $reason, 'icon' => 'moved', 'smileys_enabled' => 1);
$topicOptions = array('board' => $board, 'lock_mode' => 1, 'mark_as_read' => true, 'redirect_expires' => empty($redirect_expires) ? 0 : $redirect_expires * 60 + time(), 'redirect_topic' => $redirect_topic);
$posterOptions = array('id' => $user_info['id'], 'update_post_count' => empty($board_info['count_posts']));
createPost($msgOptions, $topicOptions, $posterOptions);
//.........这里部分代码省略.........
示例15: MoveTopic2
function MoveTopic2()
{
global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context;
global $db_prefix, $ID_MEMBER, $board, $language, $user_info, $func;
// Make sure this form hasn't been submitted before.
checkSubmitOnce('check');
$request = db_query("\n\t\tSELECT ID_MEMBER_STARTED, ID_FIRST_MSG\n\t\tFROM {$db_prefix}topics\n\t\tWHERE ID_TOPIC = {$topic}\n\t\tLIMIT 1", __FILE__, __LINE__);
list($ID_MEMBER_STARTED, $ID_FIRST_MSG) = mysql_fetch_row($request);
mysql_free_result($request);
// Can they move topics on this board?
if (!allowedTo('move_any')) {
if ($ID_MEMBER_STARTED == $ID_MEMBER) {
isAllowedTo('move_own');
$boards = array_merge(boardsAllowedTo('move_own'), boardsAllowedTo('move_any'));
} else {
isAllowedTo('move_any');
}
} else {
$boards = boardsAllowedTo('move_any');
}
checkSession();
require_once $sourcedir . '/Subs-Post.php';
// The destination board must be numeric.
$_POST['toboard'] = (int) $_POST['toboard'];
// !!!
/*if (!in_array($_POST['toboard'], $boards) && !in_array(0, $boards))
fatal_lang_error('smf232');*/
// Make sure they can see the board they are trying to move to (and get whether posts count in the target board).
$request = db_query("\n\t\tSELECT b.countPosts, b.name, m.subject\n\t\tFROM ({$db_prefix}boards AS b, {$db_prefix}topics AS t, {$db_prefix}messages AS m)\n\t\tWHERE {$user_info['query_see_board']}\n\t\t\tAND b.ID_BOARD = {$_POST['toboard']}\n\t\t\tAND t.ID_TOPIC = {$topic}\n\t\t\tAND m.ID_MSG = t.ID_FIRST_MSG\n\t\tLIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0) {
fatal_lang_error('smf232');
}
list($pcounter, $board_name, $subject) = mysql_fetch_row($request);
mysql_free_result($request);
// Remember this for later.
$_SESSION['move_to_topic'] = $_POST['toboard'];
// Rename the topic...
if (isset($_POST['reset_subject'], $_POST['custom_subject']) && $_POST['custom_subject'] != '') {
$_POST['custom_subject'] = $func['htmlspecialchars']($_POST['custom_subject']);
if (isset($_POST['enforce_subject'])) {
// Get a response prefix, but in the forum's default language.
if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) {
if ($language === $user_info['language']) {
$context['response_prefix'] = $txt['response_prefix'];
} else {
loadLanguage('index', $language, false);
$context['response_prefix'] = $txt['response_prefix'];
loadLanguage('index');
}
cache_put_data('response_prefix', $context['response_prefix'], 600);
}
db_query("\n\t\t\t\tUPDATE {$db_prefix}messages\n\t\t\t\tSET subject = '{$context['response_prefix']}{$_POST['custom_subject']}'\n\t\t\t\tWHERE ID_TOPIC = {$topic}", __FILE__, __LINE__);
}
db_query("\n\t\t\tUPDATE {$db_prefix}messages\n\t\t\tSET subject = '{$_POST['custom_subject']}'\n\t\t\tWHERE ID_MSG = {$ID_FIRST_MSG}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
// Fix the subject cache.
updateStats('subject', $topic, $_POST['custom_subject']);
}
// Create a link to this in the old board.
if (isset($_POST['postRedirect'])) {
// Should be in the boardwide language.
if ($user_info['language'] != $language) {
loadLanguage('index', $language);
}
$_POST['reason'] = $func['htmlspecialchars']($_POST['reason'], ENT_QUOTES);
preparsecode($_POST['reason']);
// Add a URL onto the message.
$_POST['reason'] = strtr($_POST['reason'], array($txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $_POST['toboard'] . ']' . addslashes($board_name) . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'));
$msgOptions = array('subject' => addslashes($txt['smf56'] . ': ' . $subject), 'body' => $_POST['reason'], 'icon' => 'moved', 'smileys_enabled' => 1);
$topicOptions = array('board' => $board, 'lock_mode' => 1, 'mark_as_read' => true);
$posterOptions = array('id' => $ID_MEMBER, 'update_post_count' => !empty($pcounter));
createPost($msgOptions, $topicOptions, $posterOptions);
}
$request = db_query("\n\t\tSELECT countPosts\n\t\tFROM {$db_prefix}boards\n\t\tWHERE ID_BOARD = {$board}\n\t\tLIMIT 1", __FILE__, __LINE__);
list($pcounter_from) = mysql_fetch_row($request);
mysql_free_result($request);
if ($pcounter_from != $pcounter) {
$request = db_query("\n\t\t\tSELECT ID_MEMBER\n\t\t\tFROM {$db_prefix}messages\n\t\t\tWHERE ID_TOPIC = {$topic}", __FILE__, __LINE__);
$posters = array();
while ($row = mysql_fetch_assoc($request)) {
$posters[] = $row['ID_MEMBER'];
}
mysql_free_result($request);
// The board we're moving from counted posts, but not to.
if (empty($pcounter_from)) {
updateMemberData($posters, array('posts' => '-'));
} else {
updateMemberData($posters, array('posts' => '+'));
}
}
// Do the move (includes statistics update needed for the redirect topic).
moveTopics($topic, $_POST['toboard']);
// Log that they moved this topic.
if (!allowedTo('move_own') || $ID_MEMBER_STARTED != $ID_MEMBER) {
logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
}
// Notify people that this topic has been moved?
sendNotifications($topic, 'move');
// Update the cache?
if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] == 3) {
cache_put_data('topic_board-' . $topic, null, 120);
//.........这里部分代码省略.........