| [ Index ] |
PHP Cross Reference of MyBB 1.8.41 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 define("IN_MYBB", 1); 12 define('THIS_SCRIPT', 'newthread.php'); 13 14 $templatelist = "newthread,previewpost,loginbox,changeuserbox,newthread_postpoll,posticons,codebuttons,postbit,post_attachments_attachment_unapproved,newreply_modoptions_close,newreply_modoptions_stick"; 15 $templatelist .= ",newthread_disablesmilies,post_attachments_new,post_attachments,post_savedraftbutton,post_subscription_method,post_attachments_attachment_remove,postbit_warninglevel_formatted,postbit_icon"; 16 $templatelist .= ",forumdisplay_rules,forumdisplay_rules_link,post_attachments_attachment_postinsert,post_attachments_attachment,newthread_signature,post_prefixselect_prefix,post_prefixselect_single,posticons_icon"; 17 $templatelist .= ",post_captcha_hidden,post_captcha_recaptcha_invisible,post_captcha_nocaptcha,post_captcha_cfturnstile,post_captcha_hcaptcha_invisible,post_captcha_hcaptcha,post_javascript,postbit_gotopost,newthread_postoptions,post_attachments_add,post_attachments_viewlink"; 18 $templatelist .= ",postbit_avatar,postbit_find,postbit_pm,postbit_rep_button,postbit_www,postbit_email,postbit_reputation,postbit_warn,postbit_warninglevel,postbit_author_user,postbit_author_guest,post_captcha"; 19 $templatelist .= ",postbit_signature,postbit_classic,postbit_attachments_thumbnails_thumbnail,postbit_attachments_images_image,postbit_attachments_attachment,postbit_attachments_attachment_unapproved"; 20 $templatelist .= ",postbit_attachments_thumbnails,postbit_attachments_images,postbit_attachments,postbit_reputation_formatted_link,post_attachments_update,postbit_offline,newreply_modoptions,newthread_multiquote_external"; 21 $templatelist .= ",postbit_profilefield_multiselect_value,postbit_profilefield_multiselect,newthread_draftinput,global_moderation_notice,postbit_online,postbit_away,attachment_icon,postbit_userstar,postbit_groupimage"; 22 23 require_once "./global.php"; 24 require_once MYBB_ROOT."inc/functions_post.php"; 25 require_once MYBB_ROOT."inc/functions_search.php"; 26 require_once MYBB_ROOT."inc/functions_user.php"; 27 require_once MYBB_ROOT."inc/functions_upload.php"; 28 29 // Load global language phrases 30 $lang->load("newthread"); 31 32 $tid = $pid = 0; 33 $mybb->input['action'] = $mybb->get_input('action'); 34 $mybb->input['tid'] = $mybb->get_input('tid', MyBB::INPUT_INT); 35 $mybb->input['pid'] = $mybb->get_input('pid', MyBB::INPUT_INT); 36 if($mybb->input['action'] == "editdraft" || ($mybb->get_input('savedraft') && $mybb->input['tid']) || ($mybb->input['tid'] && $mybb->input['pid'])) 37 { 38 $thread = get_thread($mybb->input['tid']); 39 40 $query = $db->simple_select("posts", "*", "tid='".$mybb->input['tid']."' AND visible='-2'", array('order_by' => 'dateline, pid', 'limit' => 1)); 41 $post = $db->fetch_array($query); 42 43 if(!$thread || !$post || $thread['visible'] != -2 || $thread['uid'] != $mybb->user['uid']) 44 { 45 error($lang->invalidthread); 46 } 47 48 $pid = $post['pid']; 49 $fid = $thread['fid']; 50 $tid = $thread['tid']; 51 eval("\$editdraftpid = \"".$templates->get("newthread_draftinput")."\";"); 52 } 53 else 54 { 55 $fid = $mybb->get_input('fid', MyBB::INPUT_INT); 56 $editdraftpid = ''; 57 } 58 59 // Fetch forum information. 60 $forum = get_forum($fid); 61 if(!$forum) 62 { 63 error($lang->error_invalidforum); 64 } 65 66 // Draw the navigation 67 build_forum_breadcrumb($fid); 68 add_breadcrumb($lang->nav_newthread); 69 70 $forumpermissions = forum_permissions($fid); 71 72 if($forum['open'] == 0 || $forum['type'] != "f" || $forum['linkto'] != "") 73 { 74 error($lang->error_closedinvalidforum); 75 } 76 77 if($forumpermissions['canview'] == 0 || $forumpermissions['canpostthreads'] == 0) 78 { 79 error_no_permission(); 80 } 81 82 if($mybb->user['suspendposting'] == 1) 83 { 84 $suspendedpostingtype = $lang->error_suspendedposting_permanent; 85 if($mybb->user['suspensiontime']) 86 { 87 $suspendedpostingtype = $lang->sprintf($lang->error_suspendedposting_temporal, my_date($mybb->settings['dateformat'], $mybb->user['suspensiontime'])); 88 } 89 90 $lang->error_suspendedposting = $lang->sprintf($lang->error_suspendedposting, $suspendedpostingtype, my_date($mybb->settings['timeformat'], $mybb->user['suspensiontime'])); 91 92 error($lang->error_suspendedposting); 93 } 94 95 // Check if this forum is password protected and we have a valid password 96 check_forum_password($forum['fid']); 97 98 // If MyCode is on for this forum and the MyCode editor is enabled in the Admin CP, draw the code buttons and smilie inserter. 99 $codebuttons = ''; 100 $smilieinserter = ''; 101 if($mybb->settings['bbcodeinserter'] != 0 && $forum['allowmycode'] != 0 && (!$mybb->user['uid'] || $mybb->user['showcodebuttons'] != 0)) 102 { 103 $codebuttons = build_mycode_inserter("message", $forum['allowsmilies']); 104 if($forum['allowsmilies'] != 0) 105 { 106 $smilieinserter = build_clickable_smilies(); 107 } 108 } 109 110 $posticons = ''; 111 112 // Does this forum allow post icons? If so, fetch the post icons. 113 if($mybb->settings['allowposticons'] == 1 && $forum['allowpicons'] != 0) 114 { 115 $posticons = get_post_icons(); 116 } 117 118 // If we have a currently logged in user then fetch the change user box. 119 if($mybb->user['uid'] != 0) 120 { 121 $mybb->user['username'] = htmlspecialchars_uni($mybb->user['username']); 122 eval("\$loginbox = \"".$templates->get("changeuserbox")."\";"); 123 } 124 125 // Otherwise we have a guest, determine the "username" and get the login box. 126 else 127 { 128 if(!isset($mybb->input['previewpost']) && $mybb->input['action'] != "do_newthread") 129 { 130 $username = ''; 131 } 132 else 133 { 134 $username = htmlspecialchars_uni($mybb->get_input('username')); 135 } 136 eval("\$loginbox = \"".$templates->get("loginbox")."\";"); 137 } 138 139 // If we're not performing a new thread insert and not editing a draft then we're posting a new thread. 140 if($mybb->input['action'] != "do_newthread" && $mybb->input['action'] != "editdraft") 141 { 142 $mybb->input['action'] = "newthread"; 143 } 144 145 // Previewing a post, overwrite the action to the new thread action. 146 if(!empty($mybb->input['previewpost'])) 147 { 148 $mybb->input['action'] = "newthread"; 149 } 150 151 // Setup a unique posthash for attachment management 152 if(!$mybb->get_input('posthash') && !$pid) 153 { 154 $mybb->input['posthash'] = md5($mybb->user['uid'].random_str()); 155 } 156 157 if((empty($_POST) && empty($_FILES)) && $mybb->get_input('processed', MyBB::INPUT_INT) == 1) 158 { 159 error($lang->error_empty_post_input); 160 } 161 162 $errors = array(); 163 $maximageserror = $attacherror = ''; 164 165 // Handle attachments if we've got any. 166 if($mybb->settings['enableattachments'] == 1 && 167 ($mybb->get_input('newattachment') || $mybb->get_input('updateattachment') || 168 ((($mybb->input['action'] == "do_newthread" && $mybb->get_input('submit')) || 169 ($mybb->input['action'] == "newthread" && isset($mybb->input['previewpost'])) || 170 isset($mybb->input['savedraft'])) && isset($_FILES['attachments'])))) 171 { 172 // Verify incoming POST request 173 verify_post_check($mybb->get_input('my_post_key')); 174 175 if($mybb->input['action'] == "editdraft" || ($mybb->input['tid'] && $mybb->input['pid'])) 176 { 177 $attachwhere = "pid='{$pid}'"; 178 } 179 else 180 { 181 $attachwhere = "posthash='".$db->escape_string($mybb->get_input('posthash'))."'"; 182 } 183 184 $ret = add_attachments($pid, $forumpermissions, $attachwhere, "newthread"); 185 186 if($mybb->get_input('ajax', MyBB::INPUT_INT) == 1) 187 { 188 if(isset($ret['success'])) 189 { 190 $attachment = array('aid'=>'{1}', 'icon'=>'{2}', 'filename'=>'{3}', 'size'=>'{4}'); 191 if($mybb->settings['bbcodeinserter'] != 0 && $forum['allowmycode'] != 0 && $mybb->user['showcodebuttons'] != 0) 192 { 193 eval("\$postinsert = \"".$templates->get("post_attachments_attachment_postinsert")."\";"); 194 } 195 eval("\$attach_rem_options = \"".$templates->get("post_attachments_attachment_remove")."\";"); 196 $attach_mod_options = ''; 197 eval("\$attemplate = \"".$templates->get("post_attachments_attachment")."\";"); 198 $ret['template'] = $attemplate; 199 200 $query = $db->simple_select("attachments", "SUM(filesize) AS ausage", "uid='".$mybb->user['uid']."'"); 201 $usage = $db->fetch_array($query); 202 $ret['usage'] = get_friendly_size($usage['ausage']); 203 } 204 205 header("Content-type: application/json; charset={$lang->settings['charset']}"); 206 echo json_encode($ret); 207 exit(); 208 } 209 210 if(!empty($ret['errors'])) 211 { 212 $errors = $ret['errors']; 213 } 214 215 // If we were dealing with an attachment but didn't click 'Post Thread' or 'Save as Draft', force the new thread page again. 216 if(!$mybb->get_input('submit') && !$mybb->get_input('savedraft')) 217 { 218 $mybb->input['action'] = "newthread"; 219 } 220 } 221 222 detect_attachmentact(); 223 224 // Are we removing an attachment from the thread? 225 if($mybb->settings['enableattachments'] == 1 && $mybb->get_input('attachmentaid', MyBB::INPUT_INT) && $mybb->get_input('attachmentact') == "remove") 226 { 227 // Verify incoming POST request 228 verify_post_check($mybb->get_input('my_post_key')); 229 230 remove_attachment($pid, $mybb->get_input('posthash'), $mybb->get_input('attachmentaid', MyBB::INPUT_INT)); 231 232 if(!$mybb->get_input('submit')) 233 { 234 $mybb->input['action'] = "newthread"; 235 } 236 237 if($mybb->get_input('ajax', MyBB::INPUT_INT) == 1) 238 { 239 $query = $db->simple_select("attachments", "SUM(filesize) AS ausage", "uid='".$mybb->user['uid']."'"); 240 $usage = $db->fetch_array($query); 241 242 header("Content-type: application/json; charset={$lang->settings['charset']}"); 243 echo json_encode(array("success" => true, "usage" => get_friendly_size($usage['ausage']))); 244 exit(); 245 } 246 } 247 248 $thread_errors = ""; 249 $hide_captcha = false; 250 251 // Check the maximum posts per day for this user 252 if($mybb->usergroup['maxposts'] > 0) 253 { 254 $daycut = TIME_NOW-60*60*24; 255 $query = $db->simple_select("posts", "COUNT(*) AS posts_today", "uid='{$mybb->user['uid']}' AND visible !='-1' AND dateline>{$daycut}"); 256 $post_count = $db->fetch_field($query, "posts_today"); 257 if($post_count >= $mybb->usergroup['maxposts']) 258 { 259 $lang->error_maxposts = $lang->sprintf($lang->error_maxposts, $mybb->usergroup['maxposts']); 260 error($lang->error_maxposts); 261 } 262 } 263 264 // Performing the posting of a new thread. 265 if($mybb->input['action'] == "do_newthread" && $mybb->request_method == "post") 266 { 267 // Verify incoming POST request 268 verify_post_check($mybb->get_input('my_post_key')); 269 270 $plugins->run_hooks("newthread_do_newthread_start"); 271 272 // If this isn't a logged in user, then we need to do some special validation. 273 if($mybb->user['uid'] == 0) 274 { 275 // If they didn't specify a username leave blank so $lang->guest can be used on output 276 if(!$mybb->get_input('username')) 277 { 278 $username = ''; 279 } 280 // Otherwise use the name they specified. 281 else 282 { 283 $username = $mybb->get_input('username'); 284 } 285 $uid = 0; 286 287 if(!$mybb->user['uid'] && $mybb->settings['stopforumspam_on_newthread']) 288 { 289 require_once MYBB_ROOT . '/inc/class_stopforumspamchecker.php'; 290 291 $stop_forum_spam_checker = new StopForumSpamChecker( 292 $plugins, 293 $mybb->settings['stopforumspam_min_weighting_before_spam'], 294 $mybb->settings['stopforumspam_check_usernames'], 295 $mybb->settings['stopforumspam_check_emails'], 296 $mybb->settings['stopforumspam_check_ips'], 297 $mybb->settings['stopforumspam_log_blocks'] 298 ); 299 300 try { 301 if($stop_forum_spam_checker->is_user_a_spammer($mybb->get_input('username'), '', get_ip())) 302 { 303 $errors[] = $lang->sprintf($lang->error_stop_forum_spam_spammer, 304 $stop_forum_spam_checker->getErrorText(array( 305 'stopforumspam_check_usernames', 306 'stopforumspam_check_ips' 307 ))); 308 } 309 } 310 catch (Exception $e) 311 { 312 if($mybb->settings['stopforumspam_block_on_error']) 313 { 314 $errors[] = $lang->error_stop_forum_spam_fetching; 315 } 316 } 317 } 318 } 319 // This user is logged in. 320 else 321 { 322 $username = $mybb->user['username']; 323 $uid = $mybb->user['uid']; 324 } 325 326 // Attempt to see if this post is a duplicate or not 327 if($uid > 0) 328 { 329 $user_check = "p.uid='{$uid}'"; 330 } 331 else 332 { 333 $user_check = "p.ipaddress=".$db->escape_binary($session->packedip); 334 } 335 if(!$mybb->get_input('savedraft') && !$pid) 336 { 337 $query = $db->simple_select("posts p", "p.pid", "$user_check AND p.fid='{$forum['fid']}' AND p.subject='".$db->escape_string($mybb->get_input('subject'))."' AND p.message='".$db->escape_string($mybb->get_input('message'))."' AND p.dateline>".(TIME_NOW-600)); 338 if($db->num_rows($query) > 0) 339 { 340 error($lang->error_post_already_submitted); 341 } 342 } 343 344 // Set up posthandler. 345 require_once MYBB_ROOT."inc/datahandlers/post.php"; 346 $posthandler = new PostDataHandler("insert"); 347 $posthandler->action = "thread"; 348 349 // Set the thread data that came from the input to the $thread array. 350 $new_thread = array( 351 "fid" => $forum['fid'], 352 "subject" => $mybb->get_input('subject'), 353 "prefix" => $mybb->get_input('threadprefix', MyBB::INPUT_INT), 354 "icon" => $mybb->get_input('icon', MyBB::INPUT_INT), 355 "uid" => $uid, 356 "username" => $username, 357 "message" => $mybb->get_input('message'), 358 "ipaddress" => $session->packedip, 359 "posthash" => $mybb->get_input('posthash') 360 ); 361 362 if($pid != '') 363 { 364 $new_thread['pid'] = $pid; 365 } 366 367 // Are we saving a draft thread? 368 if($mybb->get_input('savedraft') && $mybb->user['uid']) 369 { 370 $new_thread['savedraft'] = 1; 371 } 372 else 373 { 374 $new_thread['savedraft'] = 0; 375 } 376 377 // Is this thread already a draft and we're updating it? 378 if(isset($thread['tid']) && $thread['visible'] == -2) 379 { 380 $new_thread['tid'] = $thread['tid']; 381 } 382 383 $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY); 384 if(!isset($postoptions['signature'])) 385 { 386 $postoptions['signature'] = 0; 387 } 388 if(!isset($postoptions['subscriptionmethod'])) 389 { 390 $postoptions['subscriptionmethod'] = 0; 391 } 392 if(!isset($postoptions['disablesmilies'])) 393 { 394 $postoptions['disablesmilies'] = 0; 395 } 396 397 // Set up the thread options from the input. 398 $new_thread['options'] = array( 399 "signature" => $postoptions['signature'], 400 "subscriptionmethod" => $postoptions['subscriptionmethod'], 401 "disablesmilies" => $postoptions['disablesmilies'] 402 ); 403 404 // Apply moderation options if we have them 405 $new_thread['modoptions'] = $mybb->get_input('modoptions', MyBB::INPUT_ARRAY); 406 407 $posthandler->set_data($new_thread); 408 409 // Now let the post handler do all the hard work. 410 $valid_thread = $posthandler->validate_thread(); 411 412 $post_errors = array(); 413 // Fetch friendly error messages if this is an invalid thread 414 if(!$valid_thread) 415 { 416 $post_errors = $posthandler->get_friendly_errors(); 417 } 418 419 // Check captcha image 420 if($mybb->settings['captchaimage'] && !$mybb->user['uid']) 421 { 422 require_once MYBB_ROOT.'inc/class_captcha.php'; 423 $post_captcha = new captcha; 424 425 if($post_captcha->validate_captcha() == false) 426 { 427 // CAPTCHA validation failed 428 foreach($post_captcha->get_errors() as $error) 429 { 430 $post_errors[] = $error; 431 } 432 } 433 else 434 { 435 $hide_captcha = true; 436 } 437 } 438 439 // One or more errors returned, fetch error list and throw to newthread page 440 if(count($post_errors) > 0) 441 { 442 $thread_errors = inline_error($post_errors); 443 $mybb->input['action'] = "newthread"; 444 } 445 // No errors were found, it is safe to insert the thread. 446 else 447 { 448 $thread_info = $posthandler->insert_thread(); 449 $tid = $thread_info['tid']; 450 $visible = $thread_info['visible']; 451 452 // Invalidate solved captcha 453 if($mybb->settings['captchaimage'] && !$mybb->user['uid']) 454 { 455 $post_captcha->invalidate_captcha(); 456 } 457 458 $force_redirect = false; 459 460 // Mark thread as read 461 require_once MYBB_ROOT."inc/functions_indicators.php"; 462 mark_thread_read($tid, $fid); 463 464 // We were updating a draft thread, send them back to the draft listing. 465 if($new_thread['savedraft'] == 1) 466 { 467 $lang->redirect_newthread = $lang->draft_saved; 468 $url = "usercp.php?action=drafts"; 469 } 470 471 // A poll was being posted with this thread, throw them to poll posting page. 472 else if($mybb->get_input('postpoll', MyBB::INPUT_INT) && $forumpermissions['canpostpolls']) 473 { 474 $url = "polls.php?action=newpoll&tid=$tid&polloptions=".$mybb->get_input('numpolloptions', MyBB::INPUT_INT); 475 $lang->redirect_newthread .= $lang->redirect_newthread_poll; 476 } 477 478 // This thread is stuck in the moderation queue, send them back to the forum. 479 else if(!$visible) 480 { 481 // Moderated thread 482 $lang->redirect_newthread .= $lang->redirect_newthread_moderation; 483 $url = get_forum_link($fid); 484 485 // User must see moderation notice, regardless of redirect settings 486 $force_redirect = true; 487 } 488 489 // The thread is being made in a forum the user cannot see threads in, send them back to the forum. 490 else if($visible == 1 && $forumpermissions['canviewthreads'] != 1) 491 { 492 $lang->redirect_newthread .= $lang->redirect_newthread_unviewable; 493 $url = get_forum_link($fid); 494 495 // User must see permission notice, regardless of redirect settings 496 $force_redirect = true; 497 } 498 499 // This is just a normal thread - send them to it. 500 else 501 { 502 // Visible thread 503 $lang->redirect_newthread .= $lang->redirect_newthread_thread; 504 $url = get_thread_link($tid); 505 } 506 507 // Mark any quoted posts so they're no longer selected - attempts to maintain those which weren't selected 508 if(isset($mybb->input['quoted_ids']) && isset($mybb->cookies['multiquote']) && $mybb->settings['multiquote'] != 0) 509 { 510 // We quoted all posts - remove the entire cookie 511 if($mybb->get_input('quoted_ids') == "all") 512 { 513 my_unsetcookie("multiquote"); 514 } 515 } 516 517 $plugins->run_hooks("newthread_do_newthread_end"); 518 519 // Hop to it! Send them to the next page. 520 if(!$mybb->get_input('postpoll', MyBB::INPUT_INT)) 521 { 522 $lang->redirect_newthread .= $lang->sprintf($lang->redirect_return_forum, get_forum_link($fid)); 523 } 524 redirect($url, $lang->redirect_newthread, "", $force_redirect); 525 } 526 } 527 528 if($mybb->input['action'] == "newthread" || $mybb->input['action'] == "editdraft") 529 { 530 $plugins->run_hooks("newthread_start"); 531 532 // Do we have attachment errors? 533 if(count($errors) > 0) 534 { 535 $thread_errors = inline_error($errors); 536 } 537 538 $multiquote_external = $quoted_ids = ''; 539 540 $subject = $message = ''; 541 // If this isn't a preview and we're not editing a draft, then handle quoted posts 542 if(empty($mybb->input['previewpost']) && !$thread_errors && $mybb->input['action'] != "editdraft") 543 { 544 $quoted_posts = array(); 545 // Handle multiquote 546 if(isset($mybb->cookies['multiquote']) && $mybb->settings['multiquote'] != 0) 547 { 548 $multiquoted = explode("|", $mybb->cookies['multiquote']); 549 foreach($multiquoted as $post) 550 { 551 $quoted_posts[$post] = (int)$post; 552 } 553 } 554 555 // Quoting more than one post - fetch them 556 if(count($quoted_posts) > 0) 557 { 558 $external_quotes = 0; 559 $quoted_posts = implode(",", $quoted_posts); 560 $unviewable_forums = get_unviewable_forums(true); 561 $inactiveforums = get_inactive_forums(); 562 if($unviewable_forums) 563 { 564 $unviewable_forums = "AND t.fid NOT IN ({$unviewable_forums})"; 565 } 566 if($inactiveforums) 567 { 568 $inactiveforums = "AND t.fid NOT IN ({$inactiveforums})"; 569 } 570 $thread_visible_where = get_visible_where('t'); 571 $post_visible_where = get_visible_where('p'); 572 573 // Check group permissions if we can't view threads not started by us 574 $group_permissions = forum_permissions(); 575 $onlyusfids = array(); 576 $onlyusforums = ''; 577 foreach($group_permissions as $gpfid => $forum_permissions) 578 { 579 if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1) 580 { 581 $onlyusfids[] = $gpfid; 582 } 583 } 584 if(!empty($onlyusfids)) 585 { 586 $onlyusforums = "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))"; 587 } 588 589 $load_all = $mybb->get_input('load_all_quotes', MyBB::INPUT_INT); 590 $query = $db->query(" 591 SELECT p.subject, p.message, p.pid, p.tid, p.username, p.dateline, u.username AS userusername 592 FROM ".TABLE_PREFIX."posts p 593 LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) 594 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) 595 WHERE p.pid IN ({$quoted_posts}) {$unviewable_forums} {$inactiveforums} {$onlyusforums} AND {$thread_visible_where} AND {$post_visible_where} 596 ORDER BY p.dateline, p.pid 597 "); 598 while($quoted_post = $db->fetch_array($query)) 599 { 600 if($load_all == 1) 601 { 602 if($quoted_post['userusername']) 603 { 604 $quoted_post['username'] = $quoted_post['userusername']; 605 } 606 $quoted_post['message'] = preg_replace('#(^|\r|\n)/me ([^\r\n<]*)#i', "\\1* {$quoted_post['username']} \\2", $quoted_post['message']); 607 $quoted_post['message'] = preg_replace('#(^|\r|\n)/slap ([^\r\n<]*)#i', "\\1* {$quoted_post['username']} {$lang->slaps} \\2 {$lang->with_trout}", $quoted_post['message']); 608 $quoted_post['message'] = preg_replace("#\[attachment=([0-9]+?)\]#i", '', $quoted_post['message']); 609 $message .= "[quote='{$quoted_post['username']}' pid='{$quoted_post['pid']}' dateline='{$quoted_post['dateline']}']\n{$quoted_post['message']}\n[/quote]\n\n"; 610 } 611 else 612 { 613 ++$external_quotes; 614 } 615 } 616 617 if($load_all == 1) 618 { 619 $quoted_ids = "all"; 620 } 621 else 622 { 623 if($external_quotes > 0) 624 { 625 if($external_quotes == 1) 626 { 627 $multiquote_text = $lang->multiquote_external_one; 628 $multiquote_deselect = $lang->multiquote_external_one_deselect; 629 $multiquote_quote = $lang->multiquote_external_one_quote; 630 } 631 else 632 { 633 $multiquote_text = $lang->sprintf($lang->multiquote_external, $external_quotes); 634 $multiquote_deselect = $lang->multiquote_external_deselect; 635 $multiquote_quote = $lang->multiquote_external_quote; 636 } 637 eval("\$multiquote_external = \"".$templates->get("newthread_multiquote_external")."\";"); 638 } 639 } 640 } 641 } 642 643 if(isset($mybb->input['quoted_ids'])) 644 { 645 $quoted_ids = htmlspecialchars_uni($mybb->get_input('quoted_ids')); 646 } 647 648 $postoptionschecked = array('signature' => '', 'disablesmilies' => ''); 649 $subscribe = $nonesubscribe = $emailsubscribe = $pmsubscribe = ''; 650 $postpollchecked = ''; 651 652 // Check the various post options if we're 653 // a -> previewing a post 654 // b -> removing an attachment 655 // c -> adding a new attachment 656 // d -> have errors from posting 657 658 if(!empty($mybb->input['previewpost']) || $mybb->get_input('attachmentaid', MyBB::INPUT_INT) || $mybb->get_input('newattachment') || $mybb->get_input('updateattachment') || $thread_errors) 659 { 660 $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY); 661 if(isset($postoptions['signature']) && $postoptions['signature'] == 1) 662 { 663 $postoptionschecked['signature'] = " checked=\"checked\""; 664 } 665 if(isset($postoptions['disablesmilies']) && $postoptions['disablesmilies'] == 1) 666 { 667 $postoptionschecked['disablesmilies'] = " checked=\"checked\""; 668 } 669 if($mybb->get_input('postpoll', MyBB::INPUT_INT) == 1) 670 { 671 $postpollchecked = "checked=\"checked\""; 672 } 673 $subscription_method = get_subscription_method($tid, $postoptions); 674 $numpolloptions = $mybb->get_input('numpolloptions', MyBB::INPUT_INT); 675 } 676 677 // Editing a draft thread 678 else if($mybb->input['action'] == "editdraft" && $mybb->user['uid']) 679 { 680 $mybb->input['threadprefix'] = $thread['prefix']; 681 $message = htmlspecialchars_uni($post['message']); 682 $subject = htmlspecialchars_uni($post['subject']); 683 if($post['includesig'] != 0) 684 { 685 $postoptionschecked['signature'] = " checked=\"checked\""; 686 } 687 if($post['smilieoff'] == 1) 688 { 689 $postoptionschecked['disablesmilies'] = " checked=\"checked\""; 690 } 691 $icon = $post['icon']; 692 693 $subscription_method = get_subscription_method($tid); // Subscription method doesn't get saved in drafts 694 $numpolloptions = "2"; 695 } 696 697 // Otherwise, this is our initial visit to this page. 698 else 699 { 700 if($mybb->user['signature'] != '') 701 { 702 $postoptionschecked['signature'] = " checked=\"checked\""; 703 } 704 $subscription_method = get_subscription_method($tid); // Fresh thread, let the function set the appropriate method 705 $numpolloptions = "2"; 706 } 707 708 ${$subscription_method.'subscribe'} = "checked=\"checked\" "; 709 $preview = ''; 710 711 // If we're previewing a post then generate the preview. 712 if(!empty($mybb->input['previewpost'])) 713 { 714 // If this isn't a logged in user, then we need to do some special validation. 715 if($mybb->user['uid'] == 0) 716 { 717 // If they didn't specify a username leave blank so $lang->guest can be used on output 718 if(!$mybb->get_input('username')) 719 { 720 $username = ''; 721 } 722 // Otherwise use the name they specified. 723 else 724 { 725 $username = $mybb->get_input('username'); 726 } 727 $uid = 0; 728 } 729 // This user is logged in. 730 else 731 { 732 $username = $mybb->user['username']; 733 $uid = $mybb->user['uid']; 734 } 735 736 // Set up posthandler. 737 require_once MYBB_ROOT."inc/datahandlers/post.php"; 738 $posthandler = new PostDataHandler("insert"); 739 $posthandler->action = "thread"; 740 741 // Set the thread data that came from the input to the $thread array. 742 $new_thread = array( 743 "fid" => $forum['fid'], 744 "prefix" => $mybb->get_input('threadprefix', MyBB::INPUT_INT), 745 "subject" => $mybb->get_input('subject'), 746 "icon" => $mybb->get_input('icon'), 747 "uid" => $uid, 748 "username" => $username, 749 "message" => $mybb->get_input('message'), 750 "ipaddress" => $session->packedip, 751 "posthash" => $mybb->get_input('posthash') 752 ); 753 754 if($pid != '') 755 { 756 $new_thread['pid'] = $pid; 757 } 758 759 $posthandler->set_data($new_thread); 760 761 // Now let the post handler do all the hard work. 762 $valid_thread = $posthandler->verify_message(); 763 $valid_subject = $posthandler->verify_subject(); 764 765 // guest post --> verify author 766 if($new_thread['uid'] == 0) 767 { 768 $valid_username = $posthandler->verify_author(); 769 } 770 else 771 { 772 $valid_username = true; 773 } 774 775 $post_errors = array(); 776 // Fetch friendly error messages if this is an invalid post 777 if(!$valid_thread || !$valid_subject || !$valid_username) 778 { 779 $post_errors = $posthandler->get_friendly_errors(); 780 } 781 782 // One or more errors returned, fetch error list and throw to newreply page 783 if(count($post_errors) > 0) 784 { 785 $thread_errors = inline_error($post_errors); 786 } 787 else 788 { 789 $query = $db->query(" 790 SELECT u.*, f.* 791 FROM ".TABLE_PREFIX."users u 792 LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid) 793 WHERE u.uid='".$mybb->user['uid']."' 794 "); 795 $post = $db->fetch_array($query); 796 $post['username'] = $username; 797 if($mybb->user['uid']) 798 { 799 $post['userusername'] = $mybb->user['username']; 800 } 801 $previewmessage = $mybb->get_input('message'); 802 $post['message'] = $previewmessage; 803 $post['subject'] = $mybb->get_input('subject'); 804 $post['icon'] = $mybb->get_input('icon', MyBB::INPUT_INT); 805 $mybb->input['postoptions'] = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY); 806 if(isset($mybb->input['postoptions']['disablesmilies'])) 807 { 808 $post['smilieoff'] = $mybb->input['postoptions']['disablesmilies']; 809 } 810 $post['dateline'] = TIME_NOW; 811 if(isset($mybb->input['postoptions']['signature'])) 812 { 813 $post['includesig'] = $mybb->input['postoptions']['signature']; 814 } 815 if(!isset($post['includesig']) || $post['includesig'] != 1) 816 { 817 $post['includesig'] = 0; 818 } 819 820 // Fetch attachments assigned to this post 821 if($mybb->get_input('pid', MyBB::INPUT_INT)) 822 { 823 $attachwhere = "pid='".$mybb->get_input('pid', MyBB::INPUT_INT)."'"; 824 } 825 else 826 { 827 $attachwhere = "posthash='".$db->escape_string($mybb->get_input('posthash'))."'"; 828 } 829 830 $query = $db->simple_select("attachments", "*", $attachwhere); 831 while($attachment = $db->fetch_array($query)) 832 { 833 $attachcache[0][$attachment['aid']] = $attachment; 834 } 835 836 $postbit = build_postbit($post, 1); 837 eval("\$preview = \"".$templates->get("previewpost")."\";"); 838 } 839 $message = htmlspecialchars_uni($mybb->get_input('message')); 840 $subject = htmlspecialchars_uni($mybb->get_input('subject')); 841 } 842 843 // Removing an attachment or adding a new one, or showing thread errors. 844 else if($mybb->get_input('attachmentaid', MyBB::INPUT_INT) || $mybb->get_input('newattachment') || $mybb->get_input('updateattachment') || $thread_errors) 845 { 846 $message = htmlspecialchars_uni($mybb->get_input('message')); 847 $subject = htmlspecialchars_uni($mybb->get_input('subject')); 848 } 849 850 // Generate thread prefix selector 851 if(!$mybb->get_input('threadprefix', MyBB::INPUT_INT)) 852 { 853 $mybb->input['threadprefix'] = 0; 854 } 855 856 $prefixselect = build_prefix_select($forum['fid'], $mybb->get_input('threadprefix', MyBB::INPUT_INT)); 857 858 $posthash = htmlspecialchars_uni($mybb->get_input('posthash')); 859 860 // Hide signature option if no permission 861 $signature = ''; 862 if($mybb->usergroup['canusesig'] == 1 && !$mybb->user['suspendsignature']) 863 { 864 eval("\$signature = \"".$templates->get('newthread_signature')."\";"); 865 } 866 867 // Can we disable smilies or are they disabled already? 868 $disablesmilies = ''; 869 if($forum['allowsmilies'] != 0) 870 { 871 eval("\$disablesmilies = \"".$templates->get("newthread_disablesmilies")."\";"); 872 } 873 874 $postoptions = ''; 875 if(!empty($signature) || !empty($disablesmilies)) 876 { 877 eval("\$postoptions = \"".$templates->get("newthread_postoptions")."\";"); 878 $bgcolor = "trow2"; 879 $bgcolor2 = "trow1"; 880 } 881 else 882 { 883 $bgcolor = "trow1"; 884 $bgcolor2 = "trow2"; 885 } 886 887 $modoptions = ''; 888 // Show the moderator options 889 if(is_moderator($fid)) 890 { 891 $modoptions = $mybb->get_input('modoptions', MyBB::INPUT_ARRAY); 892 if(isset($modoptions['closethread']) && $modoptions['closethread'] == 1) 893 { 894 $closecheck = "checked=\"checked\""; 895 } 896 else 897 { 898 $closecheck = ''; 899 } 900 if(isset($modoptions['stickthread']) && $modoptions['stickthread'] == 1) 901 { 902 $stickycheck = "checked=\"checked\""; 903 } 904 else 905 { 906 $stickycheck = ''; 907 } 908 909 $closeoption = ''; 910 if(is_moderator($fid, "canopenclosethreads")) 911 { 912 eval("\$closeoption = \"".$templates->get("newreply_modoptions_close")."\";"); 913 } 914 915 $stickoption = ''; 916 if(is_moderator($fid, "canstickunstickthreads")) 917 { 918 eval("\$stickoption = \"".$templates->get("newreply_modoptions_stick")."\";"); 919 } 920 921 if(!empty($closeoption) || !empty($stickoption)) 922 { 923 eval("\$modoptions = \"".$templates->get("newreply_modoptions")."\";"); 924 $bgcolor = "trow1"; 925 $bgcolor2 = "trow2"; 926 } 927 else 928 { 929 $bgcolor = "trow2"; 930 $bgcolor2 = "trow1"; 931 } 932 } 933 else 934 { 935 $bgcolor = "trow2"; 936 $bgcolor2 = "trow1"; 937 } 938 939 // Fetch subscription select box 940 eval("\$subscriptionmethod = \"".$templates->get("post_subscription_method")."\";"); 941 942 if($mybb->settings['enableattachments'] != 0 && $forumpermissions['canpostattachments'] != 0) 943 { // Get a listing of the current attachments, if there are any 944 $attachcount = 0; 945 if($mybb->input['action'] == "editdraft" || ($mybb->input['tid'] && $mybb->input['pid'])) 946 { 947 $attachwhere = "pid='$pid'"; 948 } 949 else 950 { 951 $attachwhere = "posthash='".$db->escape_string($posthash)."'"; 952 } 953 $query = $db->simple_select("attachments", "*", $attachwhere); 954 $attachments = ''; 955 while($attachment = $db->fetch_array($query)) 956 { 957 $attachment['size'] = get_friendly_size($attachment['filesize']); 958 $attachment['icon'] = get_attachment_icon(get_extension($attachment['filename'])); 959 $attachment['filename'] = htmlspecialchars_uni($attachment['filename']); 960 961 if($mybb->settings['bbcodeinserter'] != 0 && $forum['allowmycode'] != 0 && (!$mybb->user['uid'] || $mybb->user['showcodebuttons'] != 0)) 962 { 963 eval("\$postinsert = \"".$templates->get("post_attachments_attachment_postinsert")."\";"); 964 } 965 966 eval("\$attach_rem_options = \"".$templates->get("post_attachments_attachment_remove")."\";"); 967 968 $attach_mod_options = ''; 969 if($attachment['visible'] != 1) 970 { 971 eval("\$attachments .= \"".$templates->get("post_attachments_attachment_unapproved")."\";"); 972 } 973 else 974 { 975 eval("\$attachments .= \"".$templates->get("post_attachments_attachment")."\";"); 976 } 977 $attachcount++; 978 } 979 $query = $db->simple_select("attachments", "SUM(filesize) AS ausage", "uid='".$mybb->user['uid']."'"); 980 $usage = $db->fetch_array($query); 981 if($usage['ausage'] > ($mybb->usergroup['attachquota']*1024) && $mybb->usergroup['attachquota'] != 0) 982 { 983 $noshowattach = 1; 984 } 985 if($mybb->usergroup['attachquota'] == 0) 986 { 987 $friendlyquota = $lang->unlimited; 988 } 989 else 990 { 991 $friendlyquota = get_friendly_size($mybb->usergroup['attachquota']*1024); 992 } 993 $lang->attach_quota = $lang->sprintf($lang->attach_quota, $friendlyquota); 994 995 $link_viewattachments = ''; 996 if($usage['ausage'] !== NULL) 997 { 998 $friendlyusage = get_friendly_size($usage['ausage']); 999 $lang->attach_usage = $lang->sprintf($lang->attach_usage, $friendlyusage); 1000 eval("\$link_viewattachments = \"".$templates->get("post_attachments_viewlink")."\";"); 1001 } 1002 else 1003 { 1004 $lang->attach_usage = ""; 1005 } 1006 1007 $attach_add_options = ''; 1008 if($mybb->settings['maxattachments'] == 0 || ($mybb->settings['maxattachments'] != 0 && $attachcount < $mybb->settings['maxattachments']) && !isset($noshowattach)) 1009 { 1010 eval("\$attach_add_options = \"".$templates->get("post_attachments_add")."\";"); 1011 } 1012 1013 $attach_update_options = ''; 1014 if(($mybb->usergroup['caneditattachments'] || $forumpermissions['caneditattachments']) && $attachcount > 0) 1015 { 1016 eval("\$attach_update_options = \"".$templates->get("post_attachments_update")."\";"); 1017 } 1018 1019 if($attach_add_options || $attach_update_options) 1020 { 1021 eval("\$newattach = \"".$templates->get("post_attachments_new")."\";"); 1022 } 1023 eval("\$attachbox = \"".$templates->get("post_attachments")."\";"); 1024 1025 $bgcolor = alt_trow(); 1026 } 1027 else 1028 { 1029 $attachbox = ''; 1030 } 1031 1032 $savedraftbutton = ''; 1033 if($mybb->user['uid']) 1034 { 1035 eval("\$savedraftbutton = \"".$templates->get("post_savedraftbutton", 1, 0)."\";"); 1036 } 1037 1038 $captcha = ''; 1039 1040 // Show captcha image for guests if enabled 1041 if($mybb->settings['captchaimage'] && !$mybb->user['uid']) 1042 { 1043 $correct = false; 1044 require_once MYBB_ROOT.'inc/class_captcha.php'; 1045 $post_captcha = new captcha(false, "post_captcha"); 1046 1047 if((!empty($mybb->input['previewpost']) || $hide_captcha == true) && $post_captcha->type == 1) 1048 { 1049 // If previewing a post - check their current captcha input - if correct, hide the captcha input area 1050 // ... but only if it's a default one, reCAPTCHA and Are You a Human must be filled in every time due to draconian limits 1051 if($post_captcha->validate_captcha() == true) 1052 { 1053 $correct = true; 1054 1055 // Generate a hidden list of items for our captcha 1056 $captcha = $post_captcha->build_hidden_captcha(); 1057 } 1058 } 1059 1060 if(!$correct) 1061 { 1062 if($post_captcha->type == captcha::DEFAULT_CAPTCHA) 1063 { 1064 $post_captcha->build_captcha(); 1065 } 1066 elseif(in_array($post_captcha->type, array(captcha::NOCAPTCHA_RECAPTCHA, captcha::RECAPTCHA_INVISIBLE, captcha::RECAPTCHA_V3))) 1067 { 1068 $post_captcha->build_recaptcha(); 1069 } 1070 elseif(in_array($post_captcha->type, array(captcha::HCAPTCHA, captcha::HCAPTCHA_INVISIBLE))) 1071 { 1072 $post_captcha->build_hcaptcha(); 1073 } 1074 elseif($post_captcha->type == captcha::CFTURNSTILE) 1075 { 1076 $post_captcha->build_cfturnstile(); 1077 } 1078 } 1079 else if($correct && (in_array($post_captcha->type, array(captcha::NOCAPTCHA_RECAPTCHA, captcha::RECAPTCHA_INVISIBLE, captcha::RECAPTCHA_V3)))) 1080 { 1081 $post_captcha->build_recaptcha(); 1082 } 1083 else if($correct && (in_array($post_captcha->type, array(captcha::HCAPTCHA, captcha::HCAPTCHA_INVISIBLE)))) 1084 { 1085 $post_captcha->build_hcaptcha(); 1086 } 1087 else if($correct && ($post_captcha->type == captcha::CFTURNSTILE)) 1088 { 1089 $post_captcha->build_cfturnstile(); 1090 } 1091 1092 if($post_captcha->html) 1093 { 1094 $captcha = $post_captcha->html; 1095 } 1096 } 1097 1098 $pollbox = ''; 1099 1100 if($forumpermissions['canpostpolls'] != 0) 1101 { 1102 $lang->max_options = $lang->sprintf($lang->max_options, $mybb->settings['maxpolloptions']); 1103 eval("\$pollbox = \"".$templates->get("newthread_postpoll")."\";"); 1104 } 1105 1106 // Do we have any forum rules to show for this forum? 1107 $forumrules = ''; 1108 if($forum['rulestype'] >= 2 && $forum['rules']) 1109 { 1110 if(!$forum['rulestitle']) 1111 { 1112 $forum['rulestitle'] = $lang->sprintf($lang->forum_rules, $forum['name']); 1113 } 1114 1115 if(empty($parser)) 1116 { 1117 require_once MYBB_ROOT.'inc/class_parser.php'; 1118 $parser = new postParser; 1119 } 1120 1121 $rules_parser = array( 1122 "allow_html" => 1, 1123 "allow_mycode" => 1, 1124 "allow_smilies" => 1, 1125 "allow_imgcode" => 1 1126 ); 1127 1128 $forum['rules'] = $parser->parse_message($forum['rules'], $rules_parser); 1129 $foruminfo = $forum; 1130 1131 if($forum['rulestype'] == 3) 1132 { 1133 eval("\$forumrules = \"".$templates->get("forumdisplay_rules")."\";"); 1134 } 1135 else if($forum['rulestype'] == 2) 1136 { 1137 eval("\$forumrules = \"".$templates->get("forumdisplay_rules_link")."\";"); 1138 } 1139 } 1140 1141 $moderation_notice = ''; 1142 if(!is_moderator($forum['fid'], "canapproveunapproveattachs")) 1143 { 1144 if($forumpermissions['modattachments'] == 1 && $forumpermissions['canpostattachments'] != 0) 1145 { 1146 $moderation_text = $lang->moderation_forum_attachments; 1147 eval('$moderation_notice = "'.$templates->get('global_moderation_notice').'";'); 1148 } 1149 } 1150 1151 if(!is_moderator($forum['fid'], "canapproveunapprovethreads")) 1152 { 1153 if($forumpermissions['modthreads'] == 1) 1154 { 1155 $moderation_text = $lang->moderation_forum_thread; 1156 eval('$moderation_notice = "'.$templates->get('global_moderation_notice').'";'); 1157 } 1158 } 1159 1160 if(!is_moderator($forum['fid'], "canapproveunapproveposts")) 1161 { 1162 if($mybb->user['moderateposts'] == 1) 1163 { 1164 $moderation_text = $lang->moderation_user_posts; 1165 eval('$moderation_notice = "'.$templates->get('global_moderation_notice').'";'); 1166 } 1167 } 1168 1169 $php_max_upload_size = get_php_upload_limit(); 1170 $php_max_file_uploads = (int)ini_get('max_file_uploads'); 1171 eval("\$post_javascript = \"".$templates->get("post_javascript")."\";"); 1172 1173 $plugins->run_hooks("newthread_end"); 1174 1175 $forum['name'] = strip_tags($forum['name']); 1176 $lang->newthread_in = $lang->sprintf($lang->newthread_in, $forum['name']); 1177 1178 eval("\$newthread = \"".$templates->get("newthread")."\";"); 1179 output_page($newthread); 1180 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| 2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |