Zeile 121 | Zeile 121 |
---|
{ $user = get_user($post['uid']); $post['username'] = $user['username'];
|
{ $user = get_user($post['uid']); $post['username'] = $user['username'];
|
| } // if the uid is 0 verify the username else if($post['uid'] == 0 && $post['username'] != $lang->guest) { // Set up user handler require_once MYBB_ROOT."inc/datahandlers/user.php"; $userhandler = new UserDataHandler();
$data_array = array('username' => $post['username']); $userhandler->set_data($data_array);
if(!$userhandler->verify_username()) { // invalid username $this->errors = array_merge($this->errors, $userhandler->get_errors()); return false; }
|
}
// After all of this, if we still don't have a username, force the username as "Guest" (Note, this is not translatable as it is always a fallback)
| }
// After all of this, if we still don't have a username, force the username as "Guest" (Note, this is not translatable as it is always a fallback)
|
Zeile 188 | Zeile 205 |
---|
// This is a new post else if($this->action == "post")
|
// This is a new post else if($this->action == "post")
|
{
| {
|
if(my_strlen($subject) == 0) { $thread = get_thread($post['tid']); $subject = "RE: ".$thread['subject'];
|
if(my_strlen($subject) == 0) { $thread = get_thread($post['tid']); $subject = "RE: ".$thread['subject'];
|
} }
| } }
|
// This is a new thread and we require that a subject is present. else
| // This is a new thread and we require that a subject is present. else
|
Zeile 209 | Zeile 226 |
---|
// If post is reply and begins with "RE: ", remove 4 from subject length. $subject_length = my_strlen($subject); if($this->action == "post")
|
// If post is reply and begins with "RE: ", remove 4 from subject length. $subject_length = my_strlen($subject); if($this->action == "post")
|
{
| {
|
$position_re = my_strpos($subject, "RE: "); if($position_re !== false && $position_re == 0) {
| $position_re = my_strpos($subject, "RE: "); if($position_re !== false && $position_re == 0) {
|
Zeile 251 | Zeile 268 |
---|
else if(strlen($post['message']) > $mybb->settings['maxmessagelength'] && $mybb->settings['maxmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid'])) { $this->set_error("message_too_long", array($mybb->settings['maxmessagelength'], strlen($post['message'])));
|
else if(strlen($post['message']) > $mybb->settings['maxmessagelength'] && $mybb->settings['maxmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid'])) { $this->set_error("message_too_long", array($mybb->settings['maxmessagelength'], strlen($post['message'])));
|
return false; }
| return false; }
|
// And if we've got a minimum message length do we meet that requirement too? else if(my_strlen($post['message']) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid'])) {
| // And if we've got a minimum message length do we meet that requirement too? else if(my_strlen($post['message']) < $mybb->settings['minmessagelength'] && $mybb->settings['minmessagelength'] > 0 && !is_moderator($post['fid'], "", $post['uid'])) {
|
Zeile 262 | Zeile 279 |
---|
} return true; }
|
} return true; }
|
|
|
/** * Verifies the specified post options are correct. *
| /** * Verifies the specified post options are correct. *
|
Zeile 275 | Zeile 292 |
---|
// Verify yes/no options. $this->verify_yesno_option($options, 'signature', 0); $this->verify_yesno_option($options, 'disablesmilies', 0);
|
// Verify yes/no options. $this->verify_yesno_option($options, 'signature', 0); $this->verify_yesno_option($options, 'disablesmilies', 0);
|
|
|
return true; }
|
return true; }
|
|
|
/** * Verify that the user is not flooding the system. *
| /** * Verify that the user is not flooding the system. *
|
Zeile 289 | Zeile 306 |
---|
global $mybb;
$post = &$this->data;
|
global $mybb;
$post = &$this->data;
|
|
|
// Check if post flooding is enabled within MyBB or if the admin override option is specified. if($mybb->settings['postfloodcheck'] == 1 && $post['uid'] != 0 && $this->admin_override == false) {
| // Check if post flooding is enabled within MyBB or if the admin override option is specified. if($mybb->settings['postfloodcheck'] == 1 && $post['uid'] != 0 && $this->admin_override == false) {
|
Zeile 297 | Zeile 314 |
---|
{ return true; }
|
{ return true; }
|
|
|
// Fetch the user information for this post - used to check their last post date. $user = get_user($post['uid']);
| // Fetch the user information for this post - used to check their last post date. $user = get_user($post['uid']);
|
Zeile 320 | Zeile 337 |
---|
// All is well that ends well - return true. return true; }
|
// All is well that ends well - return true. return true; }
|
|
|
function verify_post_merge($simple_mode=false) { global $mybb, $db, $session;
|
function verify_post_merge($simple_mode=false) { global $mybb, $db, $session;
|
|
|
$post = &$this->data;
|
$post = &$this->data;
|
|
|
// Are we starting a new thread? if(!$post['tid'])
|
// Are we starting a new thread? if(!$post['tid'])
|
{ return true; }
| { return true; }
|
// Are we even turned on? if(empty($mybb->settings['postmergemins'])) { return true; }
|
// Are we even turned on? if(empty($mybb->settings['postmergemins'])) { return true; }
|
|
|
// Assign a default separator if none is specified if(trim($mybb->settings['postmergesep']) == "") { $mybb->settings['postmergesep'] = "[hr]"; }
|
// Assign a default separator if none is specified if(trim($mybb->settings['postmergesep']) == "") { $mybb->settings['postmergesep'] = "[hr]"; }
|
|
|
// Check to see if this person is in a usergroup that is excluded if(trim($mybb->settings['postmergeuignore']) != "") { $gids = explode(',', $mybb->settings['postmergeuignore']); $gids = array_map('intval', $gids);
|
// Check to see if this person is in a usergroup that is excluded if(trim($mybb->settings['postmergeuignore']) != "") { $gids = explode(',', $mybb->settings['postmergeuignore']); $gids = array_map('intval', $gids);
|
|
|
$user_usergroups = explode(',', $mybb->user['usergroup'].",".$mybb->user['additionalgroups']); if(count(array_intersect($user_usergroups, $gids)) > 0) { return true;
|
$user_usergroups = explode(',', $mybb->user['usergroup'].",".$mybb->user['additionalgroups']); if(count(array_intersect($user_usergroups, $gids)) > 0) { return true;
|
}
| }
|
}
|
}
|
|
|
// Select the lastpost and fid information for this thread $query = $db->simple_select("threads", "lastpost,fid", "lastposteruid='".$post['uid']."' AND tid='".$post['tid']."'", array('limit' => '1')); $thread = $db->fetch_array($query);
|
// Select the lastpost and fid information for this thread $query = $db->simple_select("threads", "lastpost,fid", "lastposteruid='".$post['uid']."' AND tid='".$post['tid']."'", array('limit' => '1')); $thread = $db->fetch_array($query);
|
|
|
// Check to see if the same author has posted within the merge post time limit if((intval($mybb->settings['postmergemins']) != 0 && trim($mybb->settings['postmergemins']) != "") && (TIME_NOW-$thread['lastpost']) > (intval($mybb->settings['postmergemins'])*60)) { return true; }
|
// Check to see if the same author has posted within the merge post time limit if((intval($mybb->settings['postmergemins']) != 0 && trim($mybb->settings['postmergemins']) != "") && (TIME_NOW-$thread['lastpost']) > (intval($mybb->settings['postmergemins'])*60)) { return true; }
|
|
|
if(strstr($mybb->settings['postmergefignore'], ',')) { $fids = explode(',', $mybb->settings['postmergefignore']); foreach($fids as $key => $forumid)
|
if(strstr($mybb->settings['postmergefignore'], ',')) { $fids = explode(',', $mybb->settings['postmergefignore']); foreach($fids as $key => $forumid)
|
{
| {
|
$fid[] = intval($forumid); }
|
$fid[] = intval($forumid); }
|
|
|
if(in_array($thread['fid'], $fid)) { return true;
|
if(in_array($thread['fid'], $fid)) { return true;
|
}
| }
|
} else if(trim($mybb->settings['postmergefignore']) != "" && $thread['fid'] == intval($mybb->settings['postmergefignore']))
|
} else if(trim($mybb->settings['postmergefignore']) != "" && $thread['fid'] == intval($mybb->settings['postmergefignore']))
|
{
| {
|
return true;
|
return true;
|
}
| }
|
if($simple_mode == true) { return false; }
|
if($simple_mode == true) { return false; }
|
|
|
if($post['uid']) { $user_check = "uid='".$post['uid']."'";
| if($post['uid']) { $user_check = "uid='".$post['uid']."'";
|
Zeile 401 | Zeile 418 |
---|
{ $user_check = "ipaddress='".$db->escape_string($session->ipaddress)."'"; }
|
{ $user_check = "ipaddress='".$db->escape_string($session->ipaddress)."'"; }
|
|
|
$query = $db->simple_select("posts", "pid,message,visible", "{$user_check} AND tid='".$post['tid']."' AND dateline='".$thread['lastpost']."'", array('order_by' => 'pid', 'order_dir' => 'DESC', 'limit' => 1)); return $db->fetch_array($query); }
|
$query = $db->simple_select("posts", "pid,message,visible", "{$user_check} AND tid='".$post['tid']."' AND dateline='".$thread['lastpost']."'", array('order_by' => 'pid', 'order_dir' => 'DESC', 'limit' => 1)); return $db->fetch_array($query); }
|
|
|
/** * Verifies the image count. *
| /** * Verifies the image count. *
|
Zeile 416 | Zeile 433 |
---|
global $mybb, $db;
$post = &$this->data;
|
global $mybb, $db;
$post = &$this->data;
|
|
|
// Get the permissions of the user who is making this post or thread $permissions = user_permissions($post['uid']);
| // Get the permissions of the user who is making this post or thread $permissions = user_permissions($post['uid']);
|
Zeile 448 | Zeile 465 |
---|
$parser_options['allow_smilies'] = $forum['allowsmilies']; } else
|
$parser_options['allow_smilies'] = $forum['allowsmilies']; } else
|
{
| {
|
$parser_options['allow_smilies'] = 0;
|
$parser_options['allow_smilies'] = 0;
|
}
$image_check = $parser->parse_message($post['message'], $parser_options);
| }
$image_check = $parser->parse_message($post['message'], $parser_options);
|
// And count the number of image tags in the message. $image_count = substr_count($image_check, "<img");
| // And count the number of image tags in the message. $image_count = substr_count($image_check, "<img");
|
Zeile 464 | Zeile 481 |
---|
} } }
|
} } }
|
|
|
/** * Verifies the video count. *
| /** * Verifies the video count. *
|
Zeile 483 | Zeile 500 |
---|
if($post['savedraft'] != 1 && $mybb->settings['maxpostvideos'] != 0 && $permissions['cancp'] != 1) { // And count the number of video tags in the message.
|
if($post['savedraft'] != 1 && $mybb->settings['maxpostvideos'] != 0 && $permissions['cancp'] != 1) { // And count the number of video tags in the message.
|
$video_count = substr_count($post['message'], "[video]");
| $video_count = substr_count($post['message'], "[video=");
|
if($video_count > $mybb->settings['maxpostvideos']) { // Throw back a message if over the count with the number of images as well as the maximum number of images per post.
| if($video_count > $mybb->settings['maxpostvideos']) { // Throw back a message if over the count with the number of images as well as the maximum number of images per post.
|
Zeile 546 | Zeile 563 |
---|
$post = &$this->data;
|
$post = &$this->data;
|
// If we don't assign it as 0. if(!$post['icon'] || $post['icon'] < 0)
| $posticons_cache = $cache->read("posticons");
// If we don't have a post icon assign it as 0. if(empty($post['icon']) || !isset($posticons_cache[$post['icon']]))
|
{ $post['icon'] = 0; }
| { $post['icon'] = 0; }
|
Zeile 565 | Zeile 584 |
---|
// The date has to be numeric and > 0. if($dateline < 0 || is_numeric($dateline) == false)
|
// The date has to be numeric and > 0. if($dateline < 0 || is_numeric($dateline) == false)
|
{
| {
|
$dateline = TIME_NOW; } }
|
$dateline = TIME_NOW; } }
|
|
|
/** * Verify thread prefix.
|
/** * Verify thread prefix.
|
*
| *
|
* @return boolean True when valid, false when not valid. */ function verify_prefix() { $prefix = &$this->data['prefix'];
|
* @return boolean True when valid, false when not valid. */ function verify_prefix() { $prefix = &$this->data['prefix'];
|
|
|
// If a valid prefix isn't supplied, don't assign one.
|
// If a valid prefix isn't supplied, don't assign one.
|
if(!$prefix || $prefix < 1)
| if(empty($prefix))
|
{ $prefix = 0; }
|
{ $prefix = 0; }
|
return true; }
| else { $verification = build_prefixes($prefix); if(!$verification) { $this->set_error('invalid_prefix'); return false; } if($verification['groups'] != "-1") { if(!empty($this->data['edit_uid'])) { // Post is being edited $user = get_user($this->data['edit_uid']); } else { $user = get_user($this->data['uid']); } $groups = array($user['usergroup']); if(!empty($user['additionalgroups'])) { $groups = array_merge($groups, explode(',', $user['additionalgroups'])); } $prefix_groups = explode(",", $verification['groups']);
$valid_group = false; foreach($groups as $group) { if(in_array($group, $prefix_groups)) { $valid_group = true; break; } } if(!$valid_group) { $this->set_error('invalid_prefix'); return false; } } if($verification['forums'] != "-1") { // Decide whether this prefix can be used in our forum $forums = explode(",", $verification['forums']);
if(!in_array($this->data['fid'], $forums)) { $this->set_error('invalid_prefix'); return false; } } }
return true; }
|
/** * Validate a post.
| /** * Validate a post.
|
Zeile 596 | Zeile 668 |
---|
function validate_post() { global $mybb, $db, $plugins;
|
function validate_post() { global $mybb, $db, $plugins;
|
|
|
$post = &$this->data; $time = TIME_NOW;
|
$post = &$this->data; $time = TIME_NOW;
|
|
|
$this->action = "post";
|
$this->action = "post";
|
|
|
if($this->method != "update" && !$post['savedraft']) { $this->verify_post_flooding();
|
if($this->method != "update" && !$post['savedraft']) { $this->verify_post_flooding();
|
}
// Verify all post assets.
| }
// Verify all post assets.
|
if($this->method == "insert" || array_key_exists('uid', $post))
|
if($this->method == "insert" || array_key_exists('uid', $post))
|
{
| {
|
$this->verify_author();
|
$this->verify_author();
|
}
| }
|
if($this->method == "insert" || array_key_exists('subject', $post)) {
| if($this->method == "insert" || array_key_exists('subject', $post)) {
|
Zeile 624 | Zeile 696 |
---|
$this->verify_message(); $this->verify_image_count(); $this->verify_video_count();
|
$this->verify_message(); $this->verify_image_count(); $this->verify_video_count();
|
}
| }
|
if($this->method == "insert" || array_key_exists('dateline', $post))
|
if($this->method == "insert" || array_key_exists('dateline', $post))
|
{
| {
|
$this->verify_dateline();
|
$this->verify_dateline();
|
}
| }
|
if($this->method == "insert" || array_key_exists('replyto', $post)) {
| if($this->method == "insert" || array_key_exists('replyto', $post)) {
|
Zeile 642 | Zeile 714 |
---|
}
if($this->method == "insert" || array_key_exists('options', $post))
|
}
if($this->method == "insert" || array_key_exists('options', $post))
|
{
| {
|
$this->verify_options();
|
$this->verify_options();
|
}
| }
|
$plugins->run_hooks("datahandler_post_validate_post", $this);
// We are done validating, return. $this->set_validated(true); if(count($this->get_errors()) > 0)
|
$plugins->run_hooks("datahandler_post_validate_post", $this);
// We are done validating, return. $this->set_validated(true); if(count($this->get_errors()) > 0)
|
{
| {
|
return false;
|
return false;
|
}
| }
|
else { return true; } }
|
else { return true; } }
|
|
|
/** * Insert a post into the database. *
| /** * Insert a post into the database. *
|
Zeile 681 | Zeile 753 |
---|
{ die("The post is not valid."); }
|
{ die("The post is not valid."); }
|
|
|
// Fetch the thread $thread = get_thread($post['tid']);
// This post is being saved as a draft. if($post['savedraft'])
|
// Fetch the thread $thread = get_thread($post['tid']);
// This post is being saved as a draft. if($post['savedraft'])
|
{
| {
|
$visible = -2; }
|
$visible = -2; }
|
|
|
// Otherwise this post is being made now and we have a bit to do. else { // Automatic subscription to the thread if($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0)
|
// Otherwise this post is being made now and we have a bit to do. else { // Automatic subscription to the thread if($post['options']['subscriptionmethod'] != "" && $post['uid'] > 0)
|
{
| {
|
switch($post['options']['subscriptionmethod']) { case "instant":
| switch($post['options']['subscriptionmethod']) { case "instant":
|
Zeile 705 | Zeile 777 |
---|
default: $notification = 0; }
|
default: $notification = 0; }
|
|
|
require_once MYBB_ROOT."inc/functions_user.php"; add_subscribed_thread($post['tid'], $notification, $post['uid']); }
| require_once MYBB_ROOT."inc/functions_user.php"; add_subscribed_thread($post['tid'], $notification, $post['uid']); }
|
Zeile 714 | Zeile 786 |
---|
if(is_moderator($post['fid'], "", $post['uid'])) { $lang->load($this->language_file, true);
|
if(is_moderator($post['fid'], "", $post['uid'])) { $lang->load($this->language_file, true);
|
|
|
$modoptions = $post['modoptions']; $modlogdata['fid'] = $thread['fid']; $modlogdata['tid'] = $thread['tid'];
// Close the thread. if($modoptions['closethread'] == 1 && $thread['closed'] != 1)
|
$modoptions = $post['modoptions']; $modlogdata['fid'] = $thread['fid']; $modlogdata['tid'] = $thread['tid'];
// Close the thread. if($modoptions['closethread'] == 1 && $thread['closed'] != 1)
|
{
| {
|
$newclosed = "closed=1"; log_moderator_action($modlogdata, $lang->thread_closed); }
| $newclosed = "closed=1"; log_moderator_action($modlogdata, $lang->thread_closed); }
|
Zeile 731 | Zeile 803 |
---|
{ $newclosed = "closed=0"; log_moderator_action($modlogdata, $lang->thread_opened);
|
{ $newclosed = "closed=0"; log_moderator_action($modlogdata, $lang->thread_opened);
|
}
| }
|
// Stick the thread. if($modoptions['stickthread'] == 1 && $thread['sticky'] != 1) { $newstick = "sticky='1'"; log_moderator_action($modlogdata, $lang->thread_stuck);
|
// Stick the thread. if($modoptions['stickthread'] == 1 && $thread['sticky'] != 1) { $newstick = "sticky='1'"; log_moderator_action($modlogdata, $lang->thread_stuck);
|
}
| }
|
// Unstick the thread. if($modoptions['stickthread'] != 1 && $thread['sticky']) {
|
// Unstick the thread. if($modoptions['stickthread'] != 1 && $thread['sticky']) {
|
$newstick = "sticky='0'";
| $newstick = "sticky='0'";
|
log_moderator_action($modlogdata, $lang->thread_unstuck); }
// Execute moderation options. if($newstick && $newclosed)
|
log_moderator_action($modlogdata, $lang->thread_unstuck); }
// Execute moderation options. if($newstick && $newclosed)
|
{
| {
|
$sep = ","; } if($newstick || $newclosed)
| $sep = ","; } if($newstick || $newclosed)
|
Zeile 781 | Zeile 853 |
---|
$visible = 0; } }
|
$visible = 0; } }
|
|
|
$post['pid'] = intval($post['pid']); $post['uid'] = intval($post['uid']);
|
$post['pid'] = intval($post['pid']); $post['uid'] = intval($post['uid']);
|
|
|
if($post['pid'] > 0)
|
if($post['pid'] > 0)
|
{
| {
|
$query = $db->simple_select("posts", "tid", "pid='{$post['pid']}' AND uid='{$post['uid']}' AND visible='-2'"); $draft_check = $db->fetch_field($query, "tid");
|
$query = $db->simple_select("posts", "tid", "pid='{$post['pid']}' AND uid='{$post['uid']}' AND visible='-2'"); $draft_check = $db->fetch_field($query, "tid");
|
}
| }
|
else { $draft_check = false; }
|
else { $draft_check = false; }
|
|
|
if($this->method != "update" && $visible == 1) { $double_post = $this->verify_post_merge();
| if($this->method != "update" && $visible == 1) { $double_post = $this->verify_post_merge();
|
Zeile 803 | Zeile 875 |
---|
if($double_post !== true && $double_post['visible'] == $visible) { $this->pid = $double_post['pid'];
|
if($double_post !== true && $double_post['visible'] == $visible) { $this->pid = $double_post['pid'];
|
|
|
$post['message'] = $double_post['message'] .= "\n".$mybb->settings['postmergesep']."\n".$post['message']; $update_query = array( "message" => $db->escape_string($double_post['message'])
| $post['message'] = $double_post['message'] .= "\n".$mybb->settings['postmergesep']."\n".$post['message']; $update_query = array( "message" => $db->escape_string($double_post['message'])
|
Zeile 811 | Zeile 883 |
---|
$update_query['edituid'] = intval($post['uid']); $update_query['edittime'] = TIME_NOW; $query = $db->update_query("posts", $update_query, "pid='".$double_post['pid']."'");
|
$update_query['edituid'] = intval($post['uid']); $update_query['edittime'] = TIME_NOW; $query = $db->update_query("posts", $update_query, "pid='".$double_post['pid']."'");
|
|
|
if($draft_check) { $db->delete_query("posts", "pid='".$post['pid']."'"); }
|
if($draft_check) { $db->delete_query("posts", "pid='".$post['pid']."'"); }
|
// Assign any uploaded attachments with the specific posthash to the merged post. $post['posthash'] = $db->escape_string($post['posthash']); $query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='0' AND visible='1' AND posthash='{$post['posthash']}'"); $attachmentcount = $db->fetch_field($query, "attachmentcount"); if($attachmentcount > 0)
| if($post['posthash'])
|
{
|
{
|
// Update forum count update_thread_counters($post['tid'], array('attachmentcount' => "+{$attachmentcount}"));
| // Assign any uploaded attachments with the specific posthash to the merged post. $post['posthash'] = $db->escape_string($post['posthash']);
$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='0' AND visible='1' AND posthash='{$post['posthash']}'"); $attachmentcount = $db->fetch_field($query, "attachmentcount");
if($attachmentcount > 0) { // Update forum count update_thread_counters($post['tid'], array('attachmentcount' => "+{$attachmentcount}")); }
$attachmentassign = array( "pid" => $double_post['pid'], "posthash" => '' ); $db->update_query("attachments", $attachmentassign, "posthash='{$post['posthash']}' AND pid='0'");
|
}
|
}
|
$attachmentassign = array( "pid" => $double_post['pid'], "posthash" => '' ); $db->update_query("attachments", $attachmentassign, "posthash='{$post['posthash']}'");
|
|
// Return the post's pid and whether or not it is visible. return array( "pid" => $double_post['pid'],
| // Return the post's pid and whether or not it is visible. return array( "pid" => $double_post['pid'],
|
Zeile 842 | Zeile 917 |
---|
); } }
|
); } }
|
|
|
if($visible == 1 && $thread['visible'] == 1) { $now = TIME_NOW;
| if($visible == 1 && $thread['visible'] == 1) { $now = TIME_NOW;
|
Zeile 855 | Zeile 930 |
---|
{ $update_array['postnum'] = 'postnum+1'; }
|
{ $update_array['postnum'] = 'postnum+1'; }
|
|
|
$db->update_query("users", $update_array, "uid='{$post['uid']}'", 1, true); }
| $db->update_query("users", $update_array, "uid='{$post['uid']}'", 1, true); }
|
Zeile 915 | Zeile 990 |
---|
"pid" => $this->pid, "posthash" => '' );
|
"pid" => $this->pid, "posthash" => '' );
|
$db->update_query("attachments", $attachmentassign, "posthash='{$post['posthash']}'");
| $db->update_query("attachments", $attachmentassign, "posthash='{$post['posthash']}' AND pid='0'");
|
}
if($visible == 1 && $thread['visible'] == 1)
| }
if($visible == 1 && $thread['visible'] == 1)
|
Zeile 923 | Zeile 998 |
---|
$thread = get_thread($post['tid']); require_once MYBB_ROOT.'inc/class_parser.php'; $parser = new Postparser;
|
$thread = get_thread($post['tid']); require_once MYBB_ROOT.'inc/class_parser.php'; $parser = new Postparser;
|
|
|
$done_users = array();
|
$done_users = array();
|
|
|
$subject = $parser->parse_badwords($thread['subject']); $excerpt = $parser->text_parse_message($post['message'], array('me_username' => $post['username'], 'filter_badwords' => 1, 'safe_html' => 1)); $excerpt = my_substr($excerpt, 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
| $subject = $parser->parse_badwords($thread['subject']); $excerpt = $parser->text_parse_message($post['message'], array('me_username' => $post['username'], 'filter_badwords' => 1, 'safe_html' => 1)); $excerpt = my_substr($excerpt, 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
|
Zeile 942 | Zeile 1017 |
---|
while($subscribedmember = $db->fetch_array($query)) { if($done_users[$subscribedmember['uid']])
|
while($subscribedmember = $db->fetch_array($query)) { if($done_users[$subscribedmember['uid']])
|
{ continue; }
| { continue; }
|
$done_users[$subscribedmember['uid']] = 1;
|
$done_users[$subscribedmember['uid']] = 1;
|
|
|
$forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']); if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
| $forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']); if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
|
Zeile 958 | Zeile 1033 |
---|
// User isn't a moderator or the author of the thread... continue; }
|
// User isn't a moderator or the author of the thread... continue; }
|
|
|
if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language'])) { $uselang = $subscribedmember['language'];
| if($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language'])) { $uselang = $subscribedmember['language'];
|
Zeile 966 | Zeile 1041 |
---|
elseif($mybb->settings['orig_bblanguage']) { $uselang = $mybb->settings['orig_bblanguage'];
|
elseif($mybb->settings['orig_bblanguage']) { $uselang = $mybb->settings['orig_bblanguage'];
|
}
| }
|
else { $uselang = "english";
| else { $uselang = "english";
|
Zeile 993 | Zeile 1068 |
---|
$emailmessage = $langcache[$uselang]['email_subscription']; } $emailsubject = $lang->sprintf($emailsubject, $subject);
|
$emailmessage = $langcache[$uselang]['email_subscription']; } $emailsubject = $lang->sprintf($emailsubject, $subject);
|
$post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']);
| $post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']);
|
$emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $post['username'], $mybb->settings['bbname'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid'], $subscribedmember['subscriptionkey'], $post_code); $new_email = array( "mailto" => $db->escape_string($subscribedmember['email']),
| $emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $post['username'], $mybb->settings['bbname'], $subject, $excerpt, $mybb->settings['bburl'], str_replace("&", "&", get_thread_link($thread['tid'], 0, "newpost")), $thread['tid'], $subscribedmember['subscriptionkey'], $post_code); $new_email = array( "mailto" => $db->escape_string($subscribedmember['email']),
|
Zeile 1031 | Zeile 1106 |
---|
update_thread_counters($post['tid'], array("replies" => "+1")); update_forum_counters($post['fid'], array("unapprovedposts" => "+1")); }
|
update_thread_counters($post['tid'], array("replies" => "+1")); update_forum_counters($post['fid'], array("unapprovedposts" => "+1")); }
|
|
|
$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'"); $attachmentcount = $db->fetch_field($query, "attachmentcount"); if($attachmentcount > 0)
| $query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'"); $attachmentcount = $db->fetch_field($query, "attachmentcount"); if($attachmentcount > 0)
|
Zeile 1058 | Zeile 1133 |
---|
$thread = &$this->data;
// Validate all thread assets.
|
$thread = &$this->data;
// Validate all thread assets.
|
|
|
if(!$thread['savedraft'])
|
if(!$thread['savedraft'])
|
{
| {
|
$this->verify_post_flooding();
|
$this->verify_post_flooding();
|
}
| }
|
if($this->method == "insert" || array_key_exists('uid', $thread)) { $this->verify_author(); }
|
if($this->method == "insert" || array_key_exists('uid', $thread)) { $this->verify_author(); }
|
|
|
if($this->method == "insert" || array_key_exists('prefix', $thread))
|
if($this->method == "insert" || array_key_exists('prefix', $thread))
|
{
| {
|
$this->verify_prefix();
|
$this->verify_prefix();
|
}
| }
|
if($this->method == "insert" || array_key_exists('subject', $thread)) { $this->verify_subject();
|
if($this->method == "insert" || array_key_exists('subject', $thread)) { $this->verify_subject();
|
}
| }
|
if($this->method == "insert" || array_key_exists('message', $thread))
|
if($this->method == "insert" || array_key_exists('message', $thread))
|
{
| {
|
$this->verify_message(); $this->verify_image_count(); $this->verify_video_count();
|
$this->verify_message(); $this->verify_image_count(); $this->verify_video_count();
|
}
| }
|
if($this->method == "insert" || array_key_exists('dateline', $thread))
|
if($this->method == "insert" || array_key_exists('dateline', $thread))
|
{ $this->verify_dateline(); }
| { $this->verify_dateline(); }
|
if($this->method == "insert" || array_key_exists('icon', $thread)) {
| if($this->method == "insert" || array_key_exists('icon', $thread)) {
|
Zeile 1287 | Zeile 1362 |
---|
if(is_moderator($thread['fid'], "", $thread['uid']) && is_array($thread['modoptions'])) { $lang->load($this->language_file, true);
|
if(is_moderator($thread['fid'], "", $thread['uid']) && is_array($thread['modoptions'])) { $lang->load($this->language_file, true);
|
|
|
$modoptions = $thread['modoptions'];
|
$modoptions = $thread['modoptions'];
|
$modlogdata['fid'] = $this->tid; $modlogdata['tid'] = $thread['tid'];
| $modlogdata['fid'] = $thread['fid']; $modlogdata['tid'] = $this->tid;
|
// Close the thread. if($modoptions['closethread'] == 1)
| // Close the thread. if($modoptions['closethread'] == 1)
|
Zeile 1345 | Zeile 1420 |
---|
$db->update_query("users", $update_query, "uid='{$thread['uid']}'", 1, true); } }
|
$db->update_query("users", $update_query, "uid='{$thread['uid']}'", 1, true); } }
|
|
|
if(!$forum['lastpost']) { $forum['lastpost'] = 0; }
|
if(!$forum['lastpost']) { $forum['lastpost'] = 0; }
|
|
|
$done_users = array();
|
$done_users = array();
|
|
|
// Queue up any forum subscription notices to users who are subscribed to this forum. $excerpt = my_substr($thread['message'], 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
|
// Queue up any forum subscription notices to users who are subscribed to this forum. $excerpt = my_substr($thread['message'], 0, $mybb->settings['subscribeexcerpt']).$lang->emailbit_viewthread;
|
|
|
// Parse badwords require_once MYBB_ROOT."inc/class_parser.php"; $parser = new postParser;
| // Parse badwords require_once MYBB_ROOT."inc/class_parser.php"; $parser = new postParser;
|
Zeile 1374 | Zeile 1449 |
---|
while($subscribedmember = $db->fetch_array($query)) { if($done_users[$subscribedmember['uid']])
|
while($subscribedmember = $db->fetch_array($query)) { if($done_users[$subscribedmember['uid']])
|
{ continue;
| { continue;
|
} $done_users[$subscribedmember['uid']] = 1;
|
} $done_users[$subscribedmember['uid']] = 1;
|
|
|
$forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']); if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) { continue;
|
$forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']); if($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) { continue;
|
}
| }
|
if(!is_moderator($thread['fid'], "", $subscribedmember['uid']) && $forumpermissions['canonlyviewownthreads'] == 1) { // In a 'view own only' forum and not a moderator
| if(!is_moderator($thread['fid'], "", $subscribedmember['uid']) && $forumpermissions['canonlyviewownthreads'] == 1) { // In a 'view own only' forum and not a moderator
|
Zeile 1397 | Zeile 1472 |
---|
$uselang = $subscribedmember['language']; } else if($mybb->settings['bblanguage'])
|
$uselang = $subscribedmember['language']; } else if($mybb->settings['bblanguage'])
|
{
| {
|
$uselang = $mybb->settings['bblanguage']; } else
| $uselang = $mybb->settings['bblanguage']; } else
|
Zeile 1426 | Zeile 1501 |
---|
$emailmessage = $langcache[$uselang]['email_forumsubscription']; } $emailsubject = $lang->sprintf($emailsubject, $forum['name']);
|
$emailmessage = $langcache[$uselang]['email_forumsubscription']; } $emailsubject = $lang->sprintf($emailsubject, $forum['name']);
|
|
|
$post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']); $emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], get_thread_link($this->tid), $thread['fid'], $post_code); $new_email = array(
| $post_code = md5($subscribedmember['loginkey'].$subscribedmember['salt'].$subscribedmember['regdate']); $emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], get_thread_link($this->tid), $thread['fid'], $post_code); $new_email = array(
|
Zeile 1439 | Zeile 1514 |
---|
$db->insert_query("mailqueue", $new_email); unset($userlang); $queued_email = 1;
|
$db->insert_query("mailqueue", $new_email); unset($userlang); $queued_email = 1;
|
}
| }
|
// Have one or more emails been queued? Update the queue count if($queued_email == 1) { $cache->update_mailqueue(); } }
|
// Have one or more emails been queued? Update the queue count if($queued_email == 1) { $cache->update_mailqueue(); } }
|
}
| }
|
// Assign any uploaded attachments with the specific posthash to the newly created post. if($thread['posthash']) {
| // Assign any uploaded attachments with the specific posthash to the newly created post. if($thread['posthash']) {
|
Zeile 1456 | Zeile 1531 |
---|
"pid" => $this->pid, "posthash" => '' );
|
"pid" => $this->pid, "posthash" => '' );
|
$db->update_query("attachments", $attachmentassign, "posthash='{$thread['posthash']}'");
| $db->update_query("attachments", $attachmentassign, "posthash='{$thread['posthash']}' AND pid='0'");
|
}
|
}
|
|
|
if($visible == 1)
|
if($visible == 1)
|
{ update_thread_data($this->tid);
| { update_thread_data($this->tid);
|
update_forum_counters($thread['fid'], array("threads" => "+1", "posts" => "+1")); } else if($visible == 0)
| update_forum_counters($thread['fid'], array("threads" => "+1", "posts" => "+1")); } else if($visible == 0)
|
Zeile 1470 | Zeile 1545 |
---|
update_thread_counters($this->tid, array("replies" => 0)); update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1")); }
|
update_thread_counters($this->tid, array("replies" => 0)); update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1")); }
|
|
|
$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'"); $attachmentcount = $db->fetch_field($query, "attachmentcount"); if($attachmentcount > 0)
| $query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'"); $attachmentcount = $db->fetch_field($query, "attachmentcount"); if($attachmentcount > 0)
|
Zeile 1485 | Zeile 1560 |
---|
"visible" => $visible ); }
|
"visible" => $visible ); }
|
|
|
/** * Updates a post that is already in the database. *
| /** * Updates a post that is already in the database. *
|
Zeile 1493 | Zeile 1568 |
---|
function update_post() { global $db, $mybb, $plugins;
|
function update_post() { global $db, $mybb, $plugins;
|
|
|
// Yes, validating is required. if($this->get_validated() != true)
|
// Yes, validating is required. if($this->get_validated() != true)
|
{
| {
|
die("The post needs to be validated before inserting it into the DB."); } if(count($this->get_errors()) > 0)
| die("The post needs to be validated before inserting it into the DB."); } if(count($this->get_errors()) > 0)
|
Zeile 1507 | Zeile 1582 |
---|
$post = &$this->data;
$post['pid'] = intval($post['pid']);
|
$post = &$this->data;
$post['pid'] = intval($post['pid']);
|
|
|
$existing_post = get_post($post['pid']); $post['tid'] = $existing_post['tid']; $post['fid'] = $existing_post['fid'];
|
$existing_post = get_post($post['pid']); $post['tid'] = $existing_post['tid']; $post['fid'] = $existing_post['fid'];
|
|
|
$forum = get_forum($post['fid']);
// Decide on the visibility of this post.
| $forum = get_forum($post['fid']);
// Decide on the visibility of this post.
|
Zeile 1524 | Zeile 1599 |
---|
update_thread_data($existing_post['tid']); update_thread_counters($existing_post['tid'], array('replies' => '-1', 'unapprovedposts' => '+1')); update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '+1', 'unapprovedposts' => '+1'));
|
update_thread_data($existing_post['tid']); update_thread_counters($existing_post['tid'], array('replies' => '-1', 'unapprovedposts' => '+1')); update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '+1', 'unapprovedposts' => '+1'));
|
|
|
// Subtract from the users post count // Update the post count if this forum allows post counts to be tracked if($forum['usepostcounts'] != 0)
| // Subtract from the users post count // Update the post count if this forum allows post counts to be tracked if($forum['usepostcounts'] != 0)
|
Zeile 1533 | Zeile 1608 |
---|
} } $visible = 0;
|
} } $visible = 0;
|
}
| }
|
else { if($existing_post['visible'] == 0)
| else { if($existing_post['visible'] == 0)
|
Zeile 1541 | Zeile 1616 |
---|
update_thread_data($existing_post['tid']); update_thread_counters($existing_post['tid'], array('replies' => '+1', 'unapprovedposts' => '-1')); update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '-1', 'unapprovedposts' => '-1'));
|
update_thread_data($existing_post['tid']); update_thread_counters($existing_post['tid'], array('replies' => '+1', 'unapprovedposts' => '-1')); update_forum_counters($existing_post['fid'], array('unapprovedthreads' => '-1', 'unapprovedposts' => '-1'));
|
|
|
// Update the post count if this forum allows post counts to be tracked if($forum['usepostcounts'] != 0) {
| // Update the post count if this forum allows post counts to be tracked if($forum['usepostcounts'] != 0) {
|
Zeile 1577 | Zeile 1652 |
---|
{ $first_post = false; }
|
{ $first_post = false; }
|
|
|
if($existing_post['visible'] == 0) { $visible = 0; }
|
if($existing_post['visible'] == 0) { $visible = 0; }
|
|
|
// Update the thread details that might have been changed first. if($first_post)
|
// Update the thread details that might have been changed first. if($first_post)
|
{
| {
|
$this->tid = $post['tid'];
$this->thread_update_data['visible'] = $visible;
|
$this->tid = $post['tid'];
$this->thread_update_data['visible'] = $visible;
|
|
|
if(isset($post['prefix'])) { $this->thread_update_data['prefix'] = intval($post['prefix']);
| if(isset($post['prefix'])) { $this->thread_update_data['prefix'] = intval($post['prefix']);
|
Zeile 1598 | Zeile 1673 |
---|
if(isset($post['subject'])) { $this->thread_update_data['subject'] = $db->escape_string($post['subject']);
|
if(isset($post['subject'])) { $this->thread_update_data['subject'] = $db->escape_string($post['subject']);
|
}
| }
|
if(isset($post['icon'])) { $this->thread_update_data['icon'] = intval($post['icon']); } if(count($this->thread_update_data) > 0)
|
if(isset($post['icon'])) { $this->thread_update_data['icon'] = intval($post['icon']); } if(count($this->thread_update_data) > 0)
|
{
| {
|
$plugins->run_hooks("datahandler_post_update_thread", $this);
$db->update_query("threads", $this->thread_update_data, "tid='".intval($post['tid'])."'");
| $plugins->run_hooks("datahandler_post_update_thread", $this);
$db->update_query("threads", $this->thread_update_data, "tid='".intval($post['tid'])."'");
|
Zeile 1651 | Zeile 1726 |
---|
}
$this->post_update_data['visible'] = $visible;
|
}
$this->post_update_data['visible'] = $visible;
|
|
|
$plugins->run_hooks("datahandler_post_update", $this);
$db->update_query("posts", $this->post_update_data, "pid='".intval($post['pid'])."'");
| $plugins->run_hooks("datahandler_post_update", $this);
$db->update_query("posts", $this->post_update_data, "pid='".intval($post['pid'])."'");
|