[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[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 /** 12 * Build a post bit 13 * 14 * @param array $post The post data 15 * @param int $post_type The type of post bit we're building (1 = preview, 2 = pm, 3 = announcement, else = post) 16 * @return string The built post bit 17 */ 18 function build_postbit($post, $post_type=0) 19 { 20 global $db, $altbg, $theme, $mybb, $postcounter, $profile_fields; 21 global $titlescache, $page, $templates, $forumpermissions, $attachcache; 22 global $lang, $ismod, $inlinecookie, $inlinecount, $groupscache, $fid; 23 global $plugins, $parser, $cache, $ignored_users, $hascustomtitle; 24 25 $hascustomtitle = 0; 26 27 // Set default values for any fields not provided here 28 foreach(array('pid', 'aid', 'pmid', 'posturl', 'button_multiquote', 'subject_extra', 'attachments', 'button_rep', 'button_warn', 'button_purgespammer', 'button_pm', 'button_reply_pm', 'button_replyall_pm', 'button_forward_pm', 'button_delete_pm', 'replink', 'warninglevel') as $post_field) 29 { 30 if(empty($post[$post_field])) 31 { 32 $post[$post_field] = ''; 33 } 34 } 35 36 // Set up the message parser if it doesn't already exist. 37 if(!$parser) 38 { 39 require_once MYBB_ROOT."inc/class_parser.php"; 40 $parser = new postParser; 41 } 42 43 if(!function_exists("purgespammer_show")) 44 { 45 require_once MYBB_ROOT."inc/functions_user.php"; 46 } 47 48 $unapproved_shade = ''; 49 if(isset($post['visible']) && $post['visible'] == 0 && $post_type == 0) 50 { 51 $altbg = $unapproved_shade = 'unapproved_post'; 52 } 53 elseif(isset($post['visible']) && $post['visible'] == -1 && $post_type == 0) 54 { 55 $altbg = $unapproved_shade = 'unapproved_post deleted_post'; 56 } 57 elseif($altbg == 'trow1') 58 { 59 $altbg = 'trow2'; 60 } 61 else 62 { 63 $altbg = 'trow1'; 64 } 65 $post['fid'] = $fid; 66 switch($post_type) 67 { 68 case 1: // Message preview 69 global $forum; 70 $parser_options['allow_html'] = $forum['allowhtml']; 71 $parser_options['allow_mycode'] = $forum['allowmycode']; 72 $parser_options['allow_smilies'] = $forum['allowsmilies']; 73 $parser_options['allow_imgcode'] = $forum['allowimgcode']; 74 $parser_options['allow_videocode'] = $forum['allowvideocode']; 75 $parser_options['me_username'] = $post['username']; 76 $parser_options['filter_badwords'] = 1; 77 $id = 0; 78 break; 79 case 2: // Private message 80 global $message, $pmid; 81 $idtype = 'pmid'; 82 $parser_options['allow_html'] = $mybb->settings['pmsallowhtml']; 83 $parser_options['allow_mycode'] = $mybb->settings['pmsallowmycode']; 84 $parser_options['allow_smilies'] = $mybb->settings['pmsallowsmilies']; 85 $parser_options['allow_imgcode'] = $mybb->settings['pmsallowimgcode']; 86 $parser_options['allow_videocode'] = $mybb->settings['pmsallowvideocode']; 87 $parser_options['me_username'] = $post['username']; 88 $parser_options['filter_badwords'] = 1; 89 $id = $pmid; 90 break; 91 case 3: // Announcement 92 global $announcementarray, $message; 93 $parser_options['allow_html'] = $mybb->settings['announcementshtml'] && $announcementarray['allowhtml']; 94 $parser_options['allow_mycode'] = $announcementarray['allowmycode']; 95 $parser_options['allow_smilies'] = $announcementarray['allowsmilies']; 96 $parser_options['allow_imgcode'] = 1; 97 $parser_options['allow_videocode'] = 1; 98 $parser_options['me_username'] = $post['username']; 99 $parser_options['filter_badwords'] = 1; 100 $id = $announcementarray['aid']; 101 break; 102 default: // Regular post 103 global $forum, $thread, $tid; 104 $oldforum = $forum; 105 $id = (int)$post['pid']; 106 $idtype = 'pid'; 107 $parser_options['allow_html'] = $forum['allowhtml']; 108 $parser_options['allow_mycode'] = $forum['allowmycode']; 109 $parser_options['allow_smilies'] = $forum['allowsmilies']; 110 $parser_options['allow_imgcode'] = $forum['allowimgcode']; 111 $parser_options['allow_videocode'] = $forum['allowvideocode']; 112 $parser_options['filter_badwords'] = 1; 113 break; 114 } 115 116 if(!$post['username']) 117 { 118 $post['username'] = $lang->guest; // htmlspecialchars_uni'd below 119 } 120 121 if($post['userusername']) 122 { 123 $parser_options['me_username'] = $post['userusername']; 124 } 125 else 126 { 127 $parser_options['me_username'] = $post['username']; 128 } 129 130 $post['username'] = htmlspecialchars_uni($post['username']); 131 $post['userusername'] = htmlspecialchars_uni($post['userusername']); 132 133 if(!$postcounter) 134 { // Used to show the # of the post 135 if($page > 1) 136 { 137 if(!$mybb->settings['postsperpage'] || (int)$mybb->settings['postsperpage'] < 1) 138 { 139 $mybb->settings['postsperpage'] = 20; 140 } 141 142 $postcounter = $mybb->settings['postsperpage']*($page-1); 143 } 144 else 145 { 146 $postcounter = 0; 147 } 148 $post_extra_style = "border-top-width: 0;"; 149 } 150 elseif($mybb->get_input('mode') == "threaded") 151 { 152 $post_extra_style = "border-top-width: 0;"; 153 } 154 else 155 { 156 $post_extra_style = "margin-top: 5px;"; 157 } 158 159 if(!$altbg) 160 { // Define the alternate background colour if this is the first post 161 $altbg = "trow1"; 162 } 163 $postcounter++; 164 165 // Format the post date and time using my_date 166 $post['postdate'] = my_date('relative', $post['dateline']); 167 168 // Dont want any little 'nasties' in the subject 169 $post['subject'] = $parser->parse_badwords($post['subject']); 170 171 // Pm's have been htmlspecialchars_uni()'ed already. 172 if($post_type != 2) 173 { 174 $post['subject'] = htmlspecialchars_uni($post['subject']); 175 } 176 177 if(empty($post['subject'])) 178 { 179 $post['subject'] = ' '; 180 } 181 182 $post['author'] = $post['uid']; 183 $post['subject_title'] = $post['subject']; 184 185 // Get the usergroup 186 if($post['usergroup']) 187 { 188 $usergroup = usergroup_permissions($post['usergroup']); 189 } 190 else 191 { 192 $usergroup = usergroup_permissions(1); 193 } 194 195 // Fetch display group data. 196 $displaygroupfields = array("title", "description", "namestyle", "usertitle", "stars", "starimage", "image"); 197 198 if(empty($post['displaygroup'])) 199 { 200 $post['displaygroup'] = $post['usergroup']; 201 } 202 203 // Set to hardcoded Guest usergroup ID (1) for guest author or deleted user. 204 if(empty($post['usergroup'])) 205 { 206 $post['usergroup'] = 1; 207 } 208 if(empty($post['displaygroup'])) 209 { 210 $post['displaygroup'] = 1; 211 } 212 213 $displaygroup = usergroup_displaygroup($post['displaygroup']); 214 if(is_array($displaygroup)) 215 { 216 $usergroup = array_merge($usergroup, $displaygroup); 217 } 218 219 if(!is_array($titlescache)) 220 { 221 $cached_titles = $cache->read("usertitles"); 222 if(!empty($cached_titles)) 223 { 224 foreach($cached_titles as $usertitle) 225 { 226 $titlescache[$usertitle['posts']] = $usertitle; 227 } 228 } 229 230 if(is_array($titlescache)) 231 { 232 krsort($titlescache); 233 } 234 unset($usertitle, $cached_titles); 235 } 236 237 // Work out the usergroup/title stuff 238 $post['groupimage'] = ''; 239 if(!empty($usergroup['image'])) 240 { 241 $language = $mybb->settings['bblanguage']; 242 if(!empty($mybb->user['language'])) 243 { 244 $language = $mybb->user['language']; 245 } 246 247 $usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']); 248 $usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']); 249 eval("\$post['groupimage'] = \"".$templates->get("postbit_groupimage")."\";"); 250 251 if($mybb->settings['postlayout'] == "classic") 252 { 253 $post['groupimage'] .= "<br />"; 254 } 255 } 256 257 if($post['userusername']) 258 { 259 // This post was made by a registered user 260 $post['username'] = $post['userusername']; 261 $post['profilelink_plain'] = get_profile_link($post['uid']); 262 $post['username_formatted'] = format_name($post['username'], $post['usergroup'], $post['displaygroup']); 263 $post['profilelink'] = build_profile_link($post['username_formatted'], $post['uid']); 264 265 if(trim($post['usertitle']) != "") 266 { 267 $hascustomtitle = 1; 268 } 269 270 if($usergroup['usertitle'] != "" && !$hascustomtitle) 271 { 272 $post['usertitle'] = $usergroup['usertitle']; 273 } 274 elseif(is_array($titlescache) && !$usergroup['usertitle']) 275 { 276 reset($titlescache); 277 foreach($titlescache as $key => $titleinfo) 278 { 279 if($post['postnum'] >= $key) 280 { 281 if(!$hascustomtitle) 282 { 283 $post['usertitle'] = $titleinfo['title']; 284 } 285 $post['stars'] = $titleinfo['stars']; 286 $post['starimage'] = $titleinfo['starimage']; 287 break; 288 } 289 } 290 } 291 292 $post['usertitle'] = htmlspecialchars_uni($post['usertitle']); 293 294 if($usergroup['stars']) 295 { 296 $post['stars'] = $usergroup['stars']; 297 } 298 299 if(empty($post['starimage'])) 300 { 301 $post['starimage'] = $usergroup['starimage']; 302 } 303 304 $post['userstars'] = ''; 305 if($post['starimage'] && isset($post['stars'])) 306 { 307 // Only display stars if we have an image to use... 308 $post['starimage'] = str_replace("{theme}", $theme['imgdir'], $post['starimage']); 309 310 for($i = 0; $i < $post['stars']; ++$i) 311 { 312 eval("\$post['userstars'] .= \"".$templates->get("postbit_userstar", 1, 0)."\";"); 313 } 314 315 $post['userstars'] .= "<br />"; 316 } 317 318 $postnum = $post['postnum']; 319 $post['postnum'] = my_number_format($post['postnum']); 320 $post['threadnum'] = my_number_format($post['threadnum']); 321 322 // Determine the status to show for the user (Online/Offline/Away) 323 $timecut = TIME_NOW - $mybb->settings['wolcutoff']; 324 if($post['lastactive'] > $timecut && ($post['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $post['lastvisit'] != $post['lastactive']) 325 { 326 eval("\$post['onlinestatus'] = \"".$templates->get("postbit_online")."\";"); 327 } 328 else 329 { 330 if($post['away'] == 1 && $mybb->settings['allowaway'] != 0) 331 { 332 eval("\$post['onlinestatus'] = \"".$templates->get("postbit_away")."\";"); 333 } 334 else 335 { 336 eval("\$post['onlinestatus'] = \"".$templates->get("postbit_offline")."\";"); 337 } 338 } 339 340 $post['useravatar'] = ''; 341 if(isset($mybb->user['showavatars']) && $mybb->user['showavatars'] != 0 || $mybb->user['uid'] == 0) 342 { 343 $useravatar = format_avatar($post['avatar'], $post['avatardimensions'], $mybb->settings['postmaxavatarsize']); 344 eval("\$post['useravatar'] = \"".$templates->get("postbit_avatar")."\";"); 345 } 346 347 $post['button_find'] = ''; 348 if($mybb->usergroup['cansearch'] == 1) 349 { 350 eval("\$post['button_find'] = \"".$templates->get("postbit_find")."\";"); 351 } 352 353 if($mybb->settings['enablepms'] == 1 && $post['uid'] != $mybb->user['uid'] && (($post['receivepms'] != 0 && $usergroup['canusepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos(",".$post['ignorelist'].",", ",".$mybb->user['uid'].",") === false) || $mybb->usergroup['canoverridepm'] == 1)) 354 { 355 eval("\$post['button_pm'] = \"".$templates->get("postbit_pm")."\";"); 356 } 357 358 $post['button_rep'] = ''; 359 if($post_type != 3 && $mybb->settings['enablereputation'] == 1 && $mybb->settings['postrep'] == 1 && $mybb->usergroup['cangivereputations'] == 1 && $usergroup['usereputationsystem'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep']) && $post['uid'] != $mybb->user['uid'] && (!isset($post['visible']) || $post['visible'] == 1) && (!isset($thread['visible']) || $thread['visible'] == 1)) 360 { 361 if(empty($post['pid'])) 362 { 363 $post['pid'] = 0; 364 } 365 366 eval("\$post['button_rep'] = \"".$templates->get("postbit_rep_button")."\";"); 367 } 368 369 if($post['website'] != "" && !is_member($mybb->settings['hidewebsite']) && $usergroup['canchangewebsite'] == 1) 370 { 371 $post['website'] = htmlspecialchars_uni($post['website']); 372 eval("\$post['button_www'] = \"".$templates->get("postbit_www")."\";"); 373 } 374 else 375 { 376 $post['button_www'] = ""; 377 } 378 379 if($post['hideemail'] != 1 && $post['uid'] != $mybb->user['uid'] && $mybb->usergroup['cansendemail'] == 1) 380 { 381 eval("\$post['button_email'] = \"".$templates->get("postbit_email")."\";"); 382 } 383 else 384 { 385 $post['button_email'] = ""; 386 } 387 388 $post['userregdate'] = my_date($mybb->settings['regdateformat'], $post['regdate']); 389 390 // Work out the reputation this user has (only show if not announcement) 391 if($post_type != 3 && $usergroup['usereputationsystem'] != 0 && $mybb->settings['enablereputation'] == 1) 392 { 393 $post['userreputation'] = get_reputation($post['reputation'], $post['uid']); 394 eval("\$post['replink'] = \"".$templates->get("postbit_reputation")."\";"); 395 } 396 397 // Showing the warning level? (only show if not announcement) 398 if($post_type != 3 && $mybb->settings['enablewarningsystem'] != 0 && $usergroup['canreceivewarnings'] != 0 && ($mybb->usergroup['canwarnusers'] != 0 || ($mybb->user['uid'] == $post['uid'] && $mybb->settings['canviewownwarning'] != 0))) 399 { 400 if($mybb->settings['maxwarningpoints'] < 1) 401 { 402 $mybb->settings['maxwarningpoints'] = 10; 403 } 404 405 $warning_level = round($post['warningpoints']/$mybb->settings['maxwarningpoints']*100); 406 if($warning_level > 100) 407 { 408 $warning_level = 100; 409 } 410 $warning_level = get_colored_warning_level($warning_level); 411 412 // If we can warn them, it's not the same person, and we're in a PM or a post. 413 if($mybb->usergroup['canwarnusers'] != 0 && $post['uid'] != $mybb->user['uid'] && ($post_type == 0 || $post_type == 2)) 414 { 415 eval("\$post['button_warn'] = \"".$templates->get("postbit_warn")."\";"); 416 $warning_link = "warnings.php?uid={$post['uid']}"; 417 } 418 else 419 { 420 $post['button_warn'] = ''; 421 $warning_link = "usercp.php"; 422 } 423 eval("\$post['warninglevel'] = \"".$templates->get("postbit_warninglevel")."\";"); 424 } 425 426 if($post_type != 3 && $post_type != 1 && purgespammer_show($post['postnum'], $post['usergroup'], $post['uid'])) 427 { 428 eval("\$post['button_purgespammer'] = \"".$templates->get('postbit_purgespammer')."\";"); 429 } 430 431 if(!isset($profile_fields)) 432 { 433 $profile_fields = array(); 434 435 // Fetch profile fields to display 436 $pfcache = $cache->read('profilefields'); 437 438 if(is_array($pfcache)) 439 { 440 foreach($pfcache as $profilefield) 441 { 442 if($profilefield['postbit'] != 1) 443 { 444 continue; 445 } 446 447 $profile_fields[$profilefield['fid']] = $profilefield; 448 } 449 } 450 } 451 452 // Display profile fields on posts - only if field is filled in 453 $post['profilefield'] = ''; 454 if(!empty($profile_fields)) 455 { 456 foreach($profile_fields as $field) 457 { 458 $fieldfid = "fid{$field['fid']}"; 459 if(!empty($post[$fieldfid])) 460 { 461 $post['fieldvalue'] = ''; 462 $post['fieldname'] = htmlspecialchars_uni($field['name']); 463 464 $thing = explode("\n", $field['type'], "2"); 465 $type = trim($thing[0]); 466 $useropts = explode("\n", $post[$fieldfid]); 467 468 if(is_array($useropts) && ($type == "multiselect" || $type == "checkbox")) 469 { 470 $post['fieldvalue_option'] = ''; 471 472 foreach($useropts as $val) 473 { 474 if($val != '') 475 { 476 eval("\$post['fieldvalue_option'] .= \"".$templates->get("postbit_profilefield_multiselect_value")."\";"); 477 } 478 } 479 if($post['fieldvalue_option'] != '') 480 { 481 eval("\$post['fieldvalue'] .= \"".$templates->get("postbit_profilefield_multiselect")."\";"); 482 } 483 } 484 else 485 { 486 $field_parser_options = array( 487 "allow_html" => $field['allowhtml'], 488 "allow_mycode" => $field['allowmycode'], 489 "allow_smilies" => $field['allowsmilies'], 490 "allow_imgcode" => $field['allowimgcode'], 491 "allow_videocode" => $field['allowvideocode'], 492 #"nofollow_on" => 1, 493 "filter_badwords" => 1 494 ); 495 496 if($field['type'] == "textarea") 497 { 498 $field_parser_options['me_username'] = $post['username']; 499 } 500 else 501 { 502 $field_parser_options['nl2br'] = 0; 503 } 504 505 if($mybb->user['uid'] != 0 && $mybb->user['showimages'] != 1 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) 506 { 507 $field_parser_options['allow_imgcode'] = 0; 508 } 509 510 $post['fieldvalue'] = $parser->parse_message($post[$fieldfid], $field_parser_options); 511 } 512 513 eval("\$post['profilefield'] .= \"".$templates->get("postbit_profilefield")."\";"); 514 } 515 } 516 } 517 518 eval("\$post['user_details'] = \"".$templates->get("postbit_author_user")."\";"); 519 } 520 else 521 { // Message was posted by a guest or an unknown user 522 $post['profilelink'] = format_name($post['username'], 1); 523 524 if($usergroup['usertitle']) 525 { 526 $post['usertitle'] = $usergroup['usertitle']; 527 } 528 else 529 { 530 $post['usertitle'] = $lang->guest; 531 } 532 533 $post['usertitle'] = htmlspecialchars_uni($post['usertitle']); 534 $post['userstars'] = ''; 535 $post['useravatar'] = ''; 536 537 $usergroup['title'] = $lang->na; 538 539 $post['userregdate'] = $lang->na; 540 $post['postnum'] = $lang->na; 541 $post['button_profile'] = ''; 542 $post['button_email'] = ''; 543 $post['button_www'] = ''; 544 $post['signature'] = ''; 545 $post['button_pm'] = ''; 546 $post['button_find'] = ''; 547 $post['onlinestatus'] = ''; 548 $post['replink'] = ''; 549 eval("\$post['user_details'] = \"".$templates->get("postbit_author_guest")."\";"); 550 } 551 552 $post['input_editreason'] = ''; 553 $post['button_edit'] = ''; 554 $post['button_quickdelete'] = ''; 555 $post['button_quickrestore'] = ''; 556 $post['button_quote'] = ''; 557 $post['button_quickquote'] = ''; 558 $post['button_report'] = ''; 559 $post['button_reply_pm'] = ''; 560 $post['button_replyall_pm'] = ''; 561 $post['button_forward_pm'] = ''; 562 $post['button_delete_pm'] = ''; 563 564 // For private messages, fetch the reply/forward/delete icons 565 if($post_type == 2 && $post['pmid']) 566 { 567 global $replyall; 568 569 eval("\$post['button_reply_pm'] = \"".$templates->get("postbit_reply_pm")."\";"); 570 eval("\$post['button_forward_pm'] = \"".$templates->get("postbit_forward_pm")."\";"); 571 eval("\$post['button_delete_pm'] = \"".$templates->get("postbit_delete_pm")."\";"); 572 573 if($replyall == true) 574 { 575 eval("\$post['button_replyall_pm'] = \"".$templates->get("postbit_replyall_pm")."\";"); 576 } 577 } 578 579 $post['editedmsg'] = ''; 580 if(!$post_type) 581 { 582 if(!isset($forumpermissions)) 583 { 584 $forumpermissions = forum_permissions($fid); 585 } 586 587 // Figure out if we need to show an "edited by" message 588 if($post['edituid'] != 0 && $post['edittime'] != 0 && $post['editusername'] != "" && ($mybb->settings['showeditedby'] != 0 && $usergroup['cancp'] == 0 && !is_moderator($post['fid'], "", $post['uid']) || ($mybb->settings['showeditedbyadmin'] != 0 && ($usergroup['cancp'] == 1 || is_moderator($post['fid'], "", $post['uid']))))) 589 { 590 $post['editdate'] = my_date('relative', $post['edittime']); 591 $post['editnote'] = $lang->sprintf($lang->postbit_edited, $post['editdate']); 592 $post['editusername'] = htmlspecialchars_uni($post['editusername']); 593 $post['editedprofilelink'] = build_profile_link($post['editusername'], $post['edituid']); 594 $editreason = ""; 595 if($post['editreason'] != "") 596 { 597 $post['editreason'] = $parser->parse_badwords($post['editreason']); 598 $post['editreason'] = htmlspecialchars_uni($post['editreason']); 599 eval("\$editreason = \"".$templates->get("postbit_editedby_editreason")."\";"); 600 } 601 eval("\$post['editedmsg'] = \"".$templates->get("postbit_editedby")."\";"); 602 } 603 604 $time = TIME_NOW; 605 if((is_moderator($fid, "caneditposts") || ($forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $post['uid'] && $thread['closed'] != 1 && ($mybb->usergroup['edittimelimit'] == 0 || $mybb->usergroup['edittimelimit'] != 0 && $post['dateline'] > ($time-($mybb->usergroup['edittimelimit']*60))))) && $mybb->user['uid'] != 0) 606 { 607 eval("\$post['input_editreason'] = \"".$templates->get("postbit_editreason")."\";"); 608 eval("\$post['button_edit'] = \"".$templates->get("postbit_edit")."\";"); 609 } 610 611 // Quick Delete button 612 $can_delete_thread = $can_delete_post = 0; 613 if($mybb->user['uid'] == $post['uid'] && $thread['closed'] == 0) 614 { 615 if($forumpermissions['candeletethreads'] == 1 && $postcounter == 1) 616 { 617 $can_delete_thread = 1; 618 } 619 else if($forumpermissions['candeleteposts'] == 1 && $postcounter != 1) 620 { 621 $can_delete_post = 1; 622 } 623 } 624 625 $postbit_qdelete = $postbit_qrestore = ''; 626 if($mybb->user['uid'] != 0) 627 { 628 if((is_moderator($fid, "candeleteposts") || is_moderator($fid, "cansoftdeleteposts") || $can_delete_post == 1) && $postcounter != 1) 629 { 630 $postbit_qdelete = $lang->postbit_qdelete_post; 631 $display = ''; 632 if($post['visible'] == -1) 633 { 634 $display = "none"; 635 } 636 eval("\$post['button_quickdelete'] = \"".$templates->get("postbit_quickdelete")."\";"); 637 } 638 else if((is_moderator($fid, "candeletethreads") || is_moderator($fid, "cansoftdeletethreads") || $can_delete_thread == 1) && $postcounter == 1) 639 { 640 $postbit_qdelete = $lang->postbit_qdelete_thread; 641 $display = ''; 642 if($post['visible'] == -1) 643 { 644 $display = "none"; 645 } 646 eval("\$post['button_quickdelete'] = \"".$templates->get("postbit_quickdelete")."\";"); 647 } 648 649 // Restore Post 650 if(is_moderator($fid, "canrestoreposts") && $postcounter != 1) 651 { 652 $display = "none"; 653 if($post['visible'] == -1) 654 { 655 $display = ''; 656 } 657 $postbit_qrestore = $lang->postbit_qrestore_post; 658 eval("\$post['button_quickrestore'] = \"".$templates->get("postbit_quickrestore")."\";"); 659 } 660 661 // Restore Thread 662 else if(is_moderator($fid, "canrestorethreads") && $postcounter == 1) 663 { 664 $display = "none"; 665 if($post['visible'] == -1) 666 { 667 $display = ""; 668 } 669 $postbit_qrestore = $lang->postbit_qrestore_thread; 670 eval("\$post['button_quickrestore'] = \"".$templates->get("postbit_quickrestore")."\";"); 671 } 672 } 673 674 if(!isset($ismod)) 675 { 676 $ismod = is_moderator($fid); 677 } 678 679 // Inline moderation stuff 680 if($ismod) 681 { 682 if(isset($mybb->cookies[$inlinecookie]) && my_strpos($mybb->cookies[$inlinecookie], "|".$post['pid']."|") !== false) 683 { 684 $inlinecheck = "checked=\"checked\""; 685 $inlinecount++; 686 } 687 else 688 { 689 $inlinecheck = ""; 690 } 691 692 eval("\$post['inlinecheck'] = \"".$templates->get("postbit_inlinecheck")."\";"); 693 694 if($post['visible'] == 0) 695 { 696 $invisiblepost = 1; 697 } 698 } 699 else 700 { 701 $post['inlinecheck'] = ""; 702 } 703 $post['postlink'] = get_post_link($post['pid'], $post['tid']); 704 $post_number = my_number_format($postcounter); 705 eval("\$post['posturl'] = \"".$templates->get("postbit_posturl")."\";"); 706 global $forum, $thread; 707 708 if($forum['open'] != 0 && ($thread['closed'] != 1 || is_moderator($forum['fid'], "canpostclosedthreads")) && ($thread['uid'] == $mybb->user['uid'] || empty($forumpermissions['canonlyreplyownthreads']))) 709 { 710 eval("\$post['button_quote'] = \"".$templates->get("postbit_quote")."\";"); 711 } 712 713 if($forumpermissions['canpostreplys'] != 0 && ($thread['uid'] == $mybb->user['uid'] || empty($forumpermissions['canonlyreplyownthreads'])) && ($thread['closed'] != 1 || is_moderator($fid, "canpostclosedthreads")) && $mybb->settings['multiquote'] != 0 && $forum['open'] != 0 && !$post_type) 714 { 715 eval("\$post['button_multiquote'] = \"".$templates->get("postbit_multiquote")."\";"); 716 } 717 718 if(isset($post['reporters'])) 719 { 720 $skip_report = my_unserialize($post['reporters']); 721 if(is_array($skip_report)) 722 { 723 $skip_report[] = 0; 724 } 725 else 726 { 727 $skip_report = array(0); 728 } 729 } 730 else 731 { 732 $skip_report = array(0); 733 } 734 735 $reportable = user_permissions($post['uid']); 736 if(!in_array($mybb->user['uid'], $skip_report) && !empty($reportable['canbereported'])) 737 { 738 eval("\$post['button_report'] = \"".$templates->get("postbit_report")."\";"); 739 } 740 } 741 elseif($post_type == 3) // announcement 742 { 743 if($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canmanageannounce'] == 1 && is_moderator($fid, "canmanageannouncements")) 744 { 745 eval("\$post['button_edit'] = \"".$templates->get("announcement_edit")."\";"); 746 eval("\$post['button_quickdelete'] = \"".$templates->get("announcement_quickdelete")."\";"); 747 } 748 } 749 750 $post['iplogged'] = ''; 751 $show_ips = $mybb->settings['logip']; 752 753 // Show post IP addresses... PMs now can have IP addresses too as of 1.8! 754 if($post_type == 2) 755 { 756 $show_ips = $mybb->settings['showpmip']; 757 } 758 if(!$post_type || $post_type == 2) 759 { 760 if($show_ips != "no" && !empty($post['ipaddress'])) 761 { 762 $ipaddress = my_inet_ntop($db->unescape_binary($post['ipaddress'])); 763 764 if($show_ips == "show") 765 { 766 eval("\$post['iplogged'] = \"".$templates->get("postbit_iplogged_show")."\";"); 767 } 768 else if($show_ips == "hide" && (is_moderator($fid, "canviewips") || $mybb->usergroup['issupermod'])) 769 { 770 $action = 'getip'; 771 $javascript = 'getIP'; 772 773 if($post_type == 2) 774 { 775 $action = 'getpmip'; 776 $javascript = 'getPMIP'; 777 } 778 779 eval("\$post['iplogged'] = \"".$templates->get("postbit_iplogged_hiden")."\";"); 780 } 781 } 782 } 783 784 $post['poststatus'] = ''; 785 if(!$post_type && $post['visible'] != 1) 786 { 787 $status_type = ''; 788 if(is_moderator($fid, "canviewdeleted") && $postcounter != 1 && $post['visible'] == -1) 789 { 790 $status_type = $lang->postbit_post_deleted; 791 } 792 else if(is_moderator($fid, "canviewunapprove") && $postcounter != 1 && $post['visible'] == 0) 793 { 794 $status_type = $lang->postbit_post_unapproved; 795 } 796 else if(is_moderator($fid, "canviewdeleted") && $postcounter == 1 && $post['visible'] == -1) 797 { 798 $status_type = $lang->postbit_thread_deleted; 799 } 800 else if(is_moderator($fid, "canviewunapprove") && $postcounter == 1 && $post['visible'] == 0) 801 { 802 $status_type = $lang->postbit_thread_unapproved; 803 } 804 805 eval("\$post['poststatus'] = \"".$templates->get("postbit_status")."\";"); 806 } 807 808 if(isset($post['smilieoff']) && $post['smilieoff'] == 1) 809 { 810 $parser_options['allow_smilies'] = 0; 811 } 812 813 if($mybb->user['uid'] != 0 && $mybb->user['showimages'] != 1 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) 814 { 815 $parser_options['allow_imgcode'] = 0; 816 } 817 818 if($mybb->user['uid'] != 0 && $mybb->user['showvideos'] != 1 || $mybb->settings['guestvideos'] != 1 && $mybb->user['uid'] == 0) 819 { 820 $parser_options['allow_videocode'] = 0; 821 } 822 823 // If we have incoming search terms to highlight - get it done. 824 if(!empty($mybb->input['highlight'])) 825 { 826 $parser_options['highlight'] = $mybb->input['highlight']; 827 $post['subject'] = $parser->highlight_message($post['subject'], $parser_options['highlight']); 828 } 829 830 $post['message'] = $parser->parse_message($post['message'], $parser_options); 831 832 $post['attachments'] = ''; 833 if($mybb->settings['enableattachments'] != 0) 834 { 835 get_post_attachments($id, $post); 836 } 837 838 if(isset($post['includesig']) && $post['includesig'] != 0 && $post['username'] && $post['signature'] != "" && ($mybb->user['uid'] == 0 || $mybb->user['showsigs'] != 0) 839 && ($post['suspendsignature'] == 0 || $post['suspendsignature'] == 1 && $post['suspendsigtime'] != 0 && $post['suspendsigtime'] < TIME_NOW) && $usergroup['canusesig'] == 1 840 && ($usergroup['canusesigxposts'] == 0 || $usergroup['canusesigxposts'] > 0 && $postnum > $usergroup['canusesigxposts']) && !is_member($mybb->settings['hidesignatures'])) 841 { 842 $sig_parser = array( 843 "allow_html" => $mybb->settings['sightml'], 844 "allow_mycode" => $mybb->settings['sigmycode'], 845 "allow_smilies" => $mybb->settings['sigsmilies'], 846 "allow_imgcode" => $mybb->settings['sigimgcode'], 847 "me_username" => $parser_options['me_username'], 848 "filter_badwords" => 1 849 ); 850 851 if($usergroup['signofollow']) 852 { 853 $sig_parser['nofollow_on'] = 1; 854 } 855 856 if($mybb->user['uid'] != 0 && $mybb->user['showimages'] != 1 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) 857 { 858 $sig_parser['allow_imgcode'] = 0; 859 } 860 861 $post['signature'] = $parser->parse_message($post['signature'], $sig_parser); 862 eval("\$post['signature'] = \"".$templates->get("postbit_signature")."\";"); 863 } 864 else 865 { 866 $post['signature'] = ""; 867 } 868 869 $icon_cache = $cache->read("posticons"); 870 871 if(isset($post['icon']) && $post['icon'] > 0 && $icon_cache[$post['icon']]) 872 { 873 $icon = $icon_cache[$post['icon']]; 874 875 $icon['path'] = htmlspecialchars_uni($icon['path']); 876 $icon['path'] = str_replace("{theme}", $theme['imgdir'], $icon['path']); 877 $icon['name'] = htmlspecialchars_uni($icon['name']); 878 eval("\$post['icon'] = \"".$templates->get("postbit_icon")."\";"); 879 } 880 else 881 { 882 $post['icon'] = ""; 883 } 884 885 $post_visibility = $ignore_bit = $deleted_bit = ''; 886 switch($post_type) 887 { 888 case 1: // Message preview 889 $post = $plugins->run_hooks("postbit_prev", $post); 890 break; 891 case 2: // Private message 892 $post = $plugins->run_hooks("postbit_pm", $post); 893 break; 894 case 3: // Announcement 895 $post = $plugins->run_hooks("postbit_announcement", $post); 896 break; 897 default: // Regular post 898 $post = $plugins->run_hooks("postbit", $post); 899 900 if(!isset($ignored_users)) 901 { 902 $ignored_users = array(); 903 if($mybb->user['uid'] > 0 && $mybb->user['ignorelist'] != "") 904 { 905 $ignore_list = explode(',', $mybb->user['ignorelist']); 906 foreach($ignore_list as $uid) 907 { 908 $ignored_users[$uid] = 1; 909 } 910 } 911 } 912 913 // Has this post been deleted but can be viewed? Hide this post 914 if($post['visible'] == -1 && is_moderator($fid, "canviewdeleted")) 915 { 916 $deleted_message = $lang->sprintf($lang->postbit_deleted_post_user, $post['username']); 917 eval("\$deleted_bit = \"".$templates->get("postbit_deleted")."\";"); 918 $post_visibility = "display: none;"; 919 } 920 921 // Is the user (not moderator) logged in and have unapproved posts? 922 if($mybb->user['uid'] && $post['visible'] == 0 && $post['uid'] == $mybb->user['uid'] && !is_moderator($fid, "canviewunapprove")) 923 { 924 $ignored_message = $lang->sprintf($lang->postbit_post_under_moderation, $post['username']); 925 eval("\$ignore_bit = \"".$templates->get("postbit_ignored")."\";"); 926 $post_visibility = "display: none;"; 927 } 928 929 // Is this author on the ignore list of the current user? Hide this post 930 if(is_array($ignored_users) && $post['uid'] != 0 && isset($ignored_users[$post['uid']]) && $ignored_users[$post['uid']] == 1 && empty($deleted_bit)) 931 { 932 $ignored_message = $lang->sprintf($lang->postbit_currently_ignoring_user, $post['username']); 933 eval("\$ignore_bit = \"".$templates->get("postbit_ignored")."\";"); 934 $post_visibility = "display: none;"; 935 } 936 break; 937 } 938 939 if($post_type == 0 && $forumpermissions['canviewdeletionnotice'] == 1 && $post['visible'] == -1 && !is_moderator($fid, "canviewdeleted")) 940 { 941 eval("\$postbit = \"".$templates->get("postbit_deleted_member")."\";"); 942 } 943 else 944 { 945 if($mybb->settings['postlayout'] == "classic") 946 { 947 eval("\$postbit = \"".$templates->get("postbit_classic")."\";"); 948 } 949 else 950 { 951 eval("\$postbit = \"".$templates->get("postbit")."\";"); 952 } 953 } 954 955 $GLOBALS['post'] = ""; 956 957 return $postbit; 958 } 959 960 /** 961 * Fetch the attachments for a specific post and parse inline [attachment=id] code. 962 * Note: assumes you have $attachcache, an array of attachments set up. 963 * 964 * @param int $id The ID of the item. 965 * @param array $post The post or item passed by reference. 966 */ 967 function get_post_attachments($id, &$post) 968 { 969 global $attachcache, $mybb, $theme, $templates, $forumpermissions, $lang; 970 971 $validationcount = 0; 972 $tcount = 0; 973 $post['attachmentlist'] = $post['thumblist'] = $post['imagelist'] = ''; 974 if(!isset($forumpermissions)) 975 { 976 $forumpermissions = forum_permissions($post['fid']); 977 } 978 979 if(isset($attachcache[$id]) && is_array($attachcache[$id])) 980 { // This post has 1 or more attachments 981 foreach($attachcache[$id] as $aid => $attachment) 982 { 983 if($attachment['visible']) 984 { // There is an attachment thats visible! 985 $attachment['filename'] = htmlspecialchars_uni($attachment['filename']); 986 $attachment['filesize'] = get_friendly_size($attachment['filesize']); 987 $ext = get_extension($attachment['filename']); 988 if($ext == "jpeg" || $ext == "gif" || $ext == "bmp" || $ext == "png" || $ext == "jpg") 989 { 990 $isimage = true; 991 } 992 else 993 { 994 $isimage = false; 995 } 996 $attachment['icon'] = get_attachment_icon($ext); 997 $attachment['downloads'] = my_number_format($attachment['downloads']); 998 999 if(!$attachment['dateuploaded']) 1000 { 1001 $attachment['dateuploaded'] = $post['dateline']; 1002 } 1003 $attachdate = my_date('normal', $attachment['dateuploaded']); 1004 // Support for [attachment=id] code 1005 if(stripos($post['message'], "[attachment=".$attachment['aid']."]") !== false) 1006 { 1007 // Show as thumbnail IF image is big && thumbnail exists && setting=='thumb' 1008 // Show as full size image IF setting=='fullsize' || (image is small && permissions allow) 1009 // Show as download for all other cases 1010 if($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != "" && $mybb->settings['attachthumbnails'] == "yes") 1011 { 1012 eval("\$attbit = \"".$templates->get("postbit_attachments_thumbnails_thumbnail")."\";"); 1013 } 1014 elseif((($attachment['thumbnail'] == "SMALL" && $forumpermissions['candlattachments'] == 1) || $mybb->settings['attachthumbnails'] == "no") && $isimage) 1015 { 1016 eval("\$attbit = \"".$templates->get("postbit_attachments_images_image")."\";"); 1017 } 1018 else 1019 { 1020 eval("\$attbit = \"".$templates->get("postbit_attachments_attachment")."\";"); 1021 } 1022 $post['message'] = preg_replace("#\[attachment=".$attachment['aid']."]#si", $attbit, $post['message']); 1023 } 1024 else 1025 { 1026 // Show as thumbnail IF image is big && thumbnail exists && setting=='thumb' 1027 // Show as full size image IF setting=='fullsize' || (image is small && permissions allow) 1028 // Show as download for all other cases 1029 if($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != "" && $mybb->settings['attachthumbnails'] == "yes") 1030 { 1031 eval("\$post['thumblist'] .= \"".$templates->get("postbit_attachments_thumbnails_thumbnail")."\";"); 1032 if($tcount == 5) 1033 { 1034 $post['thumblist'] .= "<br />"; 1035 $tcount = 0; 1036 } 1037 ++$tcount; 1038 } 1039 elseif((($attachment['thumbnail'] == "SMALL" && $forumpermissions['candlattachments'] == 1) || $mybb->settings['attachthumbnails'] == "no") && $isimage) 1040 { 1041 if ($forumpermissions['candlattachments']) 1042 { 1043 eval("\$post['imagelist'] .= \"".$templates->get("postbit_attachments_images_image")."\";"); 1044 } 1045 else 1046 { 1047 eval("\$post['thumblist'] .= \"".$templates->get("postbit_attachments_thumbnails_thumbnail")."\";"); 1048 if($tcount == 5) 1049 { 1050 $post['thumblist'] .= "<br />"; 1051 $tcount = 0; 1052 } 1053 ++$tcount; 1054 } 1055 } 1056 else 1057 { 1058 eval("\$post['attachmentlist'] .= \"".$templates->get("postbit_attachments_attachment")."\";"); 1059 } 1060 } 1061 } 1062 else 1063 { 1064 $validationcount++; 1065 } 1066 } 1067 if($validationcount > 0 && is_moderator($post['fid'], "canviewunapprove")) 1068 { 1069 if($validationcount == 1) 1070 { 1071 $postbit_unapproved_attachments = $lang->postbit_unapproved_attachment; 1072 } 1073 else 1074 { 1075 $postbit_unapproved_attachments = $lang->sprintf($lang->postbit_unapproved_attachments, $validationcount); 1076 } 1077 eval("\$post['attachmentlist'] .= \"".$templates->get("postbit_attachments_attachment_unapproved")."\";"); 1078 } 1079 if($post['thumblist']) 1080 { 1081 eval("\$post['attachedthumbs'] = \"".$templates->get("postbit_attachments_thumbnails")."\";"); 1082 } 1083 else 1084 { 1085 $post['attachedthumbs'] = ''; 1086 } 1087 if($post['imagelist']) 1088 { 1089 eval("\$post['attachedimages'] = \"".$templates->get("postbit_attachments_images")."\";"); 1090 } 1091 else 1092 { 1093 $post['attachedimages'] = ''; 1094 } 1095 if($post['attachmentlist'] || $post['thumblist'] || $post['imagelist']) 1096 { 1097 eval("\$post['attachments'] = \"".$templates->get("postbit_attachments")."\";"); 1098 } 1099 } 1100 } 1101 1102 /** 1103 * Returns bytes count from human readable string 1104 * Used to parse ini_get human-readable values to int 1105 * 1106 * @param string $val Human-readable value 1107 */ 1108 function return_bytes($val) { 1109 $val = trim($val); 1110 if ($val == "") 1111 { 1112 return 0; 1113 } 1114 1115 $last = strtolower($val[strlen($val)-1]); 1116 1117 $val = intval($val); 1118 1119 switch($last) 1120 { 1121 case 'g': 1122 $val *= 1024; 1123 case 'm': 1124 $val *= 1024; 1125 case 'k': 1126 $val *= 1024; 1127 } 1128 1129 return $val; 1130 } 1131 1132 /** 1133 * Detects whether an attachment removal/approval/unapproval 1134 * submit button was pressed (without triggering an AJAX request) 1135 * and sets inputs accordingly (as for an AJAX request). 1136 */ 1137 function detect_attachmentact() 1138 { 1139 global $mybb; 1140 1141 foreach($mybb->input as $key => $val) 1142 { 1143 if(strpos($key, 'rem_') === 0) 1144 { 1145 $mybb->input['attachmentaid'] = (int)substr($key, 4); 1146 $mybb->input['attachmentact'] = 'remove'; 1147 break; 1148 } 1149 elseif(strpos($key, 'approveattach_') === 0) 1150 { 1151 $mybb->input['attachmentaid'] = (int)substr($key, 14); 1152 $mybb->input['attachmentact'] = 'approve'; 1153 break; 1154 } 1155 elseif(strpos($key, 'unapproveattach_') === 0) 1156 { 1157 $mybb->input['attachmentaid'] = (int)substr($key, 16); 1158 $mybb->input['attachmentact'] = 'unapprove'; 1159 break; 1160 } 1161 } 1162 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |