| [ 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', 'editpost.php'); 13 14 $templatelist = "editpost,previewpost,changeuserbox,codebuttons,post_attachments_attachment_postinsert,post_attachments_attachment_mod_unapprove,postbit_attachments_thumbnails,postbit_profilefield_multiselect_value"; 15 $templatelist .= ",editpost_delete,forumdisplay_password_wrongpass,forumdisplay_password,editpost_reason,post_attachments_attachment_remove,post_attachments_update,post_subscription_method,postbit_profilefield_multiselect"; 16 $templatelist .= ",postbit_avatar,postbit_find,postbit_pm,postbit_rep_button,postbit_www,postbit_email,postbit_reputation,postbit_warn,postbit_warninglevel,postbit_author_user,posticons"; 17 $templatelist .= ",postbit_signature,postbit_classic,postbit,postbit_attachments_thumbnails_thumbnail,postbit_attachments_images_image,postbit_attachments_attachment,postbit_attachments_attachment_unapproved"; 18 $templatelist .= ",posticons_icon,post_prefixselect_prefix,post_prefixselect_single,newthread_postpoll,editpost_disablesmilies,post_attachments_attachment_mod_approve,post_attachments_attachment_unapproved"; 19 $templatelist .= ",postbit_warninglevel_formatted,postbit_reputation_formatted_link,editpost_signature,attachment_icon,post_attachments_attachment,post_attachments_add,post_attachments,editpost_postoptions,post_attachments_viewlink"; 20 $templatelist .= ",postbit_attachments_images,global_moderation_notice,post_attachments_new,postbit_attachments,postbit_online,postbit_away,postbit_offline,postbit_gotopost,postbit_userstar,postbit_icon"; 21 22 require_once "./global.php"; 23 require_once MYBB_ROOT."inc/functions_post.php"; 24 require_once MYBB_ROOT."inc/functions_upload.php"; 25 require_once MYBB_ROOT."inc/class_parser.php"; 26 $parser = new postParser; 27 28 // Load global language phrases 29 $lang->load("editpost"); 30 31 $plugins->run_hooks("editpost_start"); 32 33 // No permission for guests 34 if(!$mybb->user['uid']) 35 { 36 error_no_permission(); 37 } 38 39 // Get post info 40 $pid = $mybb->get_input('pid', MyBB::INPUT_INT); 41 42 // if we already have the post information... 43 if(isset($style) && $style['pid'] == $pid && $style['type'] != 'f') 44 { 45 $post = &$style; 46 } 47 else 48 { 49 $post = get_post($pid); 50 } 51 52 if(!$post || ($post['visible'] == -1 && $mybb->input['action'] != "restorepost")) 53 { 54 error($lang->error_invalidpost); 55 } 56 57 // Get thread info 58 $tid = $post['tid']; 59 $thread = get_thread($tid); 60 61 if(!$thread) 62 { 63 error($lang->error_invalidthread); 64 } 65 66 $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject'])); 67 68 // Get forum info 69 $fid = $post['fid']; 70 $forum = get_forum($fid); 71 72 if($thread['visible'] == 0 && !is_moderator($fid, "canviewunapprove") || $thread['visible'] == -1 && !is_moderator($fid, "canviewdeleted") || ($thread['visible'] < -1 && $thread['uid'] != $mybb->user['uid'])) 73 { 74 if($thread['visible'] == 0 && !($mybb->settings['showownunapproved'] && $thread['uid'] == $mybb->user['uid'])) 75 { 76 error($lang->error_invalidthread); 77 } 78 } 79 if(!$forum || $forum['type'] != "f") 80 { 81 error($lang->error_closedinvalidforum); 82 } 83 if(($forum['open'] == 0 && !is_moderator($fid, "caneditposts")) || $mybb->user['suspendposting'] == 1) 84 { 85 error_no_permission(); 86 } 87 88 // Add prefix to breadcrumb 89 $breadcrumbprefix = ''; 90 if($thread['prefix']) 91 { 92 $threadprefixes = build_prefixes(); 93 if(!empty($threadprefixes[$thread['prefix']])) 94 { 95 $breadcrumbprefix = $threadprefixes[$thread['prefix']]['displaystyle'].' '; 96 } 97 } 98 99 // Make navigation 100 build_forum_breadcrumb($fid); 101 add_breadcrumb($breadcrumbprefix.$thread['subject'], get_thread_link($thread['tid'])); 102 add_breadcrumb($lang->nav_editpost); 103 104 $forumpermissions = forum_permissions($fid); 105 106 if($mybb->settings['bbcodeinserter'] != 0 && $forum['allowmycode'] != 0 && $mybb->user['showcodebuttons'] != 0) 107 { 108 $codebuttons = build_mycode_inserter("message", $mybb->settings['smilieinserter']); 109 } 110 if($mybb->settings['smilieinserter'] != 0) 111 { 112 $smilieinserter = build_clickable_smilies(); 113 } 114 115 $mybb->input['action'] = $mybb->get_input('action'); 116 if(!$mybb->input['action'] || isset($mybb->input['previewpost'])) 117 { 118 $mybb->input['action'] = "editpost"; 119 } 120 121 if($mybb->input['action'] == "deletepost" && $mybb->request_method == "post") 122 { 123 if(!is_moderator($fid, "candeleteposts") && !is_moderator($fid, "cansoftdeleteposts") && $pid != $thread['firstpost'] || !is_moderator($fid, "candeletethreads") && !is_moderator($fid, "cansoftdeletethreads") && $pid == $thread['firstpost']) 124 { 125 if($thread['closed'] == 1) 126 { 127 error($lang->redirect_threadclosed); 128 } 129 if($forumpermissions['candeleteposts'] == 0 && $pid != $thread['firstpost'] || $forumpermissions['candeletethreads'] == 0 && $pid == $thread['firstpost']) 130 { 131 error_no_permission(); 132 } 133 if($mybb->user['uid'] != $post['uid']) 134 { 135 error_no_permission(); 136 } 137 // User can't delete unapproved post unless allowed for own 138 if($post['visible'] == 0 && !($mybb->settings['showownunapproved'] && $post['uid'] == $mybb->user['uid'])) 139 { 140 error_no_permission(); 141 } 142 } 143 if($post['visible'] == -1 && $mybb->settings['soft_delete'] == 1) 144 { 145 error($lang->error_already_deleted); 146 } 147 } 148 elseif($mybb->input['action'] == "restorepost" && $mybb->request_method == "post") 149 { 150 if(!is_moderator($fid, "canrestoreposts") && $pid != $thread['firstpost'] || !is_moderator($fid, "canrestorethreads") && $pid == $thread['firstpost'] || $post['visible'] != -1) 151 { 152 error_no_permission(); 153 } 154 } 155 else 156 { 157 if(!is_moderator($fid, "caneditposts")) 158 { 159 if($thread['closed'] == 1) 160 { 161 error($lang->redirect_threadclosed); 162 } 163 if($forumpermissions['caneditposts'] == 0) 164 { 165 error_no_permission(); 166 } 167 if($mybb->user['uid'] != $post['uid']) 168 { 169 error_no_permission(); 170 } 171 // Edit time limit 172 $time = TIME_NOW; 173 if($mybb->usergroup['edittimelimit'] != 0 && $post['dateline'] < ($time-($mybb->usergroup['edittimelimit']*60))) 174 { 175 $lang->edit_time_limit = $lang->sprintf($lang->edit_time_limit, $mybb->usergroup['edittimelimit']); 176 error($lang->edit_time_limit); 177 } 178 // User can't edit unapproved post 179 if(($post['visible'] == 0 && !($mybb->settings['showownunapproved'] && $post['uid'] == $mybb->user['uid'])) || $post['visible'] == -1) 180 { 181 error_no_permission(); 182 } 183 } 184 } 185 186 // Check if this forum is password protected and we have a valid password 187 check_forum_password($forum['fid']); 188 189 if((empty($_POST) && empty($_FILES)) && $mybb->get_input('processed', MyBB::INPUT_INT) == '1') 190 { 191 error($lang->error_empty_post_input); 192 } 193 194 $attacherror = ''; 195 if($mybb->settings['enableattachments'] == 1 && ($mybb->get_input('newattachment') || $mybb->get_input('updateattachment') || ((($mybb->input['action'] == "do_editpost" && isset($mybb->input['submitbutton'])) || ($mybb->input['action'] == "editpost" && isset($mybb->input['previewpost']))) && isset($_FILES['attachments'])))) 196 { 197 // Verify incoming POST request 198 verify_post_check($mybb->get_input('my_post_key')); 199 200 if($pid) 201 { 202 $attachwhere = "pid='{$pid}'"; 203 } 204 else 205 { 206 $attachwhere = "posthash='".$db->escape_string($mybb->get_input('posthash'))."'"; 207 } 208 209 $ret = add_attachments($pid, $forumpermissions, $attachwhere, "editpost"); 210 211 if($mybb->get_input('ajax', MyBB::INPUT_INT) == 1) 212 { 213 if(isset($ret['success'])) 214 { 215 $attachment = array('aid'=>'{1}', 'icon'=>'{2}', 'filename'=>'{3}', 'size'=>'{4}'); 216 if($mybb->settings['bbcodeinserter'] != 0 && $forum['allowmycode'] != 0 && $mybb->user['showcodebuttons'] != 0) 217 { 218 eval("\$postinsert = \"".$templates->get("post_attachments_attachment_postinsert")."\";"); 219 } 220 // Moderating options 221 $attach_mod_options = ''; 222 if(is_moderator($fid)) 223 { 224 eval("\$attach_mod_options = \"".$templates->get("post_attachments_attachment_mod_unapprove")."\";"); 225 } 226 eval("\$attach_rem_options = \"".$templates->get("post_attachments_attachment_remove")."\";"); 227 eval("\$attemplate = \"".$templates->get("post_attachments_attachment")."\";"); 228 $ret['template'] = $attemplate; 229 230 $query = $db->simple_select("attachments", "SUM(filesize) AS ausage", "uid='".$mybb->user['uid']."'"); 231 $usage = $db->fetch_array($query); 232 $ret['usage'] = get_friendly_size($usage['ausage']); 233 } 234 235 header("Content-type: application/json; charset={$lang->settings['charset']}"); 236 echo json_encode($ret); 237 exit(); 238 } 239 240 if(!empty($ret['errors'])) 241 { 242 $errors = $ret['errors']; 243 } 244 245 // Do we have attachment errors? 246 if(!empty($errors)) 247 { 248 $attacherror = inline_error($errors); 249 } 250 251 // If we were dealing with an attachment but didn't click 'Update Post', force the post edit page again. 252 if(!isset($mybb->input['submitbutton'])) 253 { 254 $mybb->input['action'] = "editpost"; 255 } 256 } 257 258 detect_attachmentact(); 259 260 if($mybb->settings['enableattachments'] == 1 && $mybb->get_input('attachmentaid', MyBB::INPUT_INT) && isset($mybb->input['attachmentact']) && $mybb->input['action'] == "do_editpost" && $mybb->request_method == "post") // Lets remove/approve/unapprove the attachment 261 { 262 // Verify incoming POST request 263 verify_post_check($mybb->get_input('my_post_key')); 264 265 $mybb->input['attachmentaid'] = $mybb->get_input('attachmentaid', MyBB::INPUT_INT); 266 267 if($mybb->get_input('attachmentact') == "approve" || $mybb->get_input('attachmentact') == "unapprove") 268 { 269 $query = $db->simple_select("attachments", "aid", "aid='{$mybb->input['attachmentaid']}' AND pid='{$pid}'"); 270 $attachment = $db->fetch_array($query); 271 if(!$attachment) 272 { 273 error($lang->error_invalidattachment); 274 } 275 } 276 277 if($mybb->input['attachmentact'] == "remove") 278 { 279 remove_attachment($pid, "", $mybb->input['attachmentaid']); 280 } 281 elseif($mybb->get_input('attachmentact') == "approve" && is_moderator($fid, 'canapproveunapproveattachs')) 282 { 283 $update_sql = array("visible" => 1); 284 $db->update_query("attachments", $update_sql, "aid='{$mybb->input['attachmentaid']}' AND pid='{$pid}'"); 285 update_thread_counters($post['tid'], array('attachmentcount' => "+1")); 286 } 287 elseif($mybb->get_input('attachmentact') == "unapprove" && is_moderator($fid, 'canapproveunapproveattachs')) 288 { 289 $update_sql = array("visible" => 0); 290 $db->update_query("attachments", $update_sql, "aid='{$mybb->input['attachmentaid']}' AND pid='{$pid}'"); 291 update_thread_counters($post['tid'], array('attachmentcount' => "-1")); 292 } 293 294 if($mybb->get_input('ajax', MyBB::INPUT_INT) == 1) 295 { 296 $query = $db->simple_select("attachments", "SUM(filesize) AS ausage", "uid='".$mybb->user['uid']."'"); 297 $usage = $db->fetch_array($query); 298 299 header("Content-type: application/json; charset={$lang->settings['charset']}"); 300 echo json_encode(array("success" => true, "usage" => get_friendly_size($usage['ausage']))); 301 exit(); 302 } 303 304 if(!isset($mybb->input['submitbutton'])) 305 { 306 $mybb->input['action'] = "editpost"; 307 } 308 } 309 310 if($mybb->input['action'] == "deletepost" && $mybb->request_method == "post") 311 { 312 // Verify incoming POST request 313 verify_post_check($mybb->get_input('my_post_key')); 314 315 $plugins->run_hooks("editpost_deletepost"); 316 317 if($mybb->get_input('delete', MyBB::INPUT_INT) == 1) 318 { 319 $query = $db->simple_select("posts", "pid", "tid='{$tid}'", array("limit" => 1, "order_by" => "dateline, pid")); 320 $firstcheck = $db->fetch_array($query); 321 if($firstcheck['pid'] == $pid) 322 { 323 $firstpost = 1; 324 } 325 else 326 { 327 $firstpost = 0; 328 } 329 330 $modlogdata['fid'] = $fid; 331 $modlogdata['tid'] = $tid; 332 if($firstpost) 333 { 334 if($forumpermissions['candeletethreads'] == 1 || is_moderator($fid, "candeletethreads") || is_moderator($fid, "cansoftdeletethreads")) 335 { 336 require_once MYBB_ROOT."inc/class_moderation.php"; 337 $moderation = new Moderation; 338 339 if($mybb->settings['soft_delete'] == 1 || is_moderator($fid, "cansoftdeletethreads")) 340 { 341 $modlogdata['pid'] = $pid; 342 343 $moderation->soft_delete_threads(array($tid)); 344 log_moderator_action($modlogdata, $lang->thread_soft_deleted); 345 } 346 else 347 { 348 $moderation->delete_thread($tid); 349 mark_reports($tid, "thread"); 350 log_moderator_action($modlogdata, $lang->thread_deleted); 351 } 352 353 if(!empty($mybb->input['ajax'])) 354 { 355 header("Content-type: application/json; charset={$lang->settings['charset']}"); 356 if(is_moderator($fid, "canviewdeleted")) 357 { 358 echo json_encode(array("data" => '1', "first" => '1')); 359 } 360 else 361 { 362 echo json_encode(array("data" => '3', "url" => get_forum_link($fid))); 363 } 364 } 365 else 366 { 367 redirect(get_forum_link($fid), $lang->redirect_threaddeleted); 368 } 369 } 370 else 371 { 372 error_no_permission(); 373 } 374 } 375 else 376 { 377 if($forumpermissions['candeleteposts'] == 1 || is_moderator($fid, "candeleteposts") || is_moderator($fid, "cansoftdeleteposts")) 378 { 379 // Select the first post before this 380 require_once MYBB_ROOT."inc/class_moderation.php"; 381 $moderation = new Moderation; 382 383 if($mybb->settings['soft_delete'] == 1 || is_moderator($fid, "cansoftdeleteposts")) 384 { 385 $modlogdata['pid'] = $pid; 386 387 $moderation->soft_delete_posts(array($pid)); 388 log_moderator_action($modlogdata, $lang->post_soft_deleted); 389 } 390 else 391 { 392 $moderation->delete_post($pid); 393 mark_reports($pid, "post"); 394 log_moderator_action($modlogdata, $lang->post_deleted); 395 } 396 397 $query = $db->simple_select("posts", "pid", "tid='{$tid}' AND dateline <= '{$post['dateline']}'", array("limit" => 1, "order_by" => "dateline DESC, pid DESC")); 398 $next_post = $db->fetch_array($query); 399 if($next_post['pid']) 400 { 401 $redirect = get_post_link($next_post['pid'], $tid)."#pid{$next_post['pid']}"; 402 } 403 else 404 { 405 $redirect = get_thread_link($tid); 406 } 407 408 if($mybb->get_input('ajax', MyBB::INPUT_INT) == 1) 409 { 410 header("Content-type: application/json; charset={$lang->settings['charset']}"); 411 if(is_moderator($fid, "canviewdeleted")) 412 { 413 echo json_encode(array("data" => '1', "first" => '0')); 414 } 415 else 416 { 417 echo json_encode(array("data" => '2')); 418 } 419 } 420 else 421 { 422 redirect($redirect, $lang->redirect_postdeleted); 423 } 424 } 425 else 426 { 427 error_no_permission(); 428 } 429 } 430 } 431 else 432 { 433 error($lang->redirect_nodelete); 434 } 435 } 436 437 if($mybb->input['action'] == "restorepost" && $mybb->request_method == "post") 438 { 439 // Verify incoming POST request 440 verify_post_check($mybb->get_input('my_post_key')); 441 442 $plugins->run_hooks("editpost_restorepost"); 443 444 if($mybb->get_input('restore', MyBB::INPUT_INT) == 1) 445 { 446 $query = $db->simple_select("posts", "pid", "tid='{$tid}'", array("limit" => 1, "order_by" => "dateline, pid")); 447 $firstcheck = $db->fetch_array($query); 448 if($firstcheck['pid'] == $pid) 449 { 450 $firstpost = 1; 451 } 452 else 453 { 454 $firstpost = 0; 455 } 456 457 $modlogdata['fid'] = $fid; 458 $modlogdata['tid'] = $tid; 459 $modlogdata['pid'] = $pid; 460 if($firstpost) 461 { 462 if(is_moderator($fid, "canrestorethreads")) 463 { 464 require_once MYBB_ROOT."inc/class_moderation.php"; 465 $moderation = new Moderation; 466 $moderation->restore_threads(array($tid)); 467 log_moderator_action($modlogdata, $lang->thread_restored); 468 if($mybb->input['ajax'] == 1) 469 { 470 header("Content-type: application/json; charset={$lang->settings['charset']}"); 471 echo json_encode(array("data" => '1', "first" => '1')); 472 } 473 else 474 { 475 redirect(get_forum_link($fid), $lang->redirect_threadrestored); 476 } 477 } 478 else 479 { 480 error_no_permission(); 481 } 482 } 483 else 484 { 485 if(is_moderator($fid, "canrestoreposts")) 486 { 487 // Select the first post before this 488 require_once MYBB_ROOT."inc/class_moderation.php"; 489 $moderation = new Moderation; 490 $moderation->restore_posts(array($pid)); 491 log_moderator_action($modlogdata, $lang->post_restored); 492 $redirect = get_post_link($pid, $tid)."#pid{$pid}"; 493 494 if($mybb->input['ajax'] == 1) 495 { 496 header("Content-type: application/json; charset={$lang->settings['charset']}"); 497 echo json_encode(array("data" => '1', "first" => '0')); 498 } 499 else 500 { 501 redirect($redirect, $lang->redirect_postrestored); 502 } 503 } 504 else 505 { 506 error_no_permission(); 507 } 508 } 509 } 510 else 511 { 512 error($lang->redirect_norestore); 513 } 514 } 515 516 $postoptions = array(); 517 518 if($mybb->input['action'] == "do_editpost" && $mybb->request_method == "post") 519 { 520 // Verify incoming POST request 521 verify_post_check($mybb->get_input('my_post_key')); 522 523 $plugins->run_hooks("editpost_do_editpost_start"); 524 525 // Set up posthandler. 526 require_once MYBB_ROOT."inc/datahandlers/post.php"; 527 $posthandler = new PostDataHandler("update"); 528 $posthandler->action = "post"; 529 530 // Set the post data that came from the input to the $post array. 531 $post = array( 532 "pid" => $mybb->input['pid'], 533 "prefix" => $mybb->get_input('threadprefix', MyBB::INPUT_INT), 534 "subject" => $mybb->get_input('subject'), 535 "icon" => $mybb->get_input('icon', MyBB::INPUT_INT), 536 "uid" => $post['uid'], 537 "username" => $post['username'], 538 "edit_uid" => $mybb->user['uid'], 539 "message" => $mybb->get_input('message'), 540 "editreason" => $mybb->get_input('editreason'), 541 ); 542 543 $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY); 544 if(!isset($postoptions['signature'])) 545 { 546 $postoptions['signature'] = 0; 547 } 548 if(!isset($postoptions['subscriptionmethod'])) 549 { 550 $postoptions['subscriptionmethod'] = 0; 551 } 552 if(!isset($postoptions['disablesmilies'])) 553 { 554 $postoptions['disablesmilies'] = 0; 555 } 556 557 // Set up the post options from the input. 558 $post['options'] = array( 559 "signature" => $postoptions['signature'], 560 "subscriptionmethod" => $postoptions['subscriptionmethod'], 561 "disablesmilies" => $postoptions['disablesmilies'] 562 ); 563 564 $posthandler->set_data($post); 565 566 // Now let the post handler do all the hard work. 567 if(!$posthandler->validate_post()) 568 { 569 $post_errors = $posthandler->get_friendly_errors(); 570 $post_errors = inline_error($post_errors); 571 $mybb->input['action'] = "editpost"; 572 } 573 // No errors were found, we can call the update method. 574 else 575 { 576 $postinfo = $posthandler->update_post(); 577 $visible = $postinfo['visible']; 578 $first_post = $postinfo['first_post']; 579 580 // Help keep our attachments table clean. 581 $db->delete_query("attachments", "filename='' OR filesize<1"); 582 583 // Did the user choose to post a poll? Redirect them to the poll posting page. 584 if($mybb->get_input('postpoll', MyBB::INPUT_INT) && $forumpermissions['canpostpolls']) 585 { 586 $url = "polls.php?action=newpoll&tid=$tid&polloptions=".$mybb->get_input('numpolloptions', MyBB::INPUT_INT); 587 $lang->redirect_postedited = $lang->redirect_postedited_poll; 588 } 589 else if($visible == 0 && $first_post && !is_moderator($fid, "canviewunapprove", $mybb->user['uid'])) 590 { 591 // Moderated post 592 $lang->redirect_postedited .= $lang->redirect_thread_moderation; 593 $url = get_forum_link($fid); 594 } 595 else if($visible == 0 && !is_moderator($fid, "canviewunapprove", $mybb->user['uid'])) 596 { 597 $lang->redirect_postedited .= $lang->redirect_post_moderation; 598 $url = get_thread_link($tid); 599 } 600 // Otherwise, send them back to their post 601 else 602 { 603 $lang->redirect_postedited .= $lang->redirect_postedited_redirect; 604 $url = get_post_link($pid, $tid)."#pid{$pid}"; 605 } 606 $plugins->run_hooks("editpost_do_editpost_end"); 607 608 redirect($url, $lang->redirect_postedited); 609 } 610 } 611 612 if(!$mybb->input['action'] || $mybb->input['action'] == "editpost") 613 { 614 $plugins->run_hooks("editpost_action_start"); 615 616 $preview = ''; 617 $posticons = ''; 618 619 $posticons = ''; 620 621 if($mybb->settings['allowposticons'] == 1 && $forum['allowpicons'] != 0) 622 { 623 $posticons = get_post_icons(); 624 } 625 626 $mybb->user['username'] = htmlspecialchars_uni($mybb->user['username']); 627 eval("\$loginbox = \"".$templates->get("changeuserbox")."\";"); 628 629 $deletebox = ''; 630 631 if(isset($post['visible']) && $post['visible'] != -1 && (($thread['firstpost'] == $pid && (is_moderator($fid, "candeletethreads") || $forumpermissions['candeletethreads'] == 1 && $mybb->user['uid'] == $post['uid'])) || ($thread['firstpost'] != $pid && (is_moderator($fid, "candeleteposts") || $forumpermissions['candeleteposts'] == 1 && $mybb->user['uid'] == $post['uid'])))) 632 { 633 eval("\$deletebox = \"".$templates->get("editpost_delete")."\";"); 634 } 635 636 $bgcolor = "trow1"; 637 if($mybb->settings['enableattachments'] != 0 && $forumpermissions['canpostattachments'] != 0) 638 { // Get a listing of the current attachments, if there are any 639 $attachcount = 0; 640 $query = $db->simple_select("attachments", "*", "pid='{$pid}'"); 641 $attachments = ''; 642 while($attachment = $db->fetch_array($query)) 643 { 644 $attachment['size'] = get_friendly_size($attachment['filesize']); 645 $attachment['icon'] = get_attachment_icon(get_extension($attachment['filename'])); 646 $attachment['filename'] = htmlspecialchars_uni($attachment['filename']); 647 648 if($mybb->settings['bbcodeinserter'] != 0 && $forum['allowmycode'] != 0 && $mybb->user['showcodebuttons'] != 0) 649 { 650 eval("\$postinsert = \"".$templates->get("post_attachments_attachment_postinsert")."\";"); 651 } 652 // Moderating options 653 $attach_mod_options = ''; 654 if(is_moderator($fid)) 655 { 656 if($attachment['visible'] == 1) 657 { 658 eval("\$attach_mod_options = \"".$templates->get("post_attachments_attachment_mod_unapprove")."\";"); 659 } 660 else 661 { 662 eval("\$attach_mod_options = \"".$templates->get("post_attachments_attachment_mod_approve")."\";"); 663 } 664 } 665 666 // Remove Attachment 667 eval("\$attach_rem_options = \"".$templates->get("post_attachments_attachment_remove")."\";"); 668 669 if($attachment['visible'] != 1) 670 { 671 eval("\$attachments .= \"".$templates->get("post_attachments_attachment_unapproved")."\";"); 672 } 673 else 674 { 675 eval("\$attachments .= \"".$templates->get("post_attachments_attachment")."\";"); 676 } 677 $attachcount++; 678 } 679 $query = $db->simple_select("attachments", "SUM(filesize) AS ausage", "uid='".$mybb->user['uid']."'"); 680 $usage = $db->fetch_array($query); 681 if($usage['ausage'] > ($mybb->usergroup['attachquota']*1024) && $mybb->usergroup['attachquota'] != 0) 682 { 683 $noshowattach = 1; 684 } 685 else 686 { 687 $noshowattach = 0; 688 } 689 if($mybb->usergroup['attachquota'] == 0) 690 { 691 $friendlyquota = $lang->unlimited; 692 } 693 else 694 { 695 $friendlyquota = get_friendly_size($mybb->usergroup['attachquota']*1024); 696 } 697 698 $lang->attach_quota = $lang->sprintf($lang->attach_quota, $friendlyquota); 699 700 $link_viewattachments = ''; 701 702 if($usage['ausage'] !== NULL) 703 { 704 $friendlyusage = get_friendly_size($usage['ausage']); 705 $lang->attach_usage = $lang->sprintf($lang->attach_usage, $friendlyusage); 706 eval("\$link_viewattachments = \"".$templates->get("post_attachments_viewlink")."\";"); 707 } 708 else 709 { 710 $lang->attach_usage = ""; 711 } 712 713 $attach_add_options = ''; 714 if($mybb->settings['maxattachments'] == 0 || ($mybb->settings['maxattachments'] != 0 && $attachcount < $mybb->settings['maxattachments']) && !$noshowattach) 715 { 716 eval("\$attach_add_options = \"".$templates->get("post_attachments_add")."\";"); 717 } 718 719 $attach_update_options = ''; 720 if(($mybb->usergroup['caneditattachments'] || $forumpermissions['caneditattachments']) && $attachcount > 0) 721 { 722 eval("\$attach_update_options = \"".$templates->get("post_attachments_update")."\";"); 723 } 724 725 if($attach_add_options || $attach_update_options) 726 { 727 eval("\$newattach = \"".$templates->get("post_attachments_new")."\";"); 728 } 729 eval("\$attachbox = \"".$templates->get("post_attachments")."\";"); 730 } 731 else 732 { 733 $attachbox = ''; 734 } 735 if(!$mybb->get_input('attachmentaid', MyBB::INPUT_INT) && !$mybb->get_input('newattachment') && !$mybb->get_input('updateattachment') && !isset($mybb->input['previewpost'])) 736 { 737 $message = $post['message']; 738 $subject = $post['subject']; 739 $reason = htmlspecialchars_uni($post['editreason']); 740 } 741 else 742 { 743 $message = $mybb->get_input('message'); 744 $subject = $mybb->get_input('subject'); 745 $reason = htmlspecialchars_uni($mybb->get_input('editreason')); 746 } 747 748 $previewmessage = $message; 749 $previewsubject = $subject; 750 $message = htmlspecialchars_uni($message); 751 $subject = htmlspecialchars_uni($subject); 752 753 if(!isset($post_errors)) 754 { 755 $post_errors = ''; 756 } 757 758 $subscribe = $nonesubscribe = $emailsubscribe = $pmsubscribe = ''; 759 $postoptionschecked = array('signature' => '', 'disablesmilies' => ''); 760 761 if(!empty($mybb->input['previewpost']) || $post_errors) 762 { 763 // Set up posthandler. 764 require_once MYBB_ROOT."inc/datahandlers/post.php"; 765 $posthandler = new PostDataHandler("update"); 766 $posthandler->action = "post"; 767 768 // Set the post data that came from the input to the $post array. 769 $post = array( 770 "pid" => $mybb->input['pid'], 771 "prefix" => $mybb->get_input('threadprefix', MyBB::INPUT_INT), 772 "subject" => $mybb->get_input('subject'), 773 "icon" => $mybb->get_input('icon', MyBB::INPUT_INT), 774 "uid" => $post['uid'], 775 "username" => $post['username'], 776 "edit_uid" => $mybb->user['uid'], 777 "message" => $mybb->get_input('message'), 778 ); 779 780 $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY); 781 if(!isset($postoptions['signature'])) 782 { 783 $postoptions['signature'] = 0; 784 } 785 if(!isset($postoptions['emailnotify'])) 786 { 787 $postoptions['emailnotify'] = 0; 788 } 789 if(!isset($postoptions['disablesmilies'])) 790 { 791 $postoptions['disablesmilies'] = 0; 792 } 793 794 // Set up the post options from the input. 795 $post['options'] = array( 796 "signature" => $postoptions['signature'], 797 "emailnotify" => $postoptions['emailnotify'], 798 "disablesmilies" => $postoptions['disablesmilies'] 799 ); 800 801 $posthandler->set_data($post); 802 803 // Now let the post handler do all the hard work. 804 if(!$posthandler->validate_post()) 805 { 806 $post_errors = $posthandler->get_friendly_errors(); 807 $post_errors = inline_error($post_errors); 808 $mybb->input['action'] = "editpost"; 809 $mybb->input['previewpost'] = 0; 810 } 811 else 812 { 813 814 $postoptions = $mybb->get_input('postoptions', MyBB::INPUT_ARRAY); 815 816 if(isset($postoptions['signature']) && $postoptions['signature'] == 1) 817 { 818 $postoptionschecked['signature'] = " checked=\"checked\""; 819 } 820 821 if(isset($postoptions['disablesmilies']) && $postoptions['disablesmilies'] == 1) 822 { 823 $postoptionschecked['disablesmilies'] = " checked=\"checked\""; 824 } 825 826 $subscription_method = get_subscription_method($tid, $postoptions); 827 ${$subscription_method.'subscribe'} = "checked=\"checked\" "; 828 } 829 } 830 831 if(!empty($mybb->input['previewpost'])) 832 { 833 if(!$post['uid']) 834 { 835 $query = $db->simple_select('posts', 'username, dateline', "pid='{$pid}'"); 836 $postinfo = $db->fetch_array($query); 837 } 838 else 839 { 840 // Figure out the poster's other information. 841 $query = $db->query(" 842 SELECT u.*, f.*, p.dateline 843 FROM ".TABLE_PREFIX."users u 844 LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid) 845 LEFT JOIN ".TABLE_PREFIX."posts p ON (p.uid=u.uid) 846 WHERE u.uid='{$post['uid']}' AND p.pid='{$pid}' 847 LIMIT 1 848 "); 849 $postinfo = $db->fetch_array($query); 850 $postinfo['userusername'] = $postinfo['username']; 851 } 852 853 $query = $db->simple_select("attachments", "*", "pid='{$pid}'"); 854 while($attachment = $db->fetch_array($query)) 855 { 856 $attachcache[0][$attachment['aid']] = $attachment; 857 } 858 859 if(!isset($postoptions['disablesmilies'])) 860 { 861 $postoptions['disablesmilies'] = 0; 862 } 863 864 // Set the values of the post info array. 865 $postinfo['message'] = $previewmessage; 866 $postinfo['subject'] = $previewsubject; 867 $postinfo['icon'] = $post['icon']; 868 $postinfo['smilieoff'] = $postoptions['disablesmilies']; 869 870 $postbit = build_postbit($postinfo, 1); 871 eval("\$preview = \"".$templates->get("previewpost")."\";"); 872 } 873 else if(!$post_errors) 874 { 875 $preview = ''; 876 877 if($post['includesig'] != 0) 878 { 879 $postoptionschecked['signature'] = " checked=\"checked\""; 880 } 881 882 if($post['smilieoff'] == 1) 883 { 884 $postoptionschecked['disablesmilies'] = " checked=\"checked\""; 885 } 886 887 $subscription_method = get_subscription_method($tid, $postoptions); 888 ${$subscription_method.'subscribe'} = "checked=\"checked\" "; 889 } 890 891 // Generate thread prefix selector if this is the first post of the thread 892 if($thread['firstpost'] == $pid) 893 { 894 if(!$mybb->get_input('threadprefix', MyBB::INPUT_INT)) 895 { 896 $mybb->input['threadprefix'] = $thread['prefix']; 897 } 898 899 $prefixselect = build_prefix_select($forum['fid'], $mybb->get_input('threadprefix', MyBB::INPUT_INT), 0, $thread['prefix']); 900 } 901 else 902 { 903 $prefixselect = ""; 904 } 905 906 $editreason = ''; 907 if($mybb->settings['alloweditreason'] == 1) 908 { 909 eval("\$editreason = \"".$templates->get("editpost_reason")."\";"); 910 $bgcolor = "trow2"; 911 $bgcolor2 = "trow1"; 912 } 913 else 914 { 915 $bgcolor = "trow1"; 916 $bgcolor2 = "trow2"; 917 } 918 919 // Fetch subscription select box 920 eval("\$subscriptionmethod = \"".$templates->get("post_subscription_method")."\";"); 921 922 $query = $db->simple_select("posts", "*", "tid='{$tid}'", array("limit" => 1, "order_by" => "dateline, pid")); 923 $firstcheck = $db->fetch_array($query); 924 925 $time = TIME_NOW; 926 if($firstcheck['pid'] == $pid && $forumpermissions['canpostpolls'] != 0 && $thread['poll'] < 1 && (is_moderator($fid, "canmanagepolls") || $thread['dateline'] > ($time-($mybb->settings['polltimelimit']*60*60)) || $mybb->settings['polltimelimit'] == 0)) 927 { 928 $lang->max_options = $lang->sprintf($lang->max_options, $mybb->settings['maxpolloptions']); 929 $numpolloptions = $mybb->get_input('numpolloptions', MyBB::INPUT_INT); 930 $postpollchecked = ''; 931 932 if($numpolloptions < 1) 933 { 934 $numpolloptions = 2; 935 } 936 937 if($mybb->get_input('postpoll', MyBB::INPUT_INT) == 1) 938 { 939 $postpollchecked = 'checked="checked"'; 940 } 941 942 eval("\$pollbox = \"".$templates->get("newthread_postpoll")."\";"); 943 } 944 else 945 { 946 $pollbox = ''; 947 } 948 949 // Hide signature option if no permission 950 $signature = ''; 951 if($mybb->usergroup['canusesig'] == 1 && !$mybb->user['suspendsignature']) 952 { 953 eval("\$signature = \"".$templates->get('editpost_signature')."\";"); 954 } 955 956 // Can we disable smilies or are they disabled already? 957 $disablesmilies = ''; 958 if($forum['allowsmilies'] != 0) 959 { 960 eval("\$disablesmilies = \"".$templates->get("editpost_disablesmilies")."\";"); 961 } 962 963 $postoptions = ''; 964 if(!empty($signature) || !empty($disablesmilies)) 965 { 966 eval("\$postoptions = \"".$templates->get("editpost_postoptions")."\";"); 967 } 968 969 $moderation_notice = ''; 970 if(!is_moderator($forum['fid'], "canapproveunapproveattachs")) 971 { 972 if($forumpermissions['modattachments'] == 1 && $forumpermissions['canpostattachments'] != 0) 973 { 974 $moderation_text = $lang->moderation_forum_attachments; 975 eval('$moderation_notice = "'.$templates->get('global_moderation_notice').'";'); 976 } 977 } 978 979 if(!is_moderator($forum['fid'], "canapproveunapproveposts")) 980 { 981 if($forumpermissions['mod_edit_posts'] == 1) 982 { 983 $moderation_text = $lang->moderation_forum_edits; 984 eval('$moderation_notice = "'.$templates->get('global_moderation_notice').'";'); 985 } 986 } 987 988 $php_max_upload_size = get_php_upload_limit(); 989 $php_max_file_uploads = (int)ini_get('max_file_uploads'); 990 eval("\$post_javascript = \"".$templates->get("post_javascript")."\";"); 991 992 $plugins->run_hooks("editpost_end"); 993 994 $forum['name'] = strip_tags($forum['name']); 995 996 eval("\$editpost = \"".$templates->get("editpost")."\";"); 997 output_page($editpost); 998 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| 2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |